Game Development Reference
In-Depth Information
Special Scene Graph Nodes
The SceneNode class doesn
t draw anything at all. It just performs a lot of
Direct3D11 and scene graph homework. We need some classes that inherit from
SceneNode to construct an interesting scene. Here are the ones I
'
'
ll show you:
n class RootNode : Manages children as separate render passes for different
kinds of scene nodes.
n class CameraNode : Manages the camera and view frustum culling.
n class LightNode : Creates a directional diffuse light in your scene.
n class SkyNode : Creates a sky that appears to be infinitely far away.
n class D3DShaderMeshNode11 : Wraps a Direct3D SDKMESH file.
Implementing Separate Render Passes
Different render passes help optimize rendering or create interesting full-screen
effects. Drawing things in the right order can do wonders for performance. Fill rate
performance, or the lack of it, means that the more times you completely overdraw a
pixel, the more valuable time you
ve wasted. Figuring out when you can safely ignore
a pixel, or all the pixels in a polygon, or all the polygons in a mesh can get pretty
complicated. One obvious way to do this is not to draw any pixels that are
completely behind other pixels by using a depth test and generally drawing big fore-
ground stuff first and small background stuff later. Draw the sky last, but draw it
before your transparent objects, since it could cover the entire screen. One way to
do this is by creating a special scene node that manages all this, and that scene
node happens to be the root node of the entire scene graph:
'
class RootNode : public SceneNode
{
public:
RootNode();
virtual bool VAddChild(shared_ptr<ISceneNode> kid);
virtual HRESULT VRenderChildren(Scene *pScene);
virtual bool VIsVisible(Scene *pScene) const { return true; }
};
RootNode::RootNode()
: SceneNode(optional_empty(),
Root
, RenderPass_0, &Mat4x4::g_Identity)
{
m_Children.reserve(RenderPass_Last);
shared_ptr<SceneNode> staticGroup(
 
 
 
Search WWH ::




Custom Search