<!-- Wanted to avoid copying .css to each folder, so copied default .css from doxyen in here, kicked out most stuff we don't need for examples and modified some a little bit.
Target was having a single html in each example folder which is created from the main.cpp files and needs no files besides some images below media folder.
<p>This tutorial is more advanced than the previous ones. If you are currently just playing around with the Irrlicht engine, you may want to look at other examples first. This tutorials shows how to create a custom scene node and how to use it in the engine. A custom scene node is needed if you want to implement a render technique the Irrlicht Engine currently does not support. For example, you can write an indoor portal based renderer or an advanced terrain scene node with it. By creating custom scene nodes, you can easily extend the Irrlicht Engine and adapt it to your needs.</p>
<p>I will keep the tutorial simple: Keep everything very short and everything in one .cpp file. This is the style which will also be used in most of the following tutorials.</p>
<p>To start, I include the header files, use the irr namespace, and tell the linker to link with the .lib file. </p><divclass="fragment"><divclass="line"><spanclass="preprocessor">#include <irrlicht.h></span></div><divclass="line"><spanclass="preprocessor">#include "driverChoice.h"</span></div><divclass="line"></div><divclass="line"><spanclass="keyword">using namespace </span>irr;</div><divclass="line"></div><divclass="line"><spanclass="preprocessor">#ifdef _MSC_VER</span></div><divclass="line"><spanclass="preprocessor">#pragma comment(lib, "Irrlicht.lib")</span></div><divclass="line"><spanclass="preprocessor">#endif</span></div></div><!-- fragment --><p> Here comes the more sophisticated part of this tutorial: The class of our very own custom scene node. To keep it simple, our scene node will not be an indoor portal renderer nor a terrain scene node, but a simple tetrahedron, a 3D object consisting of 4 connected vertices, which only draws itself and does nothing more. Note that this scenario does not require a custom scene node in Irrlicht. Instead one would create a mesh from the geometry and pass it to a irr::scene::IMeshSceneNode. This example just illustrates creation of a custom scene node in a simple setting.</p>
<p>To allow our scene node to be inserted into the Irrlicht Engine scene, the class we create needs to be derived from the irr::scene::ISceneNode class and has to override some methods. </p><divclass="fragment"><divclass="line"><spanclass="keyword">class </span>CSampleSceneNode : <spanclass="keyword">public</span> scene::ISceneNode</div><divclass="line">{</div></div><!-- fragment --><p> First, we declare some member variables: The bounding box, 4 vertices, and the material of the tetrahedron. </p><divclass="fragment"><divclass="line"> core::aabbox3d<f32> Box;</div><divclass="line"> video::S3DVertex Vertices[4];</div><divclass="line"> video::SMaterial Material;</div><divclass="line"></div><divclass="line"><spanclass="keyword">public</span>:</div></div><!-- fragment --><p> The parameters of the constructor specify the parent of the scene node, a pointer to the scene manager, and an id of the scene node. In the constructor we call the parent class' constructor, set some properties of the material, and create the 4 vertices of the tetrahedron. </p><divclass="fragment"><divclass="line">CSampleSceneNode(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 <spanclass="keywordtype">id</span>)</div><divclass="line"> : scene::ISceneNode(parent, mgr, id)</div><divclass="line">{</div><divclass="line"> Material.Wireframe = <spanclass="keyword">false</span>;</div><divclass="line"> Material.Lighting = <spanclass="keyword">false</span>;</div><divclass="line"></div><divclass="line"> Vertices[0] = video::S3DVertex(0,0,10, 1,1,0,</div><divclass="line"> video::SColor(255,0,255,255), 0, 1);</div><divclass="line"> Vertices[1] = video::S3DVertex(10,0,-10, 1,0,0,</div><divclass="line"> video::SColor(255,255,0,255), 1, 1);</div><divclass="line"> Vertices[2] = video::S3DVertex(0,20,0, 0,1,1,</div><divclass="line"> video::SColor(255,255,255,0), 1, 0);</div><divclass="line"> Vertices[3] = video::S3DVertex(-10,0,-10, 0,0,1,</div><divclass="line"> video::SColor(255,0,255,0), 0, 0);</div></div><!-- fragment --><p> The Irrlicht Engine needs to know the bounding box of a scene node. It will use it for automatic culling and other things. Hence, we need to create a bounding box from the 4 vertices we use. If you do not want the engine to use the box for automatic culling, and/or don't want to create the box, you could also call irr::scene::ISceneNode::setAutomaticCulling() with irr::scene::EAC_OFF. </p><divclass="fragment"><divclass="line"> Box.reset(Vertices[0].Pos);</div><divclass="line"><spanclass="keywordflow">for</span> (s32 i=1; i<4; ++i)</div><divclass="line"> Box.addInternalPoint(Vertices[i].Pos);</div><divclass="line">}</div></div><!-- fragment --><p> Before it is drawn, the irr::scene::ISceneNode::OnRegisterSceneNode() method of every scene node in the scene is called by the scene manager. If the scene node wishes to draw itself, it may register itself in the scene manager to be drawn. This is necessary to tell the scene manager when it should call irr::scene::ISceneNode::render(). For example, normal scene nodes render their content one after another, while stencil buffer shadows would like to be drawn after all other scene nodes. And camera or light scene nodes need to be rendered before all other scene nodes (if at all). So here we simply register the scene node to render normally. If we would like to let it be rendered like cameras or light, we would have to call SceneManager->registerNodeForRendering(this, SNRT_LIGHT_AND_CAMERA); After this, we call the actual irr::scene::ISceneNode::OnRegisterSceneNode() method of the base class, which lets all the child scene nodes of this node register themselves. </p><divclass="fragment"><divclass="line"><spanclass="keyword">virtual</span><spanclass="keywordtype">void</span> OnRegisterSceneNode()</div><divclass="line">{</div><divclass="line"><spanclass="keywordflow">if</span> (IsVisible)</div><divclass="line"> SceneManager->registerNodeForRe