nord
17-07-2008 20:21:47
Hi.
I am trying to move my nxogre vehicle towards a destination point on the terrain. To do this, I have abstracted two functions for the vehicle as, AIvehicle->drive(Ogre::Real torquevalue) and AIvehicle->turn(bool direction) (turns the front wheels 1.5 degree on each frame).
I have got the current direction of the vehicle as :
I am trying to move my nxogre vehicle towards a destination point on the terrain. To do this, I have abstracted two functions for the vehicle as, AIvehicle->drive(Ogre::Real torquevalue) and AIvehicle->turn(bool direction) (turns the front wheels 1.5 degree on each frame).
I have got the current direction of the vehicle as :
//get orient. quaternion of the car
Quaternion orientation = AIvehicle->getBody()->getGlobalOrientation();
//consider only rotation relative to y axis(reduce the scene to 2D)
Ogre::Radian orientationRadian = orientation.getYaw(true);
//right now I know my car's orientation angle as radian
//create a unit vector that will convert the radian into a vector
Vector3 *currentDirection = new Vector3(Math::Sin(orientationRadian),0,Math::Cos(orientationRadian));
//prints the normalized direction_vector of the car
printf("CurrentDirection\nX : %f\nZ : %f\n",currentDirection->x,currentDirection->z);