Currently I am trying this:
Code: Select all
getRigidBody()->getVelocityInLocalPoint(getRigidBody()->getCenterOfMassPosition()).z()
Code: Select all
getRigidBody()->getVelocityInLocalPoint(btVector3(0, 0, 0)).z()
Any ideas?
Code: Select all
getRigidBody()->getVelocityInLocalPoint(getRigidBody()->getCenterOfMassPosition()).z()
Code: Select all
getRigidBody()->getVelocityInLocalPoint(btVector3(0, 0, 0)).z()
Code: Select all
btVector3 getVelocityAtWorldPosition(btRigidBody* body,const btVector3& worldposition,bool local)
{
/* That's the 'localpoint' */
const btVector3 relpos=worldposition-body->getCenterOfMassPosition();
/* That's velocity in world space */
const btVector3 wvel=body->getVelocityInLocalPoint(relpos);
/* Now you can transform it in body local frame */
if(local) return(body->getWorldTransform().getBasis().transpose()*wvel);
/* Or keep it in world frame */
return(wvel);
}
Code: Select all
static btVector3 getLinearVelocityInBodyFrame(btRigidBody* body)
{
return( body->getWorldTransform().getBasis().transpose() *
body->getLinearVelocity());
}