I have a very simple problem, but I can't see what I'm doing wrong.
I have a rigidbody starting at pos: 0.0, 3.0, 0.0. I apply a translate, -90 degree rotation, and then another translate. The rigidbody's final position should be 2.0, 1.0, 0.0, but the position that is printed out is still 0.0, 3.0, 0.0.
I perform a collision test by dropping some small cubes above the rigidbody in question. Oddly enough, they stop above 2.0, 1.0, 0.0 showing that the rigidbody was moved correctly.
//Rigidbody in question
btPhys->translate(btVector3(0.0, -2.0, 0.0));
//Perform -90 degree rotation
btMatrix3x3 orn = btPhys->getWorldTransform().getBasis();
orn *= btMatrix3x3(btQuaternion( btVector3(0, 0, 1), btScalar(degreesToRads(-90))));
//Perform second transform
btPhys->translate(btVector3(2.0, 0.0, 0.0));
//Print out final position
float x, y, z;
x = trans.getOrigin().getX();
y = trans.getOrigin().getY();
z = trans.getOrigin().getZ();
printf("\n\nposition: %f %f %f\n\n", x, y, z);
In your case, if you want to obtain correct position of
btRigidBody you should call:
You are calling
instead, but the
MotionState is not yet updated. All MotionStates are updated in simulation step.