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>
13 #include "renderingpipeline.hxx"
19 class GraphicsContext;
24 class GUIEventAdapter;
58 void resize(int width, int height );
62 /** Just pick into the scene and return the pick callbacks on the way ...
64 bool pick( std::vector<SGSceneryPick>& pickList,
65 const osgGA::GUIEventAdapter* ea );
67 /** Get and set the OSG Viewer object, if any.
69 osgViewer::Viewer* getViewer() { return viewer.get(); }
70 const osgViewer::Viewer* getViewer() const { return viewer.get(); }
71 void setViewer(osgViewer::Viewer* viewer);
72 /** Get and set the manipulator object, if any.
74 flightgear::FGEventHandler* getEventHandler() { return eventHandler.get(); }
75 const flightgear::FGEventHandler* getEventHandler() const { return eventHandler.get(); }
76 void setEventHandler(flightgear::FGEventHandler* manipulator);
78 /** Add a top level camera.
80 void addCamera(osg::Camera* camera, bool useSceneData);
82 void removeCamera(osg::Camera* camera);
84 /** Add a camera to the group. The camera is added to the viewer
85 * as a slave. See osgViewer::Viewer::addSlave.
86 * @param flags properties of the camera; see CameraGroup::Flags
87 * @param projection slave projection matrix
88 * @param view slave view matrix
89 * @param useMasterSceneData whether the camera displays the
90 * viewer's scene data.
91 * @return a CameraInfo object for the camera.
93 flightgear::CameraInfo* buildRenderingPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
94 const osg::Matrix& view,
95 const osg::Matrix& projection,
96 osg::GraphicsContext* gc,
97 bool useMasterSceneData);
101 flightgear::CameraInfo* buildClassicalPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
102 const osg::Matrix& view,
103 const osg::Matrix& projection,
104 bool useMasterSceneData);
108 flightgear::CameraInfo* buildDeferredPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
109 const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
113 flightgear::CameraInfo* buildDefaultDeferredPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
114 const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
116 void updateShadowCamera(const flightgear::CameraInfo* info, const osg::Vec3d& position);
117 void updateShadowMapSize(int mapSize);
118 void enableShadows(bool enabled);
119 void updateCascadeFar(int index, float far_m);
120 void updateCascadeNumber(size_t num);
122 SGSky* getSky() const { return _sky; }
124 void setPlanes( double zNear, double zFar );
127 * inform the renderer when the global (2D) panel is changed
131 osg::ref_ptr<osgViewer::Viewer> viewer;
132 osg::ref_ptr<flightgear::FGEventHandler> eventHandler;
133 SGPropertyNode_ptr _scenery_loaded,_scenery_override;
134 SGPropertyNode_ptr _skyblend, _splash_alpha;
135 SGPropertyNode_ptr _point_sprites, _enhanced_lighting, _distance_attenuation;
136 SGPropertyNode_ptr _textures;
137 SGPropertyNode_ptr _cloud_status, _visibility_m;
138 SGPropertyNode_ptr _xsize, _ysize;
139 SGPropertyNode_ptr _panel_hotspots, _sim_delta_sec, _horizon_effect, _altitude_ft;
140 SGPropertyNode_ptr _virtual_cockpit;
141 SGTimeStamp _splash_time;
143 bool _classicalRenderer;
144 std::string _renderer;
147 float _cascadeFar[4];
148 bool _useColorForDepth;
150 osg::Camera* buildDeferredGeometryCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc, const std::vector<osg::ref_ptr<FGRenderingPipeline::Attachment> > &attachments );
151 osg::Camera* buildDefaultDeferredGeometryCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
152 osg::Camera* buildDeferredShadowCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc, const std::vector<osg::ref_ptr<FGRenderingPipeline::Attachment> > &attachments );
153 osg::Camera* buildDefaultDeferredShadowCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
154 osg::Camera* buildDeferredLightingCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc, const std::vector<osg::ref_ptr<FGRenderingPipeline::Attachment> > &attachments );
155 osg::Camera* buildDefaultDeferredLightingCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc );
156 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);
157 osg::Vec3 getSunDirection() const;
158 osg::ref_ptr<osg::Uniform> _ambientFactor;
159 osg::ref_ptr<osg::Uniform> _sunDiffuse;
160 osg::ref_ptr<osg::Uniform> _sunSpecular;
161 osg::ref_ptr<osg::Uniform> _sunDirection;
162 osg::ref_ptr<osg::Uniform> _planes;
163 osg::ref_ptr<osg::Uniform> _fogColor;
164 osg::ref_ptr<osg::Uniform> _fogDensity;
165 osg::ref_ptr<osg::Uniform> _shadowNumber;
166 osg::ref_ptr<osg::Uniform> _shadowDistances;
167 osg::ref_ptr<osg::Uniform> _depthInColor;
169 osg::ref_ptr<FGRenderingPipeline> _pipeline;
172 bool fgDumpSceneGraphToFile(const char* filename);
173 bool fgDumpTerrainBranchToFile(const char* filename);
177 bool printVisibleSceneInfo(FGRenderer* renderer);