Game Development Reference
In-Depth Information
void item::Draw(const render::camera& camera)
{
if ( !m_visible )
return;
if ( m_texture != nullptr )
{
m_quad.Draw(m_localTransform * m_worldTransform, camera.View(), camera.Projection(), m_texture);
}
for ( auto& child : m_children )
{
child->Draw(camera);
}
}
If an item is not visible, none of its children should be visible either, so we return early.
Otherwise we will draw the item's quad, applying the item's local transform to its com-
puted world transform. Recall that the world transform was applied from the parent, but
each item still contains its own local transform, now is the time to apply it.
Some interesting things we can do with this hierarchy, first, if we set the quads to be view
aligned, they will always face towards the camera, no matter what, this is generally good
if you want to see the quads that have gone behind. Another option is to rotate them us-
ing their local space position as a direction vector, this makes the quad always face away
from the direction it is coming from. In the case of our circle this will give us an almost
cylindrical type shape, depending on how many items the menus has.
The best part about a system such as this is how we can achieve such seemingly complex
animation of multiple objects by simply animating one variable, the angle of the root item,
which is a lot easier than tracking angles for each menu item.
Search WWH ::




Custom Search