Please help - Bullet physics local torque (SOLVED)

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Please help - Bullet physics local torque (SOLVED)

Post by cobra »

Hi guys... I have a question. I need to rotate a btRigidBody on it's local axis. I tried very hard to do this for several weeks now but to no avail.

I also tried asking on the bullet forums but they never post there anymore.

The body's btTransform doesn't help either, because I need to only try to affect it's rotation, but it won't if it's blocked or crashing along terrain, or on the ground. Using the btTransform it is not affected by these things like rigid bodies should be.

In short: I need to apply local rotation to a btRigidBody in the form of force, so the object can still be affected by other factors.

Thanks for any help! :)
Last edited by cobra on Sat Jun 20, 2009 4:10 am, edited 1 time in total.
Josiah Hartzell
Image
H4rdStyl3r
Posts: 1
Joined: Mon Jun 08, 2009 7:16 pm
Location: Germany

Re: Please help - Bullet physics local torque

Post by H4rdStyl3r »

Hi, im new here and my english is very bad because i´m from germany.

I had this problem for few days too, but i found a solution.

This works fine for my project:

MainChar->Person.btRotation.setEuler(irr::core:: PI,0,0);
MainChar->Person.btPosition.setRotation(MainChar->Person.btRotation );
MainChar->Person.RigidBody->setWorldTransform(btTransform(MainChar->Person.btRotation,MainChar->Person.RigidBody->getCenterOfMassPosition()));


You need to set Euler Angels to PI, when your character have to look forward.
When he´s look to the left, you have to calculate : PI/2.
When he´s look to the right, you have to set : -PI/2
When he´s look backwards, you have to set : 0.

bt.Position.SetRotation sets the Euler Rotation to Quaternion.
Then, we only have to rotate the Char to the world by
setWorldTransform(...).

I dont know if this the best solution for this problem, but
it works fine for me and i think its good enough :-)

I hope i could help.
Dont laugh, im from germany!
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Well, thanks for your help, but I've tried something very similar to that, and it overrides the collision physics. I want rigid body physics while still being able to apply torque. :)
Josiah Hartzell
Image
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Post by kh_ »

If you can provide a simple demo that shows the problem I'll take look at it.
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Fixed it myself. Thanks for your replies though.
Josiah Hartzell
Image
Post Reply