[Opal-commits] opal/src Solid.h,1.85,1.86 SpringMotor.cpp,1.12,1.13
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-04-04 13:09:23
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1854/src Modified Files: Solid.h SpringMotor.cpp Log Message: made the SpringMotor depend on the Solid's mass and inertia tensor; fixed bugs in SpringMotor; added to playpen sample app Index: SpringMotor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/SpringMotor.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SpringMotor.cpp 30 Mar 2005 23:26:23 -0000 1.12 --- SpringMotor.cpp 4 Apr 2005 13:09:12 -0000 1.13 *************** *** 91,95 **** LINEAR_AND_ANGULAR_MODE == mData.mode) { ! Vec3r error = mData.desiredPos - mData.solid->getPosition(); Force f; f.singleStep = true; --- 91,95 ---- LINEAR_AND_ANGULAR_MODE == mData.mode) { ! Vec3r error = mData.desiredPos - getGlobalAttachPoint(); Force f; f.singleStep = true; *************** *** 98,101 **** --- 98,104 ---- f.vec = mData.linearKs * error - mData.linearKd * mData.solid->getGlobalLinearVel(); + + // Scale the force vector by the Solid's mass. + f.vec *= mData.solid->getMass(); mData.solid->addForce(f); } *************** *** 154,162 **** rightError *= -rangle; ! // average the vectors into one Vec3r errorAxis = (forwardError + upError + rightError) * globals::OPAL_ONE_THIRD; ! // use the error vector to calculate torque Force f; f.singleStep = true; --- 157,165 ---- rightError *= -rangle; ! // Average the vectors into one. Vec3r errorAxis = (forwardError + upError + rightError) * globals::OPAL_ONE_THIRD; ! // Use the error vector to calculate torque. Force f; f.singleStep = true; *************** *** 164,167 **** --- 167,173 ---- f.vec = mData.angularKs * errorAxis - mData.angularKd * mData.solid->getGlobalAngularVel(); + + // Scale the torque vector by the Solid's intertia tensor. + f.vec = mData.solid->getInertiaTensor() * f.vec; mData.solid->addForce(f); } *************** *** 189,196 **** } ! // Convert the global point to an offset from the Solid's transform. ! Vec3r relVec = p - mData.solid->getPosition(); ! Point3r relPos(relVec[0], relVec[1], relVec[2]); ! mData.attachOffset = mData.solid->getTransform() * relPos; } --- 195,203 ---- } ! // Convert the global point to a local point offset from the Solid's ! // transform. ! Matrix44r inv; ! fastInverse(inv, mData.solid->getTransform()); ! mData.attachOffset = inv * p; } Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** Solid.h 23 Mar 2005 07:54:34 -0000 1.85 --- Solid.h 4 Apr 2005 13:09:11 -0000 1.86 *************** *** 210,213 **** --- 210,217 ---- virtual real OPAL_CALL getMass()const = 0; + /// Returns the Solid's inertia tensor as a 4x4 matrix. This will + /// be the identity matrix if the Solid is static. + virtual Matrix44r OPAL_CALL getInertiaTensor()const = 0; + /// Update the OPAL transform using the physics engine transform. virtual void OPAL_CALL internal_updateOPALTransform() = 0; |