]> git.mxchange.org Git - flightgear.git/blobdiff - src/Viewer/CameraGroup.hxx
commradio: improvements for atis speech
[flightgear.git] / src / Viewer / CameraGroup.hxx
index 1d5bd0aa06f9ff5530f58b0fc8b41a733269d0b5..4b53359b1fe7d3fa6c532b906e30fdf55abc665d 100644 (file)
@@ -20,6 +20,7 @@
 #include <map>
 #include <string>
 #include <vector>
+#include <memory>
 
 #include <osg/Matrix>
 #include <osg/ref_ptr>
@@ -48,7 +49,9 @@ namespace flightgear
 {
 
 class GraphicsWindow;
-
+class CameraViewportListener;
+class CameraGroupListener;
+    
 struct RenderBufferInfo {
     RenderBufferInfo(osg::Texture2D* t = 0, float s = 1.0 ) : texture(t), scaleFactor(s) {}
     osg::ref_ptr<osg::Texture2D> texture;
@@ -98,7 +101,8 @@ struct CameraInfo : public osg::Referenced
           worldPosCart( new osg::Uniform( "fg_CameraPositionCart", osg::Vec3f() ) ),
           worldPosGeod( new osg::Uniform( "fg_CameraPositionGeod", osg::Vec3f() ) ),
           du( new osg::Uniform( "fg_du",osg::Vec4() ) ),
-          dv( new osg::Uniform( "fg_dv",osg::Vec4() ) )
+          dv( new osg::Uniform( "fg_dv",osg::Vec4() ) ),
+          viewportListener(NULL)
     {
         shadowMatrix[0] = new osg::Uniform("fg_ShadowMatrix_0", osg::Matrixf());
         shadowMatrix[1] = new osg::Uniform("fg_ShadowMatrix_1", osg::Matrixf());
@@ -106,10 +110,13 @@ struct CameraInfo : public osg::Referenced
         shadowMatrix[3] = new osg::Uniform("fg_ShadowMatrix_3", osg::Matrixf());
     }
 
+    ~CameraInfo();
+    
     /** Update and resize cameras
      */
     void updateCameras();
     void resized(double w, double h);
+        
     /** The name as given in the config file.
      */
     std::string name;
@@ -161,6 +168,8 @@ struct CameraInfo : public osg::Referenced
     osg::ref_ptr<osg::Uniform> dv;
     osg::ref_ptr<osg::Uniform> shadowMatrix[4];
 
+    CameraViewportListener* viewportListener;
+    
     void setMatrices( osg::Camera* c );
 
     osgUtil::RenderBin::RenderBinList savedTransparentBins;
@@ -172,10 +181,6 @@ struct CameraInfo : public osg::Referenced
     osg::Vec2d thisReference[2];
 };
 
-/** Update the OSG cameras from the camera info.
- */
-void updateCameras(const CameraInfo* info);
-
 class CameraGroup : public osg::Referenced
 {
 public:
@@ -198,6 +203,9 @@ public:
      * @param viewer the viewer
      */
     CameraGroup(osgViewer::Viewer* viewer);
+    
+    ~CameraGroup();
+    
     /** Get the camera group's Viewer.
      * @return the viewer
      */
@@ -236,11 +244,15 @@ public:
      * matters at this time.
      * @param group the group to set.
      */
+   
+    static void buildDefaultGroup(osgViewer::Viewer* viewer);
+    
     static void setDefault(CameraGroup* group) { _defaultGroup = group; }
     /** Get the default CameraGroup.
      * @return the default camera group.
      */
     static CameraGroup* getDefault() { return _defaultGroup.get(); }
+    
     typedef std::vector<osg::ref_ptr<CameraInfo> > CameraList;
     typedef CameraList::iterator CameraIterator;
     typedef CameraList::const_iterator ConstCameraIterator;
@@ -253,12 +265,6 @@ public:
     ConstCameraIterator camerasBegin() const { return _cameras.begin(); }
     ConstCameraIterator camerasEnd() const { return _cameras.end(); }
     void addCamera(CameraInfo* info) { _cameras.push_back(info); }
-    /** Build a complete CameraGroup from a property node.
-     * @param viewer the viewer associated with this camera group.
-     * @param the camera group property node.
-     */
-    static CameraGroup* buildCameraGroup(osgViewer::Viewer* viewer,
-                                         SGPropertyNode* node);
     /** Set the cull mask on all non-GUI cameras
      */
     void setCameraCullMasks(osg::Node::NodeMask nm);
@@ -278,16 +284,30 @@ public:
      * find the GUI camera if one is defined 
      */
     const CameraInfo* getGUICamera() const;
+    
+    void setZNear(float f) { _zNear = f; }
+    void setZFar(float f) { _zFar = f; }
+    void setNearField(float f) { _nearField = f; }
 protected:
     CameraList _cameras;
     osg::ref_ptr<osgViewer::Viewer> _viewer;
     static osg::ref_ptr<CameraGroup> _defaultGroup;
+    std::auto_ptr<CameraGroupListener> _listener;
+    
     // 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;
+    
+    /** Build a complete CameraGroup from a property node.
+     * @param viewer the viewer associated with this camera group.
+     * @param the camera group property node.
+     */
+    static CameraGroup* buildCameraGroup(osgViewer::Viewer* viewer,
+                                         SGPropertyNode* node);
 };
 
 }