]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/CameraGroup.hxx
Improve timing statistics
[flightgear.git] / src / Main / CameraGroup.hxx
index e76f3a5fa57493864ff4249cd43a07f5e55c27dd..1e18e28e1172702ebd12e8c7c2a826844cc23b1a 100644 (file)
 #ifndef CAMERAGROUP_HXX
 #define CAMERAGROUP_HXX 1
 
+#include <map>
 #include <string>
 #include <vector>
 
 #include <osg/Matrix>
 #include <osg/ref_ptr>
 #include <osg/Referenced>
+#include <osg/Node>
+#include <osg/TextureRectangle>
 
 // For osgUtil::LineSegmentIntersector::Intersections, which is a typedef.
 #include <osgUtil/LineSegmentIntersector>
@@ -47,8 +50,9 @@ class GraphicsWindow;
  */
 struct CameraInfo : public osg::Referenced
 {
-    CameraInfo(unsigned flags_, osg::Camera* camera_)
-        : flags(flags_), camera(camera_), slaveIndex(-1)
+    CameraInfo(unsigned flags_, osg::Camera* camera_ = 0)
+        : flags(flags_), camera(camera_), slaveIndex(-1), farSlaveIndex(-1),
+          x(0.0), y(0.0), width(0.0), height(0.0)
     {
     }
     /** Properties of the camera. @see CameraGroup::Flags.
@@ -57,11 +61,27 @@ struct CameraInfo : public osg::Referenced
     /** the camera object
      */
     osg::ref_ptr<osg::Camera> camera;
+    /** camera for rendering far field, if needed
+     */
+    osg::ref_ptr<osg::Camera> farCamera;
     /** Index of this camera in the osgViewer::Viewer slave list.
      */
     int slaveIndex;
+    /** index of far camera in slave list
+     */
+    int farSlaveIndex;
+    /** Viewport parameters.
+     */
+    double x;
+    double y;
+    double width;
+    double height;
 };
 
+/** Update the OSG cameras from the camera info.
+ */
+void updateCameras(const CameraInfo* info);
+
 class CameraGroup : public osg::Referenced
 {
 public:
@@ -103,7 +123,7 @@ public:
      * @param cameraNode the property node.
      * @return a CameraInfo object for the camera.
      */
-    CameraInfo* buildCamera(const SGPropertyNode* cameraNode);
+    CameraInfo* buildCamera(SGPropertyNode* cameraNode);
     /** Create a camera from properties that will draw the GUI and add
      * it to the camera group.
      * @param cameraNode the property node. This can be 0, in which
@@ -112,7 +132,7 @@ public:
      * this is 0, the window is determined from the property node.
      * @return a CameraInfo object for the GUI camera.
      */
-    CameraInfo* buildGUICamera(const SGPropertyNode* cameraNode,
+    CameraInfo* buildGUICamera(SGPropertyNode* cameraNode,
                                GraphicsWindow* window = 0);
     /** Update the view for the camera group.
      * @param position the world position of the view
@@ -153,11 +173,26 @@ public:
      * @param the camera group property node.
      */
     static CameraGroup* buildCameraGroup(osgViewer::Viewer* viewer,
-                                         const SGPropertyNode* node);
+                                         SGPropertyNode* node);
+    /** Set the cull mask on all non-GUI cameras
+     */
+    void setCameraCullMasks(osg::Node::NodeMask nm);
+    /** Update camera properties after a resize event.
+     */
+    void resized();
+
+    void buildDistortionCamera(const SGPropertyNode* psNode,
+                               osg::Camera* camera);
 protected:
     CameraList _cameras;
     osg::ref_ptr<osgViewer::Viewer> _viewer;
     static osg::ref_ptr<CameraGroup> _defaultGroup;
+    // Near, far for the master camera if used.
+    float _zNear;
+    float _zFar;
+    float _nearField;
+    typedef std::map<std::string, osg::ref_ptr<osg::TextureRectangle> > TextureMap;
+    TextureMap _textureTargets;
 };
 
 }