Burkey
23-04-2007 23:44:30
Hi all,
I'm a complete newbie to NxOgre, however given the fact that I need to have a small demo done by next week I'm having to learn pretty quick. Anyway, my problem is as follows: I have a tank body which I want the player to be able to rotate (at a steady rate, as opposed to adding torque) and then move forward in the direction which the tank is facing. I found trying to rotate the tank to be extremely difficult, but settled upon something that worked:
I'm pretty sure theres a better way to do this, but its all I have that works for now. My next question is how can I get the tank to move at a steady rate (again, not like adding forces) along a flat plane in the direction it is facing? I've tried many different things, such as multiplying the X and Z position vector by the X and Z rotation values (obviously my 3D mathematics is rusty!), but none are giving the desired result.
Any help is much appreciated, and if you could make it as clear as possible that would also be helpful This is obviously out of my programming league for now, but unfortunately I do not have a choice.
I'm a complete newbie to NxOgre, however given the fact that I need to have a small demo done by next week I'm having to learn pretty quick. Anyway, my problem is as follows: I have a tank body which I want the player to be able to rotate (at a steady rate, as opposed to adding torque) and then move forward in the direction which the tank is facing. I found trying to rotate the tank to be extremely difficult, but settled upon something that worked:
if(isKeyDown(P1_LEFT)){
//rotate half a degree each frame, since Quaternion(sqrt(0.5), 0, 0, sqrt(0.5)) is 90' rotation around Z axis
quat = p1Tank->getGlobalOrientation() * Ogre::Quaternion(sqrt(0.5), 0, 0, sqrt(0.5/90)/2);
p1Tank->setGlobalOrientation(quat);
}
I'm pretty sure theres a better way to do this, but its all I have that works for now. My next question is how can I get the tank to move at a steady rate (again, not like adding forces) along a flat plane in the direction it is facing? I've tried many different things, such as multiplying the X and Z position vector by the X and Z rotation values (obviously my 3D mathematics is rusty!), but none are giving the desired result.
Any help is much appreciated, and if you could make it as clear as possible that would also be helpful This is obviously out of my programming league for now, but unfortunately I do not have a choice.