Game Development Reference
In-Depth Information
pushes a new matrix on the matrix stack and then concatenates it with what was
already there, creating a new matrix. Once that is done, the new matrix is used to
draw anything sent into the render pipeline.
This is a little confusing, and I won
'
t ask you to visualize it because when I tried I got
a pounding headache
s the gist of it. The matrix that exists at the top of
the stack is either the identity matrix or the result of all the concatenated matrices
from the hierarchy in your scene nodes in the scene graph. Before you traverse
child nodes, the parent
but here
'
'
s current matrix is pushed on the stack. Each child concate-
nates its matrix with the parent on the top of the stack. When all the children are
done, the stack is popped, and the parent
s matrix is restored.
As you can see, this is quite efficient and extremely flexible for implementing hierar-
chical objects. The push/pop methods are called by the SceneNode::VPreRender()
and SceneNode::VPostRender() , respectively. The GetTopMatrix() method
gives you read-only access to the top matrix, which is useful for storing off the
world matrix of a scene node during the render pass.
Here
'
'
s how the Scene class implements FindActor() :
shared_ptr<ISceneNode> Scene::FindActor(ActorId id)
{
SceneActorMap::iterator i = m_ActorMap.find(id);
if (i==m_ActorMap.end())
{
return shared_ptr<ISceneNode>();
}
return (*i).second;
}
This is pretty standard STL <map> usage, and since we have defined the ActorId to
be unique, we don
'
t have to worry about finding multiple actors for a particular scene
node.
The last method of the Scene class is RenderAlphaPass . This method is called
after the normal rendering is done, so all the transparent scene nodes will draw on
top of everything else. Here
'
s basically what happens in this method:
n The current world transform is saved off.
n Z-sorting is disabled.
n Alpha blending is turned on.
n The alpha nodes in the alpha list are sorted.
 
Search WWH ::




Custom Search