Game Development Reference
In-Depth Information
float alpha = (*i)->VGet()->m_Material.GetAlpha();
if (alpha==fOPAQUE)
{
(*i)->VRender(pScene);
}
else if (alpha!=fTRANSPARENT)
{
// The object isn
t totally transparent...
AlphaSceneNode *asn = GCC_NEW AlphaSceneNode;
assert(asn);
asn->m_pNode = *i;
asn->m_Concat = *pScene->GetTopMatrix();
'
Vec4 worldPos(asn->m_Concat.GetPosition());
Mat4x4 fromWorld = pScene->GetCamera()->VGet()->FromWorld();
Vec4 screenPos = fromWorld.Xform(worldPos);
asn->m_ScreenZ = screenPos.z;
pScene->AddAlphaSceneNode(asn);
}
}
(*i)->VRenderChildren(pScene);
}
(*i)->VPostRender(pScene);
++i;
}
return S_OK;
}
Every child scene node in the m_Children vector gets the same processing. First,
VPreRender() is called, which at a minimum pushes the local transform matrix
onto the matrix stack. Since code called in VPreRender() might alter an object ' s
visibility, it is called before the visibility check, which is made with VIsVisible() .
If this method returns false , the scene node isn
t need to be
drawn. If it is visible, the scene node is checked if it is in any way transparent,
because the renderer draws them after everything else. If the scene node is 100 per-
cent opaque, VRender() is called to draw the object. Then, regardless of opacity,
VRenderChildren() is called to render child nodes, followed by VPostRender() .
Transparent objects need to draw after everything else in a special render pass. If they
drew in the regular order, they wouldn
'
t visible and doesn
'
t look right, since some of the background
objects might actually draw after the transparent objects. What needs to happen is
this: All transparent objects get stuck in a special list, and after the scene graph has
'
Search WWH ::




Custom Search