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;
56 void resize(int width, int height );
60 /** Just pick into the scene and return the pick callbacks on the way ...
62 bool pick( std::vector<SGSceneryPick>& pickList,
63 const osgGA::GUIEventAdapter* ea );
65 /** Get and set the OSG Viewer object, if any.
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.
72 flightgear::FGEventHandler* getEventHandler() { return eventHandler.get(); }
73 const flightgear::FGEventHandler* getEventHandler() const { return eventHandler.get(); }
74 void setEventHandler(flightgear::FGEventHandler* manipulator);
76 /** Add a top level camera.
78 void addCamera(osg::Camera* camera, bool useSceneData);
80 void removeCamera(osg::Camera* camera);
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.
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);
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);
106 flightgear::CameraInfo* buildDeferredPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
107 const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
109 void updateShadowCamera(const flightgear::CameraInfo* info, const osg::Vec3d& position);
110 void updateShadowMapSize(int mapSize);
111 void enableShadows(bool enabled);
113 SGSky* getSky() const { return _sky; }
115 void setPlanes( double zNear, double zFar );
118 * inform the renderer when the global (2D) panel is changed
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;
134 bool _classicalRenderer;
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;
152 bool fgDumpSceneGraphToFile(const char* filename);
153 bool fgDumpTerrainBranchToFile(const char* filename);
157 bool printVisibleSceneInfo(FGRenderer* renderer);