aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8.1/doc/html/example016.html
blob: 52b98934e48361ed41e50530e3391171349b9df2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Irrlicht 3D Engine: Tutorial 16: Quake3 Map Shader Support</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Irrlicht 3D Engine
   
   </div>
   
  </td>
  
  
  
   
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
   
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="dynsections.js"></script>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('example016.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">Tutorial 16: Quake3 Map Shader Support </div>  </div>
</div>
<div class="contents">
<div class="textblock"><div class="image">
<img src="016shot.jpg" alt="016shot.jpg"/>
</div>
 <p>This Tutorial shows how to load a Quake 3 map into the engine, create a SceneNode for optimizing the speed of rendering and how to create a user controlled camera.</p>
<p>Lets start like the HelloWorld example: We include the irrlicht header files and an additional file to be able to ask the user for a driver type using the console. </p>
<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>
<span class="preprocessor">#include &quot;<a class="code" href="driver_choice_8h.html">driverChoice.h</a>&quot;</span>
</pre></div><p>define which Quake3 Level should be loaded </p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#define IRRLICHT_QUAKE3_ARENA</span>
<span class="preprocessor"></span><span class="comment">//#define ORIGINAL_QUAKE3_ARENA</span>
<span class="comment">//#define CUSTOM_QUAKE3_ARENA</span>
<span class="comment">//#define SHOW_SHADER_NAME</span>

<span class="preprocessor">#ifdef ORIGINAL_QUAKE3_ARENA</span>
<span class="preprocessor"></span><span class="preprocessor">    #define QUAKE3_STORAGE_FORMAT   addFolderFileArchive</span>
<span class="preprocessor"></span><span class="preprocessor">    #define QUAKE3_STORAGE_1        &quot;/baseq3/&quot;</span>
<span class="preprocessor"></span><span class="preprocessor">    #ifdef CUSTOM_QUAKE3_ARENA</span>
<span class="preprocessor"></span><span class="preprocessor">        #define QUAKE3_STORAGE_2    &quot;/cf/&quot;</span>
<span class="preprocessor"></span><span class="preprocessor">        #define QUAKE3_MAP_NAME     &quot;maps/cf.bsp&quot;</span>
<span class="preprocessor"></span><span class="preprocessor">    #else</span>
<span class="preprocessor"></span><span class="preprocessor">        #define QUAKE3_MAP_NAME         &quot;maps/q3dm8.bsp&quot;</span>
<span class="preprocessor"></span><span class="preprocessor">    #endif</span>
<span class="preprocessor"></span><span class="preprocessor">#endif</span>
<span class="preprocessor"></span>
<span class="preprocessor">#ifdef IRRLICHT_QUAKE3_ARENA</span>
<span class="preprocessor"></span><span class="preprocessor">    #define QUAKE3_STORAGE_FORMAT   addFileArchive</span>
<span class="preprocessor"></span><span class="preprocessor">    #define QUAKE3_STORAGE_1    &quot;../../media/map-20kdm2.pk3&quot;</span>
<span class="preprocessor"></span><span class="preprocessor">    #define QUAKE3_MAP_NAME         &quot;maps/20kdm2.bsp&quot;</span>
<span class="preprocessor"></span><span class="preprocessor">#endif</span>
<span class="preprocessor"></span>
<span class="keyword">using namespace </span>irr;
<span class="keyword">using namespace </span>scene;
</pre></div><p>Again, to be able to use the Irrlicht.DLL file, we need to link with the Irrlicht.lib. We could set this option in the project settings, but to make it easy, we use a pragma comment lib: </p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#ifdef _MSC_VER</span>
<span class="preprocessor"></span><span class="preprocessor">#pragma comment(lib, &quot;Irrlicht.lib&quot;)</span>
<span class="preprocessor">#endif</span>
</pre></div><p>A class to produce a series of screenshots </p>
<div class="fragment"><pre class="fragment"><span class="keyword">class </span>CScreenShotFactory : <span class="keyword">public</span> IEventReceiver
{
<span class="keyword">public</span>:

    CScreenShotFactory( IrrlichtDevice *device, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> * templateName, ISceneNode* node )
        : Device(device), Number(0), FilenameTemplate(templateName), Node(node)
    {
        FilenameTemplate.replace ( <span class="charliteral">&#39;/&#39;</span>, <span class="charliteral">&#39;_&#39;</span> );
        FilenameTemplate.replace ( <span class="charliteral">&#39;\\&#39;</span>, <span class="charliteral">&#39;_&#39;</span> );
    }

    <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent&amp; event)
    {
        <span class="comment">// check if user presses the key F9</span>
        <span class="keywordflow">if</span> ((event.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0ca6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">EET_KEY_INPUT_EVENT</a>) &amp;&amp;
                event.KeyInput.PressedDown)
        {
            <span class="keywordflow">if</span> (event.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a5dfbe4e0c7c8d9d810717fc1331fd3c9">KEY_F9</a>)
            {
                video::IImage* image = Device-&gt;getVideoDriver()-&gt;createScreenShot();
                <span class="keywordflow">if</span> (image)
                {
                    <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[256];
                    snprintf(buf, 256, <span class="stringliteral">&quot;%s_shot%04d.jpg&quot;</span>,
                            FilenameTemplate.c_str(),
                            ++Number);
                    Device-&gt;getVideoDriver()-&gt;writeImageToFile(image, buf, 85 );
                    image-&gt;drop();
                }
            }
            <span class="keywordflow">else</span>
            <span class="keywordflow">if</span> (event.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a5111be01fea6429912b3e497b2a85d73">KEY_F8</a>)
            {
                <span class="keywordflow">if</span> (Node-&gt;isDebugDataVisible())
                    Node-&gt;setDebugDataVisible(<a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea25111b15f03bee9a99498737286916dc" title="No Debug Data ( Default )">scene::EDS_OFF</a>);
                <span class="keywordflow">else</span>
                    Node-&gt;setDebugDataVisible(<a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea80f38e42f1b8cf169e83f44092367bfe" title="EDS_BBOX | EDS_BBOX_BUFFERS.">scene::EDS_BBOX_ALL</a>);
            }
        }
        <span class="keywordflow">return</span> <span class="keyword">false</span>;
    }

<span class="keyword">private</span>:
    IrrlichtDevice *Device;
    <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> Number;
    <a class="code" href="namespaceirr_1_1core.html#ade1071a878633f2f6d8a75c5d11fec19" title="Typedef for character strings.">core::stringc</a> FilenameTemplate;
    ISceneNode* Node;
};
</pre></div><p>Ok, lets start. </p>
<div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> <a class="code" href="_irr_compile_config_8h.html#a3f9bf2240c47d3f99b86f83f9123aa9d">IRRCALLCONV</a> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
{
</pre></div><p>Like in the HelloWorld example, we create an IrrlichtDevice with <a class="el" href="namespaceirr.html#abaf4d8719cc26b0d30813abf85e47c76" title="Creates an Irrlicht device. The Irrlicht device is the root object for using the engine.">createDevice()</a>. The difference now is that we ask the user to select which hardware accelerated driver to use. The Software device would be too slow to draw a huge Quake 3 map, but just for the fun of it, we make this decision possible too. </p>
<div class="fragment"><pre class="fragment">    <span class="comment">// ask user for driver</span>
    <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();
    <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>)
        <span class="keywordflow">return</span> 1;

    <span class="comment">// create device and exit if creation failed</span>
    <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#ad2e562e3219072e2f7fc7c2bba0ef0cb" title="Typedef for an unsigned integer dimension.">core::dimension2du</a> videoDim(800,600);

    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, videoDim, 32, <span class="keyword">false</span> );

    <span class="keywordflow">if</span> (device == 0)
        <span class="keywordflow">return</span> 1; <span class="comment">// could not create selected driver.</span>

    <span class="keyword">const</span> <span class="keywordtype">char</span>* mapname=0;
    <span class="keywordflow">if</span> (argc&gt;2)
        mapname = argv[2];
    <span class="keywordflow">else</span>
        mapname = QUAKE3_MAP_NAME;
</pre></div><p>Get a pointer to the video driver and the SceneManager so that we do not always have to write device-&gt;getVideoDriver() and device-&gt;getSceneManager(). </p>
<div class="fragment"><pre class="fragment">    video::IVideoDriver* driver = device-&gt;getVideoDriver();
    scene::ISceneManager* smgr = device-&gt;getSceneManager();
    gui::IGUIEnvironment* gui = device-&gt;<a class="code" href="classirr_1_1scene_1_1_i_scene_manager.html#ad887536e9cc41d0670364f9f0a0f4510" title="Get the active GUIEnvironment.">getGUIEnvironment</a>();

    device-&gt;getFileSystem()-&gt;addFileArchive(<span class="stringliteral">&quot;../../media/&quot;</span>);
</pre></div><p>To display the Quake 3 map, we first need to load it. Quake 3 maps are packed into .pk3 files, which are nothing other than .zip files. So we add the .pk3 file to our FileSystem. After it was added, we are able to read from the files in that archive as they would directly be stored on disk. </p>
<div class="fragment"><pre class="fragment">    <span class="keywordflow">if</span> (argc&gt;2)
        device-&gt;getFileSystem()-&gt;QUAKE3_STORAGE_FORMAT(argv[1]);
    <span class="keywordflow">else</span>
        device-&gt;getFileSystem()-&gt;QUAKE3_STORAGE_FORMAT(QUAKE3_STORAGE_1);
<span class="preprocessor">#ifdef QUAKE3_STORAGE_2</span>
<span class="preprocessor"></span>    device-&gt;getFileSystem()-&gt;QUAKE3_STORAGE_FORMAT(QUAKE3_STORAGE_2);
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span>
    <span class="comment">// Quake3 Shader controls Z-Writing</span>
    smgr-&gt;getParameters()-&gt;setAttribute(<a class="code" href="namespaceirr_1_1scene.html#ab585d23bc2a3d02cd368d8bfd0b1414a" title="Name of the parameter for changing how Irrlicht handles the ZWrite flag for transparent (blending) ma...">scene::ALLOW_ZWRITE_ON_TRANSPARENT</a>, <span class="keyword">true</span>);
</pre></div><p>Now we can load the mesh by calling getMesh(). We get a pointer returned to a IAnimatedMesh. As you know, Quake 3 maps are not really animated, they are only a huge chunk of static geometry with some materials attached. Hence the IAnimated mesh consists of only one frame, so we get the "first frame" of the "animation", which is our quake level and create an Octree scene node with it, using addOctreeSceneNode(). The Octree optimizes the scene a little bit, trying to draw only geometry which is currently visible. An alternative to the Octree would be a AnimatedMeshSceneNode, which would draw always the complete geometry of the mesh, without optimization. Try it out: Write addAnimatedMeshSceneNode instead of addOctreeSceneNode and compare the primitives drawn by the video driver. (There is a getPrimitiveCountDrawed() method in the IVideoDriver class). Note that this optimization with the Octree is only useful when drawing huge meshes consisting of lots of geometry. </p>
<div class="fragment"><pre class="fragment">    scene::IQ3LevelMesh* <span class="keyword">const</span> mesh =
        (scene::IQ3LevelMesh*) smgr-&gt;getMesh(mapname);
</pre></div><p>add the geometry mesh to the Scene ( polygon &amp; patches ) The Geometry mesh is optimised for faster drawing </p>
<div class="fragment"><pre class="fragment">    scene::ISceneNode* node = 0;
    <span class="keywordflow">if</span> (mesh)
    {
        scene::IMesh * <span class="keyword">const</span> geometry = mesh-&gt;getMesh(<a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a44a1a489a965cc9a0ad2c235bbb7bf33a10a5968f2ec9c929bfbca721780a7ef6">quake3::E_Q3_MESH_GEOMETRY</a>);
        node = smgr-&gt;addOctreeSceneNode(geometry, 0, -1, 4096);
    }

    <span class="comment">// create an event receiver for making screenshots</span>
    CScreenShotFactory screenshotFactory(device, mapname, node);
    device-&gt;setEventReceiver(&amp;screenshotFactory);
</pre></div><p>now construct SceneNodes for each Shader The Objects are stored in the quake mesh scene::E_Q3_MESH_ITEMS and the Shader ID is stored in the MaterialParameters mostly dark looking skulls and moving lava.. or green flashing tubes? </p>
<div class="fragment"><pre class="fragment">    <span class="keywordflow">if</span> ( mesh )
    {
        <span class="comment">// the additional mesh can be quite huge and is unoptimized</span>
        <span class="keyword">const</span> scene::IMesh * <span class="keyword">const</span> additional_mesh = mesh-&gt;getMesh(<a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a44a1a489a965cc9a0ad2c235bbb7bf33a15b1dd0b29d69900d070346d61f44319">quake3::E_Q3_MESH_ITEMS</a>);

<span class="preprocessor">#ifdef SHOW_SHADER_NAME</span>
<span class="preprocessor"></span>        gui::IGUIFont *font = device-&gt;getGUIEnvironment()-&gt;getFont(<span class="stringliteral">&quot;../../media/fontlucida.png&quot;</span>);
        <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> count = 0;
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span>
        <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i = 0; i!= additional_mesh-&gt;getMeshBufferCount(); ++i )
        {
            <span class="keyword">const</span> IMeshBuffer* meshBuffer = additional_mesh-&gt;getMeshBuffer(i);
            <span class="keyword">const</span> video::SMaterial&amp; material = meshBuffer-&gt;getMaterial();

            <span class="comment">// The ShaderIndex is stored in the material parameter</span>
            <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> shaderIndex = (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) material.MaterialTypeParam2;

            <span class="comment">// the meshbuffer can be rendered without additional support, or it has no shader</span>
            <span class="keyword">const</span> quake3::IShader *shader = mesh-&gt;getShader(shaderIndex);
            <span class="keywordflow">if</span> (0 == shader)
            {
                <span class="keywordflow">continue</span>;
            }

            <span class="comment">// we can dump the shader to the console in its</span>
            <span class="comment">// original but already parsed layout in a pretty</span>
            <span class="comment">// printers way.. commented out, because the console</span>
            <span class="comment">// would be full...</span>
            <span class="comment">// quake3::dumpShader ( Shader );</span>

            node = smgr-&gt;addQuake3SceneNode(meshBuffer, shader);

<span class="preprocessor">#ifdef SHOW_SHADER_NAME</span>
<span class="preprocessor"></span>            count += 1;
            <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> name( node-&gt;getName() );
            node = smgr-&gt;addBillboardTextSceneNode(
                    font, name.c_str(), node,
                    core::dimension2d&lt;f32&gt;(80.0f, 8.0f),
                    <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0, 10, 0));
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span>        }
    }
</pre></div><p>Now we only need a Camera to look at the Quake 3 map. And we want to create a user controlled camera. There are some different cameras available in the Irrlicht engine. For example the Maya Camera which can be controlled comparable to the camera in Maya: Rotate with left mouse button pressed, Zoom with both buttons pressed, translate with right mouse button pressed. This could be created with addCameraSceneNodeMaya(). But for this example, we want to create a camera which behaves like the ones in first person shooter games (FPS). </p>
<div class="fragment"><pre class="fragment">    scene::ICameraSceneNode* camera = smgr-&gt;addCameraSceneNodeFPS();
</pre></div><p>so we need a good starting Position in the level. we can ask the Quake3 Loader for all entities with class_name "info_player_deathmatch" we choose a random launch </p>
<div class="fragment"><pre class="fragment">    <span class="keywordflow">if</span> ( mesh )
    {
        <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a312f35a37540d810fcb14b75fd449c9e">quake3::tQ3EntityList</a> &amp;entityList = mesh-&gt;getEntityList();

        <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a93ed78aeb11a2a7e8f8ae9b99801aba7">quake3::IEntity</a> search;
        search.name = <span class="stringliteral">&quot;info_player_deathmatch&quot;</span>;

        <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> index = entityList.binary_search(search);
        <span class="keywordflow">if</span> (index &gt;= 0)
        {
            <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> notEndList;
            <span class="keywordflow">do</span>
            {
                <span class="keyword">const</span> quake3::SVarGroup *group = entityList[index].getGroup(1);

                <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> parsepos = 0;
                <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> pos =
                    <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a6163d5a7fba9950a2f390a42fe354c3f" title="get a quake3 vector translated to irrlicht position (x,-z,y )">quake3::getAsVector3df</a>(group-&gt;get(<span class="stringliteral">&quot;origin&quot;</span>), parsepos);

                parsepos = 0;
                <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> angle = <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#adca7fb6948f37384aca94a4c9ac73f14">quake3::getAsFloat</a>(group-&gt;get(<span class="stringliteral">&quot;angle&quot;</span>), parsepos);

                <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> target(0.f, 0.f, 1.f);
                target.rotateXZBy(angle);

                camera-&gt;setPosition(pos);
                camera-&gt;setTarget(pos + target);

                ++index;
</pre></div><p>notEndList = ( index &lt; (s32) entityList.size () &amp;&amp; entityList[index].name == search.name &amp;&amp; (device-&gt;getTimer()-&gt;getRealTime() &gt;&gt; 3 ) &amp; 1 ); </p>
<div class="fragment"><pre class="fragment">                notEndList = index == 2;
            } <span class="keywordflow">while</span> ( notEndList );
        }
    }
</pre></div><p>The mouse cursor needs not to be visible, so we make it invisible. </p>
<div class="fragment"><pre class="fragment">    device-&gt;getCursorControl()-&gt;setVisible(<span class="keyword">false</span>);

    <span class="comment">// load the engine logo</span>
    gui-&gt;addImage(driver-&gt;getTexture(<span class="stringliteral">&quot;irrlichtlogo2.png&quot;</span>),
            core::position2d&lt;s32&gt;(10, 10));

    <span class="comment">// show the driver logo</span>
    <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a3643c2cc7820dd78cd87e73a46b92145">core::position2di</a> pos(videoDim.Width - 128, videoDim.Height - 64);

    <span class="keywordflow">switch</span> ( driverType )
    {
        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0ae85481da26159b967191ccc6de1e4a05" title="The Burning&#39;s Software Renderer, an alternative software renderer.">video::EDT_BURNINGSVIDEO</a>:
            gui-&gt;addImage(driver-&gt;getTexture(<span class="stringliteral">&quot;burninglogo.png&quot;</span>), pos);
            <span class="keywordflow">break</span>;
        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a2715182a79f1cb8e2826fd68a8150a53" title="OpenGL device, available on most platforms.">video::EDT_OPENGL</a>:
            gui-&gt;addImage(driver-&gt;getTexture(<span class="stringliteral">&quot;opengllogo.png&quot;</span>), pos);
            <span class="keywordflow">break</span>;
        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a8cc3807f6f28404f3424ad7e31b3142f" title="Direct3D8 device, only available on Win32 platforms.">video::EDT_DIRECT3D8</a>:
        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a4691ca314f9018f508dcf2c57dcaacec" title="Direct3D 9 device, only available on Win32 platforms.">video::EDT_DIRECT3D9</a>:
            gui-&gt;addImage(driver-&gt;getTexture(<span class="stringliteral">&quot;directxlogo.png&quot;</span>), pos);
            <span class="keywordflow">break</span>;
    }
</pre></div><p>We have done everything, so lets draw it. We also write the current frames per second and the drawn primitives to the caption of the window. The 'if (device-&gt;isWindowActive())' line is optional, but prevents the engine render to set the position of the mouse cursor after task switching when other program are active. </p>
<div class="fragment"><pre class="fragment">    <span class="keywordtype">int</span> lastFPS = -1;

    <span class="keywordflow">while</span>(device-&gt;run())
    <span class="keywordflow">if</span> (device-&gt;isWindowActive())
    {
        driver-&gt;beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, video::SColor(255,20,20,40));
        smgr-&gt;drawAll();
        gui-&gt;drawAll();
        driver-&gt;endScene();

        <span class="keywordtype">int</span> fps = driver-&gt;getFPS();
        <span class="comment">//if (lastFPS != fps)</span>
        {
            io::IAttributes * <span class="keyword">const</span> attr = smgr-&gt;getParameters();
            <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> str = L<span class="stringliteral">&quot;Q3 [&quot;</span>;
            str += driver-&gt;getName();
            str += <span class="stringliteral">&quot;] FPS:&quot;</span>;
            str += fps;
<span class="preprocessor">#ifdef _IRR_SCENEMANAGER_DEBUG          </span>
<span class="preprocessor"></span>            str += <span class="stringliteral">&quot; Cull:&quot;</span>;
            str += attr-&gt;getAttributeAsInt(<span class="stringliteral">&quot;calls&quot;</span>);
            str += <span class="stringliteral">&quot;/&quot;</span>;
            str += attr-&gt;getAttributeAsInt(<span class="stringliteral">&quot;culled&quot;</span>);
            str += <span class="stringliteral">&quot; Draw: &quot;</span>;
            str += attr-&gt;getAttributeAsInt(<span class="stringliteral">&quot;drawn_solid&quot;</span>);
            str += <span class="stringliteral">&quot;/&quot;</span>;
            str += attr-&gt;getAttributeAsInt(<span class="stringliteral">&quot;drawn_transparent&quot;</span>);
            str += <span class="stringliteral">&quot;/&quot;</span>;
            str += attr-&gt;getAttributeAsInt(<span class="stringliteral">&quot;drawn_transparent_effect&quot;</span>);
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span>            device-&gt;setWindowCaption(str.c_str());
            lastFPS = fps;
        }
    }
</pre></div><p>In the end, delete the Irrlicht device. </p>
<div class="fragment"><pre class="fragment">    device-&gt;drop();

    <span class="keywordflow">return</span> 0;
}
</pre></div> </div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<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>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
<a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht 
Engine</a> Documentation &copy; 2003-2012 by Nikolaus Gebhardt. Generated on Sun Nov 17 2013 20:18:41 for Irrlicht 3D Engine by
<a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>