I am currently using Bullet in order to have precise raycasting on various collision shapes in a 3D world. Rendering is done through Ogre3D.
3D objects are associated to an Ogre SceneNode and to a Bullet btRigidBody, both should always be at the same position.
When selecting a 3D object (with a mouse click), I perform a rayTest , and it works well. Then, the 3d object is moved (following the mouse mouvement) to a new position. the sceneNode coordinates are updated, the btRigidBody also seems to be moved (the center of mass coordinates do change)
in the following piece of code, _body is a btRigidBody *
Code: Select all
Vector3 pos = this->ogreSceneNode()->getPosition();
bt Transform btt;
this->_body->getMotionState()->getWorldTransform(btt);
btt.setOrigin(btVector3(pos.x,pos.y,pos.z)); // move body to the scene node new position
// update _body according to CharacterDemo demo
_body->getMotionState()->setWorldTransform(btt);
_body->setCenterOfMassTransform(btt);
small picture to explain :