Help please - Local Axis Rotation

Cobra
Posts: 6
Joined: Wed Apr 29, 2009 11:45 pm

Help please - Local Axis Rotation

Post by Cobra »

Hello all. I have been working on a flight simulator for about 1 year now... and you can see the website at http://www.fighterstw.co.nr, but I need help currently getting my aircraft to rotate on it's local axis.. right now it only rotates according to it's current rotation, so if I turn East-West and apply pitch, it affects the aircraft like it would with a very powerful rudder, but I'd like it to apply pitch according to how it's orientation is, properly controlling the btRigidBody aircraft.


Right now I have this code to always update the aircraft's systems:

Code: Select all

void CPlayerAircraft::updateAllFactors()
{
    body->applyTorque(btVector3(pitch, rudder, roll));
    force = btVector3(0.0f, 0.0f, energy);
    force = force.rotate(btVector3(0.8f, 0.0f, 0.0f), -body->getOrientation().getAngle());

    body->applyForce(force, btVector3(0.0f,0.0f,0.0f));
}

What code would I put in there so it would go in the direction it's pointing?


I tried this code here, that I found in another problem thread:

Code: Select all

btTransform   trans;
btQuaternion   quat;

trans.setOrigin(btVector3(0.0f, 0.0f, 0.0f)); //translation

quat.setEuler(pitch, rudder, roll);//rotation
trans.setRotation(quat);
but I don't know what to do with it because I don't know enough about bullet right now.

Please help, I really want to get the simulator out with a beta soon. I've been working hard on it for a long time. =/