Game Development Reference
In-Depth Information
Airplane.fSpeed = 60.0f;
// Set initial angular velocity
Airplane.vAngularVelocity.x = 0.0f;
Airplane.vAngularVelocity.y = 0.0f;
Airplane.vAngularVelocity.z = 0.0f;
// Set the initial thrust, forces, and moments
Airplane.vForces.x = 500.0f;
Airplane.vForces.y = 0.0f;
Airplane.vForces.z = 0.0f;
ThrustForce = 500.0;
Airplane.vMoments.x = 0.0f;
Airplane.vMoments.y = 0.0f;
Airplane.vMoments.z = 0.0f;
// Zero the velocity in body space coordinates
Airplane.vVelocityBody.x = 0.0f;
Airplane.vVelocityBody.y = 0.0f;
Airplane.vVelocityBody.z = 0.0f;
// Set these to false at first,
// you can control later using the keyboard
Stalling = false;
Flaps = false;
// Set the initial orientation
iRoll = 0.0f;
iPitch = 0.0f;
iYaw = 0.0f;
Airplane.qOrientation = MakeQFromEulerAngles(iRoll, iPitch, iYaw);
// Now go ahead and calculate the plane's mass properties
This function sets the initial location, speed, attitude, and thrust for the airplane and
goes on to calculate its mass properties by making a call to CalcAirplaneMassProper
ties . You'll see much more of this function in Chapter 15 , so we won't show the whole
thing here. We do want to point out a portion of the code that is distinctly different from
what you do in a 2D simulation, and that's the calculation of the moment of inertia
void CalcAirplaneMassProperties(void)
// Now calculate the moments and products of inertia for the
// combined elements.
Search Nedrilad ::

Custom Search