Game Development Reference
In-Depth Information
// Calculate the air speed:
Bodies[i].fSpeed = Bodies[i].vVelocity.Magnitude();
// Get the Euler angles for our information
Vector u;
u = MakeEulerAnglesFromQ(Bodies[i].qOrientation);
Bodies[i].vEulerAngles.x = u.x; // roll
Bodies[i].vEulerAngles.y = u.y; // pitch
Bodies[i].vEulerAngles.z = u.z; // yaw
}
// Handle Collisions :
check = CheckForCollisions();
if(check == COLLISION)
ResolveCollisions();
}
Calculating Forces
The first function call made by StepSimulation is a call to CalcObjectForces , which
is responsible for computing all the forces on each ball except collision forces. This is
the same approach used in previous examples. The entire CalcObjectForces source
code is included here:
void CalcObjectForces(void)
{
Vector Fb, Mb;
Vector vDragVector;
Vector vAngularDragVector;
int i, j;
Vector ContactForce;
Vector pt;
int check = NOCOLLISION;
pCollision pCollisionData;
Vector FrictionForce;
Vector fDir;
double speed;
Vector FRn, FRt;
for(i=0; i<NUMBODIES; i++)
{
// Reset forces and moments:
Bodies[i].vForces.x = 0.0f;
Bodies[i].vForces.y = 0.0f;
Bodies[i].vForces.z = 0.0f;
Bodies[i].vMoments.x = 0.0f;
Bodies[i].vMoments.y = 0.0f;
Bodies[i].vMoments.z = 0.0f;
Search Nedrilad ::




Custom Search