]> git.mxchange.org Git - flightgear.git/blobdiff - src/Viewer/CameraGroup.hxx
commradio: improvements for atis speech
[flightgear.git] / src / Viewer / CameraGroup.hxx
index 46b576ba25b2537cd8c0b4289a99b564b7f9769d..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;
@@ -95,15 +98,25 @@ struct CameraInfo : public osg::Referenced
           projInverse( new osg::Uniform( "fg_ProjectionMatrixInverse", osg::Matrixf() ) ),
           viewInverse( new osg::Uniform( "fg_ViewMatrixInverse",osg::Matrixf() ) ),
           view( new osg::Uniform( "fg_ViewMatrix",osg::Matrixf() ) ),
+          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());
+        shadowMatrix[2] = new osg::Uniform("fg_ShadowMatrix_2", osg::Matrixf());
+        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;
@@ -134,7 +147,7 @@ struct CameraInfo : public osg::Referenced
     CameraMap cameras;
     void addCamera( const std::string& k, osg::Camera* c, int si = -1, bool fs = false ) { cameras[k].camera = c; cameras[k].slaveIndex = si; cameras[k].fullscreen = fs; }
     void addCamera( const std::string& k, osg::Camera* c, bool fs ) { cameras[k].camera = c; cameras[k].fullscreen = fs; }
-    void addCamera( const std::string& k, osg::Camera* c, float s ) { cameras[k].camera = c; cameras[k].scaleFactor = s; }
+    void addCamera( const std::string& k, osg::Camera* c, float s, bool fs = false ) { cameras[k].camera = c; cameras[k].scaleFactor = s; cameras[k].fullscreen = fs; }
     osg::Camera* getCamera(const std::string& k) const;
     int getMainSlaveIndex() const;
     RenderStageInfo& getRenderStageInfo( const std::string& k ) { return cameras[k]; }
@@ -145,16 +158,18 @@ struct CameraInfo : public osg::Referenced
     void addBuffer(const std::string& k, osg::Texture2D* tex, float scale = 1.0 ) { buffers[k] = RenderBufferInfo(tex,scale); }
     osg::Texture2D* getBuffer(const std::string& k) const;
 
-    osg::ref_ptr<osg::TexGen> shadowTexGen[4];
-
     osg::ref_ptr<osg::Uniform> bufferSize;
-    //osg::ref_ptr<osg::Uniform> bloomOffset[2];
     osg::ref_ptr<osg::Uniform> projInverse;
     osg::ref_ptr<osg::Uniform> viewInverse;
     osg::ref_ptr<osg::Uniform> view;
+    osg::ref_ptr<osg::Uniform> worldPosCart;
+    osg::ref_ptr<osg::Uniform> worldPosGeod;
     osg::ref_ptr<osg::Uniform> du;
     osg::ref_ptr<osg::Uniform> dv;
+    osg::ref_ptr<osg::Uniform> shadowMatrix[4];
 
+    CameraViewportListener* viewportListener;
+    
     void setMatrices( osg::Camera* c );
 
     osgUtil::RenderBin::RenderBinList savedTransparentBins;
@@ -166,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:
@@ -192,6 +203,9 @@ public:
      * @param viewer the viewer
      */
     CameraGroup(osgViewer::Viewer* viewer);
+    
+    ~CameraGroup();
+    
     /** Get the camera group's Viewer.
      * @return the viewer
      */
@@ -230,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;
@@ -247,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);
@@ -272,25 +284,34 @@ 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);
 };
 
 }
 
-namespace osgGA
-{
-class GUIEventAdapter;
-}
-
 namespace flightgear
 {
 /** Get the osg::Camera that draws the GUI, if any, from a camera
@@ -309,7 +330,7 @@ osg::Camera* getGUICamera(CameraGroup* cgroup);
  * @return true if any intersections are found
  */
 bool computeIntersections(const CameraGroup* cgroup,
-                          const osgGA::GUIEventAdapter* ea,
+                          const osg::Vec2d& windowPos,
                           osgUtil::LineSegmentIntersector::Intersections&
                           intersections);
 /** Warp the pointer to coordinates in the GUI camera of a camera group.