Transform matrix for Bullet's rigidbodies

Ipredlol
Posts: 8
Joined: Fri Mar 11, 2011 6:23 pm

Transform matrix for Bullet's rigidbodies

Post by Ipredlol »

Hello folks!

I am wondering if anyone knows how Bullet keeps track of all its rigidbodies, in other words, where can I find the transform matrix for for example spheres that are rolling? When I tried to get for instance the vector for up direction by calling aRigidBody->getMotionState()->getWorldTransform()->getBasis()[1], I always get the same vector which is pointing straight up (0,1,0) as result no matter if the sphere has rolled over an uneven ground or crashed into walls. I used applyCentralForce on the sphere to make it move and crash, the sphere should have at least different up vectors when it hits something. Anybody has any idea on what I've done wrong here? Thank you!

Cheers,
Allan
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Transform matrix for Bullet's rigidbodies

Post by Erwin Coumans »

Have you tried rigidbody->getWorldTransform(); ?

Code: Select all

int indexUpAxis = 1;
btVector3 upAxis  = getRigidBody()->getWorldTransform().getBasis().getColumn(indexUpAxis);
Thanks,
Erwin
Ipredlol
Posts: 8
Joined: Fri Mar 11, 2011 6:23 pm

Re: Transform matrix for Bullet's rigidbodies

Post by Ipredlol »

Yes, I have tried that one as well and I got the same result. Is there any other way to track the up vector?
Ipredlol
Posts: 8
Joined: Fri Mar 11, 2011 6:23 pm

Re: Transform matrix for Bullet's rigidbodies

Post by Ipredlol »

(Bump) Anyone wants to give me a hand? To make it short I'd just like to know exakt how the runtime direction of the ridigbody is pointing at after falling down to an uneven surface with only the gravity applied. I know that getOrigin would return the runtime position in the world but all other "get"-methods' value seem only to change when I apply different forces on them and not base on the nature collision. Thanks!