<!-- 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 shows how to move and animate SceneNodes. The basic concept of SceneNodeAnimators is shown as well as manual movement of nodes using the keyboard. We'll demonstrate framerate independent movement, which means moving by an amount dependent on the duration of the last run of the Irrlicht loop.</p>
<p>Example 19.MouseAndJoystick shows how to handle those kinds of input.</p>
<p>As always, 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">#ifdef _MSC_VER</span></div><divclass="line"><spanclass="comment">// We'll also define this to stop MSVC complaining about sprintf().</span></div><divclass="line"><spanclass="preprocessor">#define _CRT_SECURE_NO_WARNINGS</span></div><divclass="line"><spanclass="preprocessor">#pragma comment(lib, "Irrlicht.lib")</span></div><divclass="line"><spanclass="preprocessor">#endif</span></div><divclass="line"></div><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></div><!-- fragment --><p> To receive events like mouse and keyboard input, or GUI events like "the OK
button has been clicked", we need an object which is derived from the irr::IEventReceiver object. There is only one method to override: irr::IEventReceiver::OnEvent(). This method will be called by the engine once when an event happens. What we really want to know is whether a key is being held down, and so we will remember the current state of each key. </p><divclass="fragment"><divclass="line"><spanclass="keyword">class </span>MyEventReceiver : <spanclass="keyword">public</span> IEventReceiver</div><divclass="line">{</div><divclass="line"><spanclass="keyword">public</span>:</div><divclass="line"><spanclass="comment">// This is the one method that we have to implement</span></div><divclass="line"><spanclass="keyword">virtual</span><spanclass="keywordtype">bool</span> OnEvent(<spanclass="keyword">const</span> SEvent& event)</div><divclass="line"> {</div><divclass="line"><spanclass="comment">// Remember whether each key is down or up</span></div><divclass="line"><spanclass="keywordflow">if</span> (event.EventType == irr::EET_KEY_INPUT_EVENT)</div><divclass="line"> KeyIsDown[<spanclass="keyword">event</span>.KeyInput.Key] = <spanclass="keyword">event</span>.KeyInput.PressedDown;</div><divclass="line"></div><divclass="line"><spanclass="keywordflow">return</span><spanclass="keyword">false</span>;</div><divclass="line"> }</div><divclass="line"></div><divclass="line"><spanclass="comment">// This is used to check whether a key is being held down</span></div><divclass="line"><spanclass="keyword">virtual</span><spanclass="keywordtype">bool</span> IsKeyDown(EKEY_CODE keyCode)<spanclass="keyword"> const</span></div><divclass="line"><spanclass="keyword"></span>{</div><divclass="line"><spanclass="keywordflow">return</span> KeyIsDown[keyCode];</div><divclass="line"> }</div><divclass="line"></div><divclass="line"> MyEventReceiver()</div><divclass="line"> {</div><divclass="line"><spanclass="keywordflow">for</span> (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)</div><divclass="line"> KeyIsDown[i] = <spanclass="keyword">false</span>;</div><divclass="line"> }</div><divclass="line"></div><divclass="line"><spanclass="keyword">private</span>:</div><divclass="line"><spanclass="comment">// We use this array to store the current state of each key</span></div><divclass="line"><spanclass="keywordtype">bool</span> KeyIsDown[KEY_KEY_CODES_COUNT];</div><divclass="line">};</div></div><!-- fragment --><p> The event receiver for keeping the pressed keys is ready, the actual responses will be made inside the render loop, right before drawing the scene. So lets just create an irr::IrrlichtDevice and the scene node we want to move. We also create some other additional scene nodes, to show that there are also some different possibilities to move and animate scene nodes. </p><divclass="fragment"><divclass="line"><spanclass="keywordtype">int</span> main()</div><divclass="line">{</div><divclass="line"><spanclass="comment">// ask user for driver</span></div><divclass="line"> video::E_DRIVER_TYPE driverType=driverChoiceConsole();</div><divclass="line"><spanclass="keywordflow">if</span> (driverType==video::EDT_COUNT)</div><divclass="line"><spanclass="keywordflow">return</span> 1;</div><divclass="line"></div><divclass="line"><spanclass="comment">// create device</span></div><divclass="line"> MyEventReceiver receiver;</div><divclass="line"></div><divclass="line"> IrrlichtDevice* device = createDevice(driverType,</div><divclass="line"> core::dimension2d<u32>(640, 480), 16, <spanclass="keyword">false</span>, <spanclass="keyword">false</span>, <spanclass="keyword">false</span>, &receiver);</div><divclass="line"></div><divclass="line"><spanclass="keywordflow">if</span> (device == 0)</div><divclass="line"><spanclass="keywordflow">return</span> 1; <spanclass="comment">// could not create selected driver.</span></div><d