aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/doc/html/example019.html
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-01-13 19:47:58 +1000
committerDavid Walter Seikel2014-01-13 19:47:58 +1000
commitf9158592e1478b2013afc7041d9ed041cf2d2f4a (patch)
treeb16e389d7988700e21b4c9741044cefa536dcbae /libraries/irrlicht-1.8/doc/html/example019.html
parentLibraries readme updated with change markers and more of the Irrlicht changes. (diff)
downloadSledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.zip
SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.gz
SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.bz2
SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.xz
Update Irrlicht to 1.8.1. Include actual change markers this time. lol
Diffstat (limited to '')
-rw-r--r--libraries/irrlicht-1.8/doc/html/example019.html378
1 files changed, 0 insertions, 378 deletions
diff --git a/libraries/irrlicht-1.8/doc/html/example019.html b/libraries/irrlicht-1.8/doc/html/example019.html
deleted file mode 100644
index e010790..0000000
--- a/libraries/irrlicht-1.8/doc/html/example019.html
+++ /dev/null
@@ -1,378 +0,0 @@
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5<title>Irrlicht 3D Engine: Tutorial 19: Mouse and Joystick</title>
6
7<link href="tabs.css" rel="stylesheet" type="text/css"/>
8<link href="doxygen.css" rel="stylesheet" type="text/css" />
9<link href="navtree.css" rel="stylesheet" type="text/css"/>
10<script type="text/javascript" src="jquery.js"></script>
11<script type="text/javascript" src="resize.js"></script>
12<script type="text/javascript" src="navtree.js"></script>
13<script type="text/javascript">
14 $(document).ready(initResizable);
15</script>
16<link href="search/search.css" rel="stylesheet" type="text/css"/>
17<script type="text/javascript" src="search/search.js"></script>
18<script type="text/javascript">
19 $(document).ready(function() { searchBox.OnSelectItem(0); });
20</script>
21
22</head>
23<body>
24<div id="top"><!-- do not remove this div! -->
25
26
27<div id="titlearea">
28<table cellspacing="0" cellpadding="0">
29 <tbody>
30 <tr style="height: 56px;">
31
32 <td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td>
33
34
35 <td style="padding-left: 0.5em;">
36 <div id="projectname">Irrlicht 3D Engine
37
38 </div>
39
40 </td>
41
42
43
44
45 <td> <div id="MSearchBox" class="MSearchBoxInactive">
46 <span class="left">
47 <img id="MSearchSelect" src="search/mag_sel.png"
48 onmouseover="return searchBox.OnSearchSelectShow()"
49 onmouseout="return searchBox.OnSearchSelectHide()"
50 alt=""/>
51 <input type="text" id="MSearchField" value="Search" accesskey="S"
52 onfocus="searchBox.OnSearchFieldFocus(true)"
53 onblur="searchBox.OnSearchFieldFocus(false)"
54 onkeyup="searchBox.OnSearchFieldChange(event)"/>
55 </span><span class="right">
56 <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
57 </span>
58 </div>
59</td>
60
61
62 </tr>
63 </tbody>
64</table>
65</div>
66
67<!-- Generated by Doxygen 1.7.5.1 -->
68<script type="text/javascript">
69var searchBox = new SearchBox("searchBox", "search",false,'Search');
70</script>
71<script type="text/javascript" src="dynsections.js"></script>
72</div>
73<div id="side-nav" class="ui-resizable side-nav-resizable">
74 <div id="nav-tree">
75 <div id="nav-tree-contents">
76 </div>
77 </div>
78 <div id="splitbar" style="-moz-user-select:none;"
79 class="ui-resizable-handle">
80 </div>
81</div>
82<script type="text/javascript">
83 initNavTree('example019.html','');
84</script>
85<div id="doc-content">
86<div class="header">
87 <div class="headertitle">
88<div class="title">Tutorial 19: Mouse and Joystick </div> </div>
89</div>
90<div class="contents">
91<div class="textblock"><div class="image">
92<img src="019shot.jpg" alt="019shot.jpg"/>
93</div>
94 <p>This tutorial builds on example 04.Movement which showed how to handle keyboard events in Irrlicht. Here we'll handle mouse events and joystick events, if you have a joystick connected and a device that supports joysticks. These are currently Windows, Linux and SDL devices. </p>
95<div class="fragment"><pre class="fragment"><span class="preprocessor">#ifdef _MSC_VER</span>
96<span class="preprocessor"></span><span class="comment">// We&#39;ll define this to stop MSVC complaining about sprintf().</span>
97<span class="preprocessor">#define _CRT_SECURE_NO_WARNINGS</span>
98<span class="preprocessor"></span><span class="preprocessor">#pragma comment(lib, &quot;Irrlicht.lib&quot;)</span>
99<span class="preprocessor"></span><span class="preprocessor">#endif</span>
100<span class="preprocessor"></span>
101<span class="preprocessor">#include &lt;<a class="code" href="irrlicht_8h.html" title="Main header file of the irrlicht, the only file needed to include.">irrlicht.h</a>&gt;</span>
102<span class="preprocessor">#include &quot;<a class="code" href="driver_choice_8h.html">driverChoice.h</a>&quot;</span>
103
104<span class="keyword">using namespace </span>irr;
105</pre></div><p>Just as we did in example 04.Movement, we'll store the latest state of the mouse and the first joystick, updating them as we receive events. </p>
106<div class="fragment"><pre class="fragment"><span class="keyword">class </span>MyEventReceiver : <span class="keyword">public</span> IEventReceiver
107{
108<span class="keyword">public</span>:
109 <span class="comment">// We&#39;ll create a struct to record info on the mouse state</span>
110 <span class="keyword">struct </span>SMouseState
111 {
112 <a class="code" href="namespaceirr_1_1core.html#a3643c2cc7820dd78cd87e73a46b92145">core::position2di</a> Position;
113 <span class="keywordtype">bool</span> LeftButtonDown;
114 SMouseState() : LeftButtonDown(false) { }
115 } MouseState;
116
117 <span class="comment">// This is the one method that we have to implement</span>
118 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent&amp; event)
119 {
120 <span class="comment">// Remember the mouse state</span>
121 <span class="keywordflow">if</span> (event.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0caa230b748674e074aa67f661819ad5891" title="A mouse input event.">irr::EET_MOUSE_INPUT_EVENT</a>)
122 {
123 <span class="keywordflow">switch</span>(event.MouseInput.Event)
124 {
125 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa3f551814f5f38596ea1f3ed7c6c7bad7" title="Left mouse button was pressed down.">EMIE_LMOUSE_PRESSED_DOWN</a>:
126 MouseState.LeftButtonDown = <span class="keyword">true</span>;
127 <span class="keywordflow">break</span>;
128
129 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa26d91b99a8912ff622133f02c60f306a" title="Left mouse button was left up.">EMIE_LMOUSE_LEFT_UP</a>:
130 MouseState.LeftButtonDown = <span class="keyword">false</span>;
131 <span class="keywordflow">break</span>;
132
133 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fae3288f42ed4b8372853c1822bbc0a7a1" title="The mouse cursor changed its position.">EMIE_MOUSE_MOVED</a>:
134 MouseState.Position.X = <span class="keyword">event</span>.MouseInput.X;
135 MouseState.Position.Y = <span class="keyword">event</span>.MouseInput.Y;
136 <span class="keywordflow">break</span>;
137
138 <span class="keywordflow">default</span>:
139 <span class="comment">// We won&#39;t use the wheel</span>
140 <span class="keywordflow">break</span>;
141 }
142 }
143
144 <span class="comment">// The state of each connected joystick is sent to us</span>
145 <span class="comment">// once every run() of the Irrlicht device. Store the</span>
146 <span class="comment">// state of the first joystick, ignoring other joysticks.</span>
147 <span class="comment">// This is currently only supported on Windows and Linux.</span>
148 <span class="keywordflow">if</span> (event.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0cac81558e4607ad260e96ae0f7b889e9a5" title="A joystick (joypad, gamepad) input event.">irr::EET_JOYSTICK_INPUT_EVENT</a>
149 &amp;&amp; event.JoystickEvent.Joystick == 0)
150 {
151 JoystickState = <span class="keyword">event</span>.JoystickEvent;
152 }
153
154 <span class="keywordflow">return</span> <span class="keyword">false</span>;
155 }
156
157 <span class="keyword">const</span> SEvent::SJoystickEvent &amp; GetJoystickState(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
158<span class="keyword"> </span>{
159 <span class="keywordflow">return</span> JoystickState;
160 }
161
162 <span class="keyword">const</span> SMouseState &amp; GetMouseState(<span class="keywordtype">void</span>)<span class="keyword"> const</span>
163<span class="keyword"> </span>{
164 <span class="keywordflow">return</span> MouseState;
165 }
166
167
168 MyEventReceiver()
169 {
170 }
171
172<span class="keyword">private</span>:
173 SEvent::SJoystickEvent JoystickState;
174};
175</pre></div><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 <a class="el" href="classirr_1_1_irrlicht_device.html" title="The Irrlicht device. You can create it with createDevice() or createDeviceEx().">irr::IrrlichtDevice</a> 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>
176<div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> main()
177{
178 <span class="comment">// ask user for driver</span>
179 <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0" title="An enum for all types of drivers the Irrlicht Engine supports.">video::E_DRIVER_TYPE</a> driverType=driverChoiceConsole();
180 <span class="keywordflow">if</span> (driverType==<a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0ae685cada50f8c100403134d932d0414c" title="No driver, just for counting the elements.">video::EDT_COUNT</a>)
181 <span class="keywordflow">return</span> 1;
182
183 <span class="comment">// create device</span>
184 MyEventReceiver receiver;
185
186 IrrlichtDevice* device = <a class="code" href="namespaceirr.html#abaf4d8719cc26b0d30813abf85e47c76" title="Creates an Irrlicht device. The Irrlicht device is the root object for using the engine.">createDevice</a>(driverType,
187 core::dimension2d&lt;u32&gt;(640, 480), 16, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, &amp;receiver);
188
189 <span class="keywordflow">if</span> (device == 0)
190 <span class="keywordflow">return</span> 1; <span class="comment">// could not create selected driver.</span>
191
192
193 core::array&lt;SJoystickInfo&gt; joystickInfo;
194 <span class="keywordflow">if</span>(device-&gt;activateJoysticks(joystickInfo))
195 {
196 std::cout &lt;&lt; <span class="stringliteral">&quot;Joystick support is enabled and &quot;</span> &lt;&lt; joystickInfo.size() &lt;&lt; <span class="stringliteral">&quot; joystick(s) are present.&quot;</span> &lt;&lt; std::endl;
197
198 <span class="keywordflow">for</span>(<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> joystick = 0; joystick &lt; joystickInfo.size(); ++joystick)
199 {
200 std::cout &lt;&lt; <span class="stringliteral">&quot;Joystick &quot;</span> &lt;&lt; joystick &lt;&lt; <span class="stringliteral">&quot;:&quot;</span> &lt;&lt; std::endl;
201 std::cout &lt;&lt; <span class="stringliteral">&quot;\tName: &#39;&quot;</span> &lt;&lt; joystickInfo[joystick].Name.c_str() &lt;&lt; <span class="stringliteral">&quot;&#39;&quot;</span> &lt;&lt; std::endl;
202 std::cout &lt;&lt; <span class="stringliteral">&quot;\tAxes: &quot;</span> &lt;&lt; joystickInfo[joystick].Axes &lt;&lt; std::endl;
203 std::cout &lt;&lt; <span class="stringliteral">&quot;\tButtons: &quot;</span> &lt;&lt; joystickInfo[joystick].Buttons &lt;&lt; std::endl;
204
205 std::cout &lt;&lt; <span class="stringliteral">&quot;\tHat is: &quot;</span>;
206
207 <span class="keywordflow">switch</span>(joystickInfo[joystick].PovHat)
208 {
209 <span class="keywordflow">case</span> SJoystickInfo::POV_HAT_PRESENT:
210 std::cout &lt;&lt; <span class="stringliteral">&quot;present&quot;</span> &lt;&lt; std::endl;
211 <span class="keywordflow">break</span>;
212
213 <span class="keywordflow">case</span> SJoystickInfo::POV_HAT_ABSENT:
214 std::cout &lt;&lt; <span class="stringliteral">&quot;absent&quot;</span> &lt;&lt; std::endl;
215 <span class="keywordflow">break</span>;
216
217 <span class="keywordflow">case</span> SJoystickInfo::POV_HAT_UNKNOWN:
218 <span class="keywordflow">default</span>:
219 std::cout &lt;&lt; <span class="stringliteral">&quot;unknown&quot;</span> &lt;&lt; std::endl;
220 <span class="keywordflow">break</span>;
221 }
222 }
223 }
224 <span class="keywordflow">else</span>
225 {
226 std::cout &lt;&lt; <span class="stringliteral">&quot;Joystick support is not enabled.&quot;</span> &lt;&lt; std::endl;
227 }
228
229 <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> tmp = L<span class="stringliteral">&quot;Irrlicht Joystick Example (&quot;</span>;
230 tmp += joystickInfo.size();
231 tmp += <span class="stringliteral">&quot; joysticks)&quot;</span>;
232 device-&gt;setWindowCaption(tmp.c_str());
233
234 video::IVideoDriver* driver = device-&gt;getVideoDriver();
235 scene::ISceneManager* smgr = device-&gt;getSceneManager();
236</pre></div><p>We'll create an arrow mesh and move it around either with the joystick axis/hat, or make it follow the mouse pointer. </p>
237<div class="fragment"><pre class="fragment"> scene::ISceneNode * node = smgr-&gt;addMeshSceneNode(
238 smgr-&gt;addArrowMesh( <span class="stringliteral">&quot;Arrow&quot;</span>,
239 video::SColor(255, 255, 0, 0),
240 video::SColor(255, 0, 255, 0),
241 16,16,
242 2.f, 1.3f,
243 0.1f, 0.6f
244 )
245 );
246 node-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3acea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">video::EMF_LIGHTING</a>, <span class="keyword">false</span>);
247
248 scene::ICameraSceneNode * camera = smgr-&gt;addCameraSceneNode();
249 camera-&gt;setPosition(<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0, 0, -10));
250
251 <span class="comment">// As in example 04, we&#39;ll use framerate independent movement.</span>
252 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> then = device-&gt;getTimer()-&gt;getTime();
253 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> MOVEMENT_SPEED = 5.f;
254
255 <span class="keywordflow">while</span>(device-&gt;run())
256 {
257 <span class="comment">// Work out a frame delta time.</span>
258 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> now = device-&gt;getTimer()-&gt;getTime();
259 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> frameDeltaTime = (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)(now - then) / 1000.f; <span class="comment">// Time in seconds</span>
260 then = now;
261
262 <span class="keywordtype">bool</span> movedWithJoystick = <span class="keyword">false</span>;
263 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> nodePosition = node-&gt;getPosition();
264
265 <span class="keywordflow">if</span>(joystickInfo.size() &gt; 0)
266 {
267 <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> moveHorizontal = 0.f; <span class="comment">// Range is -1.f for full left to +1.f for full right</span>
268 <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> moveVertical = 0.f; <span class="comment">// -1.f for full down to +1.f for full up.</span>
269
270 <span class="keyword">const</span> SEvent::SJoystickEvent &amp; joystickData = receiver.GetJoystickState();
271
272 <span class="comment">// We receive the full analog range of the axes, and so have to implement our</span>
273 <span class="comment">// own dead zone. This is an empirical value, since some joysticks have more</span>
274 <span class="comment">// jitter or creep around the center point than others. We&#39;ll use 5% of the</span>
275 <span class="comment">// range as the dead zone, but generally you would want to give the user the</span>
276 <span class="comment">// option to change this.</span>
277 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> DEAD_ZONE = 0.05f;
278
279 moveHorizontal =
280 (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)joystickData.Axis[SEvent::SJoystickEvent::AXIS_X] / 32767.f;
281 <span class="keywordflow">if</span>(fabs(moveHorizontal) &lt; DEAD_ZONE)
282 moveHorizontal = 0.f;
283
284 moveVertical =
285 (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)joystickData.Axis[SEvent::SJoystickEvent::AXIS_Y] / -32767.f;
286 <span class="keywordflow">if</span>(fabs(moveVertical) &lt; DEAD_ZONE)
287 moveVertical = 0.f;
288
289 <span class="comment">// POV hat info is only currently supported on Windows, but the value is</span>
290 <span class="comment">// guaranteed to be 65535 if it&#39;s not supported, so we can check its range.</span>
291 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ae9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> povDegrees = joystickData.POV / 100;
292 <span class="keywordflow">if</span>(povDegrees &lt; 360)
293 {
294 <span class="keywordflow">if</span>(povDegrees &gt; 0 &amp;&amp; povDegrees &lt; 180)
295 moveHorizontal = 1.f;
296 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(povDegrees &gt; 180)
297 moveHorizontal = -1.f;
298
299 <span class="keywordflow">if</span>(povDegrees &gt; 90 &amp;&amp; povDegrees &lt; 270)
300 moveVertical = -1.f;
301 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(povDegrees &gt; 270 || povDegrees &lt; 90)
302 moveVertical = +1.f;
303 }
304
305 <span class="keywordflow">if</span>(!<a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a>(moveHorizontal, 0.f) || !<a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a>(moveVertical, 0.f))
306 {
307 nodePosition.X += MOVEMENT_SPEED * frameDeltaTime * moveHorizontal;
308 nodePosition.Y += MOVEMENT_SPEED * frameDeltaTime * moveVertical;
309 movedWithJoystick = <span class="keyword">true</span>;
310 }
311 }
312
313 <span class="comment">// If the arrow node isn&#39;t being moved with the joystick, then have it follow the mouse cursor.</span>
314 <span class="keywordflow">if</span>(!movedWithJoystick)
315 {
316 <span class="comment">// Create a ray through the mouse cursor.</span>
317 <a class="code" href="namespaceirr_1_1core.html#a384a3bb17659466af5521c7f74cfcea7" title="Typedef for an f32 line.">core::line3df</a> ray = smgr-&gt;getSceneCollisionManager()-&gt;getRayFromScreenCoordinates(
318 receiver.GetMouseState().Position, camera);
319
320 <span class="comment">// And intersect the ray with a plane around the node facing towards the camera.</span>
321 <a class="code" href="namespaceirr_1_1core.html#ae7491b7985dcb74b840bfcd9c054b232" title="Typedef for a f32 3d plane.">core::plane3df</a> plane(nodePosition, <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0, 0, -1));
322 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> mousePosition;
323 <span class="keywordflow">if</span>(plane.getIntersectionWithLine(ray.start, ray.getVector(), mousePosition))
324 {
325 <span class="comment">// We now have a mouse position in 3d space; move towards it.</span>
326 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> toMousePosition(mousePosition - nodePosition);
327 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> availableMovement = MOVEMENT_SPEED * frameDeltaTime;
328
329 <span class="keywordflow">if</span>(toMousePosition.getLength() &lt;= availableMovement)
330 nodePosition = mousePosition; <span class="comment">// Jump to the final position</span>
331 <span class="keywordflow">else</span>
332 nodePosition += toMousePosition.normalize() * availableMovement; <span class="comment">// Move towards it</span>
333 }
334 }
335
336 node-&gt;setPosition(nodePosition);
337
338 <span class="comment">// Turn lighting on and off depending on whether the left mouse button is down.</span>
339 node-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3acea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">video::EMF_LIGHTING</a>, receiver.GetMouseState().LeftButtonDown);
340
341 driver-&gt;beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, video::SColor(255,113,113,133));
342 smgr-&gt;drawAll(); <span class="comment">// draw the 3d scene</span>
343 driver-&gt;endScene();
344 }
345</pre></div><p>In the end, delete the Irrlicht device. </p>
346<div class="fragment"><pre class="fragment"> device-&gt;drop();
347
348 <span class="keywordflow">return</span> 0;
349}
350</pre></div> </div></div>
351</div>
352 <div id="nav-path" class="navpath">
353 <ul>
354<!-- window showing the filter options -->
355<div id="MSearchSelectWindow"
356 onmouseover="return searchBox.OnSearchSelectShow()"
357 onmouseout="return searchBox.OnSearchSelectHide()"
358 onkeydown="return searchBox.OnSearchSelectKey(event)">
359<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>
360
361<!-- iframe showing the search results (closed by default) -->
362<div id="MSearchResultsWindow">
363<iframe src="javascript:void(0)" frameborder="0"
364 name="MSearchResults" id="MSearchResults">
365</iframe>
366</div>
367
368
369 <li class="footer">
370<a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht
371Engine</a> Documentation &copy; 2003-2012 by Nikolaus Gebhardt. Generated on Tue Nov 6 2012 11:06:01 for Irrlicht 3D Engine by
372<a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li>
373 </ul>
374 </div>
375
376
377</body>
378</html>