Game Development Reference
In-Depth Information
Modifying the Object3d Class
The GetRadius() function has been added to the Object3d class. This function returns the collision
radius of the object's mesh. (See Listing 5-16.)
Listing 5-16. The GetRadius() Function
float GetRadius()
{
if (m_MeshEx != null)
{
return m_MeshEx.GetRadius();
}
return -1;
}
The GetScaledRadius() function returns the radius of the bounding/collision sphere of the object
scaled by the object's scale factor. (See Listing 5-17.) Thus, an object that has been scaled twice the
size of the original mesh will have a radius twice that of the original mesh.
Listing 5-17. Getting the Scaled Object3d Mesh Radius
float GetScaledRadius()
{
float LargestScaleFactor = 0;
float ScaledRadius = 0;
float RawRadius = GetRadius();
Vector3 ObjectScale = m_Orientation.GetScale();
if (ObjectScale.x > LargestScaleFactor)
{
LargestScaleFactor = ObjectScale.x;
}
if (ObjectScale.y > LargestScaleFactor)
{
LargestScaleFactor = ObjectScale.y;
}
if (ObjectScale.z > LargestScaleFactor)
{
LargestScaleFactor = ObjectScale.z;
}
ScaledRadius = RawRadius * LargestScaleFactor;
return ScaledRadius;
}
 
Search WWH ::




Custom Search