2 #ifndef __FG_RENDERER_HXX
3 #define __FG_RENDERER_HXX 1
5 #include <simgear/scene/util/SGPickCallback.hxx>
6 #include <simgear/props/props.hxx>
7 #include <simgear/timing/timestamp.hxx>
17 class GraphicsContext;
22 class GUIEventAdapter;
43 class FGRenderingPipeline;
57 void resize(int width, int height );
61 /** Just pick into the scene and return the pick callbacks on the way ...
63 bool pick( std::vector<SGSceneryPick>& pickList,
64 const osgGA::GUIEventAdapter* ea );
66 /** Get and set the OSG Viewer object, if any.
68 osgViewer::Viewer* getViewer() { return viewer.get(); }
69 const osgViewer::Viewer* getViewer() const { return viewer.get(); }
70 void setViewer(osgViewer::Viewer* viewer);
71 /** Get and set the manipulator object, if any.
73 flightgear::FGEventHandler* getEventHandler() { return eventHandler.get(); }
74 const flightgear::FGEventHandler* getEventHandler() const { return eventHandler.get(); }
75 void setEventHandler(flightgear::FGEventHandler* manipulator);
77 /** Add a top level camera.
79 void addCamera(osg::Camera* camera, bool useSceneData);
81 void removeCamera(osg::Camera* camera);
83 /** Add a camera to the group. The camera is added to the viewer
84 * as a slave. See osgViewer::Viewer::addSlave.
85 * @param flags properties of the camera; see CameraGroup::Flags
86 * @param projection slave projection matrix
87 * @param view slave view matrix
88 * @param useMasterSceneData whether the camera displays the
89 * viewer's scene data.
90 * @return a CameraInfo object for the camera.
92 flightgear::CameraInfo* buildRenderingPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
93 const osg::Matrix& view,
94 const osg::Matrix& projection,
95 osg::GraphicsContext* gc,
96 bool useMasterSceneData);
100 flightgear::CameraInfo* buildClassicalPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
101 const osg::Matrix& view,
102 const osg::Matrix& projection,
103 bool useMasterSceneData);
107 flightgear::CameraInfo* buildDeferredPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
108 const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
112 flightgear::CameraInfo* buildDefaultDeferredPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
113 const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
115 void updateShadowCamera(const flightgear::CameraInfo* info, const osg::Vec3d& position);
116 void updateShadowMapSize(int mapSize);
117 void enableShadows(bool enabled);
118 void updateCascadeFar(int index, float far_m);
119 void updateCascadeNumber(size_t num);
121 SGSky* getSky() const { return _sky; }
123 void setPlanes( double zNear, double zFar );
126 * inform the renderer when the global (2D) panel is changed
130 osg::ref_ptr<osgViewer::Viewer> viewer;
131 osg::ref_ptr<flightgear::FGEventHandler> eventHandler;
132 SGPropertyNode_ptr _scenery_loaded,_scenery_override;
133 SGPropertyNode_ptr _skyblend, _splash_alpha;
134 SGPropertyNode_ptr _point_sprites, _enhanced_lighting, _distance_attenuation;
135 SGPropertyNode_ptr _textures;
136 SGPropertyNode_ptr _cloud_status, _visibility_m;
137 SGPropertyNode_ptr _xsize, _ysize;
138 SGPropertyNode_ptr _panel_hotspots, _sim_delta_sec, _horizon_effect, _altitude_ft;
139 SGPropertyNode_ptr _virtual_cockpit;
140 SGTimeStamp _splash_time;
142 bool _classicalRenderer;
143 std::string _renderer;
146 float _cascadeFar[4];
147 bool _useColorForDepth;
149 osg::Camera* buildDeferredGeometryCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
150 osg::Camera* buildDeferredShadowCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
151 osg::Camera* buildDeferredLightingCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
152 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);
153 osg::Vec3 getSunDirection() const;
154 osg::ref_ptr<osg::Uniform> _ambientFactor;
155 osg::ref_ptr<osg::Uniform> _sunDiffuse;
156 osg::ref_ptr<osg::Uniform> _sunSpecular;
157 osg::ref_ptr<osg::Uniform> _sunDirection;
158 osg::ref_ptr<osg::Uniform> _planes;
159 osg::ref_ptr<osg::Uniform> _fogColor;
160 osg::ref_ptr<osg::Uniform> _fogDensity;
161 osg::ref_ptr<osg::Uniform> _shadowNumber;
162 osg::ref_ptr<osg::Uniform> _shadowDistances;
163 osg::ref_ptr<osg::Uniform> _depthInColor;
165 osg::ref_ptr<FGRenderingPipeline> _pipeline;
168 bool fgDumpSceneGraphToFile(const char* filename);
169 bool fgDumpTerrainBranchToFile(const char* filename);
173 bool printVisibleSceneInfo(FGRenderer* renderer);