motion_state.cpp
Go to the documentation of this file.
00001 
00031 #include <LinearMath/btDefaultMotionState.h>
00032 
00033 extern double bulletWorldScalingFactor;
00034 
00035 extern "C"
00036 {
00037 
00038   btDefaultMotionState *newMotionState(const double *transform)
00039   {
00040     return new btDefaultMotionState(
00041       btTransform(
00042         btQuaternion(transform[3],
00043           transform[4],
00044           transform[5],
00045           transform[6]),
00046         btVector3(transform[0] * bulletWorldScalingFactor,
00047           transform[1] * bulletWorldScalingFactor,
00048           transform[2] * bulletWorldScalingFactor)));
00049   }
00050 
00051   void deleteMotionState(btDefaultMotionState *motionState)
00052   {
00053     delete motionState;
00054   }
00055 
00056   void setCenterOfMass(btDefaultMotionState *motionState, const double *centerOfMass)
00057   {
00058     motionState->m_centerOfMassOffset =
00059       btTransform(
00060         btQuaternion(0, 0, 0, 1),
00061         btVector3(centerOfMass[0] * bulletWorldScalingFactor,
00062           centerOfMass[1] * bulletWorldScalingFactor,
00063           centerOfMass[2] * bulletWorldScalingFactor));
00064   }
00065 
00066   void setWorldTransform(btMotionState *motionState, double *transform)
00067   {
00068     motionState->setWorldTransform(
00069       btTransform(
00070         btQuaternion(transform[3],
00071           transform[4],
00072           transform[5],
00073           transform[6]),
00074         btVector3(transform[0] * bulletWorldScalingFactor,
00075           transform[1] * bulletWorldScalingFactor,
00076           transform[2] * bulletWorldScalingFactor)));
00077   }
00078   
00079   void getWorldTransform(btMotionState *motionState, double *transform)
00080   {
00081     btTransform result;
00082 
00083     motionState->getWorldTransform(result);
00084     transform[0] = result.getOrigin().x() / bulletWorldScalingFactor;
00085     transform[1] = result.getOrigin().y() / bulletWorldScalingFactor;
00086     transform[2] = result.getOrigin().z() / bulletWorldScalingFactor;
00087     transform[3] = result.getRotation().x();
00088     transform[4] = result.getRotation().y();
00089     transform[5] = result.getRotation().z();
00090     transform[6] = result.getRotation().w();
00091   }
00092   
00093 }


cl_bullet
Author(s): Lorenz Moesenlechner
autogenerated on Sun Oct 5 2014 23:22:10