Sign in to follow this  
OnkyDong

ogrekit applyTorque orientation problem

Recommended Posts

OnkyDong    103
Hi,

I am trying to rotate a 3d object in ogrekit by applying applyTorque(). This works fine when the object orientation is not changed. But for example if i rotate my object 90 degrees to the left, only the object itself seems to rotate, the orientation of the object seems to stay the same. This causes the following problem:

If i use applyTorque() while the object is still in it's begin orientation(with up Arrow keyboard button):

http://i.imgur.com/e5f24.png

If i use applyTorque() while the object is rotated 90 degrees clockwise(with up Arrow keyboard button):

http://i.imgur.com/G0CR9.png

I tried to use quaternions to change the orientation, but this doesn't seem to do anything. What am i doing wrong?


Code:

[CODE]
gkVector3 speedd, torque;

gkQuaternion orientation;
orientation = blockObj->getOrientation();//blockObj is the object i'm trying to rotate.

gkVector3 newX;


if(Buttonpress)){
newX = orientation * gkVector3::UNIT_X;
torque -= newX;


}

blockObj->applyTorque(gkVector3(torque.y, torque.x, torque.z));

torque=0;

[/CODE]


I hope my explanation/question is understandable. It's hard to explain.

thanks.

Share this post


Link to post
Share on other sites
Faelenor    396
What do you want to do exactly, rotate around the local X axis or the world X axis? The torque is in [b]world[/b] coordinates, so what you're seeing seems normal to me. Also, what do you mean by "only the object itself seems to rotate, the orientation of the object seems to stay the same", how can the orientation stay the same if the object rotates? It's also not clear if your images were with or without the rotation in your code snippet.

Share this post


Link to post
Share on other sites
OnkyDong    103
[quote name='Faelenor' timestamp='1350670820' post='4991854']
What do you want to do exactly, rotate around the local X axis or the world X axis? The torque is in [b]world[/b] coordinates, so what you're seeing seems normal to me. Also, what do you mean by "only the object itself seems to rotate, the orientation of the object seems to stay the same", how can the orientation stay the same if the object rotates? It's also not clear if your images were with or without the rotation in your code snippet.
[/quote]

Hi thanks for your reply!

What i want is to rotate an object around the local X axis. No matter how it's located in the world, it should always rotate the same way. So for example, i have a camera pointing to the side of an object, i rotate the object around it's z axis, after doing that i rotate the object 90 degrees in the world and rotate the object around it's z axis again. I should see the same output. However, this is not the case right now. I am not sure what i'm doing wrong, and how it should be done. There seems to be very little documentation about this.

Share this post


Link to post
Share on other sites
erwincoumans    281
You need to use the local X axis for example:

[code]
btVector3 torqueAxis = body->getWorldTransform().getBasis().getColumn(0);
[/code]

Here is some modified BasicDemo that might help you, you can use the cursor keys to move and rotate a 'character' capsule:
http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?p=29081#p29081

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