Game Development Reference
In-Depth Information
m_MassLocations[MassLocationIndex + 2]= Mass.m_Orientation.GetPosition().z;
MassLocationIndex = MassLocationIndex + 3;
// Add the Radius of the Spotlight for the Mass
m_MassEffectiveRadius[MassesIndex] = Mass.GetObjectPhysics().GetMassEffectiveRadius();
// Add the SpotLight Color for the mass
Color = Mass.GetGridSpotLightColor();
m_MassSpotLightColor[SpotLightLocationIndex] = Color[0];
m_MassSpotLightColor[SpotLightLocationIndex + 1] = Color[1];
m_MassSpotLightColor[SpotLightLocationIndex + 2] = Color[2];
SpotLightLocationIndex = SpotLightLocationIndex + 3;
MassesIndex++;
m_NumberMasses++;
return result;
}
The AddMasses() function shown in Listing 5-29 adds in iNumberMasses objects from the Masses
array to the gravity grid. This is basically the same function as in Listing 5-28, except that instead of
reading in the data for one object, multiple objects are read in from an array.
Listing 5-29. Adding Multiple Masses from an Array
boolean AddMasses(int iNumberMasses, Object3d[] Masses)
{
boolean result = true;
int MassLocationIndex = MassesIndex * 3; // each mass has 3 components x,y,z
int SpotLightLocationIndex = MassesIndex * 3; // each spotlight has 3 components r,g,b
float[] Color;
for (int i = 0; i < iNumberMasses; i++)
{
if (m_NumberMasses >= MAX_MASSES)
{
return false;
}
// Add Value of the Mass
m_MassValues[MassesIndex] = Masses[i].GetObjectPhysics().GetMass();
// Add the x,y,z location of the Mass
m_MassLocations[MassLocationIndex] = Masses[i].m_Orientation.GetPosition().x;
m_MassLocations[MassLocationIndex + 1]= Masses[i].m_Orientation.GetPosition().y;
m_MassLocations[MassLocationIndex + 2]= Masses[i].m_Orientation.GetPosition().z;
MassLocationIndex = MassLocationIndex + 3;
// Add the Radius of the Spotlight for the Mass
m_MassEffectiveRadius[MassesIndex] = Masses[i].GetObjectPhysics().
GetMassEffectiveRadius();
Search WWH ::




Custom Search