Game Development Reference
In-Depth Information
HUDComposite.m_Orientation.GetPosition().Set(PositionWorld.x, PositionWorld.y,
PositionWorld.z);
// Update BillBoard orientation
HUDComposite.UpdateObject3d(Cam);
}
The UpdateHUD() function updates every HUD item that is visible and valid by calling the
UpdateHUDItem() function. (See Listing 6-34.)
Listing 6-34. Updating the HUD
void UpdateHUD(Camera Cam)
{
for (int i = 0; i < MAX_HUDITEMS; i++)
{
if (m_HUDItems[i].IsValid() && m_HUDItems[i].IsVisible())
{
UpdateHUDItem(Cam,m_HUDItems[i]);
}
}
}
The RenderHUD() function renders the m_HUDImage BillBoard object for each HUD item that is visible
and valid. (See Listing 6-35.)
Listing 6-35. Rendering the HUD
void RenderHUD(Camera Cam, PointLight light)
{
for (int i = 0; i < MAX_HUDITEMS; i++)
{
if (m_HUDItems[i].IsValid()&& m_HUDItems[i].IsVisible())
{
HUDItem Item = m_HUDItems[i];
BillBoard HUDComposite = Item.GetHUDImage();
HUDComposite.DrawObject(Cam, light);
}
}
}
Modifying the Object3d Class
Next, we need to add some code to the Object3d class, so that the black portions of our HUD items
are transparent when displayed on the screen with other objects.
The m_Blend variable is set to true if we intend to combine colors from an object being rendered with
colors already in the background and false otherwise.
private boolean m_Blend = false;
 
Search WWH ::




Custom Search