Game Development Reference
In-Depth Information
ticular covered some aspects of this flight simulation; therefore, some of the code to
follow will be familiar to you. In this present chapter, though, we're going to focus on a
few specific functions that implement the flight model. These functions are contained
in the source file Physics.cpp .
The first function we want you to look at is CalcAirplaneMassProperties :
// This model uses a set of eight discrete elements to represent the
// airplane. The elements are described below:
// Element 0: Outboard; port (left) wing section fitted with ailerons
// Element 1: Inboard; port wing section fitted with landing flaps
// Element 2: Inboard; starboard (right) wing section fitted with
landing flaps
// Element 3: Outboard; starboard wing section fitted with ailerons
// Element 4: Port elevator fitted with flap
// Element 5: Starboard elevator fitted with flap
// Element 6: Vertical tail/rudder (no flap; the whole thing rotates)
// Element 7: The fuselage
// This function first sets up each element and then goes on to calculate
// the combined weight, center of gravity, and inertia tensor for the plane.
// Some other properties of each element are also calculated, which you'll
// need when calculating the lift and drag forces on the plane.
void CalcAirplaneMassProperties(void)
float mass;
Vector vMoment;
Vector CG;
int i;
float Ixx, Iyy, Izz, Ixy, Ixz, Iyz;
float in, di;
// Initialize the elements here
// Initially the coordinates of each element are referenced from
// a design coordinates system located at the very tail end of the plane,
// its baseline and center line. Later, these coordinates will be adjusted
// so that each element is referenced to the combined center of gravity of
// the airplane.
Element[0].fMass = 6.56f;
Element[0].vDCoords = Vector(14.5f,12.0f,2.5f);
Element[0].vLocalInertia = Vector(13.92f,10.50f,24.00f);
Element[0].fIncidence = −3.5f;
Element[0].fDihedral = 0.0f;
Element[0].fArea = 31.2f;
Element[0].iFlap = 0;
Element[1].fMass = 7.31f;
Element[1].vDCoords = Vector(14.5f,5.5f,2.5f);
Element[1].vLocalInertia = Vector(21.95f,12.22f,33.67f);
Search Nedrilad ::

Custom Search