Rotating btCompound object in bullet 2.77

Naruto
Posts: 13
Joined: Sun Mar 13, 2011 2:11 am

Rotating btCompound object in bullet 2.77

Post by Naruto »

Hi,

I am using bullet 2.77 and openGL. Please tell me how can I apply rotation to compound objects (btCompoundShape)?
I am creating a jack with 3 arms and the arms are parallel to x, y, z angular system.
Here is the code I am using;

btCompoundShape* colShape = new btCompoundShape;
btTransform localTransform;
localTransform.setIdentity();
btCollisionShape* boxShape1 = new btBoxShape(btVector3(3,.5,.5));
colShape->addChildShape(localTransform,boxShape1);
btCollisionShape* boxShape2 = new btBoxShape(btVector3(3,.5,.5));
btQuaternion orn2(SIMD_HALF_PI,0,0);
localTransform.setRotation(orn2);
colShape->addChildShape(localTransform,boxShape2);
btCollisionShape* boxShape3= new btBoxShape(btVector3(3,.5,.5));
btQuaternion orn3(0,0,SIMD_HALF_PI);
localTransform.setRotation(orn3);
colShape->addChildShape(localTransform,boxShape3);
m_collisionShapes.push_back(colShape);

Now I want to rotate complete colShape compound object so that it is at the particular position I want.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Rotating btCompound object in bullet 2.77

Post by Flix »

btQuaternion has another ctr that takes an angle in radians and a btVector3 which represent the axis of rotation.
Try that instead of using the one that takes the 3 scalars.

Code: Select all

btQuaternion q(btVector3(0,1,0),SIMD_HALF_PI);
If you need degrees, use something like: btRadians(90) to convert them in radians.

Hope it helps.
Naruto
Posts: 13
Joined: Sun Mar 13, 2011 2:11 am

Re: Rotating btCompound object in bullet 2.77

Post by Naruto »

Thanx a lot for the reply