Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Rotation
PostPosted: Tue Aug 07, 2012 10:28 pm 
Offline

Joined: Thu Aug 02, 2012 1:07 pm
Posts: 5
I apologize if this is a bit newbish, but I'm having trouble with my rotation.

I'm integrating bullet into a game engine that uses euler XYZ rotation for it's objects..

What I'm trying to do, is write code that fetches the rotation from a bullet body in the world, to update the display object in the engine. And another bit of code, that can update the rotation of the bullet body, if the display object is changed directly.

Here's what I'm doing to fetch the rotation from the body...
Code:
    btTransform t=_rigidBody->getWorldTransform();   
    btMatrix3x3 m=btMatrix3x3(t.getRotation());
    btScalar rot[3];
    m.getEulerZYX(rot[0], rot[1], rot[2]);
   
    return glm::vec3(glm::degrees(rot[2]), glm::degrees(rot[1]), glm::degrees(rot[0]));


And to change the rotation,
Code:
    btTransform t;
    _motionState->getWorldTransform(t);
    t.setRotation(btQuaternion(glm::radians(z), glm::radians(y), glm::radians(x)));
    _motionState->setWorldTransform(t);


Is there anything obviously wrong with this? What happens, is that when I change the rotation, it seems to "jump", and never quite end up what I'm expecting.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group