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