Implemented the DOF handling more cleanly, as per OpenFlight15.7 docs.

This commit is contained in:
Robert Osfield
2002-07-24 16:29:00 +00:00
parent 42358b61ae
commit 55b7ed10a1

View File

@@ -627,30 +627,26 @@ osg::Group* ConvertFromFLT::visitDOF(osg::Group& osgParent, DofRecord* rec)
visitAncillary(osgParent, *transform, rec)->addChild( transform );
visitPrimaryNode(*transform, (PrimNodeRecord*)rec);
// note for Judd (and others) shouldn't there be code in here to set up the transform matrix?
// as a transform with an identity matrix is effectively only a
// a Group... I will leave for other more familiar with the
// DofRecord to create the matrix as I don't have any Open Flight
// documentation. RO August 2001.
// below is DOF code submitted by Sasa Bistrovic
SDegreeOfFreedom* p_data = rec->getData();
osg::Matrix mat;
mat.makeTranslate(_unitScale*p_data->dfX._dfCurrent,
_unitScale*p_data->dfY._dfCurrent,
_unitScale*p_data->dfZ._dfCurrent);
osg::Vec3 trans(_unitScale*p_data->dfX._dfCurrent,
_unitScale*p_data->dfY._dfCurrent,
_unitScale*p_data->dfZ._dfCurrent);
float roll_rad = osg::inDegrees(p_data->dfRoll._dfCurrent);
float pitch_rad = osg::inDegrees(p_data->dfPitch._dfCurrent);
float yaw_rad = osg::inDegrees(p_data->dfYaw._dfCurrent);
osg::Matrix mat_rot = osg::Matrix::rotate(-yaw_rad, pitch_rad,roll_rad);
float sx = rec->getData()->dfXscale.current();
float sy = rec->getData()->dfYscale.current();
float sz = rec->getData()->dfZscale.current();
mat.preMult(mat_rot);
transform->setMatrix(mat);
transform->setMatrix( osg::Matrix::scale(sx, sy, sz)*
osg::Matrix::rotate(-yaw_rad, 0.0f,0.0f,1.0f)*
osg::Matrix::rotate(roll_rad, 0.0f,1.0f,0.0f)*
osg::Matrix::rotate(pitch_rad, 1.0f,0.0f,0.0f)*
osg::Matrix::translate(trans)
);
return transform;
}