Game Development Reference
In-Depth Information
As another convenience, we calculate the air speed, which is simply the magnitude of
the linear velocity vector. This is used to report the air speed in the main window title
bar.
Lastly, the three Euler angles—roll, pitch, and yaw—are extracted from the orientation
quaternion so that they can also be reported in the main window title bar. The function
to use here is MakeEulerAnglesFromQ , which is defined in Appendix C .
Don't forget, StepSimulation must be called once per simulation cycle.
Flight Controls
At this point, the simulation still won't work very well because you have not implemented
the flight controls. The flight controls allow you to interact with the airplane's various
controls surfaces in order to actually fly the plane. We'll use the keyboard as the main
input device for the flight controls. Remember, in a physics-based simulation such as
this one, you don't directly control the motion of the airplane; you control only how
various forces are applied to the airplane, which then, by integration over time, affect
the airplane's motion.
For this simulation, the flight stick is simulated by the arrow keys. The down arrow pulls
back on the stick, raising the nose; the up arrow pushes the stick forward, causing the
nose to dive; the left arrow rolls the plane to the left (port side); and the right arrow
rolls the plane to the right (starboard side). The X key applies left rudder action to cause
the nose of the plane to yaw toward the left, while the C key applies right rudder action
to cause the nose to yaw toward the right. Thrust is controlled by the A and Z keys. The
A key increments the propeller thrust by 100 pounds, and the Z key decrements the
thrust by 100 pounds. The minimum thrust is 0, while the maximum available thrust is
3,000 pounds. The F key activates the landing flaps to increase lift at low speed, while
the D key deactivates the landing flaps.
We control pitch by deflecting the flaps on the aft elevators; for example, to pitch the
nose up, we deflect the aft elevator flaps upward (that is, the trailing edge of the elevator
is raised with respect to the leading edge). We control roll in this simulation by applying
the flaps differentially; for example, to roll right, we deflect the right flap upward and
the left flap downward. Finally, we control yaw by deflecting the vertical tail rudder; for
example, to yaw left, we deflect the trailing edge of the tail rudder toward the left.
We've prepared several functions to handle the flight controls that should be called
whenever the user is pressing one of the flight control keys. There are two functions for
the propeller thrust:
void IncThrust(void)
{
ThrustForce += _DTHRUST;
if(ThrustForce > _MAXTHRUST)
Search Nedrilad ::




Custom Search