]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/CameraGroup.hxx
Fix shared library build for metar executable
[flightgear.git] / src / Main / CameraGroup.hxx
index e76f3a5fa57493864ff4249cd43a07f5e55c27dd..a74895e467f7946e155d1199815c559f30b8a950 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,21 +50,61 @@ 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),
+          physicalWidth(0), physicalHeight(0), bezelHeightTop(0),
+          bezelHeightBottom(0), bezelWidthLeft(0), bezelWidthRight(0),
+          relativeCameraParent(~0u)
     {
     }
+    /** The name as given in the config file.
+     */
+    std::string name;
     /** Properties of the camera. @see CameraGroup::Flags.
      */
     unsigned flags;
     /** 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;
+    /** Physical size parameters.
+     */
+    double physicalWidth;
+    double physicalHeight;
+    double bezelHeightTop;
+    double bezelHeightBottom;
+    double bezelWidthLeft;
+    double bezelWidthRight;
+    /** The parent camera for relative camera configurations.
+     */
+    unsigned relativeCameraParent;
+    /** The reference points in the parents projection space.
+     */
+    osg::Vec2d parentReference[2];
+    /** The reference points in the current projection space.
+     */
+    osg::Vec2d thisReference[2];
 };
 
+/** Update the OSG cameras from the camera info.
+ */
+void updateCameras(const CameraInfo* info);
+
 class CameraGroup : public osg::Referenced
 {
 public:
@@ -74,8 +117,11 @@ public:
         PROJECTION_ABSOLUTE = 0x2, /**< The projection is absolute. */
         ORTHO = 0x4,               /**< The projection is orthographic */
         GUI = 0x8,                 /**< Camera draws the GUI. */
-        DO_INTERSECTION_TEST = 0x10 /**< scene intersection tests this
+        DO_INTERSECTION_TEST = 0x10,/**< scene intersection tests this
                                        camera. */
+        FIXED_NEAR_FAR = 0x20,     /**< take the near far values in the
+                                      projection for real. */
+        ENABLE_MASTER_ZOOM = 0x40  /**< Can apply the zoom algorithm. */
     };
     /** Create a camera group associated with an osgViewer::Viewer.
      * @param viewer the viewer
@@ -103,7 +149,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 +158,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 +199,31 @@ 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);
+  
+    /**
+     * get aspect ratio of master camera's viewport
+     */
+    double getMasterAspectRatio() const;
 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;
 };
 
 }