Game Development Reference
In-Depth Information
/////////////////////////////////////////////////////
// Initialize the other balls
for(i=1; i<NUMBODIES; i++)
{
// Set initial position
if(i==1)
{
Bodies[i].vPosition.x = 0.0;
Bodies[i].vPosition.y = -(BALLDIAMETER/2.0f+0.25*BALLDIAMETER);
Bodies[i].vPosition.z = BALLDIAMETER/2.0f;
} else if(i==2) {
Bodies[i].vPosition.x = 0.0;
Bodies[i].vPosition.y = BALLDIAMETER/2.0f+0.25*BALLDIAMETER;
Bodies[i].vPosition.z = BALLDIAMETER/2.0f;
} else {
Bodies[i].vPosition.x = -BALLDIAMETER;
Bodies[i].vPosition.y = 0.0f;
Bodies[i].vPosition.z = BALLDIAMETER/2.0f;
}
// Set initial velocity
Bodies[i].vVelocity.x = 0.0f;
Bodies[i].vVelocity.y = 0.0f;
Bodies[i].vVelocity.z = 0.0f;
Bodies[i].fSpeed = 0.0f;
// Set initial angular velocity
Bodies[i].vAngularVelocity.x = 0.0f;
Bodies[i].vAngularVelocity.y = 0.0f;
Bodies[i].vAngularVelocity.z = 0.0f;
Bodies[i].vAngularAcceleration.x = 0.0f;
Bodies[i].vAngularAcceleration.y = 0.0f;
Bodies[i].vAngularAcceleration.z = 0.0f;
Bodies[i].vAcceleration.x = 0.0f;
Bodies[i].vAcceleration.y = 0.0f;
Bodies[i].vAcceleration.z = 0.0f;
// Set the initial 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;
// Zero the velocity in body space coordinates