2004-09-19 17:02:16 +00:00
|
|
|
|
|
|
|
#ifndef __FG_RENDERER_HXX
|
|
|
|
#define __FG_RENDERER_HXX 1
|
|
|
|
|
2007-01-07 12:02:50 +00:00
|
|
|
#include <simgear/scene/util/SGPickCallback.hxx>
|
2011-05-21 13:22:47 +02:00
|
|
|
#include <simgear/props/props.hxx>
|
2011-05-21 14:51:10 +02:00
|
|
|
#include <simgear/timing/timestamp.hxx>
|
2004-09-19 17:02:16 +00:00
|
|
|
|
2008-11-18 22:45:57 +00:00
|
|
|
#include <osg/ref_ptr>
|
2012-03-10 14:57:43 +01:00
|
|
|
#include <osg/Matrix>
|
2012-03-30 07:26:29 +02:00
|
|
|
#include <osg/Vec3>
|
2008-11-18 22:45:57 +00:00
|
|
|
|
2012-05-01 16:44:59 +02:00
|
|
|
#include "renderingpipeline.hxx"
|
|
|
|
|
2008-11-18 22:45:57 +00:00
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Camera;
|
|
|
|
class Group;
|
2012-03-25 14:37:01 +02:00
|
|
|
class GraphicsContext;
|
2008-11-18 22:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace osgGA
|
|
|
|
{
|
|
|
|
class GUIEventAdapter;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace osgShadow
|
|
|
|
{
|
|
|
|
class ShadowedScene;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace osgViewer
|
|
|
|
{
|
|
|
|
class Viewer;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace flightgear
|
|
|
|
{
|
|
|
|
class FGEventHandler;
|
2012-03-10 14:57:43 +01:00
|
|
|
struct CameraInfo;
|
|
|
|
class CameraGroup;
|
2008-11-18 22:45:57 +00:00
|
|
|
}
|
2007-05-21 17:50:02 +00:00
|
|
|
|
2004-09-19 17:02:16 +00:00
|
|
|
class SGSky;
|
|
|
|
|
|
|
|
class FGRenderer {
|
|
|
|
|
|
|
|
public:
|
2005-02-25 19:41:53 +00:00
|
|
|
|
2004-10-06 09:57:37 +00:00
|
|
|
FGRenderer();
|
|
|
|
~FGRenderer();
|
2004-09-19 17:02:16 +00:00
|
|
|
|
2007-05-03 18:12:29 +00:00
|
|
|
void splashinit();
|
2004-09-19 17:02:16 +00:00
|
|
|
void init();
|
|
|
|
|
2011-05-22 18:28:42 +02:00
|
|
|
void setupView();
|
|
|
|
|
2011-05-21 13:22:47 +02:00
|
|
|
void resize(int width, int height );
|
2004-10-06 03:29:14 +00:00
|
|
|
|
2011-09-19 09:00:23 +01:00
|
|
|
void update();
|
2011-09-18 15:05:05 +01:00
|
|
|
|
2007-01-07 12:02:50 +00:00
|
|
|
/** Just pick into the scene and return the pick callbacks on the way ...
|
2005-12-12 21:15:20 +00:00
|
|
|
*/
|
2013-02-09 16:05:54 +00:00
|
|
|
bool pick( std::vector<SGSceneryPick>& pickList, const osg::Vec2& windowPos);
|
2007-05-21 17:50:02 +00:00
|
|
|
|
|
|
|
/** Get and set the OSG Viewer object, if any.
|
|
|
|
*/
|
|
|
|
osgViewer::Viewer* getViewer() { return viewer.get(); }
|
|
|
|
const osgViewer::Viewer* getViewer() const { return viewer.get(); }
|
2008-11-18 22:45:57 +00:00
|
|
|
void setViewer(osgViewer::Viewer* viewer);
|
2007-05-21 17:50:02 +00:00
|
|
|
/** Get and set the manipulator object, if any.
|
|
|
|
*/
|
2008-11-18 22:45:57 +00:00
|
|
|
flightgear::FGEventHandler* getEventHandler() { return eventHandler.get(); }
|
|
|
|
const flightgear::FGEventHandler* getEventHandler() const { return eventHandler.get(); }
|
|
|
|
void setEventHandler(flightgear::FGEventHandler* manipulator);
|
2007-06-24 07:52:50 +00:00
|
|
|
|
|
|
|
/** Add a top level camera.
|
2012-03-10 14:57:43 +01:00
|
|
|
*/
|
2007-06-24 07:52:50 +00:00
|
|
|
void addCamera(osg::Camera* camera, bool useSceneData);
|
|
|
|
|
2012-04-15 12:03:21 +01:00
|
|
|
void removeCamera(osg::Camera* camera);
|
|
|
|
|
2012-03-10 14:57:43 +01:00
|
|
|
/** Add a camera to the group. The camera is added to the viewer
|
|
|
|
* as a slave. See osgViewer::Viewer::addSlave.
|
|
|
|
* @param flags properties of the camera; see CameraGroup::Flags
|
|
|
|
* @param projection slave projection matrix
|
|
|
|
* @param view slave view matrix
|
|
|
|
* @param useMasterSceneData whether the camera displays the
|
|
|
|
* viewer's scene data.
|
|
|
|
* @return a CameraInfo object for the camera.
|
|
|
|
*/
|
|
|
|
flightgear::CameraInfo* buildRenderingPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
|
|
|
|
const osg::Matrix& view,
|
|
|
|
const osg::Matrix& projection,
|
2012-03-25 14:37:01 +02:00
|
|
|
osg::GraphicsContext* gc,
|
2012-03-10 14:57:43 +01:00
|
|
|
bool useMasterSceneData);
|
|
|
|
|
2012-03-11 15:50:18 +01:00
|
|
|
/**
|
|
|
|
*/
|
|
|
|
flightgear::CameraInfo* buildClassicalPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
|
|
|
|
const osg::Matrix& view,
|
|
|
|
const osg::Matrix& projection,
|
|
|
|
bool useMasterSceneData);
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
flightgear::CameraInfo* buildDeferredPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
|
2012-03-25 14:37:01 +02:00
|
|
|
const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
|
2012-03-11 15:50:18 +01:00
|
|
|
|
2012-03-30 07:26:29 +02:00
|
|
|
void updateShadowCamera(const flightgear::CameraInfo* info, const osg::Vec3d& position);
|
2012-03-30 22:30:26 +02:00
|
|
|
void updateShadowMapSize(int mapSize);
|
2012-04-04 20:43:16 +02:00
|
|
|
void enableShadows(bool enabled);
|
2012-04-17 09:10:53 +02:00
|
|
|
void updateCascadeFar(int index, float far_m);
|
|
|
|
void updateCascadeNumber(size_t num);
|
2012-03-30 07:26:29 +02:00
|
|
|
|
2011-11-05 13:18:36 +00:00
|
|
|
SGSky* getSky() const { return _sky; }
|
2012-03-25 14:37:01 +02:00
|
|
|
|
|
|
|
void setPlanes( double zNear, double zFar );
|
2012-05-16 11:43:09 +01:00
|
|
|
|
2007-05-21 17:50:02 +00:00
|
|
|
protected:
|
|
|
|
osg::ref_ptr<osgViewer::Viewer> viewer;
|
2008-11-18 22:45:57 +00:00
|
|
|
osg::ref_ptr<flightgear::FGEventHandler> eventHandler;
|
2012-12-15 15:25:45 +00:00
|
|
|
SGPropertyNode_ptr _scenery_loaded, _position_finalized;
|
|
|
|
|
2011-05-21 17:12:37 +02:00
|
|
|
SGPropertyNode_ptr _skyblend, _splash_alpha;
|
2011-05-21 13:22:47 +02:00
|
|
|
SGPropertyNode_ptr _point_sprites, _enhanced_lighting, _distance_attenuation;
|
|
|
|
SGPropertyNode_ptr _textures;
|
|
|
|
SGPropertyNode_ptr _cloud_status, _visibility_m;
|
|
|
|
SGPropertyNode_ptr _xsize, _ysize;
|
|
|
|
SGPropertyNode_ptr _panel_hotspots, _sim_delta_sec, _horizon_effect, _altitude_ft;
|
|
|
|
SGPropertyNode_ptr _virtual_cockpit;
|
2011-05-21 14:51:10 +02:00
|
|
|
SGTimeStamp _splash_time;
|
2011-11-05 13:18:36 +00:00
|
|
|
SGSky* _sky;
|
2012-04-17 09:10:53 +02:00
|
|
|
bool _classicalRenderer;
|
2012-04-19 20:31:53 +02:00
|
|
|
std::string _renderer;
|
2012-03-30 07:26:29 +02:00
|
|
|
int _shadowMapSize;
|
2012-04-17 09:10:53 +02:00
|
|
|
size_t _numCascades;
|
|
|
|
float _cascadeFar[4];
|
2012-05-01 08:27:13 +02:00
|
|
|
bool _useColorForDepth;
|
2012-03-25 14:37:01 +02:00
|
|
|
|
2013-12-04 09:11:26 +00:00
|
|
|
typedef std::vector<SGPropertyChangeListener*> SGPropertyChangeListenerVec;
|
|
|
|
SGPropertyChangeListenerVec _listeners;
|
|
|
|
|
2012-05-12 15:19:11 +02:00
|
|
|
flightgear::CameraInfo* buildCameraFromRenderingPipeline(FGRenderingPipeline* rpipe, flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
|
2012-05-08 15:13:38 +02:00
|
|
|
const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
|
|
|
|
|
|
|
|
void buildBuffers(FGRenderingPipeline* rpipe, flightgear::CameraInfo* info);
|
2012-05-19 15:43:49 +02:00
|
|
|
void buildStage(flightgear::CameraInfo* info, FGRenderingPipeline::Stage* stage, flightgear::CameraGroup* cgroup, osg::Camera* mainCamera, const osg::Matrix& view, const osg::Matrix& projection, osg::GraphicsContext* gc);
|
2012-05-13 18:57:00 +02:00
|
|
|
osg::Node* buildPass(flightgear::CameraInfo* info, FGRenderingPipeline::Pass* pass);
|
|
|
|
osg::Node* buildLightingSkyCloudsPass(FGRenderingPipeline::Pass* pass);
|
|
|
|
osg::Node* buildLightingLightsPass(flightgear::CameraInfo* info, FGRenderingPipeline::Pass* pass);
|
|
|
|
|
|
|
|
osg::Camera* buildDeferredGeometryCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc, const std::string& name, const FGRenderingPipeline::AttachmentList& attachments );
|
|
|
|
osg::Camera* buildDeferredShadowCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc, const std::string& name, const FGRenderingPipeline::AttachmentList& attachments );
|
|
|
|
osg::Camera* buildDeferredLightingCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc, const FGRenderingPipeline::Stage* stage );
|
|
|
|
osg::Camera* buildDeferredFullscreenCamera( flightgear::CameraInfo* info, osg::GraphicsContext* gc, const FGRenderingPipeline::Stage* stage );
|
|
|
|
osg::Camera* buildDeferredFullscreenCamera( flightgear::CameraInfo* info, const FGRenderingPipeline::Pass* pass );
|
2012-08-02 22:59:49 +02:00
|
|
|
void buildDeferredDisplayCamera( osg::Camera* camera, flightgear::CameraInfo* info, const FGRenderingPipeline::Stage* stage, osg::GraphicsContext* gc );
|
2012-05-08 15:13:38 +02:00
|
|
|
|
2012-03-30 07:26:29 +02:00
|
|
|
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);
|
|
|
|
osg::Vec3 getSunDirection() const;
|
2012-04-17 09:10:53 +02:00
|
|
|
osg::ref_ptr<osg::Uniform> _ambientFactor;
|
2012-03-25 14:37:01 +02:00
|
|
|
osg::ref_ptr<osg::Uniform> _sunDiffuse;
|
|
|
|
osg::ref_ptr<osg::Uniform> _sunSpecular;
|
|
|
|
osg::ref_ptr<osg::Uniform> _sunDirection;
|
|
|
|
osg::ref_ptr<osg::Uniform> _planes;
|
|
|
|
osg::ref_ptr<osg::Uniform> _fogColor;
|
|
|
|
osg::ref_ptr<osg::Uniform> _fogDensity;
|
2012-04-17 09:10:53 +02:00
|
|
|
osg::ref_ptr<osg::Uniform> _shadowNumber;
|
|
|
|
osg::ref_ptr<osg::Uniform> _shadowDistances;
|
2012-05-01 08:27:13 +02:00
|
|
|
osg::ref_ptr<osg::Uniform> _depthInColor;
|
2012-04-19 20:31:53 +02:00
|
|
|
|
|
|
|
osg::ref_ptr<FGRenderingPipeline> _pipeline;
|
2013-12-04 09:11:26 +00:00
|
|
|
|
|
|
|
void addChangeListener(SGPropertyChangeListener* l, const char* path);
|
2004-09-19 17:02:16 +00:00
|
|
|
};
|
|
|
|
|
2007-05-26 11:39:13 +00:00
|
|
|
bool fgDumpSceneGraphToFile(const char* filename);
|
2007-11-21 20:51:49 +00:00
|
|
|
bool fgDumpTerrainBranchToFile(const char* filename);
|
2007-05-26 11:39:13 +00:00
|
|
|
|
2010-11-14 15:12:58 +01:00
|
|
|
namespace flightgear
|
|
|
|
{
|
|
|
|
bool printVisibleSceneInfo(FGRenderer* renderer);
|
|
|
|
}
|
|
|
|
|
2004-09-19 17:02:16 +00:00
|
|
|
#endif
|