Game Development Reference
In-Depth Information
m_DrawOrder[index + 1] = (short)VertexIndexBelowCurrent;
index = index + 2;
}
}
// Create Mesh
m_LineMeshGrid = new MeshEx(m_CoordsPerVertex, m_MeshVerticesDataPosOffset, m_
MeshVerticesUVOffset, m_MeshVerticesNormalOffset,m_Vertices,m_DrawOrder);
m_LineMeshGrid.SetMeshType(MeshType.Lines);
// Clear Value of Masses
ClearMasses();
}
The function ClearMasses() does the actual job of clearing the grid of all the masses from the
m_MassValues array. Clearing all the masses from the grid has to be done for each frame update,
because a mass such as an enemy object can be destroyed and thus will need to be removed from
the gravity grid. For every frame update, only masses that are currently active will be added to the
gravity grid. (See Listing 5-25.)
Listing 5-25. Clearing the Grid
void ClearMasses()
{
for (int i = 0; i < MAX_MASSES; i++)
{
m_MassValues[i] = 0;
}
}
The ResetGrid() function clears the grid of all masses and all other related variables that are needed
to keep track of the number of masses. (See Listing 5-26.)
Listing 5-26. Resetting the Grid
void ResetGrid()
{
// Clears Grid of All Masses
MassesIndex = 0;
m_NumberMasses = 0;
ClearMasses();
}
The code in Listing 5-27 provides access to key grid data, including the following:
1.
The maximum number of masses allowed on the gravity grid
2.
The current number of masses on the gravity grid
3.
The x boundaries of the gravity grid
4.
The z boundaries of the gravity grid
 
Search WWH ::




Custom Search