Problem in rotation rigid body

comtihon
Posts: 2
Joined: Sun Feb 26, 2012 7:00 am

Problem in rotation rigid body

Post by comtihon »

Hi there!
I have a problem in rotation a rigid body.
There is a Ogre::sceneNode and a rigidBody.
Ogre object is a sphere and rigidBody is jast a sphere too, created in the same position.

Everything is ok, but now I need to apply Ogre::SceneNode rotation to bullet rigidBody, because without it applyCentralImpulse makes sphere fly in one direction.

I found a solution - make btQuaternion, set rotation of the transform and set the center of mass transform of the rigid body.
But I can't connect Ogre Quaternion and btQuaternion :(

I tried this:

Code: Select all

btTransform; 
tr.setIdentity();
btQuaternion quat;

const btScalar yaw = (sceneNode->getOrientation()).getYaw().valueRadians();
const btScalar pitch = (sceneNode->getOrientation()).getPitch().valueRadians();
const btScalar roll = (sceneNode->getOrientation()).getRoll().valueRadians();

quat.setEuler(yaw,pitch,roll);
tr.setRotation(quat);
rigidBody->setCenterOfMassTransform(tr);
but it works even worse, with this code. Spheres fly in the same direction (as without this code) - and from the same place.
My question - how can I rotate rigid body due to rotation sceneNode?
Any help will be appreciated.
jauthu
Posts: 12
Joined: Tue Feb 28, 2012 7:34 pm

Re: Problem in rotation rigid body

Post by jauthu »

Code: Select all

const &Ogre::Quaternion o_quat = sceneNode->getOrientation();

tr.setRotation(btQuaternion(o_quat.x, o_quat.y, o_quat.z, o_quat.w);
However, I suggest you to look at MotionStates.
comtihon
Posts: 2
Joined: Sun Feb 26, 2012 7:00 am

Re: Problem in rotation rigid body

Post by comtihon »

Niether

Code: Select all

                btTransform tr;
                tr.setIdentity();
                Quaternion o_quat = firstNode->getOrientation();
                tr.setRotation(btQuaternion(o_quat.x, o_quat.y, o_quat.z, o_quat.w));
                secondRigidbody->setCenterOfMassTransform(tr);
nor

Code: Select all

                btTransform tr;
                tr.setIdentity();
                tr.setRotation(firstRigidBody->getOrientation());
                secondRigidbody->setCenterOfMassTransform(tr);
want to work. All I have is spheres, which fly in one direction and from one point.
I use BtOgre now, and it has its own class, based on MotionState

Code: Select all

class RigidBodyState : public btMotionState 
but I don't know, how I can use it in a needed way...