Made the following name changes to Matrix and Quat to clean them up and make

the functionality clear given the name.  This will break user code unfortunately
so please be away of the following mapping.

  osg::Matrix::makeTrans(..)?\026 -> osg::Matrix::makeTranslate(..)
  osg::Matrix::makeRot(..)?\026   -> osg::Matrix::makeRotate(..)
  osg::Matrix::trans(..)?\026     -> osg::Matrix::translate(..)

  osg::Quat::makeRot(..)?\026     -> osg::Quat::makeRotate(..)

Also updated the rest of the OSG distribution to use the new names, and
have removed the old deprecated Matrix methods too.
This commit is contained in:
Robert Osfield
2001-12-12 20:29:10 +00:00
parent 79c1fb531d
commit f848c54ba3
21 changed files with 71 additions and 240 deletions

View File

@@ -208,7 +208,7 @@ bool GliderManipulator::calcMovement()
float roll = inDegrees(dx*0.1f*dt);
osg::Matrix mat;
mat.makeTrans(-center);
mat.makeTranslate(-center);
mat *= Matrix::rotate(pitch,sv.x(),sv.y(),sv.z());
mat *= Matrix::rotate(roll,lv.x(),lv.y(),lv.z());
if (_yawMode==YAW_AUTOMATICALLY_WHEN_BANKED)
@@ -220,7 +220,7 @@ bool GliderManipulator::calcMovement()
lv *= (_velocity*dt);
mat *= Matrix::trans(center + lv);
mat *= Matrix::translate(center + lv);
_camera->transformLookAt(mat);

View File

