From 55b7ed10a1b2db3347990587b68427aee37b6c95 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 24 Jul 2002 16:29:00 +0000 Subject: [PATCH] Implemented the DOF handling more cleanly, as per OpenFlight15.7 docs. --- src/osgPlugins/flt/flt2osg.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/osgPlugins/flt/flt2osg.cpp b/src/osgPlugins/flt/flt2osg.cpp index 53756601e..ec2d549de 100644 --- a/src/osgPlugins/flt/flt2osg.cpp +++ b/src/osgPlugins/flt/flt2osg.cpp @@ -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; }