]> git.mxchange.org Git - flightgear.git/blob - src/Main/renderer.hxx
Restore splash screen for the Rembrandt renderer
[flightgear.git] / src / Main / renderer.hxx
1
2 #ifndef __FG_RENDERER_HXX
3 #define __FG_RENDERER_HXX 1
4
5 #include <simgear/scene/util/SGPickCallback.hxx>
6 #include <simgear/props/props.hxx>
7 #include <simgear/timing/timestamp.hxx>
8
9 #include <osg/ref_ptr>
10 #include <osg/Matrix>
11 #include <osg/Vec3>
12
13 namespace osg
14 {
15 class Camera;
16 class Group;
17 class GraphicsContext;
18 }
19
20 namespace osgGA
21 {
22 class GUIEventAdapter;
23 }
24
25 namespace osgShadow
26 {
27 class ShadowedScene;
28 }
29
30 namespace osgViewer
31 {
32 class Viewer;
33 }
34
35 namespace flightgear
36 {
37 class FGEventHandler;
38 struct CameraInfo;
39 class CameraGroup;
40 }
41
42 class SGSky;
43
44 class FGRenderer {
45
46 public:
47
48     FGRenderer();
49     ~FGRenderer();
50
51     void splashinit();
52     void init();
53
54     void setupView();
55
56     void resize(int width, int height );
57
58     void update();
59   
60     /** Just pick into the scene and return the pick callbacks on the way ...
61      */
62     bool pick( std::vector<SGSceneryPick>& pickList,
63                const osgGA::GUIEventAdapter* ea );
64
65     /** Get and set the OSG Viewer object, if any.
66      */
67     osgViewer::Viewer* getViewer() { return viewer.get(); }
68     const osgViewer::Viewer* getViewer() const { return viewer.get(); }
69     void setViewer(osgViewer::Viewer* viewer);
70     /** Get and set the manipulator object, if any.
71      */
72     flightgear::FGEventHandler* getEventHandler() { return eventHandler.get(); }
73     const flightgear::FGEventHandler* getEventHandler() const { return eventHandler.get(); }
74     void setEventHandler(flightgear::FGEventHandler* manipulator);
75
76     /** Add a top level camera.
77      */
78     void addCamera(osg::Camera* camera, bool useSceneData);
79
80     /** Add a camera to the group. The camera is added to the viewer
81      * as a slave. See osgViewer::Viewer::addSlave.
82      * @param flags properties of the camera; see CameraGroup::Flags
83      * @param projection slave projection matrix
84      * @param view slave view matrix
85      * @param useMasterSceneData whether the camera displays the
86      * viewer's scene data.
87      * @return a CameraInfo object for the camera.
88      */
89         flightgear::CameraInfo* buildRenderingPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
90                                    const osg::Matrix& view,
91                                    const osg::Matrix& projection,
92                                                                    osg::GraphicsContext* gc,
93                                    bool useMasterSceneData);
94
95         /**
96          */
97         flightgear::CameraInfo* buildClassicalPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
98                                    const osg::Matrix& view,
99                                    const osg::Matrix& projection,
100                                    bool useMasterSceneData);
101
102         /**
103          */
104         flightgear::CameraInfo* buildDeferredPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
105                                    const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
106
107     void updateShadowCamera(const flightgear::CameraInfo* info, const osg::Vec3d& position);
108     void updateShadowMapSize(int mapSize);
109     void enableShadows(bool enabled);
110
111     SGSky* getSky() const { return _sky; }
112
113         void setPlanes( double zNear, double zFar );
114     
115     /**
116      * inform the renderer when the global (2D) panel is changed
117      */
118     void panelChanged();
119 protected:
120     osg::ref_ptr<osgViewer::Viewer> viewer;
121     osg::ref_ptr<flightgear::FGEventHandler> eventHandler;
122     SGPropertyNode_ptr _scenery_loaded,_scenery_override;
123     SGPropertyNode_ptr _skyblend, _splash_alpha;
124     SGPropertyNode_ptr _point_sprites, _enhanced_lighting, _distance_attenuation;
125     SGPropertyNode_ptr _textures;
126     SGPropertyNode_ptr _cloud_status, _visibility_m; 
127     SGPropertyNode_ptr _xsize, _ysize;
128     SGPropertyNode_ptr _panel_hotspots, _sim_delta_sec, _horizon_effect, _altitude_ft;
129     SGPropertyNode_ptr _virtual_cockpit;
130     SGTimeStamp _splash_time;
131     SGSky* _sky;
132         bool _classicalRenderer;
133     int _shadowMapSize;
134
135         osg::Camera* buildDeferredGeometryCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
136         osg::Camera* buildDeferredShadowCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
137         osg::Camera* buildDeferredLightingCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
138     void updateShadowCascade(const flightgear::CameraInfo* info, osg::Camera* camera, osg::Group* grp, int idx, double left, double right, double bottom, double top, double zNear, double f1, double f2);
139     osg::Vec3 getSunDirection() const;
140         osg::ref_ptr<osg::Uniform> _ambientFactor;
141     osg::ref_ptr<osg::Uniform> _sunDiffuse;
142     osg::ref_ptr<osg::Uniform> _sunSpecular;
143     osg::ref_ptr<osg::Uniform> _sunDirection;
144     osg::ref_ptr<osg::Uniform> _planes;
145     osg::ref_ptr<osg::Uniform> _fogColor;
146     osg::ref_ptr<osg::Uniform> _fogDensity;
147
148 };
149
150 bool fgDumpSceneGraphToFile(const char* filename);
151 bool fgDumpTerrainBranchToFile(const char* filename);
152
153 namespace flightgear
154 {
155 bool printVisibleSceneInfo(FGRenderer* renderer);
156 }
157
158 #endif