]> git.mxchange.org Git - flightgear.git/blob - src/Main/renderer.hxx
Tweak ODGauge usage, fix multiple instances of NavDisplay or wxRadar.
[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     void removeCamera(osg::Camera* camera);
81   
82     /** Add a camera to the group. The camera is added to the viewer
83      * as a slave. See osgViewer::Viewer::addSlave.
84      * @param flags properties of the camera; see CameraGroup::Flags
85      * @param projection slave projection matrix
86      * @param view slave view matrix
87      * @param useMasterSceneData whether the camera displays the
88      * viewer's scene data.
89      * @return a CameraInfo object for the camera.
90      */
91         flightgear::CameraInfo* buildRenderingPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
92                                    const osg::Matrix& view,
93                                    const osg::Matrix& projection,
94                                                                    osg::GraphicsContext* gc,
95                                    bool useMasterSceneData);
96
97         /**
98          */
99         flightgear::CameraInfo* buildClassicalPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
100                                    const osg::Matrix& view,
101                                    const osg::Matrix& projection,
102                                    bool useMasterSceneData);
103
104         /**
105          */
106         flightgear::CameraInfo* buildDeferredPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
107                                    const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
108
109     void updateShadowCamera(const flightgear::CameraInfo* info, const osg::Vec3d& position);
110     void updateShadowMapSize(int mapSize);
111     void enableShadows(bool enabled);
112
113     SGSky* getSky() const { return _sky; }
114
115         void setPlanes( double zNear, double zFar );
116     
117     /**
118      * inform the renderer when the global (2D) panel is changed
119      */
120     void panelChanged();
121 protected:
122     osg::ref_ptr<osgViewer::Viewer> viewer;
123     osg::ref_ptr<flightgear::FGEventHandler> eventHandler;
124     SGPropertyNode_ptr _scenery_loaded,_scenery_override;
125     SGPropertyNode_ptr _skyblend, _splash_alpha;
126     SGPropertyNode_ptr _point_sprites, _enhanced_lighting, _distance_attenuation;
127     SGPropertyNode_ptr _textures;
128     SGPropertyNode_ptr _cloud_status, _visibility_m; 
129     SGPropertyNode_ptr _xsize, _ysize;
130     SGPropertyNode_ptr _panel_hotspots, _sim_delta_sec, _horizon_effect, _altitude_ft;
131     SGPropertyNode_ptr _virtual_cockpit;
132     SGTimeStamp _splash_time;
133     SGSky* _sky;
134         bool _classicalRenderer;
135     int _shadowMapSize;
136
137         osg::Camera* buildDeferredGeometryCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
138         osg::Camera* buildDeferredShadowCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
139         osg::Camera* buildDeferredLightingCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
140     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);
141     osg::Vec3 getSunDirection() const;
142         osg::ref_ptr<osg::Uniform> _ambientFactor;
143     osg::ref_ptr<osg::Uniform> _sunDiffuse;
144     osg::ref_ptr<osg::Uniform> _sunSpecular;
145     osg::ref_ptr<osg::Uniform> _sunDirection;
146     osg::ref_ptr<osg::Uniform> _planes;
147     osg::ref_ptr<osg::Uniform> _fogColor;
148     osg::ref_ptr<osg::Uniform> _fogDensity;
149
150 };
151
152 bool fgDumpSceneGraphToFile(const char* filename);
153 bool fgDumpTerrainBranchToFile(const char* filename);
154
155 namespace flightgear
156 {
157 bool printVisibleSceneInfo(FGRenderer* renderer);
158 }
159
160 #endif