Jump to content

  • Log In with Google      Sign In   
  • Create Account


ogrekit applyTorque orientation problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 OnkyDong   Members   -  Reputation: 103

Like
0Likes
Like

Posted 19 October 2012 - 11:39 AM

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.

Sponsor:

#2 Faelenor   Members   -  Reputation: 389

Like
0Likes
Like

Posted 19 October 2012 - 12:20 PM

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.

#3 OnkyDong   Members   -  Reputation: 103

Like
0Likes
Like

Posted 19 October 2012 - 01:44 PM

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.

#4 erwincoumans   Members   -  Reputation: 272

Like
0Likes
Like

Posted 26 October 2012 - 11:35 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS