]> git.mxchange.org Git - flightgear.git/blob - src/Main/renderer.hxx
Move camera setup to the renderer
[flightgear.git] / src / Main / renderer.hxx
1
2 #ifndef __FG_RENDERER_HXX
3 #define __FG_RENDERER_HXX 1
4
5 #include <simgear/scene/util/SGPickCallback.hxx>
6 #include <simgear/props/props.hxx>
7 #include <simgear/timing/timestamp.hxx>
8
9 #include <osg/ref_ptr>
10 #include <osg/Matrix>
11
12 namespace osg
13 {
14 class Camera;
15 class Group;
16 }
17
18 namespace osgGA
19 {
20 class GUIEventAdapter;
21 }
22
23 namespace osgShadow
24 {
25 class ShadowedScene;
26 }
27
28 namespace osgViewer
29 {
30 class Viewer;
31 }
32
33 namespace flightgear
34 {
35 class FGEventHandler;
36 struct CameraInfo;
37 class CameraGroup;
38 }
39
40 class SGSky;
41
42 class FGRenderer {
43
44 public:
45
46     FGRenderer();
47     ~FGRenderer();
48
49     void splashinit();
50     void init();
51
52     void setupView();
53
54     void resize(int width, int height );
55
56     void update();
57   
58     /** Just pick into the scene and return the pick callbacks on the way ...
59      */
60     bool pick( std::vector<SGSceneryPick>& pickList,
61                const osgGA::GUIEventAdapter* ea );
62
63     /** Get and set the OSG Viewer object, if any.
64      */
65     osgViewer::Viewer* getViewer() { return viewer.get(); }
66     const osgViewer::Viewer* getViewer() const { return viewer.get(); }
67     void setViewer(osgViewer::Viewer* viewer);
68     /** Get and set the manipulator object, if any.
69      */
70     flightgear::FGEventHandler* getEventHandler() { return eventHandler.get(); }
71     const flightgear::FGEventHandler* getEventHandler() const { return eventHandler.get(); }
72     void setEventHandler(flightgear::FGEventHandler* manipulator);
73
74     /** Add a top level camera.
75      */
76     void addCamera(osg::Camera* camera, bool useSceneData);
77
78     /** Add a camera to the group. The camera is added to the viewer
79      * as a slave. See osgViewer::Viewer::addSlave.
80      * @param flags properties of the camera; see CameraGroup::Flags
81      * @param projection slave projection matrix
82      * @param view slave view matrix
83      * @param useMasterSceneData whether the camera displays the
84      * viewer's scene data.
85      * @return a CameraInfo object for the camera.
86      */
87         flightgear::CameraInfo* buildRenderingPipeline(flightgear::CameraGroup* cgroup, unsigned flags, osg::Camera* camera,
88                                    const osg::Matrix& view,
89                                    const osg::Matrix& projection,
90                                    bool useMasterSceneData);
91
92     SGSky* getSky() const { return _sky; }
93     
94     /**
95      * inform the renderer when the global (2D) panel is changed
96      */
97     void panelChanged();
98 protected:
99     osg::ref_ptr<osgViewer::Viewer> viewer;
100     osg::ref_ptr<flightgear::FGEventHandler> eventHandler;
101     SGPropertyNode_ptr _scenery_loaded,_scenery_override;
102     SGPropertyNode_ptr _skyblend, _splash_alpha;
103     SGPropertyNode_ptr _point_sprites, _enhanced_lighting, _distance_attenuation;
104     SGPropertyNode_ptr _textures;
105     SGPropertyNode_ptr _cloud_status, _visibility_m; 
106     SGPropertyNode_ptr _xsize, _ysize;
107     SGPropertyNode_ptr _panel_hotspots, _sim_delta_sec, _horizon_effect, _altitude_ft;
108     SGPropertyNode_ptr _virtual_cockpit;
109     SGTimeStamp _splash_time;
110     SGSky* _sky;
111 };
112
113 bool fgDumpSceneGraphToFile(const char* filename);
114 bool fgDumpTerrainBranchToFile(const char* filename);
115
116 namespace flightgear
117 {
118 bool printVisibleSceneInfo(FGRenderer* renderer);
119 }
120
121 #endif