Game Development Reference
In-Depth Information
'
everything checks out fine, the camera
s SetViewTransform() method is called
to send the camera position and orientation into the rendering device. The Light-
Manager::CalcLighting() method runs through the list of lights and calculates
data that will be sent to shaders during this frame. Then the rendering methods of
the root node are called, which in turn propagate throughout the entire scene
graph. Finally, the scene graph calls the RenderAlphaPass() method to handle
any scene nodes that were found to have some translucency during this render.
The OnRestore() method is so trivial I think I can trust you to figure it out. There
is one trick, though. The camera node must clearly be attached to the scene graph as
a child of a scene node, in addition to having it as a member of the scene graph. If it
isn
t, it would never have its critical virtual functions called properly.
Lastly, OnUpdate() is what separates rendering from updating. Updating is gener-
ally called as fast as possible, where the render pass might be delayed to keep a par-
ticular frame rate. Rendering is usually much more expensive than updating, too.
You
'
ll also notice that the update pass is called with a delta time in milliseconds,
where the render is called with no parameters. That in itself is telling since there
shouldn
'
t be any time-variant code running inside the render pass, such as anima-
tions. Keep that stuff inside the update pass, and you
'
ll find your entire graphics sys-
tem will be flexible enough to run on pokey hardware and still have the chops to
blaze on the fast machines.
'
void Scene::PushAndSetMatrix(const Mat4x4 &toWorld)
{
m_MatrixStack->Push();
m_MatrixStack->MultMatrixLocal(&toWorld);
DXUTGetD3DDevice()->SetTransform(D3DTS_WORLD, m_MatrixStack->GetTop());
}
void Scene::PopMatrix()
{
m_MatrixStack->Pop();
DXUTGetD3DDevice()->SetTransform(D3DTS_WORLD, m_MatrixStack->GetTop());
}
const Mat4x4 *Scene::GetTopMatrix()
{
return static_cast<const Mat4x4 *>(m_MatrixStack->GetTop());
}
Remember matrix concatenation? I don
'
t think I
'
ve gone two paragraphs without men-
tioning it. There
s a useful thing in both Direct3D and OpenGL called a matrix stack,
anditisusedtokeeptrackofmatricesinahierarchy.Thecallto VPreRender()
'
 
Search WWH ::




Custom Search