Removed remaining dependancies on osg::Camera.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
#include <osg/AnimationPath>
|
||||
#include <osg/Notify>
|
||||
#include <osgGA/CameraManipulator>
|
||||
#include <osgGA/MatrixManipulator>
|
||||
|
||||
namespace osgGA{
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace osgGA{
|
||||
// px py pz = World position in catesian coordinates
|
||||
// ax ay az aw = Orientation (attitude) defined as a quaternion
|
||||
|
||||
class OSGGA_EXPORT AnimationPathManipulator : public CameraManipulator
|
||||
class OSGGA_EXPORT AnimationPathManipulator : public MatrixManipulator
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -41,6 +41,19 @@ class OSGGA_EXPORT AnimationPathManipulator : public CameraManipulator
|
||||
|
||||
virtual const char* className() const { return "AnimationPath"; }
|
||||
|
||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||
virtual void setByMatrix(const osg::Matrix& matrix) { _matrix = matrix; }
|
||||
|
||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||
virtual void setByInverseMatrix(const osg::Matrix& matrix) { _matrix.invert(matrix); }
|
||||
|
||||
/** get the position of the manipulator as 4x4 Matrix.*/
|
||||
virtual osg::Matrix getMatrix() const { return _matrix; }
|
||||
|
||||
/** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
|
||||
virtual osg::Matrix getInverseMatrix() const { return osg::Matrix::inverse(_matrix); }
|
||||
|
||||
|
||||
void setAnimationPath( osg::AnimationPath* animationPath ) { _animationPath=animationPath; }
|
||||
|
||||
osg::AnimationPath* getAnimationPath() { return _animationPath.get(); }
|
||||
@@ -74,6 +87,8 @@ class OSGGA_EXPORT AnimationPathManipulator : public CameraManipulator
|
||||
double _realStartOfTimedPeriod;
|
||||
double _animStartOfTimedPeriod;
|
||||
int _numOfFramesSinceStartOfTimedPeriod;
|
||||
|
||||
osg::Matrix _matrix;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
#ifndef OSGGA_DRIVEMANIPULATOR
|
||||
#define OSGGA_DRIVEMANIPULATOR 1
|
||||
|
||||
#include <osgGA/CameraManipulator>
|
||||
#include <osgGA/MatrixManipulator>
|
||||
#include <osg/Quat>
|
||||
|
||||
namespace osgGA{
|
||||
|
||||
@@ -25,7 +26,7 @@ mouse button decelerates, and the middle mouse button (or left and
|
||||
right simultaneously) stops dead.
|
||||
*/
|
||||
|
||||
class OSGGA_EXPORT DriveManipulator : public CameraManipulator
|
||||
class OSGGA_EXPORT DriveManipulator : public MatrixManipulator
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -33,6 +34,18 @@ class OSGGA_EXPORT DriveManipulator : public CameraManipulator
|
||||
|
||||
virtual const char* className() const { return "Drive"; }
|
||||
|
||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||
virtual void setByMatrix(const osg::Matrix& matrix);
|
||||
|
||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||
virtual void setByInverseMatrix(const osg::Matrix& matrix) { setByMatrix(osg::Matrix::inverse(matrix)); }
|
||||
|
||||
/** get the position of the manipulator as 4x4 Matrix.*/
|
||||
virtual osg::Matrix getMatrix() const;
|
||||
|
||||
/** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
|
||||
virtual osg::Matrix getInverseMatrix() const;
|
||||
|
||||
virtual void setNode(osg::Node*);
|
||||
|
||||
virtual const osg::Node* getNode() const;
|
||||
@@ -58,10 +71,7 @@ class OSGGA_EXPORT DriveManipulator : public CameraManipulator
|
||||
/** Add the current mouse GUIEvent to internal stack.*/
|
||||
void addMouseEvent(const GUIEventAdapter& ea);
|
||||
|
||||
void computeLocalDataFromCamera();
|
||||
|
||||
void computeCameraFromLocalData();
|
||||
void computeCameraFromLocalData(const osg::Vec3& lv,const osg::Vec3& up);
|
||||
void computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up);
|
||||
|
||||
/** For the give mouse movement calculate the movement of the camera.
|
||||
Return true is camera has moved and a redraw is required.*/
|
||||
|
||||
@@ -14,18 +14,19 @@
|
||||
#ifndef OSGGA_FLIGHTMANIPULATOR
|
||||
#define OSGGA_FLIGHTMANIPULATOR 1
|
||||
|
||||
#include <osgGA/CameraManipulator>
|
||||
#include <osgGA/MatrixManipulator>
|
||||
#include <osg/Quat>
|
||||
|
||||
namespace osgGA{
|
||||
|
||||
/**
|
||||
FlightManipulator is a CameraManipulator which provides flight simulator-like
|
||||
FlightManipulator is a MatrixManipulator which provides flight simulator-like
|
||||
updating of the camera position & orientation. By default, the left mouse
|
||||
button accelerates, the right mouse button decelerates, and the middle mouse
|
||||
button (or left and right simultaneously) stops dead.
|
||||
*/
|
||||
|
||||
class OSGGA_EXPORT FlightManipulator : public CameraManipulator
|
||||
class OSGGA_EXPORT FlightManipulator : public MatrixManipulator
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -33,6 +34,19 @@ class OSGGA_EXPORT FlightManipulator : public CameraManipulator
|
||||
|
||||
virtual const char* className() const { return "Flight"; }
|
||||
|
||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||
virtual void setByMatrix(const osg::Matrix& matrix);
|
||||
|
||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||
virtual void setByInverseMatrix(const osg::Matrix& matrix) { setByMatrix(osg::Matrix::inverse(matrix)); }
|
||||
|
||||
/** get the position of the manipulator as 4x4 Matrix.*/
|
||||
virtual osg::Matrix getMatrix() const;
|
||||
|
||||
/** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
|
||||
virtual osg::Matrix getInverseMatrix() const;
|
||||
|
||||
|
||||
virtual void setNode(osg::Node*);
|
||||
|
||||
virtual const osg::Node* getNode() const;
|
||||
@@ -65,9 +79,7 @@ class OSGGA_EXPORT FlightManipulator : public CameraManipulator
|
||||
/** Add the current mouse GUIEvent to internal stack.*/
|
||||
void addMouseEvent(const GUIEventAdapter& ea);
|
||||
|
||||
void computeLocalDataFromCamera();
|
||||
|
||||
void computeCameraFromLocalData();
|
||||
void computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up);
|
||||
|
||||
/** For the give mouse movement calculate the movement of the camera.
|
||||
Return true is camera has moved and a redraw is required.*/
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
|
||||
/**
|
||||
requestContinousUpdate(bool) is for en/disabling a throw or idle
|
||||
callback to be requested by a GUIEventHandler (typically a CameraManipulator,
|
||||
callback to be requested by a GUIEventHandler (typically a MatrixManipulator,
|
||||
though other GUIEventHandler's may also provide functionality).
|
||||
GUI toolkits can respond to this immediately by registering an idle/timed
|
||||
callback, or can delay setting the callback and update at their own leisure.
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace osgGA{
|
||||
class GUIActionAdapter;
|
||||
class GUIEventHandler;
|
||||
class CompositeGUIEventHandler;
|
||||
class CameraManipulator;
|
||||
class MatrixManipulator;
|
||||
class StateSetManipulator;
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ class OSGGA_EXPORT GUIEventHandlerVisitor
|
||||
|
||||
virtual void visit(GUIEventHandler&) {}
|
||||
virtual void visit(CompositeGUIEventHandler&);
|
||||
virtual void visit(CameraManipulator&) {};
|
||||
virtual void visit(MatrixManipulator&) {};
|
||||
virtual void visit(StateSetManipulator&) {};
|
||||
|
||||
// Accessors
|
||||
|
||||
@@ -11,11 +11,13 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGGA_CAMERAMANIPULATOR
|
||||
#define OSGGA_CAMERAMANIPULATOR 1
|
||||
#ifndef OSGGA_MatrixManipulator
|
||||
#define OSGGA_MatrixManipulator 1
|
||||
|
||||
#include <osg/Camera>
|
||||
#include <osg/Node>
|
||||
#include <osg/Matrix>
|
||||
|
||||
#include <osgUtil/SceneView>
|
||||
|
||||
#include <osgGA/Export>
|
||||
#include <osgGA/GUIEventHandler>
|
||||
@@ -26,26 +28,36 @@ namespace osgGA{
|
||||
|
||||
/**
|
||||
|
||||
CameraManipulator is an abstract base class defining the interface, and a certain
|
||||
MatrixManipulator is an abstract base class defining the interface, and a certain
|
||||
amount of default functionality, for classes which wish to control OSG cameras
|
||||
in response to GUI events.
|
||||
|
||||
*/
|
||||
class OSGGA_EXPORT CameraManipulator : public GUIEventHandler
|
||||
class OSGGA_EXPORT MatrixManipulator : public GUIEventHandler
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
virtual const char* className() const { return "CameraManipulator"; }
|
||||
virtual const char* className() const { return "MatrixManipulator"; }
|
||||
|
||||
/** Attach a camera to the manipulator to be used for specifying view.*/
|
||||
virtual void setCamera(osg::Camera*);
|
||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||
virtual void setByMatrix(const osg::Matrix& matrix) = 0;
|
||||
|
||||
/** Get the attached camera.*/
|
||||
virtual const osg::Camera * getCamera() const;
|
||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||
virtual void setByInverseMatrix(const osg::Matrix& matrix) = 0;
|
||||
|
||||
/** get the position of the manipulator as 4x4 Matrix.*/
|
||||
virtual osg::Matrix getMatrix() const = 0;
|
||||
|
||||
/** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
|
||||
virtual osg::Matrix getInverseMatrix() const = 0;
|
||||
|
||||
/** Get the FusionDistanceMode. Used by SceneView for setting up setereo convergence.*/
|
||||
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::PROPORTIONAL_TO_SCREEN_DISTANCE; }
|
||||
|
||||
/** Get the FusionDistanceValue. Used by SceneView for setting up setereo convergence.*/
|
||||
virtual float getFusionDistanceValue() const { return 1.0f; }
|
||||
|
||||
/** Get the attached camera.*/
|
||||
virtual osg::Camera * getCamera();
|
||||
|
||||
/**
|
||||
Attach a node to the manipulator, automatically detaching any previously attached node.
|
||||
@@ -80,11 +92,8 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
CameraManipulator();
|
||||
virtual ~CameraManipulator();
|
||||
|
||||
// Reference pointer to a camera
|
||||
osg::ref_ptr<osg::Camera> _camera;
|
||||
MatrixManipulator();
|
||||
virtual ~MatrixManipulator();
|
||||
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace osgGA{
|
||||
|
||||
// Some forward declarations
|
||||
class GUIEventHandler;
|
||||
class CameraManipulator;
|
||||
class MatrixManipulator;
|
||||
|
||||
/**
|
||||
SetSceneViewGUIEventHandlerVisitor which visits various types of
|
||||
@@ -40,7 +40,7 @@ class OSGGA_EXPORT SetSceneViewVisitor: public GUIEventHandlerVisitor
|
||||
|
||||
virtual ~SetSceneViewVisitor() {}
|
||||
|
||||
virtual void visit(CameraManipulator& cm);
|
||||
virtual void visit(MatrixManipulator& cm);
|
||||
virtual void visit(StateSetManipulator& cm);
|
||||
|
||||
private:
|
||||
|
||||
@@ -14,11 +14,12 @@
|
||||
#ifndef OSGGA_TRACKBALLMANIPULATOR
|
||||
#define OSGGA_TRACKBALLMANIPULATOR 1
|
||||
|
||||
#include <osgGA/CameraManipulator>
|
||||
#include <osgGA/MatrixManipulator>
|
||||
#include <osg/Quat>
|
||||
|
||||
namespace osgGA{
|
||||
|
||||
class OSGGA_EXPORT TrackballManipulator : public CameraManipulator
|
||||
class OSGGA_EXPORT TrackballManipulator : public MatrixManipulator
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -26,6 +27,24 @@ class OSGGA_EXPORT TrackballManipulator : public CameraManipulator
|
||||
|
||||
virtual const char* className() const { return "Trackball"; }
|
||||
|
||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||
virtual void setByMatrix(const osg::Matrix& matrix);
|
||||
|
||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||
virtual void setByInverseMatrix(const osg::Matrix& matrix) { setByMatrix(osg::Matrix::inverse(matrix)); }
|
||||
|
||||
/** get the position of the manipulator as 4x4 Matrix.*/
|
||||
virtual osg::Matrix getMatrix() const;
|
||||
|
||||
/** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
|
||||
virtual osg::Matrix getInverseMatrix() const;
|
||||
|
||||
/** Get the FusionDistanceMode. Used by SceneView for setting up setereo convergence.*/
|
||||
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE; }
|
||||
|
||||
/** Get the FusionDistanceValue. Used by SceneView for setting up setereo convergence.*/
|
||||
virtual float getFusionDistanceValue() const { return _distance; }
|
||||
|
||||
/** Attach a node to the manipulator.
|
||||
Automatically detaches previously attached node.
|
||||
setNode(NULL) detaches previously nodes.
|
||||
@@ -60,9 +79,7 @@ class OSGGA_EXPORT TrackballManipulator : public CameraManipulator
|
||||
/** Add the current mouse GUIEvent to internal stack.*/
|
||||
void addMouseEvent(const GUIEventAdapter& ea);
|
||||
|
||||
void computeLocalDataFromCamera();
|
||||
|
||||
void computeCameraFromLocalData();
|
||||
void computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up);
|
||||
|
||||
/** For the give mouse movement calculate the movement of the camera.
|
||||
Return true is camera has moved and a redraw is required.*/
|
||||
|
||||
Reference in New Issue
Block a user