Removed remaining dependancies on osg::Camera.

This commit is contained in:
Robert Osfield
2003-05-19 15:15:17 +00:00
parent 4151312dc5
commit 940ce67133
31 changed files with 506 additions and 616 deletions

View File

@@ -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;
};

View File

@@ -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.*/

View File

@@ -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.*/

View File

@@ -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.

View File

@@ -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

View File

@@ -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();
};

View File

@@ -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:

View File

@@ -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.*/

View File

@@ -23,7 +23,7 @@
#include <osgGA/GUIActionAdapter>
#include <osgGA/GUIEventHandler>
#include <osgGA/KeySwitchCameraManipulator>
#include <osgGA/KeySwitchMatrixManipulator>
#include <osgProducer/OsgCameraGroup>
#include <osgProducer/KeyboardMouseCallback>
@@ -117,10 +117,10 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
EventHandlerList& getEventHandlerList() { return _eventHandlerList; }
const EventHandlerList& getEventHandlerList() const { return _eventHandlerList; }
osgGA::KeySwitchCameraManipulator* getKeySwitchCameraManipulator() { return _keyswitchManipulator.get(); }
const osgGA::KeySwitchCameraManipulator* getKeySwitchCameraManipulator() const { return _keyswitchManipulator.get(); }
osgGA::KeySwitchMatrixManipulator* getKeySwitchMatrixManipulator() { return _keyswitchManipulator.get(); }
const osgGA::KeySwitchMatrixManipulator* getKeySwitchMatrixManipulator() const { return _keyswitchManipulator.get(); }
unsigned int addCameraManipulator(osgGA::CameraManipulator* cm);
unsigned int addCameraManipulator(osgGA::MatrixManipulator* cm);
void selectCameraManipulator(unsigned int no);
@@ -143,13 +143,10 @@ class OSGPRODUCER_EXPORT Viewer : public OsgCameraGroup, public osgGA::GUIAction
osgProducer::KeyboardMouseCallback* _kbmcb;
EventHandlerList _eventHandlerList;
osg::ref_ptr<osgGA::KeySwitchCameraManipulator> _keyswitchManipulator;
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> _keyswitchManipulator;
osg::ref_ptr<osg::Camera> _old_style_osg_camera;
osg::ref_ptr<osg::NodeVisitor> _updateVisitor;
bool _recordingAnimationPath;
osg::ref_ptr<osg::AnimationPath> _animationPath;

View File

@@ -17,7 +17,6 @@
#include <osg/Node>
#include <osg/StateSet>
#include <osg/Light>
#include <osg/Camera>
#include <osg/FrameStamp>
#include <osg/DisplaySettings>
@@ -28,7 +27,7 @@ namespace osgUtil {
/**
* SceneView is literally a view of a scene, encapsulating the
* camera, global state, lights and the scene itself. Provides
* camera (modelview+projection matrices), global state, lights and the scene itself. Provides
* methods for setting up the view and rendering it.
*/
class OSGUTIL_EXPORT SceneView : public osg::Referenced
@@ -129,15 +128,6 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
const osg::State* getState() const { return _state.get(); }
/** set an osg::Camera for the scene view to use for setting projection and modelview matrices internaly.
* However, the projection matrix from the camera will be overriden by a projection matrix which is set explicitly
* via setProjectionMatrix(..), see below.
* Also, the model matrix from the camera will be overriden by a modelview matrix which is set explicitly
* via setModelViewMatrix(..), see below.*/
void setCamera(osg::Camera* camera) { _camera = camera; }
osg::Camera* getCamera() { return _camera.get(); }
const osg::Camera* getCamera() const { return _camera.get(); }
/** set a projection matrix. Note, this will override a camera's projection matrix if it is not NULL.*/
void setProjectionMatrix(osg::RefMatrix* matrix) { _projectionMatrix = matrix; }
osg::RefMatrix* getProjectionMatrix() { return _projectionMatrix.get(); }
@@ -206,8 +196,6 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
/** FusionDistanceMode is used only when working in stereo.*/
enum FusionDistanceMode
{
/** Use fusion distance from the attached camera if one exist.*/
USE_CAMERA_FUSION_DISTANCE,
/** Use fusion distance from the value set on the SceneView.*/
USE_FUSION_DISTANCE_VALUE,
/** Compute the fusion distance by multiplying the screen distance by the fusion distance value.*/
@@ -306,7 +294,6 @@ class OSGUTIL_EXPORT SceneView : public osg::Referenced
osg::ref_ptr<osg::StateSet> _globalStateSet;
osg::ref_ptr<osg::StateSet> _localStateSet;
osg::ref_ptr<osg::Light> _light;
osg::ref_ptr<osg::Camera> _camera;
osg::ref_ptr<osg::RefMatrix> _projectionMatrix;
osg::ref_ptr<osg::RefMatrix> _modelviewMatrix;
osg::ref_ptr<osg::DisplaySettings> _displaySettings;