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:
Robert Osfield
2003-09-05 22:35:34 +00:00
parent a2834d74d2
commit 792bba05b9
23 changed files with 203 additions and 129 deletions

View File

@@ -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();
matrix.get(_rotation);
_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)
@@ -207,7 +207,7 @@ void GliderManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv
osg::Vec3 u(s^f);
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[2], u[2], -f[2], 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
@@ -261,7 +261,7 @@ bool GliderManipulator::calcMovement()
float dy = _ga_t0->getYnormalized();
osg::Matrix rotation_matrix;
osg::Matrixd rotation_matrix;
rotation_matrix.makeRotate(_rotation);
osg::Vec3 up = osg::Vec3(0.0f,1.0f,0.0) * rotation_matrix;

View File

@@ -33,16 +33,16 @@ class GliderManipulator : public osgGA::MatrixManipulator
virtual const char* className() const { return "Glider"; }
/** 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.*/
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.*/
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.*/
virtual osg::Matrix getInverseMatrix() const;
virtual osg::Matrixd getInverseMatrix() const;
virtual void setNode(osg::Node*);

View File

@@ -179,21 +179,21 @@ void TestManipulator::addMouseEvent(const GUIEventAdapter& ea)
_ga_t0 = &ea;
}
void TestManipulator::setByMatrix(const osg::Matrix& matrix)
void TestManipulator::setByMatrix(const osg::Matrixd& matrix)
{
_center = matrix.getTrans();
matrix.get(_rotation);
_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)
@@ -205,7 +205,7 @@ void TestManipulator::computePosition(const osg::Vec3& eye,const osg::Vec3& lv,c
osg::Vec3 u(s^f);
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[2], u[2], -f[2], 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
@@ -258,7 +258,7 @@ bool TestManipulator::calcMovement()
}
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;

View File

@@ -16,16 +16,16 @@ class TestManipulator : public osgGA::MatrixManipulator
virtual ~TestManipulator();
/** 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.*/
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.*/
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.*/
virtual osg::Matrix getInverseMatrix() const;
virtual osg::Matrixd getInverseMatrix() const;
/** Attach a node to the manipulator.
Automatically detaches previously attached node.