Game Development Reference
In-Depth Information
// velocity but in the opposing direction
if(fLocalSpeed > tol)
{
vLocalVelocity.Normalize();
vDragVector = -vLocalVelocity;
// Determine the resultant force on the element.
tmp = 0.5f * rho * fLocalSpeed*fLocalSpeed
* ProjectedArea;
vResultant = vDragVector * _LINEARDRAGCOEFFICIENT * tmp;
// Keep a running total of these resultant forces
Fb += vResultant;
// Calculate the moment about the CG
// and keep a running total of these moments
vtmp = CD^vResultant;
Mb += vtmp;
}
// Calculate the Port & Starboard bow thruster forces:
// Keep a running total of these resultant forces
Fb += PThrust;
// Calculate the moment about the CG of this element's force
// and keep a running total of these moments (total moment)
vtmp = CPT^PThrust;
Mb += vtmp;
// Keep a running total of these resultant forces (total force)
Fb += SThrust;
// Calculate the moment about the CG of this element's force
// and keep a running total of these moments (total moment)
vtmp = CST^SThrust;
Mb += vtmp;
// Now add the propulsion thrust
Fb += Thrust; // no moment since line of action is through CG
// Convert forces from model space to earth space
vForces = VRotate2D(fOrientation, Fb);
vMoment += Mb;
}
The first thing that CalcLoads does is initialize the force and moment variables that will
contain the total of all forces and moments acting on the craft at any instant in time.
Just as we must aggregate forces, we must also aggregate moments. The forces will be