I used the free space flight functions to make a player object. This player object is a airplane. Airplanes in real live level out horizontally along the plane of the earth.
I want my plane to do the same. I was thinking about getting the rotation of the plane, getting its roll and roll it back using the rotation functions.
I can't figure out how to do this. Does anyone know enough matrix/ vector math to help me?
Get turn / pitch / roll of rotation
Re: Get turn / pitch / roll of rotation
There is no way of getting ALL the yaw, roll and pitch values from the single rotation vector of the airplane scene node.
I used a hierarchy of empty scene nodes to control the yaw, roll and pitch of the airplane, like this:
root node (for translation)-> yaw node -> roll node -> pitch node -> airplane
Just do some bookkeeping (and clamping of angles) whenever the airplane yaws, rolls and pitches.
I used a hierarchy of empty scene nodes to control the yaw, roll and pitch of the airplane, like this:
root node (for translation)-> yaw node -> roll node -> pitch node -> airplane
Just do some bookkeeping (and clamping of angles) whenever the airplane yaws, rolls and pitches.
Re: Get turn / pitch / roll of rotation
I found the solution by changing the rotation to a direction vector then taking the cross product of up.
I could then work out if the airship was banking left or right then rotate it accordingly.
I could then work out if the airship was banking left or right then rotate it accordingly.
Code: Select all
core::vector3df rotdir = spacecraft->getRotation().rotationToDirection();
core::vector3df cdiff = rotdir.crossProduct(core::vector3df(0, 0, 1));
if(cdiff.X > 0){
spacecraft->setRotation(pitch(spacecraft->getRotation(), .2));
}
if(cdiff.X < 0){
spacecraft->setRotation(pitch(spacecraft->getRotation(), -.2));
}