aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/doc/html/example017.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/example017.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/example017.html544
1 files changed, 0 insertions, 544 deletions
diff --git a/libraries/irrlicht-1.8/doc/html/example017.html b/libraries/irrlicht-1.8/doc/html/example017.html
deleted file mode 100644
index cdb1ae1..0000000
--- a/libraries/irrlicht-1.8/doc/html/example017.html
+++ /dev/null
@@ -1,544 +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 17: Helloworld mobile</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('example017.html','');
84</script>
85<div id="doc-content">
86<div class="header">
87 <div class="headertitle">
88<div class="title">Tutorial 17: Helloworld mobile </div> </div>
89</div>
90<div class="contents">
91<div class="textblock"><div class="image">
92<img src="017shot.jpg" alt="017shot.jpg"/>
93</div>
94 This example show Hello World for Windows mobile. It compiles on other platform too. The only differences between the original examples are. You need a GUI, because otherwise you can't quit the application. You need a Filesystem, which is relative based to your executable. </p>
95<div class="fragment"><pre class="fragment"><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>
96
97<span class="preprocessor">#if defined ( _IRR_WINDOWS_ )</span>
98<span class="preprocessor"></span><span class="preprocessor"> #include &lt;windows.h&gt;</span>
99<span class="preprocessor">#endif</span>
100<span class="preprocessor"></span>
101<span class="keyword">using namespace </span>irr;
102<span class="keyword">using namespace </span>core;
103<span class="keyword">using namespace </span>scene;
104<span class="keyword">using namespace </span>video;
105<span class="keyword">using namespace </span>io;
106<span class="keyword">using namespace </span>gui;
107
108<span class="preprocessor">#pragma comment(lib, &quot;Irrlicht.lib&quot;)</span>
109<span class="preprocessor"></span>
110<span class="keyword">class </span>EventReceiver_basic : <span class="keyword">public</span> <a class="code" href="classirr_1_1_i_event_receiver.html" title="Interface of an object which can receive events.">IEventReceiver</a>
111{
112<span class="keyword">private</span>:
113 <a class="code" href="classirr_1_1_irrlicht_device.html" title="The Irrlicht device. You can create it with createDevice() or createDeviceEx().">IrrlichtDevice</a> *Device;
114<span class="keyword">public</span>:
115 EventReceiver_basic ( <a class="code" href="classirr_1_1_irrlicht_device.html" title="The Irrlicht device. You can create it with createDevice() or createDeviceEx().">IrrlichtDevice</a> *device ): Device ( device ) {}
116
117 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> <a class="code" href="structirr_1_1_s_event.html" title="SEvents hold information about an event. See irr::IEventReceiver for details on event handling...">SEvent</a>&amp; event)
118 {
119 <span class="keywordflow">if</span> (event.<a class="code" href="structirr_1_1_s_event.html#a8b48c016d5c20a9b0967b1ce0fb3ef15">EventType</a> == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0cae85bb44dd09a29c879d64a05047fc1d2" title="An event of the graphical user interface.">EET_GUI_EVENT</a>)
120 {
121 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <span class="keywordtype">id</span> = <span class="keyword">event</span>.GUIEvent.Caller-&gt;getID();
122
123 <span class="keywordflow">switch</span>(event.<a class="code" href="structirr_1_1_s_event.html#a8efed75c2ae2e39c0f5208bffbe5e009">GUIEvent</a>.EventType)
124 {
125 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" title="A button was clicked.">EGET_BUTTON_CLICKED</a>:
126 <span class="keywordflow">if</span> (<span class="keywordtype">id</span> == 2)
127 {
128 Device-&gt;closeDevice();
129 <span class="keywordflow">return</span> <span class="keyword">true</span>;
130 } <span class="keywordflow">break</span>;
131 }
132 }
133
134 <span class="keywordflow">return</span> <span class="keyword">false</span>;
135 }
136};
137
138<span class="keyword">class </span>CSampleSceneNode : <span class="keyword">public</span> ISceneNode
139{
140 aabbox3d&lt;f32&gt; Box;
141 S3DVertex Vertices[4];
142 SMaterial Material;
143<span class="keyword">public</span>:
144
145 CSampleSceneNode(ISceneNode* parent, ISceneManager* mgr, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <span class="keywordtype">id</span>)
146 : ISceneNode(parent, mgr, id)
147 {
148 Material.Wireframe = <span class="keyword">false</span>;
149 Material.Lighting = <span class="keyword">false</span>;
150
151 Vertices[0] = S3DVertex(0,0,10, 1,1,0, SColor(255,0,255,255), 0, 1);
152 Vertices[1] = S3DVertex(10,0,-10, 1,0,0, SColor(255,255,0,255), 1, 1);
153 Vertices[2] = S3DVertex(0,20,0, 0,1,1, SColor(255,255,255,0), 1, 0);
154 Vertices[3] = S3DVertex(-10,0,-10, 0,0,1, SColor(255,0,255,0), 0, 0);
155 Box.reset(Vertices[0].Pos);
156 <span class="keywordflow">for</span> (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> i=1; i&lt;4; ++i)
157 Box.addInternalPoint(Vertices[i].Pos);
158 }
159 <span class="keyword">virtual</span> <span class="keywordtype">void</span> OnRegisterSceneNode()
160 {
161 <span class="keywordflow">if</span> (IsVisible)
162 SceneManager-&gt;registerNodeForRendering(<span class="keyword">this</span>);
163
164 ISceneNode::OnRegisterSceneNode();
165 }
166
167 <span class="keyword">virtual</span> <span class="keywordtype">void</span> render()
168 {
169 <a class="code" href="namespaceirr.html#ae9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> indices[] = { 0,2,3, 2,1,3, 1,0,3, 2,0,1 };
170 IVideoDriver* driver = SceneManager-&gt;getVideoDriver();
171
172 driver-&gt;setMaterial(Material);
173 driver-&gt;setTransform(<a class="code" href="namespaceirr_1_1video.html#a15b57657a320243be03ae6f66fcff43da843cf42adb3fa9caf61c9e228cf14e85" title="World transformation.">ETS_WORLD</a>, AbsoluteTransformation);
174 driver-&gt;drawIndexedTriangleList(&amp;Vertices[0], 4, &amp;indices[0], 4);
175 }
176
177 <span class="keyword">virtual</span> <span class="keyword">const</span> aabbox3d&lt;f32&gt;&amp; getBoundingBox()<span class="keyword"> const</span>
178<span class="keyword"> </span>{
179 <span class="keywordflow">return</span> Box;
180 }
181
182 <span class="keyword">virtual</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> getMaterialCount()
183 {
184 <span class="keywordflow">return</span> 1;
185 }
186
187 <span class="keyword">virtual</span> SMaterial&amp; getMaterial(<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i)
188 {
189 <span class="keywordflow">return</span> Material;
190 }
191};
192</pre></div><p> ! Startup a Windows Mobile Device </p>
193<div class="fragment"><pre class="fragment">IrrlichtDevice *startup()
194{
195 <span class="comment">// both software and burnings video can be used</span>
196 <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0" title="An enum for all types of drivers the Irrlicht Engine supports.">E_DRIVER_TYPE</a> driverType = <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a1598cd235a1a6bd052e2011b559e8995" title="The Irrlicht Engine Software renderer.">EDT_SOFTWARE</a>; <span class="comment">// EDT_BURNINGSVIDEO;</span>
197
198 <span class="comment">// create device</span>
199 IrrlichtDevice *device = 0;
200
201<span class="preprocessor">#if defined (_IRR_USE_WINDOWS_CE_DEVICE_)</span>
202<span class="preprocessor"></span> <span class="comment">// set to standard mobile fullscreen 240x320</span>
203 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, dimension2d&lt;u32&gt;(240, 320), 16, <span class="keyword">true</span> );
204<span class="preprocessor">#else</span>
205<span class="preprocessor"></span> <span class="comment">// on PC. use window mode</span>
206 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, dimension2d&lt;u32&gt;(240, 320), 16, <span class="keyword">false</span> );
207<span class="preprocessor">#endif </span>
208<span class="preprocessor"></span> <span class="keywordflow">if</span> ( 0 == device )
209 <span class="keywordflow">return</span> 0;
210
211 IVideoDriver* driver = device-&gt;getVideoDriver();
212 ISceneManager* smgr = device-&gt;getSceneManager();
213 IGUIEnvironment* guienv = device-&gt;getGUIEnvironment();
214
215 <span class="comment">// set the filesystem relative to the executable</span>
216<span class="preprocessor">#if defined (_IRR_WINDOWS_)</span>
217<span class="preprocessor"></span> {
218 <span class="keywordtype">wchar_t</span> buf[255];
219 GetModuleFileNameW ( 0, buf, 255 );
220
221 <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a> base = buf;
222 base = base.subString ( 0, base.findLast ( <span class="charliteral">&#39;\\&#39;</span> ) + 1 );
223 device-&gt;getFileSystem()-&gt;addFileArchive ( base );
224 }
225<span class="preprocessor">#endif</span>
226<span class="preprocessor"></span>
227 IGUIStaticText *text = guienv-&gt;addStaticText(L<span class="stringliteral">&quot;FPS: 25&quot;</span>,
228 rect&lt;s32&gt;(140,15,200,30), <span class="keyword">false</span>, <span class="keyword">false</span>, 0, 100 );
229
230 guienv-&gt;addButton(core::rect&lt;int&gt;(200,10,238,30), 0, 2, L<span class="stringliteral">&quot;Quit&quot;</span>);
231
232 <span class="comment">// add irrlicht logo</span>
233 guienv-&gt;addImage(driver-&gt;getTexture(<span class="stringliteral">&quot;../../media/irrlichtlogo3.png&quot;</span>),
234 core::position2d&lt;s32&gt;(0,-2));
235 <span class="keywordflow">return</span> device;
236}
237</pre></div><p> ! </p>
238<div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> run ( IrrlichtDevice *device )
239{
240 <span class="keywordflow">while</span>(device-&gt;run())
241 <span class="keywordflow">if</span> (device-&gt;isWindowActive())
242 {
243 device-&gt;getVideoDriver()-&gt;beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, SColor(0,100,100,100));
244 device-&gt;getSceneManager()-&gt;drawAll();
245 device-&gt;getGUIEnvironment()-&gt;drawAll();
246 device-&gt;getVideoDriver()-&gt;endScene ();
247
248 IGUIElement *stat = device-&gt;getGUIEnvironment()-&gt;
249 getRootGUIElement()-&gt;getElementFromId ( 100 );
250 <span class="keywordflow">if</span> ( stat )
251 {
252 <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> str = L<span class="stringliteral">&quot;FPS: &quot;</span>;
253 str += (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>)device-&gt;getVideoDriver()-&gt;getFPS();
254
255 stat-&gt;setText ( str.c_str() );
256 }
257 }
258
259 device-&gt;drop();
260 <span class="keywordflow">return</span> 0;
261}
262</pre></div><p> ! </p>
263<div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> example_customscenenode()
264{
265 <span class="comment">// create device</span>
266 IrrlichtDevice *device = startup();
267 <span class="keywordflow">if</span> (device == 0)
268 <span class="keywordflow">return</span> 1; <span class="comment">// could not create selected driver.</span>
269
270 <span class="comment">// create engine and camera</span>
271 EventReceiver_basic receiver(device);
272 device-&gt;setEventReceiver(&amp;receiver);
273
274 IVideoDriver* driver = device-&gt;getVideoDriver();
275 ISceneManager* smgr = device-&gt;getSceneManager();
276 IGUIEnvironment* guienv = device-&gt;getGUIEnvironment();
277
278
279 smgr-&gt;addCameraSceneNode(0, <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0,-40,0), <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0,0,0));
280
281 CSampleSceneNode *myNode =
282 <span class="keyword">new</span> CSampleSceneNode(smgr-&gt;getRootSceneNode(), smgr, 666);
283
284 ISceneNodeAnimator* anim =
285 smgr-&gt;createRotationAnimator(<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0.8f, 0, 0.8f));
286
287 <span class="keywordflow">if</span>(anim)
288 {
289 myNode-&gt;addAnimator(anim);
290 anim-&gt;drop();
291 anim = 0; <span class="comment">// As I shouldn&#39;t refer to it again, ensure that I can&#39;t</span>
292 }
293
294 myNode-&gt;drop();
295 myNode = 0; <span class="comment">// As I shouldn&#39;t refer to it again, ensure that I can&#39;t</span>
296
297 <span class="keywordflow">return</span> run ( device );
298}
299
300<span class="keyword">class </span>EventReceiver_terrain : <span class="keyword">public</span> IEventReceiver
301{
302<span class="keyword">public</span>:
303
304 EventReceiver_terrain(IrrlichtDevice *device, scene::ISceneNode* terrain, scene::ISceneNode* skybox, scene::ISceneNode* skydome) :
305 Device ( device ), Terrain(terrain), Skybox(skybox), Skydome(skydome), showBox(true)
306 {
307 Skybox-&gt;setVisible(<span class="keyword">true</span>);
308 Skydome-&gt;setVisible(<span class="keyword">false</span>);
309 }
310
311 <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent&amp; event)
312 {
313 <span class="keywordflow">if</span> (event.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0cae85bb44dd09a29c879d64a05047fc1d2" title="An event of the graphical user interface.">EET_GUI_EVENT</a>)
314 {
315 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <span class="keywordtype">id</span> = <span class="keyword">event</span>.GUIEvent.Caller-&gt;getID();
316
317 <span class="keywordflow">switch</span>(event.GUIEvent.EventType)
318 {
319 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" title="A button was clicked.">EGET_BUTTON_CLICKED</a>:
320 <span class="keywordflow">if</span> (<span class="keywordtype">id</span> == 2)
321 {
322 Device-&gt;closeDevice();
323 <span class="keywordflow">return</span> <span class="keyword">true</span>;
324 } <span class="keywordflow">break</span>;
325 }
326 }
327
328 <span class="comment">// check if user presses the key &#39;W&#39; or &#39;D&#39;</span>
329 <span class="keywordflow">if</span> (event.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0ca6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">irr::EET_KEY_INPUT_EVENT</a> &amp;&amp; !event.KeyInput.PressedDown)
330 {
331 <span class="keywordflow">switch</span> (event.KeyInput.Key)
332 {
333 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae559e3169016a3180c45c2828f391af2">irr::KEY_KEY_W</a>: <span class="comment">// switch wire frame mode</span>
334 Terrain-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3abc620823efed8d6bdbd46c8a0180893a" title="Draw as wireframe or filled triangles? Default: false.">video::EMF_WIREFRAME</a>,
335 !Terrain-&gt;getMaterial(0).Wireframe);
336 Terrain-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a3726bbddc57e6b37b05481b640eefb07" title="Draw as point cloud or filled triangles? Default: false.">video::EMF_POINTCLOUD</a>, <span class="keyword">false</span>);
337 <span class="keywordflow">return</span> <span class="keyword">true</span>;
338 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a52e3c10f6d5c2bc0bd446273879f9519">irr::KEY_KEY_P</a>: <span class="comment">// switch wire frame mode</span>
339 Terrain-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a3726bbddc57e6b37b05481b640eefb07" title="Draw as point cloud or filled triangles? Default: false.">video::EMF_POINTCLOUD</a>,
340 !Terrain-&gt;getMaterial(0).PointCloud);
341 Terrain-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3abc620823efed8d6bdbd46c8a0180893a" title="Draw as wireframe or filled triangles? Default: false.">video::EMF_WIREFRAME</a>, <span class="keyword">false</span>);
342 <span class="keywordflow">return</span> <span class="keyword">true</span>;
343 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ad20e7e220103e611752b90edeb6cbc9d">irr::KEY_KEY_D</a>: <span class="comment">// toggle detail map</span>
344 Terrain-&gt;setMaterialType(
345 Terrain-&gt;getMaterial(0).MaterialType == <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a9bc471b9c18c9e2d20496004d2a2e803" title="Standard solid material.">video::EMT_SOLID</a> ?
346 <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a065af4f8daeb15f81bfe0417a3f231b1" title="Detail mapped material.">video::EMT_DETAIL_MAP</a> : <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a9bc471b9c18c9e2d20496004d2a2e803" title="Standard solid material.">video::EMT_SOLID</a>);
347 <span class="keywordflow">return</span> <span class="keyword">true</span>;
348 <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae52bafc112fc6c52f6b49cea42fa246e">irr::KEY_KEY_S</a>: <span class="comment">// toggle skies</span>
349 showBox=!showBox;
350 Skybox-&gt;setVisible(showBox);
351 Skydome-&gt;setVisible(!showBox);
352 <span class="keywordflow">return</span> <span class="keyword">true</span>;
353 <span class="keywordflow">default</span>:
354 <span class="keywordflow">break</span>;
355 }
356 }
357
358 <span class="keywordflow">return</span> <span class="keyword">false</span>;
359 }
360
361<span class="keyword">private</span>:
362 IrrlichtDevice *Device;
363 scene::ISceneNode* Terrain;
364 scene::ISceneNode* Skybox;
365 scene::ISceneNode* Skydome;
366 <span class="keywordtype">bool</span> showBox;
367};
368</pre></div><p>The start of the main function starts like in most other example. We ask the user for the desired renderer and start it up. This time with the advanced parameter handling. </p>
369<div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> example_terrain()
370{
371 <span class="comment">// create device</span>
372 IrrlichtDevice *device = startup();
373 <span class="keywordflow">if</span> (device == 0)
374 <span class="keywordflow">return</span> 1; <span class="comment">// could not create selected driver.</span>
375</pre></div><p>First, we add standard stuff to the scene: A nice irrlicht engine logo, a small help text, a user controlled camera, and we disable the mouse cursor. </p>
376<div class="fragment"><pre class="fragment"> video::IVideoDriver* driver = device-&gt;getVideoDriver();
377 scene::ISceneManager* smgr = device-&gt;getSceneManager();
378 gui::IGUIEnvironment* env = device-&gt;getGUIEnvironment();
379
380
381 <span class="comment">//set other font</span>
382 <span class="comment">//env-&gt;getSkin()-&gt;setFont(env-&gt;getFont(&quot;../../media/fontlucida.png&quot;));</span>
383
384 <span class="comment">// add some help text</span>
385 env-&gt;<a class="code" href="classirr_1_1gui_1_1_i_g_u_i_environment.html#adb56652b23932a391b08f710a9546ef3" title="Adds a static text.">addStaticText</a>(
386 L<span class="stringliteral">&quot;Press &#39;W&#39; to change wireframe mode\nPress &#39;D&#39; to toggle detail map\nPress &#39;S&#39; to toggle skybox/skydome&quot;</span>,
387 core::rect&lt;s32&gt;(5,250,235,320), <span class="keyword">true</span>, <span class="keyword">true</span>, 0, -1, <span class="keyword">true</span>);
388
389 <span class="comment">// add camera</span>
390 scene::ICameraSceneNode* camera =
391 smgr-&gt;addCameraSceneNodeFPS(0,100.0f,1.2f);
392
393 camera-&gt;setPosition(<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(2700*2,255*2,2600*2));
394 camera-&gt;setTarget(<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(2397*2,343*2,2700*2));
395 camera-&gt;setFarValue(42000.0f);
396
397 <span class="comment">// disable mouse cursor</span>
398 device-&gt;getCursorControl()-&gt;setVisible(<span class="keyword">false</span>);
399</pre></div><p>Here comes the terrain renderer scene node: We add it just like any other scene node to the scene using ISceneManager::addTerrainSceneNode(). The only parameter we use is a file name to the heightmap we use. A heightmap is simply a gray scale texture. The terrain renderer loads it and creates the 3D terrain from it.</p>
400<p>To make the terrain look more big, we change the scale factor of it to (40, 4.4, 40). Because we don't have any dynamic lights in the scene, we switch off the lighting, and we set the file terrain-texture.jpg as texture for the terrain and detailmap3.jpg as second texture, called detail map. At last, we set the scale values for the texture: The first texture will be repeated only one time over the whole terrain, and the second one (detail map) 20 times. </p>
401<div class="fragment"><pre class="fragment"> <span class="comment">// add terrain scene node</span>
402 scene::ITerrainSceneNode* terrain = smgr-&gt;addTerrainSceneNode(
403 <span class="stringliteral">&quot;../../media/terrain-heightmap.bmp&quot;</span>,
404 0, <span class="comment">// parent node</span>
405 -1, <span class="comment">// node id</span>
406 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0.f, 0.f, 0.f), <span class="comment">// position</span>
407 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0.f, 0.f, 0.f), <span class="comment">// rotation</span>
408 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(40.f, 4.4f, 40.f), <span class="comment">// scale</span>
409 video::SColor ( 255, 255, 255, 255 ), <span class="comment">// vertexColor</span>
410 5, <span class="comment">// maxLOD</span>
411 <a class="code" href="namespaceirr_1_1scene.html#a6de1eb2d024f82b5b1af499d61523044abe94d6195f435b8e08a38269e63af72e" title="patch size of 17, at most, use 5 levels of detail with this patch size.">scene::ETPS_17</a>, <span class="comment">// patchSize</span>
412 4 <span class="comment">// smoothFactor</span>
413 );
414
415 <span class="keywordflow">if</span> ( terrain )
416 {
417 terrain-&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>);
418
419 terrain-&gt;setMaterialTexture(0,
420 driver-&gt;getTexture(<span class="stringliteral">&quot;../../media/terrain-texture.jpg&quot;</span>));
421 terrain-&gt;setMaterialTexture(1,
422 driver-&gt;getTexture(<span class="stringliteral">&quot;../../media/detailmap3.jpg&quot;</span>));
423
424 terrain-&gt;setMaterialType(<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a065af4f8daeb15f81bfe0417a3f231b1" title="Detail mapped material.">video::EMT_DETAIL_MAP</a>);
425
426 terrain-&gt;scaleTexture(1.0f, 20.0f);
427 <span class="comment">//terrain-&gt;setDebugDataVisible ( true );</span>
428</pre></div><p>To be able to do collision with the terrain, we create a triangle selector. If you want to know what triangle selectors do, just take a look into the collision tutorial. The terrain triangle selector works together with the terrain. To demonstrate this, we create a collision response animator and attach it to the camera, so that the camera will not be able to fly through the terrain. </p>
429<div class="fragment"><pre class="fragment"> <span class="comment">// create triangle selector for the terrain </span>
430 scene::ITriangleSelector* selector
431 = smgr-&gt;createTerrainTriangleSelector(terrain, 0);
432 terrain-&gt;setTriangleSelector(selector);
433
434 <span class="comment">// create collision response animator and attach it to the camera</span>
435 scene::ISceneNodeAnimator* anim = smgr-&gt;createCollisionResponseAnimator(
436 selector, camera, <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(60,100,60),
437 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0,0,0),
438 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0,50,0));
439 selector-&gt;drop();
440 camera-&gt;addAnimator(anim);
441 anim-&gt;drop();
442</pre></div><p> If you need access to the terrain data you can also do this directly via the following code fragment. </p>
443<div class="fragment"><pre class="fragment"> scene::CDynamicMeshBuffer* buffer = <span class="keyword">new</span> scene::CDynamicMeshBuffer(<a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca7b5127a706ee33eb4385d702da007016" title="Vertex with two texture coordinates, video::S3DVertex2TCoords.">video::EVT_2TCOORDS</a>, <a class="code" href="namespaceirr_1_1video.html#af152a1edea2579f0517e0049525acb55a1c79610ea1191e124887efa16626f299">video::EIT_16BIT</a>);
444 terrain-&gt;getMeshBufferForLOD(*buffer, 0);
445 video::S3DVertex2TCoords* data = (video::S3DVertex2TCoords*)buffer-&gt;getVertexBuffer().getData();
446 <span class="comment">// Work on data or get the IndexBuffer with a similar call.</span>
447 buffer-&gt;drop(); <span class="comment">// When done drop the buffer again.</span>
448 }
449</pre></div><p>To make the user be able to switch between normal and wireframe mode, we create an instance of the event receiver from above and let Irrlicht know about it. In addition, we add the skybox which we already used in lots of Irrlicht examples and a skydome, which is shown mutually exclusive with the skybox by pressing 'S'. </p>
450<div class="fragment"><pre class="fragment"> <span class="comment">// create skybox and skydome</span>
451 driver-&gt;setTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#acaf6f7414534f7d62bff18c5bf11876fa288b302e9d4faaba80c7796c7bc1682c">video::ETCF_CREATE_MIP_MAPS</a>, <span class="keyword">false</span>);
452
453 scene::ISceneNode* skybox=smgr-&gt;addSkyBoxSceneNode(
454 driver-&gt;getTexture(<span class="stringliteral">&quot;../../media/irrlicht2_up.jpg&quot;</span>),
455 driver-&gt;getTexture(<span class="stringliteral">&quot;../../media/irrlicht2_dn.jpg&quot;</span>),
456 driver-&gt;getTexture(<span class="stringliteral">&quot;../../media/irrlicht2_lf.jpg&quot;</span>),
457 driver-&gt;getTexture(<span class="stringliteral">&quot;../../media/irrlicht2_rt.jpg&quot;</span>),
458 driver-&gt;getTexture(<span class="stringliteral">&quot;../../media/irrlicht2_ft.jpg&quot;</span>),
459 driver-&gt;getTexture(<span class="stringliteral">&quot;../../media/irrlicht2_bk.jpg&quot;</span>));
460 scene::ISceneNode* skydome=smgr-&gt;addSkyDomeSceneNode(driver-&gt;getTexture(<span class="stringliteral">&quot;../../media/skydome.jpg&quot;</span>),16,8,0.95f,2.0f);
461
462 driver-&gt;setTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#acaf6f7414534f7d62bff18c5bf11876fa288b302e9d4faaba80c7796c7bc1682c">video::ETCF_CREATE_MIP_MAPS</a>, <span class="keyword">true</span>);
463
464 <span class="comment">// create event receiver</span>
465 EventReceiver_terrain receiver( device, terrain, skybox, skydome);
466 device-&gt;setEventReceiver(&amp;receiver);
467
468 <span class="keywordflow">return</span> run ( device );
469}
470</pre></div><div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> example_helloworld()
471{
472 <span class="comment">// create device</span>
473 IrrlichtDevice *device = startup();
474 <span class="keywordflow">if</span> (device == 0)
475 <span class="keywordflow">return</span> 1; <span class="comment">// could not create selected driver.</span>
476
477 IVideoDriver* driver = device-&gt;getVideoDriver();
478 ISceneManager* smgr = device-&gt;getSceneManager();
479 IGUIEnvironment* guienv = device-&gt;getGUIEnvironment();
480
481 IAnimatedMesh* mesh = smgr-&gt;getMesh(<span class="stringliteral">&quot;../../media/sydney.md2&quot;</span>);
482 <span class="keywordflow">if</span> (!mesh)
483 {
484 device-&gt;drop();
485 <span class="keywordflow">return</span> 1;
486 }
487 IAnimatedMeshSceneNode* node = smgr-&gt;addAnimatedMeshSceneNode( mesh );
488</pre></div><p>To let the mesh look a little bit nicer, we change its material. We disable lighting because we do not have a dynamic light in here, and the mesh would be totally black otherwise. Then we set the frame loop, such that the predefined STAND animation is used. And last, we apply a texture to the mesh. Without it the mesh would be drawn using only a color. </p>
489<div class="fragment"><pre class="fragment"> <span class="keywordflow">if</span> (node)
490 {
491 node-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3acea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">EMF_LIGHTING</a>, <span class="keyword">false</span>);
492 node-&gt;setMD2Animation(<a class="code" href="namespaceirr_1_1scene.html#a08d4a84966e1d2886d0d57e4acbb4f19a35893ae58423c41dace23ad13e262e2c">scene::EMAT_STAND</a>);
493 node-&gt;setMaterialTexture( 0, driver-&gt;getTexture(<span class="stringliteral">&quot;../../media/sydney.bmp&quot;</span>) );
494 }
495</pre></div><p>To look at the mesh, we place a camera into 3d space at the position (0, 30, -40). The camera looks from there to (0,5,0), which is approximately the place where our md2 model is. </p>
496<div class="fragment"><pre class="fragment"> smgr-&gt;addCameraSceneNode(0, <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0,30,-40), <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0,5,0));
497
498 EventReceiver_basic receiver(device);
499 device-&gt;setEventReceiver(&amp;receiver);
500
501 <span class="keywordflow">return</span> run ( device );
502
503}
504
505<span class="preprocessor">#if defined (_IRR_USE_WINDOWS_CE_DEVICE_)</span>
506<span class="preprocessor"></span><span class="preprocessor"> #pragma comment(linker, &quot;/subsystem:WINDOWSCE /ENTRY:main&quot;) </span>
507<span class="preprocessor"></span><span class="preprocessor">#elif defined (_IRR_WINDOWS_)</span>
508<span class="preprocessor"></span><span class="preprocessor"> #pragma comment(linker, &quot;/subsystem:windows /ENTRY:mainCRTStartup&quot;)</span>
509<span class="preprocessor">#endif</span>
510</pre></div><div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> main()
511{
512 example_helloworld ();
513 example_customscenenode();
514 <span class="comment">//example_terrain();</span>
515}
516</pre></div> </div></div>
517</div>
518 <div id="nav-path" class="navpath">
519 <ul>
520<!-- window showing the filter options -->
521<div id="MSearchSelectWindow"
522 onmouseover="return searchBox.OnSearchSelectShow()"
523 onmouseout="return searchBox.OnSearchSelectHide()"
524 onkeydown="return searchBox.OnSearchSelectKey(event)">
525<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>
526
527<!-- iframe showing the search results (closed by default) -->
528<div id="MSearchResultsWindow">
529<iframe src="javascript:void(0)" frameborder="0"
530 name="MSearchResults" id="MSearchResults">
531</iframe>
532</div>
533
534
535 <li class="footer">
536<a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht
537Engine</a> Documentation &copy; 2003-2012 by Nikolaus Gebhardt. Generated on Tue Nov 6 2012 11:06:01 for Irrlicht 3D Engine by
538<a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li>
539 </ul>
540 </div>
541
542
543</body>
544</html>