Sign in to follow this  
Medo Mex

Trouble with rotation

Recommended Posts

Medo Mex    891
I'm trying to rotate RigidBody but having trouble, it's rotating correctly for few seconds and then I see the rotation stop (like it's restricted).

Here is the code I'm using:
[CODE]
btTransform worldTrans;
body->getMotionState()->getWorldTransform(worldTrans);
float x, y, z;
worldTrans.getBasis().getEulerZYX(x, y, z);
// Rotate
y+=0.1f;
worldTrans.getBasis().setEulerZYX(x, y, z);
body->setWorldTransform(worldTrans);
[/CODE]

Share this post


Link to post
Share on other sites
Ashaman73    13715
When using euler for rotation you most likely encounter a [url="http://en.wikipedia.org/wiki/Gimbal_lock"]gimbal lock[/url]. Try to fix two axis and rotate only one or avoid euler.

Share this post


Link to post
Share on other sites
alvaro    21246
You don't want to go through Euler angles at all. Your world transform contains a rotation, which is probably represented as a 3x3 matrix. You seem to want to "add" (the technical term is "compose") an extra rotation of 0.1 radians along some axis. You can do that by creating a 3x3 matrix corresponding to the rotation around the axis and then multiplying the world transform by it.

I have never used Bullet before, so I can't write that in code, but hopefully you can understand it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this