ogrekit applyTorque orientation problem

Started by
2 comments, last by erwincoumans 11 years, 5 months ago
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:


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;




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

thanks.
Advertisement
What do you want to do exactly, rotate around the local X axis or the world X axis? The torque is in world 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.

What do you want to do exactly, rotate around the local X axis or the world X axis? The torque is in world 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.


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.
You need to use the local X axis for example:


btVector3 torqueAxis = body->getWorldTransform().getBasis().getColumn(0);


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

This topic is closed to new replies.

Advertisement