Rocko Bonaparte wrote:Is there some way with irrBullet or the underlying Bullet physics library to reposition something instantly in space? This is coming up particularly in creating game entities. I might not have the position information up front, so the mesh is first placed at (0, 0, 0), but maybe a few lines of code later it'll get put in its real spot. This is happening between simulation steps so I wouldn't expect any change in physics. I can't then reposition Irrlicht's mesh node and get the physics wrapper to understand it. I'm afraid I have to completely re-create the physics object. I would rather not argue about why I'm not getting the position to it right then and there, since I expect eventually I'd want to do something like teleport an object without having a problem.
Hi Rocko,
irrBullet makes this very easy. First, the object is located in the world wherever your scene node is at creation time (if you choose to do it that way).
The second option is this (taken from the irrBullet FAQ included with the SDK; please refer to this and the Doxygen documentation for future questions because it's likely already answered):
- cpp Code: Select all
1.2
A: How do I change the position or rotation of one of my
objects?
Q: Changing the world transform of an object is easy with
2
irrBullet.
Here is an example:
irr::core::matrix4 mat;
mat.setTranslation(irr::core::vector3df(0,1000,1000));
mat.setRotationDegrees(irr::core::vector3df(0,0,0));
object->setWorldTransform(mat);