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:
@@ -166,7 +166,7 @@ void DriveManipulator::init(const GUIEventAdapter& ea,GUIActionAdapter& us)
|
||||
|
||||
osg::Vec3 ep = _eye;
|
||||
|
||||
Matrix rotation_matrix;
|
||||
Matrixd rotation_matrix;
|
||||
rotation_matrix.get(_rotation);
|
||||
osg::Vec3 sv = osg::Vec3(1.0f,0.0f,0.0f) * rotation_matrix;
|
||||
osg::Vec3 bp = ep;
|
||||
@@ -353,20 +353,20 @@ void DriveManipulator::addMouseEvent(const GUIEventAdapter& ea)
|
||||
_ga_t0 = &ea;
|
||||
}
|
||||
|
||||
void DriveManipulator::setByMatrix(const osg::Matrix& matrix)
|
||||
void DriveManipulator::setByMatrix(const osg::Matrixd& matrix)
|
||||
{
|
||||
_eye = matrix.getTrans();
|
||||
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)
|
||||
|
||||
@@ -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();
|
||||
matrix.get(_rotation);
|
||||
_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)
|
||||
@@ -206,7 +206,7 @@ void FlightManipulator::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);
|
||||
@@ -258,7 +258,7 @@ bool FlightManipulator::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;
|
||||
|
||||
@@ -189,24 +189,20 @@ void TrackballManipulator::addMouseEvent(const GUIEventAdapter& 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);
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user