Added new Matrixf and Matrixd implementations.
Made Matrix be a typedef to either Matrixf or Matrixd. Defaults to Matrixf. Converted the osgGA::MatrixManipulators and osgProducer::Viewer/OsgCameraGroup across to using exclusively Matrixd for internal computations and passing betwen Manipulators, Producer and SceneView. Note, SceneView still uses Matrix internally so will depend on what is set as the default in include/osg/Matrix. Added the ability to osgProducer::setDone/getDone(), kept done() as the method that the viewer main loop uses for detecting the exit condition.
This commit is contained in:
parent
a2834d74d2
commit
792bba05b9
@ -181,21 +181,21 @@ void GliderManipulator::addMouseEvent(const GUIEventAdapter& ea)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GliderManipulator::setByMatrix(const osg::Matrix& matrix)
|
void GliderManipulator::setByMatrix(const osg::Matrixd& matrix)
|
||||||
{
|
{
|
||||||
_eye = matrix.getTrans();
|
_eye = matrix.getTrans();
|
||||||
matrix.get(_rotation);
|
matrix.get(_rotation);
|
||||||
_distance = 1.0f;
|
_distance = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Matrix GliderManipulator::getMatrix() const
|
osg::Matrixd GliderManipulator::getMatrix() const
|
||||||
{
|
{
|
||||||
return osg::Matrix::rotate(_rotation)*osg::Matrix::translate(_eye);
|
return osg::Matrixd::rotate(_rotation)*osg::Matrixd::translate(_eye);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Matrix GliderManipulator::getInverseMatrix() const
|
osg::Matrixd GliderManipulator::getInverseMatrix() const
|
||||||
{
|
{
|
||||||
return osg::Matrix::translate(-_eye)*osg::Matrix::rotate(_rotation.inverse());
|
return osg::Matrixd::translate(-_eye)*osg::Matrixd::rotate(_rotation.inverse());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GliderManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up)
|
void GliderManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up)
|
||||||
@ -207,7 +207,7 @@ void GliderManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv
|
|||||||
osg::Vec3 u(s^f);
|
osg::Vec3 u(s^f);
|
||||||
u.normalize();
|
u.normalize();
|
||||||
|
|
||||||
osg::Matrix rotation_matrix(s[0], u[0], -f[0], 0.0f,
|
osg::Matrixd rotation_matrix(s[0], u[0], -f[0], 0.0f,
|
||||||
s[1], u[1], -f[1], 0.0f,
|
s[1], u[1], -f[1], 0.0f,
|
||||||
s[2], u[2], -f[2], 0.0f,
|
s[2], u[2], -f[2], 0.0f,
|
||||||
0.0f, 0.0f, 0.0f, 1.0f);
|
0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
@ -261,7 +261,7 @@ bool GliderManipulator::calcMovement()
|
|||||||
float dy = _ga_t0->getYnormalized();
|
float dy = _ga_t0->getYnormalized();
|
||||||
|
|
||||||
|
|
||||||
osg::Matrix rotation_matrix;
|
osg::Matrixd rotation_matrix;
|
||||||
rotation_matrix.makeRotate(_rotation);
|
rotation_matrix.makeRotate(_rotation);
|
||||||
|
|
||||||
osg::Vec3 up = osg::Vec3(0.0f,1.0f,0.0) * rotation_matrix;
|
osg::Vec3 up = osg::Vec3(0.0f,1.0f,0.0) * rotation_matrix;
|
||||||
|
@ -33,16 +33,16 @@ class GliderManipulator : public osgGA::MatrixManipulator
|
|||||||
virtual const char* className() const { return "Glider"; }
|
virtual const char* className() const { return "Glider"; }
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByMatrix(const osg::Matrix& matrix);
|
virtual void setByMatrix(const osg::Matrixd& matrix);
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByInverseMatrix(const osg::Matrix& matrix) { setByMatrix(osg::Matrix::inverse(matrix)); }
|
virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
|
||||||
|
|
||||||
/** get the position of the manipulator as 4x4 Matrix.*/
|
/** get the position of the manipulator as 4x4 Matrix.*/
|
||||||
virtual osg::Matrix getMatrix() const;
|
virtual osg::Matrixd getMatrix() const;
|
||||||
|
|
||||||
/** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view 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;
|
virtual osg::Matrixd getInverseMatrix() const;
|
||||||
|
|
||||||
|
|
||||||
virtual void setNode(osg::Node*);
|
virtual void setNode(osg::Node*);
|
||||||
|
@ -179,21 +179,21 @@ void TestManipulator::addMouseEvent(const GUIEventAdapter& ea)
|
|||||||
_ga_t0 = &ea;
|
_ga_t0 = &ea;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestManipulator::setByMatrix(const osg::Matrix& matrix)
|
void TestManipulator::setByMatrix(const osg::Matrixd& matrix)
|
||||||
{
|
{
|
||||||
_center = matrix.getTrans();
|
_center = matrix.getTrans();
|
||||||
matrix.get(_rotation);
|
matrix.get(_rotation);
|
||||||
_distance = 1.0f;
|
_distance = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Matrix TestManipulator::getMatrix() const
|
osg::Matrixd TestManipulator::getMatrix() const
|
||||||
{
|
{
|
||||||
return osg::Matrix::rotate(_rotation)*osg::Matrix::translate(_center);
|
return osg::Matrixd::rotate(_rotation)*osg::Matrixd::translate(_center);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Matrix TestManipulator::getInverseMatrix() const
|
osg::Matrixd TestManipulator::getInverseMatrix() const
|
||||||
{
|
{
|
||||||
return osg::Matrix::translate(-_center)*osg::Matrix::rotate(_rotation.inverse());
|
return osg::Matrixd::translate(-_center)*osg::Matrixd::rotate(_rotation.inverse());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up)
|
void TestManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up)
|
||||||
@ -205,7 +205,7 @@ void TestManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv,c
|
|||||||
osg::Vec3 u(s^f);
|
osg::Vec3 u(s^f);
|
||||||
u.normalize();
|
u.normalize();
|
||||||
|
|
||||||
osg::Matrix rotation_matrix(s[0], u[0], -f[0], 0.0f,
|
osg::Matrixd rotation_matrix(s[0], u[0], -f[0], 0.0f,
|
||||||
s[1], u[1], -f[1], 0.0f,
|
s[1], u[1], -f[1], 0.0f,
|
||||||
s[2], u[2], -f[2], 0.0f,
|
s[2], u[2], -f[2], 0.0f,
|
||||||
0.0f, 0.0f, 0.0f, 1.0f);
|
0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
@ -258,7 +258,7 @@ bool TestManipulator::calcMovement()
|
|||||||
}
|
}
|
||||||
else if (buttonMask==GUIEventAdapter::RIGHT_MOUSE_BUTTON)
|
else if (buttonMask==GUIEventAdapter::RIGHT_MOUSE_BUTTON)
|
||||||
{
|
{
|
||||||
osg::Matrix rotation_matrix(_rotation);
|
osg::Matrixd rotation_matrix(_rotation);
|
||||||
|
|
||||||
|
|
||||||
osg::Vec3 uv = osg::Vec3(0.0f,1.0f,0.0f)*rotation_matrix;
|
osg::Vec3 uv = osg::Vec3(0.0f,1.0f,0.0f)*rotation_matrix;
|
||||||
|
@ -16,16 +16,16 @@ class TestManipulator : public osgGA::MatrixManipulator
|
|||||||
virtual ~TestManipulator();
|
virtual ~TestManipulator();
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByMatrix(const osg::Matrix& matrix);
|
virtual void setByMatrix(const osg::Matrixd& matrix);
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByInverseMatrix(const osg::Matrix& matrix) { setByMatrix(osg::Matrix::inverse(matrix)); }
|
virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
|
||||||
|
|
||||||
/** get the position of the manipulator as 4x4 Matrix.*/
|
/** get the position of the manipulator as 4x4 Matrix.*/
|
||||||
virtual osg::Matrix getMatrix() const;
|
virtual osg::Matrixd getMatrix() const;
|
||||||
|
|
||||||
/** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view 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;
|
virtual osg::Matrixd getInverseMatrix() const;
|
||||||
|
|
||||||
/** Attach a node to the manipulator.
|
/** Attach a node to the manipulator.
|
||||||
Automatically detaches previously attached node.
|
Automatically detaches previously attached node.
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
#ifndef OSG_ANIMATIONPATH
|
#ifndef OSG_ANIMATIONPATH
|
||||||
#define OSG_ANIMATIONPATH 1
|
#define OSG_ANIMATIONPATH 1
|
||||||
|
|
||||||
#include <osg/Matrix>
|
#include <osg/Matrixf>
|
||||||
|
#include <osg/Matrixd>
|
||||||
#include <osg/Quat>
|
#include <osg/Quat>
|
||||||
#include <osg/NodeCallback>
|
#include <osg/NodeCallback>
|
||||||
|
|
||||||
@ -71,24 +72,47 @@ class SG_EXPORT AnimationPath : public virtual osg::Object
|
|||||||
_scale = first._scale*one_minus_ratio + second._scale*ratio;
|
_scale = first._scale*one_minus_ratio + second._scale*ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void getMatrix(Matrix& matrix) const
|
inline void getMatrix(Matrixf& matrix) const
|
||||||
{
|
{
|
||||||
matrix.makeScale(_scale);
|
matrix.makeScale(_scale);
|
||||||
matrix.postMult(osg::Matrix::rotate(_rotation));
|
matrix.postMult(osg::Matrixf::rotate(_rotation));
|
||||||
matrix.postMult(osg::Matrix::translate(_position));
|
matrix.postMult(osg::Matrixf::translate(_position));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void getInverse(Matrix& matrix) const
|
inline void getMatrix(Matrixd& matrix) const
|
||||||
|
{
|
||||||
|
matrix.makeScale(_scale);
|
||||||
|
matrix.postMult(osg::Matrixd::rotate(_rotation));
|
||||||
|
matrix.postMult(osg::Matrixd::translate(_position));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void getInverse(Matrixf& matrix) const
|
||||||
{
|
{
|
||||||
matrix.makeScale(1.0f/_scale.x(),1.0f/_scale.y(),1.0f/_scale.y());
|
matrix.makeScale(1.0f/_scale.x(),1.0f/_scale.y(),1.0f/_scale.y());
|
||||||
matrix.postMult(osg::Matrix::rotate(_rotation.inverse()));
|
matrix.postMult(osg::Matrixf::rotate(_rotation.inverse()));
|
||||||
matrix.postMult(osg::Matrix::translate(-_position));
|
matrix.postMult(osg::Matrixf::translate(-_position));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void getInverse(Matrixd& matrix) const
|
||||||
|
{
|
||||||
|
matrix.makeScale(1.0f/_scale.x(),1.0f/_scale.y(),1.0f/_scale.y());
|
||||||
|
matrix.postMult(osg::Matrixd::rotate(_rotation.inverse()));
|
||||||
|
matrix.postMult(osg::Matrixd::translate(-_position));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** get the transformation matrix for a point in time.*/
|
/** get the transformation matrix for a point in time.*/
|
||||||
bool getMatrix(double time,Matrix& matrix) const
|
bool getMatrix(double time,Matrixf& matrix) const
|
||||||
|
{
|
||||||
|
ControlPoint cp;
|
||||||
|
if (!getInterpolatedControlPoint(time,cp)) return false;
|
||||||
|
cp.getMatrix(matrix);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** get the transformation matrix for a point in time.*/
|
||||||
|
bool getMatrix(double time,Matrixd& matrix) const
|
||||||
{
|
{
|
||||||
ControlPoint cp;
|
ControlPoint cp;
|
||||||
if (!getInterpolatedControlPoint(time,cp)) return false;
|
if (!getInterpolatedControlPoint(time,cp)) return false;
|
||||||
@ -97,7 +121,7 @@ class SG_EXPORT AnimationPath : public virtual osg::Object
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** get the inverse transformation matrix for a point in time.*/
|
/** get the inverse transformation matrix for a point in time.*/
|
||||||
bool getInverse(double time,Matrix& matrix) const
|
bool getInverse(double time,Matrixf& matrix) const
|
||||||
{
|
{
|
||||||
ControlPoint cp;
|
ControlPoint cp;
|
||||||
if (!getInterpolatedControlPoint(time,cp)) return false;
|
if (!getInterpolatedControlPoint(time,cp)) return false;
|
||||||
@ -105,6 +129,14 @@ class SG_EXPORT AnimationPath : public virtual osg::Object
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getInverse(double time,Matrixd& matrix) const
|
||||||
|
{
|
||||||
|
ControlPoint cp;
|
||||||
|
if (!getInterpolatedControlPoint(time,cp)) return false;
|
||||||
|
cp.getInverse(matrix);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/** get the local ControlPoint frame for a point in time.*/
|
/** get the local ControlPoint frame for a point in time.*/
|
||||||
virtual bool getInterpolatedControlPoint(double time,ControlPoint& controlPoint) const;
|
virtual bool getInterpolatedControlPoint(double time,ControlPoint& controlPoint) const;
|
||||||
|
|
||||||
|
@ -20,8 +20,13 @@
|
|||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
|
|
||||||
typedef Matrixd Matrix;
|
// default to using floating Matrices - Matrixf
|
||||||
typedef RefMatrixd RefMatrix;
|
typedef Matrixf Matrix;
|
||||||
|
typedef RefMatrixf RefMatrix;
|
||||||
|
|
||||||
|
// // default to using double Matrices - Matrixd
|
||||||
|
// typedef Matrixd Matrix;
|
||||||
|
// typedef RefMatrixd RefMatrix;
|
||||||
|
|
||||||
|
|
||||||
} //namespace osg
|
} //namespace osg
|
||||||
|
@ -26,15 +26,18 @@
|
|||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
|
class Matrixf;
|
||||||
|
|
||||||
class SG_EXPORT Matrixd
|
class SG_EXPORT Matrixd
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef double value_type;
|
typedef float value_type;
|
||||||
|
|
||||||
inline Matrixd() { makeIdentity(); }
|
inline Matrixd() { makeIdentity(); }
|
||||||
inline Matrixd( const Matrixd& other) { set(other.ptr()); }
|
inline Matrixd( const Matrixd& mat) { set(mat.ptr()); }
|
||||||
|
Matrixd( const Matrixf& mat );
|
||||||
inline explicit Matrixd( float const * const ptr ) { set(ptr); }
|
inline explicit Matrixd( float const * const ptr ) { set(ptr); }
|
||||||
inline explicit Matrixd( double const * const ptr ) { set(ptr); }
|
inline explicit Matrixd( double const * const ptr ) { set(ptr); }
|
||||||
inline explicit Matrixd( const Quat& quat ) { set(quat); }
|
inline explicit Matrixd( const Quat& quat ) { set(quat); }
|
||||||
@ -61,26 +64,29 @@ class SG_EXPORT Matrixd
|
|||||||
osg::isNaN(_mat[2][0]) || osg::isNaN(_mat[2][1]) || osg::isNaN(_mat[2][2]) || osg::isNaN(_mat[2][3]) ||
|
osg::isNaN(_mat[2][0]) || osg::isNaN(_mat[2][1]) || osg::isNaN(_mat[2][2]) || osg::isNaN(_mat[2][3]) ||
|
||||||
osg::isNaN(_mat[3][0]) || osg::isNaN(_mat[3][1]) || osg::isNaN(_mat[3][2]) || osg::isNaN(_mat[3][3]); }
|
osg::isNaN(_mat[3][0]) || osg::isNaN(_mat[3][1]) || osg::isNaN(_mat[3][2]) || osg::isNaN(_mat[3][3]); }
|
||||||
|
|
||||||
inline Matrixd& operator = (const Matrixd& other)
|
inline Matrixd& operator = (const Matrixd& rhs)
|
||||||
{
|
{
|
||||||
if( &other == this ) return *this;
|
if( &rhs == this ) return *this;
|
||||||
set(other.ptr());
|
set(rhs.ptr());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void set(const Matrixd& other)
|
inline Matrixd& operator = (const Matrixf& other);
|
||||||
{
|
|
||||||
set(other.ptr());
|
inline void set(const Matrixd& rhs) { set(rhs.ptr()); }
|
||||||
}
|
|
||||||
|
void set(const Matrixf& rhs);
|
||||||
|
|
||||||
inline void set(float const * const ptr)
|
inline void set(float const * const ptr)
|
||||||
{
|
{
|
||||||
std::copy(ptr,ptr+16,(value_type*)_mat);
|
value_type* local_ptr = (value_type*)_mat;
|
||||||
|
for(int i=0;i<16;++i) local_ptr[i]=(value_type)ptr[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void set(double const * const ptr)
|
inline void set(double const * const ptr)
|
||||||
{
|
{
|
||||||
std::copy(ptr,ptr+16,(value_type*)_mat);
|
value_type* local_ptr = (value_type*)_mat;
|
||||||
|
for(int i=0;i<16;++i) local_ptr[i]=(value_type)ptr[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void set( value_type a00, value_type a01, value_type a02, value_type a03,
|
void set( value_type a00, value_type a01, value_type a02, value_type a03,
|
||||||
@ -234,7 +240,7 @@ class SG_EXPORT Matrixd
|
|||||||
r.mult(*this,m);
|
r.mult(*this,m);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
value_type _mat[4][4];
|
value_type _mat[4][4];
|
||||||
|
|
||||||
@ -246,6 +252,7 @@ class RefMatrixd : public Object, public Matrixd
|
|||||||
|
|
||||||
RefMatrixd():Matrixd() {}
|
RefMatrixd():Matrixd() {}
|
||||||
RefMatrixd( const Matrixd& other) : Matrixd(other) {}
|
RefMatrixd( const Matrixd& other) : Matrixd(other) {}
|
||||||
|
RefMatrixd( const Matrixf& other) : Matrixd(other) {}
|
||||||
RefMatrixd( const RefMatrixd& other) : Object(other), Matrixd(other) {}
|
RefMatrixd( const RefMatrixd& other) : Object(other), Matrixd(other) {}
|
||||||
explicit RefMatrixd( Matrixd::value_type const * const def ):Matrixd(def) {}
|
explicit RefMatrixd( Matrixd::value_type const * const def ):Matrixd(def) {}
|
||||||
RefMatrixd( Matrixd::value_type a00, Matrixd::value_type a01, Matrixd::value_type a02, Matrixd::value_type a03,
|
RefMatrixd( Matrixd::value_type a00, Matrixd::value_type a01, Matrixd::value_type a02, Matrixd::value_type a03,
|
||||||
@ -304,9 +311,7 @@ inline Matrixd Matrixd::translate(const Vec3& v )
|
|||||||
|
|
||||||
inline Matrixd Matrixd::rotate( const Quat& q )
|
inline Matrixd Matrixd::rotate( const Quat& q )
|
||||||
{
|
{
|
||||||
Matrixd m;
|
return Matrixd(q);
|
||||||
m.makeRotate( q );
|
|
||||||
return m;
|
|
||||||
}
|
}
|
||||||
inline Matrixd Matrixd::rotate(float angle, float x, float y, float z )
|
inline Matrixd Matrixd::rotate(float angle, float x, float y, float z )
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,8 @@ class SG_EXPORT Matrixf
|
|||||||
typedef float value_type;
|
typedef float value_type;
|
||||||
|
|
||||||
inline Matrixf() { makeIdentity(); }
|
inline Matrixf() { makeIdentity(); }
|
||||||
inline Matrixf( const Matrixf& other) { set(other.ptr()); }
|
inline Matrixf( const Matrixf& mat) { set(mat.ptr()); }
|
||||||
|
Matrixf( const Matrixd& mat );
|
||||||
inline explicit Matrixf( float const * const ptr ) { set(ptr); }
|
inline explicit Matrixf( float const * const ptr ) { set(ptr); }
|
||||||
inline explicit Matrixf( double const * const ptr ) { set(ptr); }
|
inline explicit Matrixf( double const * const ptr ) { set(ptr); }
|
||||||
inline explicit Matrixf( const Quat& quat ) { set(quat); }
|
inline explicit Matrixf( const Quat& quat ) { set(quat); }
|
||||||
@ -61,26 +62,29 @@ class SG_EXPORT Matrixf
|
|||||||
osg::isNaN(_mat[2][0]) || osg::isNaN(_mat[2][1]) || osg::isNaN(_mat[2][2]) || osg::isNaN(_mat[2][3]) ||
|
osg::isNaN(_mat[2][0]) || osg::isNaN(_mat[2][1]) || osg::isNaN(_mat[2][2]) || osg::isNaN(_mat[2][3]) ||
|
||||||
osg::isNaN(_mat[3][0]) || osg::isNaN(_mat[3][1]) || osg::isNaN(_mat[3][2]) || osg::isNaN(_mat[3][3]); }
|
osg::isNaN(_mat[3][0]) || osg::isNaN(_mat[3][1]) || osg::isNaN(_mat[3][2]) || osg::isNaN(_mat[3][3]); }
|
||||||
|
|
||||||
inline Matrixf& operator = (const Matrixf& other)
|
inline Matrixf& operator = (const Matrixf& rhs)
|
||||||
{
|
{
|
||||||
if( &other == this ) return *this;
|
if( &rhs == this ) return *this;
|
||||||
set(other.ptr());
|
set(rhs.ptr());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void set(const Matrixf& other)
|
Matrixf& operator = (const Matrixd& rhs);
|
||||||
{
|
|
||||||
set(other.ptr());
|
void set(const Matrixd& rhs);
|
||||||
}
|
|
||||||
|
inline void set(const Matrixf& rhs) { set(rhs.ptr()); }
|
||||||
|
|
||||||
inline void set(float const * const ptr)
|
inline void set(float const * const ptr)
|
||||||
{
|
{
|
||||||
std::copy(ptr,ptr+16,(value_type*)_mat);
|
value_type* local_ptr = (value_type*)_mat;
|
||||||
|
for(int i=0;i<16;++i) local_ptr[i]=(value_type)ptr[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void set(double const * const ptr)
|
inline void set(double const * const ptr)
|
||||||
{
|
{
|
||||||
std::copy(ptr,ptr+16,(value_type*)_mat);
|
value_type* local_ptr = (value_type*)_mat;
|
||||||
|
for(int i=0;i<16;++i) local_ptr[i]=(value_type)ptr[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void set( value_type a00, value_type a01, value_type a02, value_type a03,
|
void set( value_type a00, value_type a01, value_type a02, value_type a03,
|
||||||
@ -246,6 +250,7 @@ class RefMatrixf : public Object, public Matrixf
|
|||||||
|
|
||||||
RefMatrixf():Matrixf() {}
|
RefMatrixf():Matrixf() {}
|
||||||
RefMatrixf( const Matrixf& other) : Matrixf(other) {}
|
RefMatrixf( const Matrixf& other) : Matrixf(other) {}
|
||||||
|
RefMatrixf( const Matrixd& other) : Matrixf(other) {}
|
||||||
RefMatrixf( const RefMatrixf& other) : Object(other), Matrixf(other) {}
|
RefMatrixf( const RefMatrixf& other) : Object(other), Matrixf(other) {}
|
||||||
explicit RefMatrixf( Matrixf::value_type const * const def ):Matrixf(def) {}
|
explicit RefMatrixf( Matrixf::value_type const * const def ):Matrixf(def) {}
|
||||||
RefMatrixf( Matrixf::value_type a00, Matrixf::value_type a01, Matrixf::value_type a02, Matrixf::value_type a03,
|
RefMatrixf( Matrixf::value_type a00, Matrixf::value_type a01, Matrixf::value_type a02, Matrixf::value_type a03,
|
||||||
|
@ -42,16 +42,16 @@ class OSGGA_EXPORT AnimationPathManipulator : public MatrixManipulator
|
|||||||
virtual const char* className() const { return "AnimationPath"; }
|
virtual const char* className() const { return "AnimationPath"; }
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByMatrix(const osg::Matrix& matrix) { _matrix = matrix; }
|
virtual void setByMatrix(const osg::Matrixd& matrix) { _matrix = matrix; }
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByInverseMatrix(const osg::Matrix& matrix) { _matrix.invert(matrix); }
|
virtual void setByInverseMatrix(const osg::Matrixd& matrix) { _matrix.invert(matrix); }
|
||||||
|
|
||||||
/** get the position of the manipulator as 4x4 Matrix.*/
|
/** get the position of the manipulator as 4x4 Matrix.*/
|
||||||
virtual osg::Matrix getMatrix() const { return _matrix; }
|
virtual osg::Matrixd getMatrix() const { return _matrix; }
|
||||||
|
|
||||||
/** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view 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); }
|
virtual osg::Matrixd getInverseMatrix() const { return osg::Matrixd::inverse(_matrix); }
|
||||||
|
|
||||||
|
|
||||||
void setAnimationPath( osg::AnimationPath* animationPath ) { _animationPath=animationPath; }
|
void setAnimationPath( osg::AnimationPath* animationPath ) { _animationPath=animationPath; }
|
||||||
@ -88,7 +88,7 @@ class OSGGA_EXPORT AnimationPathManipulator : public MatrixManipulator
|
|||||||
double _animStartOfTimedPeriod;
|
double _animStartOfTimedPeriod;
|
||||||
int _numOfFramesSinceStartOfTimedPeriod;
|
int _numOfFramesSinceStartOfTimedPeriod;
|
||||||
|
|
||||||
osg::Matrix _matrix;
|
osg::Matrixd _matrix;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,16 +35,16 @@ class OSGGA_EXPORT DriveManipulator : public MatrixManipulator
|
|||||||
virtual const char* className() const { return "Drive"; }
|
virtual const char* className() const { return "Drive"; }
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByMatrix(const osg::Matrix& matrix);
|
virtual void setByMatrix(const osg::Matrixd& matrix);
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByInverseMatrix(const osg::Matrix& matrix) { setByMatrix(osg::Matrix::inverse(matrix)); }
|
virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
|
||||||
|
|
||||||
/** get the position of the manipulator as 4x4 Matrix.*/
|
/** get the position of the manipulator as 4x4 Matrix.*/
|
||||||
virtual osg::Matrix getMatrix() const;
|
virtual osg::Matrixd getMatrix() const;
|
||||||
|
|
||||||
/** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view 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;
|
virtual osg::Matrixd getInverseMatrix() const;
|
||||||
|
|
||||||
virtual void setNode(osg::Node*);
|
virtual void setNode(osg::Node*);
|
||||||
|
|
||||||
|
@ -35,16 +35,16 @@ class OSGGA_EXPORT FlightManipulator : public MatrixManipulator
|
|||||||
virtual const char* className() const { return "Flight"; }
|
virtual const char* className() const { return "Flight"; }
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByMatrix(const osg::Matrix& matrix);
|
virtual void setByMatrix(const osg::Matrixd& matrix);
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByInverseMatrix(const osg::Matrix& matrix) { setByMatrix(osg::Matrix::inverse(matrix)); }
|
virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
|
||||||
|
|
||||||
/** get the position of the manipulator as 4x4 Matrix.*/
|
/** get the position of the manipulator as 4x4 Matrix.*/
|
||||||
virtual osg::Matrix getMatrix() const;
|
virtual osg::Matrixd getMatrix() const;
|
||||||
|
|
||||||
/** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view 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;
|
virtual osg::Matrixd getInverseMatrix() const;
|
||||||
|
|
||||||
|
|
||||||
virtual void setNode(osg::Node*);
|
virtual void setNode(osg::Node*);
|
||||||
|
@ -66,16 +66,16 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByMatrix(const osg::Matrix& matrix) { _current->setByMatrix(matrix); }
|
virtual void setByMatrix(const osg::Matrixd& matrix) { _current->setByMatrix(matrix); }
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByInverseMatrix(const osg::Matrix& matrix) { _current->setByInverseMatrix(matrix); }
|
virtual void setByInverseMatrix(const osg::Matrixd& matrix) { _current->setByInverseMatrix(matrix); }
|
||||||
|
|
||||||
/** get the position of the manipulator as 4x4 Matrix.*/
|
/** get the position of the manipulator as 4x4 Matrix.*/
|
||||||
virtual osg::Matrix getMatrix() const { return _current->getMatrix(); }
|
virtual osg::Matrixd getMatrix() const { return _current->getMatrix(); }
|
||||||
|
|
||||||
/** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view 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 _current->getInverseMatrix(); }
|
virtual osg::Matrixd getInverseMatrix() const { return _current->getInverseMatrix(); }
|
||||||
|
|
||||||
/** Get the FusionDistanceMode. Used by SceneView for setting up setereo convergence.*/
|
/** Get the FusionDistanceMode. Used by SceneView for setting up setereo convergence.*/
|
||||||
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return _current->getFusionDistanceMode(); }
|
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return _current->getFusionDistanceMode(); }
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#define OSGGA_MatrixManipulator 1
|
#define OSGGA_MatrixManipulator 1
|
||||||
|
|
||||||
#include <osg/Node>
|
#include <osg/Node>
|
||||||
#include <osg/Matrix>
|
#include <osg/Matrixd>
|
||||||
|
|
||||||
#include <osgUtil/SceneView>
|
#include <osgUtil/SceneView>
|
||||||
|
|
||||||
@ -41,16 +41,16 @@ public:
|
|||||||
virtual const char* className() const { return "MatrixManipulator"; }
|
virtual const char* className() const { return "MatrixManipulator"; }
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByMatrix(const osg::Matrix& matrix) = 0;
|
virtual void setByMatrix(const osg::Matrixd& matrix) = 0;
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByInverseMatrix(const osg::Matrix& matrix) = 0;
|
virtual void setByInverseMatrix(const osg::Matrixd& matrix) = 0;
|
||||||
|
|
||||||
/** get the position of the manipulator as 4x4 Matrix.*/
|
/** get the position of the manipulator as 4x4 Matrix.*/
|
||||||
virtual osg::Matrix getMatrix() const = 0;
|
virtual osg::Matrixd getMatrix() const = 0;
|
||||||
|
|
||||||
/** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view 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 = 0;
|
virtual osg::Matrixd getInverseMatrix() const = 0;
|
||||||
|
|
||||||
/** Get the FusionDistanceMode. Used by SceneView for setting up setereo convergence.*/
|
/** Get the FusionDistanceMode. Used by SceneView for setting up setereo convergence.*/
|
||||||
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::PROPORTIONAL_TO_SCREEN_DISTANCE; }
|
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::PROPORTIONAL_TO_SCREEN_DISTANCE; }
|
||||||
|
@ -28,16 +28,16 @@ class OSGGA_EXPORT TrackballManipulator : public MatrixManipulator
|
|||||||
virtual const char* className() const { return "Trackball"; }
|
virtual const char* className() const { return "Trackball"; }
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByMatrix(const osg::Matrix& matrix);
|
virtual void setByMatrix(const osg::Matrixd& matrix);
|
||||||
|
|
||||||
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
/** set the position of the matrix manipulator using a 4x4 Matrix.*/
|
||||||
virtual void setByInverseMatrix(const osg::Matrix& matrix) { setByMatrix(osg::Matrix::inverse(matrix)); }
|
virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
|
||||||
|
|
||||||
/** get the position of the manipulator as 4x4 Matrix.*/
|
/** get the position of the manipulator as 4x4 Matrix.*/
|
||||||
virtual osg::Matrix getMatrix() const;
|
virtual osg::Matrixd getMatrix() const;
|
||||||
|
|
||||||
/** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view 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;
|
virtual osg::Matrixd getInverseMatrix() const;
|
||||||
|
|
||||||
/** Get the FusionDistanceMode. Used by SceneView for setting up setereo convergence.*/
|
/** Get the FusionDistanceMode. Used by SceneView for setting up setereo convergence.*/
|
||||||
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE; }
|
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE; }
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <osg/StateSet>
|
#include <osg/StateSet>
|
||||||
#include <osg/FrameStamp>
|
#include <osg/FrameStamp>
|
||||||
#include <osg/DisplaySettings>
|
#include <osg/DisplaySettings>
|
||||||
|
#include <osg/Matrixd>
|
||||||
|
|
||||||
#include <osgDB/DatabasePager>
|
#include <osgDB/DatabasePager>
|
||||||
|
|
||||||
@ -155,11 +156,11 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
|
|||||||
|
|
||||||
/** Set the model view matrix of the camera group,
|
/** Set the model view matrix of the camera group,
|
||||||
* by individually set all the camera groups's camera.*/
|
* by individually set all the camera groups's camera.*/
|
||||||
virtual void setView(const osg::Matrix& matrix);
|
virtual void setView(const osg::Matrixd& matrix);
|
||||||
|
|
||||||
/** Get the model view martrix of the camera group,
|
/** Get the model view martrix of the camera group,
|
||||||
* taking its value for camera 0.*/
|
* taking its value for camera 0.*/
|
||||||
const osg::Matrix getViewMatrix() const;
|
osg::Matrixd getViewMatrix() const;
|
||||||
|
|
||||||
|
|
||||||
virtual void sync();
|
virtual void sync();
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
#include <Producer/Camera>
|
#include <Producer/Camera>
|
||||||
#include <osgUtil/SceneView>
|
#include <osgUtil/SceneView>
|
||||||
#include <osg/Matrix>
|
|
||||||
|
|
||||||
namespace osgProducer {
|
namespace osgProducer {
|
||||||
|
|
||||||
|
@ -12,9 +12,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <osg/Matrixd>
|
#include <osg/Matrixd>
|
||||||
|
#include <osg/Matrixf>
|
||||||
|
|
||||||
// specialise Matrix_implementaiton to be Matrixd
|
// specialise Matrix_implementaiton to be Matrixd
|
||||||
#define Matrix_implementation Matrixd
|
#define Matrix_implementation Matrixd
|
||||||
|
|
||||||
|
osg::Matrixd::Matrixd( const osg::Matrixf& mat )
|
||||||
|
{
|
||||||
|
set(mat.ptr());
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::Matrixd& osg::Matrixd::operator = (const osg::Matrixf& rhs)
|
||||||
|
{
|
||||||
|
set(rhs.ptr());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void osg::Matrixd::set(const osg::Matrixf& rhs)
|
||||||
|
{
|
||||||
|
set(rhs.ptr());
|
||||||
|
}
|
||||||
|
|
||||||
// now compile up Matrix via Matrix_implementation
|
// now compile up Matrix via Matrix_implementation
|
||||||
#include "Matrix_implementation.cpp"
|
#include "Matrix_implementation.cpp"
|
||||||
|
@ -12,9 +12,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <osg/Matrixf>
|
#include <osg/Matrixf>
|
||||||
|
#include <osg/Matrixd>
|
||||||
|
|
||||||
// specialise Matrix_implementaiton to be Matrixf
|
// specialise Matrix_implementaiton to be Matrixf
|
||||||
#define Matrix_implementation Matrixf
|
#define Matrix_implementation Matrixf
|
||||||
|
|
||||||
|
osg::Matrixf::Matrixf( const osg::Matrixd& mat )
|
||||||
|
{
|
||||||
|
set(mat.ptr());
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::Matrixf& osg::Matrixf::operator = (const osg::Matrixd& rhs)
|
||||||
|
{
|
||||||
|
set(rhs.ptr());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void osg::Matrixf::set(const osg::Matrixd& rhs)
|
||||||
|
{
|
||||||
|
set(rhs.ptr());
|
||||||
|
}
|
||||||
|
|
||||||
// now compile up Matrix via Matrix_implementation
|
// now compile up Matrix via Matrix_implementation
|
||||||
#include "Matrix_implementation.cpp"
|
#include "Matrix_implementation.cpp"
|
||||||
|
@ -166,7 +166,7 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
|||||||
|
|
||||||
osg::Vec3 ep = _eye;
|
osg::Vec3 ep = _eye;
|
||||||
|
|
||||||
Matrix rotation_matrix;
|
Matrixd rotation_matrix;
|
||||||
rotation_matrix.get(_rotation);
|
rotation_matrix.get(_rotation);
|
||||||
osg::Vec3 sv = osg::Vec3(1.0f,0.0f,0.0f) * rotation_matrix;
|
osg::Vec3 sv = osg::Vec3(1.0f,0.0f,0.0f) * rotation_matrix;
|
||||||
osg::Vec3 bp = ep;
|
osg::Vec3 bp = ep;
|
||||||
@ -353,20 +353,20 @@ void DriveManipulator::addMouseEvent(const GUIEventAdapter& ea)
|
|||||||
_ga_t0 = &ea;
|
_ga_t0 = &ea;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriveManipulator::setByMatrix(const osg::Matrix& matrix)
|
void DriveManipulator::setByMatrix(const osg::Matrixd& matrix)
|
||||||
{
|
{
|
||||||
_eye = matrix.getTrans();
|
_eye = matrix.getTrans();
|
||||||
matrix.get(_rotation);
|
matrix.get(_rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Matrix DriveManipulator::getMatrix() const
|
osg::Matrixd DriveManipulator::getMatrix() const
|
||||||
{
|
{
|
||||||
return osg::Matrix::rotate(_rotation)*osg::Matrix::translate(_eye);
|
return osg::Matrixd::rotate(_rotation)*osg::Matrixd::translate(_eye);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Matrix DriveManipulator::getInverseMatrix() const
|
osg::Matrixd DriveManipulator::getInverseMatrix() const
|
||||||
{
|
{
|
||||||
return osg::Matrix::translate(-_eye)*osg::Matrix::rotate(_rotation.inverse());
|
return osg::Matrixd::translate(-_eye)*osg::Matrixd::rotate(_rotation.inverse());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriveManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up)
|
void DriveManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up)
|
||||||
|
@ -180,21 +180,21 @@ void FlightManipulator::addMouseEvent(const GUIEventAdapter& ea)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FlightManipulator::setByMatrix(const osg::Matrix& matrix)
|
void FlightManipulator::setByMatrix(const osg::Matrixd& matrix)
|
||||||
{
|
{
|
||||||
_eye = matrix.getTrans();
|
_eye = matrix.getTrans();
|
||||||
matrix.get(_rotation);
|
matrix.get(_rotation);
|
||||||
_distance = 1.0f;
|
_distance = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Matrix FlightManipulator::getMatrix() const
|
osg::Matrixd FlightManipulator::getMatrix() const
|
||||||
{
|
{
|
||||||
return osg::Matrix::rotate(_rotation)*osg::Matrix::translate(_eye);
|
return osg::Matrixd::rotate(_rotation)*osg::Matrixd::translate(_eye);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Matrix FlightManipulator::getInverseMatrix() const
|
osg::Matrixd FlightManipulator::getInverseMatrix() const
|
||||||
{
|
{
|
||||||
return osg::Matrix::translate(-_eye)*osg::Matrix::rotate(_rotation.inverse());
|
return osg::Matrixd::translate(-_eye)*osg::Matrixd::rotate(_rotation.inverse());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlightManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up)
|
void FlightManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up)
|
||||||
@ -206,7 +206,7 @@ void FlightManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv
|
|||||||
osg::Vec3 u(s^f);
|
osg::Vec3 u(s^f);
|
||||||
u.normalize();
|
u.normalize();
|
||||||
|
|
||||||
osg::Matrix rotation_matrix(s[0], u[0], -f[0], 0.0f,
|
osg::Matrixd rotation_matrix(s[0], u[0], -f[0], 0.0f,
|
||||||
s[1], u[1], -f[1], 0.0f,
|
s[1], u[1], -f[1], 0.0f,
|
||||||
s[2], u[2], -f[2], 0.0f,
|
s[2], u[2], -f[2], 0.0f,
|
||||||
0.0f, 0.0f, 0.0f, 1.0f);
|
0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
@ -258,7 +258,7 @@ bool FlightManipulator::calcMovement()
|
|||||||
float dy = _ga_t0->getYnormalized();
|
float dy = _ga_t0->getYnormalized();
|
||||||
|
|
||||||
|
|
||||||
osg::Matrix rotation_matrix;
|
osg::Matrixd rotation_matrix;
|
||||||
rotation_matrix.makeRotate(_rotation);
|
rotation_matrix.makeRotate(_rotation);
|
||||||
|
|
||||||
osg::Vec3 up = osg::Vec3(0.0f,1.0f,0.0) * rotation_matrix;
|
osg::Vec3 up = osg::Vec3(0.0f,1.0f,0.0) * rotation_matrix;
|
||||||
|
@ -189,24 +189,20 @@ void TrackballManipulator::addMouseEvent(const GUIEventAdapter& ea)
|
|||||||
_ga_t0 = &ea;
|
_ga_t0 = &ea;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackballManipulator::setByMatrix(const osg::Matrix& matrix)
|
void TrackballManipulator::setByMatrix(const osg::Matrixd& matrix)
|
||||||
{
|
{
|
||||||
_center = osg::Vec3(0.0f,0.0f,-_distance)*matrix;//matrix.getTrans();
|
_center = osg::Vec3(0.0f,0.0f,-_distance)*matrix;
|
||||||
matrix.get(_rotation);
|
matrix.get(_rotation);
|
||||||
|
|
||||||
osg::Matrix rotation_matrix(_rotation);
|
|
||||||
// _center -= osg::Vec3(0.0f,0.0f,_distance)*rotation_matrix;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Matrix TrackballManipulator::getMatrix() const
|
osg::Matrixd TrackballManipulator::getMatrix() const
|
||||||
{
|
{
|
||||||
return osg::Matrix::translate(0.0f,0.0f,_distance)*osg::Matrix::rotate(_rotation)*osg::Matrix::translate(_center);
|
return osg::Matrixd::translate(0.0,0.0,_distance)*osg::Matrixd::rotate(_rotation)*osg::Matrixd::translate(_center);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Matrix TrackballManipulator::getInverseMatrix() const
|
osg::Matrixd TrackballManipulator::getInverseMatrix() const
|
||||||
{
|
{
|
||||||
return osg::Matrix::translate(-_center)*osg::Matrix::rotate(_rotation.inverse())*osg::Matrix::translate(0.0f,0.0f,-_distance);
|
return osg::Matrixd::translate(-_center)*osg::Matrixd::rotate(_rotation.inverse())*osg::Matrixd::translate(0.0,0.0,-_distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackballManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up)
|
void TrackballManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up)
|
||||||
|
@ -436,19 +436,16 @@ const osg::Node* OsgCameraGroup::getTopMostSceneData() const
|
|||||||
return _scene_data.get();
|
return _scene_data.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgCameraGroup::setView(const osg::Matrix& matrix)
|
void OsgCameraGroup::setView(const osg::Matrixd& matrix)
|
||||||
{
|
{
|
||||||
Producer::Matrix pm;//(matrix.ptr());
|
Producer::Matrix pm(matrix.ptr());
|
||||||
for(int i=0;i<4;++i)
|
|
||||||
for(int j=0;j<4;++j)
|
|
||||||
pm(i,j)=matrix(i,j);
|
|
||||||
|
|
||||||
setViewByMatrix(pm);
|
setViewByMatrix(pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
const osg::Matrix OsgCameraGroup::getViewMatrix() const
|
osg::Matrixd OsgCameraGroup::getViewMatrix() const
|
||||||
{
|
{
|
||||||
osg::Matrix matrix;
|
osg::Matrixd matrix;
|
||||||
if (_cfg.valid() && _cfg->getNumberOfCameras()>=1)
|
if (_cfg.valid() && _cfg->getNumberOfCameras()>=1)
|
||||||
{
|
{
|
||||||
const Producer::Camera *cam = _cfg->getCamera(0);
|
const Producer::Camera *cam = _cfg->getCamera(0);
|
||||||
|
@ -72,7 +72,7 @@ public:
|
|||||||
virtual void apply(osg::Projection& pr)
|
virtual void apply(osg::Projection& pr)
|
||||||
{ // stack the intersect rays, transform to new projection, traverse
|
{ // stack the intersect rays, transform to new projection, traverse
|
||||||
// Assumes that the Projection is an absolute projection
|
// Assumes that the Projection is an absolute projection
|
||||||
osg::Matrix mt;
|
osg::Matrixd mt;
|
||||||
mt.invert(pr.getMatrix());
|
mt.invert(pr.getMatrix());
|
||||||
osg::Vec3 npt=osg::Vec3(xp,yp,-1.0f) * mt, farpt=osg::Vec3(xp,yp,1.0f) * mt;
|
osg::Vec3 npt=osg::Vec3(xp,yp,-1.0f) * mt, farpt=osg::Vec3(xp,yp,1.0f) * mt;
|
||||||
|
|
||||||
@ -105,11 +105,11 @@ public:
|
|||||||
return _PIVsegHitList;
|
return _PIVsegHitList;
|
||||||
}
|
}
|
||||||
|
|
||||||
osgUtil::IntersectVisitor::HitList& getHits(osg::Node *node, const osg::Matrix &projm, const float x, const float y)
|
osgUtil::IntersectVisitor::HitList& getHits(osg::Node *node, const osg::Matrixd &projm, const float x, const float y)
|
||||||
{
|
{
|
||||||
// utility for non=sceneview viewers
|
// utility for non=sceneview viewers
|
||||||
// x,y are values returned by
|
// x,y are values returned by
|
||||||
osg::Matrix inverseMVPW;
|
osg::Matrixd inverseMVPW;
|
||||||
inverseMVPW.invert(projm);
|
inverseMVPW.invert(projm);
|
||||||
osg::Vec3 near_point = osg::Vec3(x,y,-1.0f)*inverseMVPW;
|
osg::Vec3 near_point = osg::Vec3(x,y,-1.0f)*inverseMVPW;
|
||||||
osg::Vec3 far_point = osg::Vec3(x,y,1.0f)*inverseMVPW;
|
osg::Vec3 far_point = osg::Vec3(x,y,1.0f)*inverseMVPW;
|
||||||
@ -303,7 +303,7 @@ void Viewer::setViewByMatrix( const Producer::Matrix & pm)
|
|||||||
// now convert Producer matrix to an osg::Matrix so we can update
|
// now convert Producer matrix to an osg::Matrix so we can update
|
||||||
// the internal camera...
|
// the internal camera...
|
||||||
|
|
||||||
osg::Matrix matrix(pm.ptr());
|
osg::Matrixd matrix(pm.ptr());
|
||||||
_keyswitchManipulator->setByInverseMatrix(matrix);
|
_keyswitchManipulator->setByInverseMatrix(matrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -439,7 +439,7 @@ void Viewer::update()
|
|||||||
if (_keyswitchManipulator.valid() && _keyswitchManipulator->getCurrentMatrixManipulator())
|
if (_keyswitchManipulator.valid() && _keyswitchManipulator->getCurrentMatrixManipulator())
|
||||||
{
|
{
|
||||||
osgGA::MatrixManipulator* mm = _keyswitchManipulator->getCurrentMatrixManipulator();
|
osgGA::MatrixManipulator* mm = _keyswitchManipulator->getCurrentMatrixManipulator();
|
||||||
osg::Matrix matrix = mm->getInverseMatrix();
|
osg::Matrixd matrix = mm->getInverseMatrix();
|
||||||
CameraGroup::setViewByMatrix(Producer::Matrix(matrix.ptr()));
|
CameraGroup::setViewByMatrix(Producer::Matrix(matrix.ptr()));
|
||||||
|
|
||||||
setFusionDistance(mm->getFusionDistanceMode(),mm->getFusionDistanceValue());
|
setFusionDistance(mm->getFusionDistanceMode(),mm->getFusionDistanceValue());
|
||||||
@ -452,7 +452,7 @@ void Viewer::frame()
|
|||||||
|
|
||||||
if (getRecordingAnimationPath() && getAnimationPath())
|
if (getRecordingAnimationPath() && getAnimationPath())
|
||||||
{
|
{
|
||||||
osg::Matrix matrix;
|
osg::Matrixd matrix;
|
||||||
matrix.invert(getViewMatrix());
|
matrix.invert(getViewMatrix());
|
||||||
osg::Quat quat;
|
osg::Quat quat;
|
||||||
matrix.get(quat);
|
matrix.get(quat);
|
||||||
@ -538,7 +538,7 @@ bool Viewer::computeIntersections(float x,float y,unsigned int cameraNum,osgUtil
|
|||||||
|
|
||||||
osgProducer::OsgSceneHandler* sh = dynamic_cast<osgProducer::OsgSceneHandler*>(camera->getSceneHandler());
|
osgProducer::OsgSceneHandler* sh = dynamic_cast<osgProducer::OsgSceneHandler*>(camera->getSceneHandler());
|
||||||
osgUtil::SceneView* sv = sh?sh->getSceneView():0;
|
osgUtil::SceneView* sv = sh?sh->getSceneView():0;
|
||||||
osg::Matrix vum;
|
osg::Matrixd vum;
|
||||||
if (sv!=0)
|
if (sv!=0)
|
||||||
{
|
{
|
||||||
vum.set(sv->getViewMatrix() *
|
vum.set(sv->getViewMatrix() *
|
||||||
@ -546,8 +546,8 @@ bool Viewer::computeIntersections(float x,float y,unsigned int cameraNum,osgUtil
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vum.set(osg::Matrix(camera->getViewMatrix()) *
|
vum.set(osg::Matrixd(camera->getViewMatrix()) *
|
||||||
osg::Matrix(camera->getProjectionMatrix()));
|
osg::Matrixd(camera->getProjectionMatrix()));
|
||||||
}
|
}
|
||||||
|
|
||||||
PickVisitor iv;
|
PickVisitor iv;
|
||||||
|
Loading…
Reference in New Issue
Block a user