<!-- 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>Written by Colin MacDonald. This tutorial explains the use of the Light Manager of Irrlicht. It enables the use of more dynamic light sources than the actual hardware supports. Further applications of the Light Manager, such as per scene node callbacks, are left out for simplicity of the example. </p><divclass="fragment"><divclass="line"><spanclass="preprocessor">#include <irrlicht.h></span></div><divclass="line"><spanclass="preprocessor">#include "driverChoice.h"</span></div><divclass="line"><spanclass="preprocessor">#include "exampleHelper.h"</span></div><divclass="line"></div><divclass="line"><spanclass="keyword">using namespace </span>irr;</div><divclass="line"><spanclass="keyword">using namespace </span>core;</div><divclass="line"></div><divclass="line"><spanclass="preprocessor">#if defined(_MSC_VER)</span></div><divclass="line"><spanclass="preprocessor">#pragma comment(lib, "Irrlicht.lib")</span></div><divclass="line"><spanclass="preprocessor">#endif // MSC_VER</span></div></div><!-- fragment --><p> Normally, you are limited to 8 dynamic lights per scene: this is a hardware limit. If you want to use more dynamic lights in your scene, then you can register an optional light manager that allows you to to turn lights on and off at specific point during rendering. You are still limited to 8 lights, but the limit is per scene node.</p>
<p>This is completely optional: if you do not register a light manager, then a default distance-based scheme will be used to prioritise hardware lights based on their distance from the active camera.</p>
<p>NO_MANAGEMENT disables the light manager and shows Irrlicht's default light behaviour. The 8 lights nearest to the camera will be turned on, and other lights will be turned off. In this example, this produces a funky looking but incoherent light display.</p>
<p>LIGHTS_NEAREST_NODE shows an implementation that turns on a limited number of lights per mesh scene node. If finds the 3 lights that are nearest to the node being rendered, and turns them on, turning all other lights off. This works, but as it operates on every light for every node, it does not scale well with many lights. The flickering you can see in this demo is due to the lights swapping their relative positions from the cubes (a deliberate demonstration of the limitations of this technique).</p>
<p>LIGHTS_IN_ZONE shows a technique for turning on lights based on a 'zone'. Each empty scene node is considered to be the parent of a zone. When nodes are rendered, they turn off all lights, then find their parent 'zone' and turn on all lights that are inside that zone, i.e. are descendents of it in the scene graph. This produces true 'local' lighting for each cube in this example. You could use a similar technique to locally light all meshes in (e.g.) a room, without the lights spilling out to other rooms.</p>
<p>This light manager is also an event receiver; this is purely for simplicity in this example, it's neither necessary nor recommended for a real application. </p><divclass="fragment"><divclass="line"><spanclass="keyword">class </span>CMyLightManager : <spanclass="keyword">public</span> scene::ILightManager, <spanclass="keyword">public</span> IEventReceiver</div><divclass="line">{</div><divclass="line"><spanclass="keyword">typedef</span><spanclass="keyword">enum</span></div><divclass="line"> {</div><divclass="line"> NO_MANAGEMENT,</div><divclass="line"> LIGHTS_NEAREST_NODE,</div><divclass="line"> LIGHTS_IN_ZONE</div><divclass="line"> }</div><divclass="line"> LightManagementMode;</div><divclass="line"></div><divclass="line"> LightManagementMode Mode;</div><divclass="line"> LightManagementMode RequestedMode;</div><divclass="line"></div><divclass="line"><spanclass="comment">// These data represent the state information that this light manager</span></div><divclass="line"><spanclass="comment">// is interested in.</span></div><divclass="line"> scene::ISceneManager * SceneManager;</div><divclass="line"> core::array<scene::ISceneNode*> * SceneLightList;</div><divclass="line"> scene::E_SCENE_NODE_RENDER_PASS CurrentRenderPass;</div><divclass="line"> scene::ISceneNode * CurrentSceneNode;</div><divclass="line"></div><divclass="line"><spanclass="keyword">public</span>:</div><divclass="line"> CMyLightManager(scene::ISceneManager* sceneManager)</div><divclass="line"> : Mode(NO_MANAGEMENT), RequestedMode(NO_MANAGEMENT),</div><divclass="line"> SceneManager(sceneManager), SceneLightList(0),</div><divclass="line"> CurrentRenderPass(scene::ESNRP_NONE), CurrentSceneNode(0)</div><divclass="line"> { }</div><divclass="line"></div><divclass="line"><spanclass="comment">// The input receiver interface, which just switches light management strategy</span></div><divclass="line"><spanclass="keywordtype">bool</span> OnEvent(<spanclass="keyword">const</span> SEvent & event)</div><divclass="line"> {</div><divclass="line"><spanclass="keywordtype">bool</span> handled = <spanclass="keyword">false</span>;</div><divclass="line"></div><divclass="line"><spanclass="keywordflow">if</span> (event.EventType == irr::EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown)</div><divclass="line"> {</div><divclass="line"> handled = <spanclass="keyword">true</span>;</div><divclass="line"><spanclass="keywordflow">switch</span>(event.KeyInput.Key)</div><divclass="line"> {</div><divclass="line"><spanclass="keywordflow">case</span> irr::KEY_KEY_1:</div><divclass="line"> RequestedMode = NO_MANAGEMENT;</div><divclass="line"><spanclass="keywordflow">break</span>;</div><divclass="line"><spanclass="keywordflow">case</span> irr::KEY_KEY_2:</div><divclass="line"> RequestedMode = LIGHTS_NEAREST_NODE;</div><divclass="line"><spanclass="keywordflow">break</span>;</div><divclass="line"><spanclass="keywordflow">case</span> irr::KEY_KEY_3:</div><divclass="line"> RequestedMode = LIGHTS_IN_ZONE;</div><divclass="line"><spanclass="keywordflow">break</span>;</div><divclass="line"><spanclass="keywordflow">default</span>:</div><divclass="line"> handled = <spanclass="keyword">false</span>;</div><divclass="line"><spanclass="keywordflow">break</span>;</div><divclass="line"> }</div><divclass="line"></div><divclass="line"><spanclass="keywordflow">if</span>(NO_MANAGEMENT == RequestedMode)</div><divclass="line"> SceneManager->setLightManager(0); <spanclass="comment">// Show that it's safe to register the light manager</span></div><divclass="line"><spanclass="keywordflow">else</span></div><divclass="line"> Scene