It is very convenient to represent a light source as a part of a 3D scene. When we write "a 3D scene", we mean a scene graph. In order to attach a light source to a scene graph, we need a special node for it. Here is the clLightNode
class that holds a pointer to iLight
with all light properties:
class clLightNode: public clSceneNode { public: clLightNode() {} clPtr<iLight> GetLight() const { return m_Light; } void SetLight( const clPtr<iLight>& L ) { m_Light = L; } virtual void AcceptTraverser( iSceneTraverser* Traverser ) override; clPtr<iLight> m_Light; };
The AcceptTraverser()
method is similar to those in clGeometryNode
and clMaterialNode
. But this time, we will call the PreAcceptLightNode()
and PostAcceptLightNode()
methods of iSceneTraverser
:
void clLightNode::AcceptTraverser( iSceneTraverser* Traverser ) { Traverser->PreAcceptSceneNode( this ); Traverser->PreAcceptLightNode( this ); AcceptChildren...