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 /** 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.
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);
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);
104 flightgear::CameraInfo* buildDeferredPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
105 const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
107 void updateShadowCamera(const flightgear::CameraInfo* info, const osg::Vec3d& position);
109 SGSky* getSky() const { return _sky; }
111 void setPlanes( double zNear, double zFar );
114 * inform the renderer when the global (2D) panel is changed
118 osg::ref_ptr<osgViewer::Viewer> viewer;
119 osg::ref_ptr<flightgear::FGEventHandler> eventHandler;
120 SGPropertyNode_ptr _scenery_loaded,_scenery_override;
121 SGPropertyNode_ptr _skyblend, _splash_alpha;
122 SGPropertyNode_ptr _point_sprites, _enhanced_lighting, _distance_attenuation;
123 SGPropertyNode_ptr _textures;
124 SGPropertyNode_ptr _cloud_status, _visibility_m;
125 SGPropertyNode_ptr _xsize, _ysize;
126 SGPropertyNode_ptr _panel_hotspots, _sim_delta_sec, _horizon_effect, _altitude_ft;
127 SGPropertyNode_ptr _virtual_cockpit;
128 SGTimeStamp _splash_time;
130 bool _classicalRenderer;
133 osg::Camera* buildDeferredGeometryCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
134 osg::Camera* buildDeferredShadowCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
135 osg::Camera* buildDeferredLightingCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
136 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);
137 osg::Vec3 getSunDirection() const;
138 osg::ref_ptr<osg::Uniform> _ambientFactor;
139 osg::ref_ptr<osg::Uniform> _sunDiffuse;
140 osg::ref_ptr<osg::Uniform> _sunSpecular;
141 osg::ref_ptr<osg::Uniform> _sunDirection;
142 osg::ref_ptr<osg::Uniform> _planes;
143 osg::ref_ptr<osg::Uniform> _fogColor;
144 osg::ref_ptr<osg::Uniform> _fogDensity;
148 bool fgDumpSceneGraphToFile(const char* filename);
149 bool fgDumpTerrainBranchToFile(const char* filename);
153 bool printVisibleSceneInfo(FGRenderer* renderer);