@@ -43,7 +43,7 @@ class CameraPacket {
osg::Vec3 lv = _center-_eye;
osg::Matrix matrix;
matrix.makeIdent();
matrix.makeRot(angle_offset,_up.x(),_up.y(),_up.z());
matrix.makeRotate(angle_offset,_up.x(),_up.y(),_up.z());
lv = lv*matrix;
camera.setLookAt(_eye,_eye+lv,_up);

View File

@@ -24,7 +24,7 @@ void OrientationConverter::setRotation( const Vec3 &from, const Vec3 &to )
void OrientationConverter::setTranslation( const Vec3 &trans )
{
T = Matrix::trans(trans);
T = Matrix::translate(trans);
_trans_set = true;
}
@@ -45,9 +45,9 @@ void OrientationConverter::convert( Node &node )
// else
// - translate back to model's original origin.
BoundingSphere bs = node.getBound();
Matrix C = Matrix::trans( Vec3(0,0,0) - bs.center() );
Matrix C = Matrix::translate( Vec3(0,0,0) - bs.center() );
if( _trans_set == false )
T = Matrix::trans( bs.center() );
T = Matrix::translate( bs.center() );
_cv.setMatrix( C * R * S * T );
node.accept(_cv);

View File

@@ -45,8 +45,8 @@ class MyTransformCallback : public osg::NodeCallback{
float delta_angle = _angular_velocity*_timer.delta_s(_orig_t,new_t);
osg::Matrix matrix;
matrix.makeRot(delta_angle,1.0f,1.0f,1.0f);
matrix *= osg::Matrix::trans(1.0f,0.0f,0.0f);
matrix.makeRotate(delta_angle,1.0f,1.0f,1.0f);
matrix *= osg::Matrix::translate(1.0f,0.0f,0.0f);
matrix *= osg::Matrix::rotate(delta_angle,0.0f,0.0f,1.0f);
_nodeToOperateOn->setMatrix(matrix);

View File

@@ -367,9 +367,9 @@ int main( int argc, char **argv )
osg::Transform* dcs = new osg::Transform;
dcs->setStateSet(dstate);
dcs->preMult(osg::Matrix::trans(0.0f,0.0f,-z)*
dcs->preMult(osg::Matrix::translate(0.0f,0.0f,-z)*
osg::Matrix::scale(1.0f,1.0f,-1.0f)*
osg::Matrix::trans(0.0f,0.0f,z));
osg::Matrix::translate(0.0f,0.0f,z));
dcs->addChild(loadedModelTransform);

View File

@@ -115,7 +115,7 @@ osg::Node* createTexturedItem(const osg::Vec3& offset,osg::Texture* texture,osg:
// place and also to add individual texture set to it, so that
// that state is inherited down to its children.
osg::Transform* local_transform = new osg::Transform;
local_transform->postMult(osg::Matrix::trans(offset));
local_transform->postMult(osg::Matrix::translate(offset));
// create the StateSet to store the texture data
osg::StateSet* stateset = new osg::StateSet;
@@ -140,7 +140,7 @@ osg::Node* createLayer(const osg::Vec3& offset,osg::Image* image,osg::Node* geom
if (image==NULL) return NULL;
osg::Transform* top_transform = new osg::Transform;
top_transform->postMult(osg::Matrix::trans(offset));
top_transform->postMult(osg::Matrix::translate(offset));
osg::Vec3 local_offset(0.0f,0.0f,0.0f);
osg::Vec3 local_delta(3.0f,0.0f,0.0f);

View File

@@ -84,7 +84,7 @@ void Billboard::calcRotation(const Vec3& eye_local, const Vec3& pos_local,Matrix
{
mat.makeIdent();
//float rotation_zrotation_z = atan2f(ev.x(),ev.y());
//mat.makeRot(inRadians(rotation_z),0.0f,0.0f,1.0f);
//mat.makeRotate(inRadians(rotation_z),0.0f,0.0f,1.0f);
float inv = 1.0f/ev_length;
float c = ev.y()*inv;
float s = ev.x()*inv;
@@ -122,7 +122,7 @@ void Billboard::calcRotation(const Vec3& eye_local, const Vec3& pos_local,Matrix
cp /= cp_len;
float rotation_cp = acosf(dot);
mat.makeRot(inRadians(rotation_cp),cp[0],cp[1],cp[2]);
mat.makeRotate(inRadians(rotation_cp),cp[0],cp[1],cp[2]);
}
}
break;
@@ -133,7 +133,7 @@ void Billboard::calcRotation(const Vec3& eye_local, const Vec3& pos_local,Matrix
void Billboard::calcTransform(const Vec3& eye_local, const Vec3& pos_local,Matrix& mat) const
{
// mat.makeTrans(pos_local[0],pos_local[1],pos_local[2]);
// mat.makeTranslate(pos_local[0],pos_local[1],pos_local[2]);
// mat.makeIdent();
calcRotation(eye_local,pos_local,mat);

View File

@@ -678,7 +678,7 @@ void Camera::calculateMatricesAndClippingVolume() const
s[2], u[2], -f[2], 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
(*matrix) = Matrix::trans(-_eye[0], -_eye[1], -_eye[2]) * (*matrix);
(*matrix) = Matrix::translate(-_eye[0], -_eye[1], -_eye[2]) * (*matrix);
if (_modelToEyeTransform.valid())
{
@@ -696,7 +696,7 @@ void Camera::calculateMatricesAndClippingVolume() const
if (_useEyeOffset)
{
(*_modelViewMatrix) = (*_modelViewMatrix) * Matrix::trans(-_eyeOffset*_focalLength/_screenDistance);
(*_modelViewMatrix) = (*_modelViewMatrix) * Matrix::translate(-_eyeOffset*_focalLength/_screenDistance);
}

View File

@@ -8,31 +8,9 @@
using namespace osg;
#define DEG2RAD(x) ((x)*M_PI/180.0)
#define RAD2DEG(x) ((x)*180.0/M_PI)
// temporary #define's for warning that deprecated methods are being
// used which should be replaced by the new variants.
#define WARN_DEPRECATED
//#define ABORT_DEPRECATED
#ifdef WARN_DEPRECATED
#ifdef ABORT_DEPRECATED
#define DEPRECATED(message) \
notify(NOTICE) << message<<endl; \
abort();
#else
#define DEPRECATED(message) \
notify(NOTICE) << message<<endl;
#endif
#else
#define DEPRECATED(message)
#endif
#define SET_ROW(row, v1, v2, v3, v4 ) \
_mat[(row)][0] = (v1); \
_mat[(row)][1] = (v2); \
@@ -142,12 +120,12 @@ void Matrix::makeScale( float x, float y, float z )
fully_realized = true;
}
void Matrix::makeTrans( const Vec3& v )
void Matrix::makeTranslate( const Vec3& v )
{
makeTrans( v[0], v[1], v[2] );
makeTranslate( v[0], v[1], v[2] );
}
void Matrix::makeTrans( float x, float y, float z )
void Matrix::makeTranslate( float x, float y, float z )
{
SET_ROW(0, 1, 0, 0, 0 )
SET_ROW(1, 0, 1, 0, 0 )
@@ -157,40 +135,35 @@ void Matrix::makeTrans( float x, float y, float z )
fully_realized = true;
}
void Matrix::makeRot( const Vec3& from, const Vec3& to )
void Matrix::makeRotate( const Vec3& from, const Vec3& to )
{
Quat quat;
quat.makeRot(from,to);
quat.makeRotate(from,to);
quat.get(*this);
}
void Matrix::makeRot( float angle, const Vec3& axis )
void Matrix::makeRotate( float angle, const Vec3& axis )
{
Quat quat;
quat.makeRot( angle, axis);
quat.makeRotate( angle, axis);
quat.get(*this);
}
void Matrix::makeRot( float angle, float x, float y, float z )
void Matrix::makeRotate( float angle, float x, float y, float z )
{
Quat quat;
quat.makeRot( angle, x, y, z);
quat.makeRotate( angle, x, y, z);
quat.get(*this);
}
void Matrix::makeRot( const Quat& q )
void Matrix::makeRotate( const Quat& q )
{
q.get(*this);
fully_realized = true;
}
void Matrix::makeRot( float yaw, float pitch, float roll)
void Matrix::makeRotate( float yaw, float pitch, float roll)
{
#ifdef USE_DEGREES_INTERNALLY
yaw = DEG2RAD(yaw);
pitch = DEG2RAD(pitch);
roll = DEG2RAD(roll);
#endif
// lifted straight from SOLID library v1.01 Quaternion.h
// available from http://www.win.tue.nl/~gino/solid/
@@ -467,87 +440,3 @@ bool Matrix::invertAffine( const Matrix& _m )
return true;
}
#ifdef USE_DEPRECATED_MATRIX_METHODS
//Deprecated methods
void Matrix::copy( const Matrix& other)
{
DEPRECATED("Matrix::copy is deprecated. Use = instead.")
(*this) = other;
}
void Matrix::preScale( float sx, float sy, float sz, const Matrix& m )
{
DEPRECATED("Matrix::preScale is deprecated. Use result = (Matrix::scale * m) instead.")
(*this) = ( scale(sx,sy,sz) * m );
}
void Matrix::postScale( const Matrix& m, float sx, float sy, float sz )
{
DEPRECATED("Matrix::postScale is deprecated. Use result = (m * Matrix::scale()) instead.")
(*this) = ( m * scale(sx,sy,sz) );
}
void Matrix::preScale( float sx, float sy, float sz )
{
DEPRECATED("Matrix::preScale is deprecated. Use M.preMult( Matrix::scale ) instead.")
preMult( scale(sx,sy,sz) );
}
void Matrix::postScale( float sx, float sy, float sz )
{
DEPRECATED("Matrix::postScale is deprecated. Use M.postMult( Matrix::scale ) instead.")
postMult( scale(sx,sy,sz) );
}
void Matrix::preTrans( float tx, float ty, float tz, const Matrix& m )
{
DEPRECATED("Matrix::preTrans is deprecated. Use result = Matrix::trans * m instead.")
(*this) = trans(tx,ty,tz) * m;
}
void Matrix::postTrans( const Matrix& m, float tx, float ty, float tz )
{
DEPRECATED("Matrix::postTrans is deprecated. Use result = m * Matrix::trans instead.")
(*this) = m * trans(tx,ty,tz);
}
void Matrix::preTrans( float tx, float ty, float tz )
{
DEPRECATED("Matrix::preTrans is deprecated. Use result = Matrix::trans * m instead.")
preMult( trans(tx,ty,tz) );
}
void Matrix::postTrans( float sx, float sy, float sz )
{
DEPRECATED("Matrix::postTrans is deprecated. Use result = m * Matrix::trans instead.")
postMult( trans(sx,sy,sz) );
}
void Matrix::preRot( float deg, float x, float y, float z, const Matrix& m )
{
DEPRECATED("Matrix::preRot is deprecated. Use result = Matrix::rot * m instead.")
(*this) = rotate(deg,x,y,z) * m;
}
void Matrix::postRot( const Matrix& m, float deg, float x, float y, float z )
{
DEPRECATED("Matrix::postRot is deprecated. Use result = m * Matrix::rotate instead.")
(*this) = m * rotate(deg,x,y,z);
}
void Matrix::preRot( float deg, float x, float y, float z )
{
DEPRECATED("Matrix::preRot is deprecated. Use m.preMult( Matrix::rotate ) instead.")
preMult( rotate(deg,x,y,z) );
}
void Matrix::postRot( float deg, float x, float y, float z )
{
DEPRECATED("Matrix::postRot is deprecated. Use m.postMult( Matrix::rotate ) instead.")
postMult( rotate(deg,x,y,z) );
}
#endif

View File

@@ -15,7 +15,7 @@ using namespace osg;
/// Set the elements of the Quat to represent a rotation of angle
/// (radians) around the axis (x,y,z)
void Quat::makeRot( const float angle,
void Quat::makeRotate( const float angle,
const float x,
const float y,
const float z )
@@ -31,9 +31,9 @@ const float z )
}
void Quat::makeRot( const float angle, const Vec3& vec )
void Quat::makeRotate( const float angle, const Vec3& vec )
{
makeRot( angle, vec[0], vec[1], vec[2] );
makeRotate( angle, vec[0], vec[1], vec[2] );
}
@@ -42,7 +42,7 @@ void Quat::makeRot( const float angle, const Vec3& vec )
// and then use a cross product to get the rotation axis
// Watch out for the two special cases of when the vectors
// are co-incident or opposite in direction.
void Quat::makeRot( const Vec3& from, const Vec3& to )
void Quat::makeRotate( const Vec3& from, const Vec3& to )
{
const float epsilon = 0.00001f;
@@ -57,7 +57,7 @@ void Quat::makeRot( const Vec3& from, const Vec3& to )
// cosangle is close to 1, so the vectors are close to being coincident
// Need to generate an angle of zero with any vector we like
// We'll choose (1,0,0)
makeRot( 0.0, 1.0, 0.0, 0.0 );
makeRotate( 0.0, 1.0, 0.0, 0.0 );
}
else
if ( fabs(cosangle + 1.0) < epsilon )
@@ -87,7 +87,7 @@ void Quat::makeRot( const Vec3& from, const Vec3& to )
// and that is the axis around which to rotate.
Vec3 axis(from^to);
float angle = acos( cosangle );
makeRot( angle, axis );
makeRotate( angle, axis );
}
}

View File

@@ -21,26 +21,6 @@ Transform::~Transform()
{
}
#ifdef USE_DEPRECATED_MATRIX_METHODS
void Transform::preScale( const float sx, const float sy, const float sz )
{
(*_matrix) = Matrix::scale( sx, sy, sz ) * (*_matrix);
dirtyBound();
}
void Transform::preTranslate( const float tx, const float ty, const float tz )
{
(*_matrix) = Matrix::trans( tx, ty, tz ) * (*_matrix);
dirtyBound();
}
void Transform::preRotate( const float deg, const float x, const float y, const float z )
{
(*_matrix) = Matrix::rotate( deg, x, y, z ) * (*_matrix);
dirtyBound();
}
#endif
const bool Transform::computeBound() const
{
if (!Group::computeBound()) return false;

View File

@@ -1103,9 +1103,9 @@ osg::Node* ConvertFromFLT::visitMatrix(osg::Group* osgParent, MatrixRecord* rec)
// scale position.
// BJ Don't know if this should be done if version > 12
osg::Vec3 pos = m.getTrans();
m *= osg::Matrix::trans(-pos.x(),-pos.y(),-pos.z());
m *= osg::Matrix::translate(-pos.x(),-pos.y(),-pos.z());
pos *= (float)_unitScale;
m *= osg::Matrix::trans(pos);
m *= osg::Matrix::translate(pos);
dcs->setMatrix(m);
osgParent->addChild(dcs);

View File

@@ -157,7 +157,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterOBJ::readNode(const std::string& fil
// note obj_x -> osg_x,
// obj_y -> osg_z,
// obj_z -> osg_y,
xform->setMatrix(osg::Matrix::trans(obj->position[0], obj->position[2], obj->position[1]));
xform->setMatrix(osg::Matrix::translate(obj->position[0], obj->position[2], obj->position[1]));
osg_top = xform;
}
else

View File

@@ -408,9 +408,9 @@ bool DriveManipulator::calcMovement()
float yaw = -inDegrees(dx*0.1f*dt);
osg::Matrix mat;
mat.makeTrans(-center.x(),-center.y(),-center.z());
mat.makeTranslate(-center.x(),-center.y(),-center.z());
mat *= Matrix::rotate(yaw,uv.x(),uv.y(),uv.z());
mat *= Matrix::trans(center.x(),center.y(),center.z());
mat *= Matrix::translate(center.x(),center.y(),center.z());
center = _camera->getEyePoint();
uv = _camera->getUpVector();

View File

@@ -205,7 +205,7 @@ bool FlightManipulator::calcMovement()
float roll = inDegrees(dx*0.1f*dt);
osg::Matrix mat;
mat.makeTrans(-center);
mat.makeTranslate(-center);
mat *= Matrix::rotate(pitch,sv.x(),sv.y(),sv.z());
mat *= Matrix::rotate(roll,lv.x(),lv.y(),lv.z());
if (_yawMode==YAW_AUTOMATICALLY_WHEN_BANKED)
@@ -217,7 +217,7 @@ bool FlightManipulator::calcMovement()
lv *= (_velocity*dt);
mat *= Matrix::trans(center+lv);
mat *= Matrix::translate(center+lv);
_camera->transformLookAt(mat);

View File

@@ -215,9 +215,9 @@ bool TrackballManipulator::calcMovement()
trackball(axis,angle,px1,py1,px0,py0);
osg::Matrix mat;
mat.makeTrans(-center.x(),-center.y(),-center.z());
mat.makeTranslate(-center.x(),-center.y(),-center.z());
mat *= Matrix::rotate(angle,axis.x(),axis.y(),axis.z());
mat *= Matrix::trans(center.x(),center.y(),center.z());
mat *= Matrix::translate(center.x(),center.y(),center.z());
_camera->transformLookAt(mat);
@@ -237,7 +237,7 @@ bool TrackballManipulator::calcMovement()
osg::Vec3 dv = uv*(dy*scale)-sv*(dx*scale);
osg::Matrix mat;
mat.makeTrans(dv.x(),dv.y(),dv.z());
mat.makeTranslate(dv.x(),dv.y(),dv.z());
_camera->transformLookAt(mat);
@@ -257,9 +257,9 @@ bool TrackballManipulator::calcMovement()
osg::Vec3 center = _camera->getCenterPoint();
osg::Matrix mat;
mat.makeTrans(-center.x(),-center.y(),-center.z());
mat.makeTranslate(-center.x(),-center.y(),-center.z());
mat *= Matrix::scale(scale,scale,scale);
mat *= Matrix::trans(center.x(),center.y(),center.z());
mat *= Matrix::translate(center.x(),center.y(),center.z());
_camera->transformLookAt(mat);
@@ -273,7 +273,7 @@ bool TrackballManipulator::calcMovement()
osg::Vec3 dv = _camera->getLookVector()*(dy*scale);
osg::Matrix mat;
mat.makeTrans(dv.x(),dv.y(),dv.z());
mat.makeTranslate(dv.x(),dv.y(),dv.z());
_camera->transformLookAt(mat);

View File

@@ -32,9 +32,9 @@ void TransformCallback::operator() (osg::Node* node, osg::NodeVisitor* nv)
double newTime = fs->getReferenceTime();
float delta_angle = _angular_velocity*(newTime-_previousTime);
osg::Matrix mat = osg::Matrix::trans(-_pivot)*
osg::Matrix mat = osg::Matrix::translate(-_pivot)*
osg::Matrix::rotate(delta_angle,_axis)*
osg::Matrix::trans(_pivot);
osg::Matrix::translate(_pivot);
// update the specified transform