Game Development Reference
In-Depth Information
introduction to the concepts and code behind a scene graph
think of this as a scene
graph with training wheels.
ISceneNode Interface Class
The base class for all nodes in the scene graph is the interface class ISceneNode .
Everything else inherits from that class and extends the class to create every part of
your 3D world, including the simple geometry, meshes, a camera, and so on. Here
'
s
the ISceneNode class:
class ISceneNode
{
public:
virtual const SceneNodeProperties * const VGet() const=0;
virtual void VSetTransform(const Mat4x4 *toWorld,
const Mat4x4 *fromWorld=NULL)=0;
virtual HRESULT VOnUpdate(Scene *pScene, DWORD const elapsedMs)=0;
virtual HRESULT VOnRestore(Scene *pScene)=0;
virtual HRESULT VPreRender(Scene *pScene)=0;
virtual bool VIsVisible(Scene *pScene) const=0;
virtual HRESULT VRender(Scene *pScene)=0;
virtual HRESULT VRenderChildren(Scene *pScene)=0;
virtual HRESULT VPostRender(Scene *pScene)=0;
virtual bool VAddChild(shared_ptr<ISceneNode> kid)=0;
virtual bool VRemoveChild(ActorId id)=0;
virtual HRESULT VOnLostDevice(Scene *pScene)=0;
virtual ~ISceneNode() { };
};
Each node has certain properties that affect how the node will draw, such as its mate-
rial, its geometric extents, what game actor it represents, and so on. We
'
ll cover the
details of the SceneNodeProperties structure in the next section.
As you learned previously, every object in a 3D universe needs a transform matrix.
The matrix encodes the orientation and position of the object in the environment. In
a scene graph, this idea is extended to a hierarchy of objects. For example, imagine a
boat with people on it, and those people have guns in their hands. When the boat
moves, all the people on the boat move with it. Their position and orientation stay
the same relative to the boat. When the people aim their weapons, the bones of their
arms move and the guns move with them.
 
 
Search WWH ::




Custom Search