Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > 58828b263d8f56d90ac336dea07a4586 > files > 752

irrlicht-doc-1.6.1-1mdv2010.1.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Irrlicht Engine: Tutorial 21: Quake3 Explorer</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<table class="irrlicht" >
  <tr valign="middle"> 
    <td><font size="2"><a class="qindex" href="index.html"><font color="#FFFFFF">Home</font></a> 
      | <a class="qindex" href="namespaces.html"><font color="#FFFFFF">Namespaces</font></a> 
      | <a class="qindex" href="hierarchy.html"><font color="#FFFFFF">Hierarchy</font></a> 
      | <a class="qindex" href="classes.html"><font color="#FFFFFF">Alphabetical 
      List</font></a> | <a class="qindex" href="annotated.html"><font color="#FFFFFF"> 
      Class list</font></a> | <a class="qindex" href="files.html"><font color="#FFFFFF">Files</font></a> 
      | <a class="qindex" href="namespacemembers.html"><font color="#FFFFFF"> 
      Namespace&nbsp;Members</font></a> | <a class="qindex" href="functions.html"><font color="#FFFFFF">Class 
      members</font></a> | <a class="qindex" href="globals.html"><font color="#FFFFFF">File 
      members</font></a> | <a class="qindex" href="pages.html"><font color="#FFFFFF">Tutorials</font></a></font> </td>
  </tr>
</table>
<!-- Generated by Doxygen 1.5.6 -->
<div class="contents">
<h1><a class="anchor" name="example021">Tutorial 21: Quake3 Explorer </a></h1><div align="center">
<img src="021shot.jpg" alt="021shot.jpg">
</div>
 <p>
This Tutorial shows how to load different Quake 3 maps.<p>
Features:<ul>
<li>Load BSP Archives at Runtime from the menu</li><li>Load a Map from the menu. Showing with Screenshot</li><li>Set the VideoDriver at runtime from menu</li><li>Adjust GammaLevel at runtime</li><li>Create SceneNodes for the Shaders</li><li>Load EntityList and create Entity SceneNodes</li><li>Create Players with Weapons and with Collison Respsone</li><li>Play music</li></ul>
<p>
You can download the Quake III Arena demo ( copyright id software ) at the following location: <a href="ftp://ftp.idsoftware.com/idstuff/quake3/win32/q3ademo.exe">ftp://ftp.idsoftware.com/idstuff/quake3/win32/q3ademo.exe</a><p>
Copyright 2006-2009 Burningwater, Thomas Alten <div class="fragment"><pre class="fragment"><span class="preprocessor">#include "q3factory.h"</span>
<span class="preprocessor">#include "sound.h"</span>
<span class="preprocessor">#include &lt;iostream&gt;</span>
</pre></div><p>
Game Data is used to hold Data which is needed to drive the game <div class="fragment"><pre class="fragment"><span class="keyword">struct </span>GameData
{
        GameData ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#b1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> &amp;startupDir) :
                retVal(0), createExDevice(0), Device(0), StartupDir(startupDir)
        {
                setDefault ();
        }

        <span class="keywordtype">void</span> setDefault ();
        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> save ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#b1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> &amp;filename );
        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> load ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#b1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> &amp;filename );

        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> debugState;
        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> gravityState;
        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> flyTroughState;
        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> wireFrame;
        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> guiActive;
        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> guiInputActive;
        <a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> GammaValue;
        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> retVal;
        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> sound;

        <a class="code" href="namespaceirr_1_1io.html#b1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> StartupDir;
        <a class="code" href="namespaceirr_1_1core.html#ef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> CurrentMapName;
        array&lt;path&gt; CurrentArchiveList;

        <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> PlayerPosition;
        <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> PlayerRotation;

        <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#312f35a37540d810fcb14b75fd449c9e">tQ3EntityList</a> Variable;

        Q3LevelLoadParameter loadParam;
        SIrrlichtCreationParameters deviceParam;
        <a class="code" href="namespaceirr.html#5137701377b2241305607fc37a27e9f8" title="typedef for Function Pointer">funcptr_createDeviceEx</a> createExDevice;
        IrrlichtDevice *Device;
};
</pre></div><p>
set default settings <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> GameData::setDefault ()
{
        debugState = <a class="code" href="namespaceirr_1_1scene.html#52b664c4c988113735042b168fc32dbe25111b15f03bee9a99498737286916dc" title="No Debug Data ( Default ).">EDS_OFF</a>;
        gravityState = 1;
        flyTroughState = 0;
        wireFrame = 0;
        guiActive = 1;
        guiInputActive = 0;
        GammaValue = 1.f;

        <span class="comment">// default deviceParam;</span>
<span class="preprocessor">#if defined ( _IRR_WINDOWS_ )</span>
<span class="preprocessor"></span>        deviceParam.DriverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d04691ca314f9018f508dcf2c57dcaacec" title="Direct3D 9 device, only available on Win32 platforms.">EDT_DIRECT3D9</a>;
<span class="preprocessor">#else</span>
<span class="preprocessor"></span>        deviceParam.DriverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d02715182a79f1cb8e2826fd68a8150a53" title="OpenGL device, available on most platforms.">EDT_OPENGL</a>;
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span>        deviceParam.WindowSize.Width = 800;
        deviceParam.WindowSize.Height = 600;
        deviceParam.Fullscreen = <span class="keyword">false</span>;
        deviceParam.Bits = 32;
        deviceParam.ZBufferBits = 16;
        deviceParam.Vsync = <span class="keyword">false</span>;
        deviceParam.AntiAlias = <span class="keyword">false</span>;

        <span class="comment">// default Quake3 loadParam</span>
        loadParam.defaultLightMapMaterial = <a class="code" href="namespaceirr_1_1video.html#c8e9b6c66f7cebabd1a6d30cbc5430f15dc90a3b4a8d82f10503ddf834a3143f" title="Material type with standard lightmap technique.">EMT_LIGHTMAP</a>;
        loadParam.defaultModulate = <a class="code" href="namespaceirr_1_1video.html#1402e9045137ae232fafbdf38580084358cc346f344fb488d403a3783675e5d7">EMFN_MODULATE_1X</a>;
        loadParam.defaultFilter = <a class="code" href="namespaceirr_1_1video.html#8a3bc00ae8137535b9fbc5f40add70d3941c0756b9dc3f987a183a401c6fd4ad" title="Is anisotropic filtering? Default: false.">EMF_ANISOTROPIC_FILTER</a>;
        loadParam.verbose = 2;
        loadParam.mergeShaderBuffer = 1;                <span class="comment">// merge meshbuffers with same material</span>
        loadParam.cleanUnResolvedMeshes = 1;    <span class="comment">// should unresolved meshes be cleaned. otherwise blue texture</span>
        loadParam.loadAllShaders = 1;                   <span class="comment">// load all scripts in the script directory</span>
        loadParam.loadSkyShader = 0;                    <span class="comment">// load sky Shader</span>
        loadParam.alpharef = 1;

        sound = 0;

        CurrentMapName = <span class="stringliteral">""</span>;
        CurrentArchiveList.clear ();

        <span class="comment">// Explorer Media directory</span>
        CurrentArchiveList.push_back ( StartupDir + <span class="stringliteral">"../../media/"</span> );

        <span class="comment">// Add the original quake3 files before you load your custom map</span>
        <span class="comment">// Most mods are using the original shaders, models&amp;items&amp;weapons</span>
        CurrentArchiveList.push_back(<span class="stringliteral">"/q/baseq3/"</span>);

        CurrentArchiveList.push_back(StartupDir + <span class="stringliteral">"../../media/map-20kdm2.pk3"</span>);
}
</pre></div><p>
Load the current game State from a typical quake3 cfg file <div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> GameData::load ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#b1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> &amp;filename )
{
        <span class="keywordflow">if</span> (!Device)
                <span class="keywordflow">return</span> 0;

        <span class="comment">// the quake3 mesh loader can also handle *.shader and *.cfg file</span>
        IQ3LevelMesh* mesh = (IQ3LevelMesh*) Device-&gt;getSceneManager()-&gt;getMesh ( filename );
        <span class="keywordflow">if</span> (!mesh)
                <span class="keywordflow">return</span> 0;

        <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#312f35a37540d810fcb14b75fd449c9e">tQ3EntityList</a> &amp;entityList = mesh-&gt;getEntityList ();

        <a class="code" href="namespaceirr_1_1core.html#de1071a878633f2f6d8a75c5d11fec19" title="Typedef for character strings.">stringc</a> s;
        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> pos;

        <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> e = 0; e != entityList.size (); ++e )
        {
                <span class="comment">//dumpShader ( s, &amp;entityList[e], false );</span>
                <span class="comment">//printf ( s.c_str () );</span>

                <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> g = 0; g != entityList[e].getGroupSize (); ++g )
                {
                        <span class="keyword">const</span> SVarGroup *group = entityList[e].getGroup ( g );

                        <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index = 0; index &lt; group-&gt;Variable.size (); ++index )
                        {
                                <span class="keyword">const</span> SVariable &amp;v = group-&gt;Variable[index];
                                pos = 0;
                                <span class="keywordflow">if</span> ( v.name == <span class="stringliteral">"playerposition"</span> )
                                {
                                        PlayerPosition = <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#6163d5a7fba9950a2f390a42fe354c3f" title="get a quake3 vector translated to irrlicht position (x,-z,y )">getAsVector3df</a> ( v.content, pos );
                                }
                                <span class="keywordflow">else</span>
                                <span class="keywordflow">if</span> ( v.name == <span class="stringliteral">"playerrotation"</span> )
                                {
                                        PlayerRotation = <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#6163d5a7fba9950a2f390a42fe354c3f" title="get a quake3 vector translated to irrlicht position (x,-z,y )">getAsVector3df</a> ( v.content, pos );
                                }
                        }
                }
        }

        <span class="keywordflow">return</span> 1;
}
</pre></div><p>
Store the current game State in a quake3 configuration file <div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> GameData::save ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#b1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> &amp;filename )
{
        <span class="keywordflow">return</span> 0;
        <span class="keywordflow">if</span> (!Device)
                <span class="keywordflow">return</span> 0;

        <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[128];
        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i;

        <span class="comment">// Store current Archive for restart</span>
        CurrentArchiveList.clear();
        IFileSystem *fs = Device-&gt;getFileSystem();
        <span class="keywordflow">for</span> ( i = 0; i != fs-&gt;getFileArchiveCount(); ++i )
        {
                CurrentArchiveList.push_back ( fs-&gt;getFileArchive(i)-&gt;getFileList()-&gt;getPath() );
        }

        <span class="comment">// Store Player Position and Rotation</span>
        ICameraSceneNode * camera = Device-&gt;getSceneManager()-&gt;getActiveCamera ();
        <span class="keywordflow">if</span> ( camera )
        {
                PlayerPosition = camera-&gt;getPosition ();
                PlayerRotation = camera-&gt;getRotation ();
        }

        IWriteFile *file = fs-&gt;createAndWriteFile ( filename );
        <span class="keywordflow">if</span> (!file)
                <span class="keywordflow">return</span> 0;

        snprintf ( buf, 128, <span class="stringliteral">"playerposition %.f %.f %.f\nplayerrotation %.f %.f %.f\n"</span>,
                        PlayerPosition.X, PlayerPosition.Z, PlayerPosition.Y,
                        PlayerRotation.X, PlayerRotation.Z, PlayerRotation.Y);
        file-&gt;write ( buf, (<a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) strlen ( buf ) );
        <span class="keywordflow">for</span> ( i = 0; i != fs-&gt;getFileArchiveCount(); ++i )
        {
                snprintf ( buf, 128, <span class="stringliteral">"archive %s\n"</span>,<a class="code" href="namespaceirr_1_1core.html#de1071a878633f2f6d8a75c5d11fec19" title="Typedef for character strings.">stringc</a> ( fs-&gt;getFileArchive(i)-&gt;getFileList()-&gt;getPath() ).c_str () );
                file-&gt;write ( buf, (<a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) strlen ( buf ) );
        }

        file-&gt;drop ();
        <span class="keywordflow">return</span> 1;
}
</pre></div><p>
Representing a player <div class="fragment"><pre class="fragment"><span class="keyword">struct </span>Q3Player : <span class="keyword">public</span> IAnimationEndCallBack
{
        Q3Player ()
        : Device(0), MapParent(0), Mesh(0), WeaponNode(0), StartPositionCurrent(0)
        {
                animation[0] = 0;
                memset(Anim, 0, <span class="keyword">sizeof</span>(TimeFire)*4);
        }

        <span class="keyword">virtual</span> <span class="keywordtype">void</span> OnAnimationEnd(IAnimatedMeshSceneNode* node);

        <span class="keywordtype">void</span> create (   IrrlichtDevice *device,
                                        IQ3LevelMesh* mesh,
                                        ISceneNode *mapNode,
                                        IMetaTriangleSelector *meta
                                );
        <span class="keywordtype">void</span> shutdown ();
        <span class="keywordtype">void</span> setAnim ( <span class="keyword">const</span> <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *name );
        <span class="keywordtype">void</span> respawn ();
        <span class="keywordtype">void</span> setpos ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> &amp;pos, <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>&amp; rotation );

        ISceneNodeAnimatorCollisionResponse * cam() { <span class="keywordflow">return</span> camCollisionResponse ( Device ); }

        IrrlichtDevice *Device;
        ISceneNode* MapParent;
        IQ3LevelMesh* Mesh;
        IAnimatedMeshSceneNode* WeaponNode;
        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> StartPositionCurrent;
        TimeFire Anim[4];
        <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> animation[64];
        <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[64];
};
</pre></div> End player <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::shutdown ()
{
        setAnim ( 0 );

        dropElement (WeaponNode);

        <span class="keywordflow">if</span> ( Device )
        {
                ICameraSceneNode* camera = Device-&gt;getSceneManager()-&gt;getActiveCamera();
                dropElement ( camera );
                Device = 0;
        }

        MapParent = 0;
        Mesh = 0;
}
</pre></div> create a new player <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::create ( IrrlichtDevice *device, IQ3LevelMesh* mesh, ISceneNode *mapNode, IMetaTriangleSelector *meta )
{
        setTimeFire ( Anim + 0, 200, FIRED );
        setTimeFire ( Anim + 1, 5000 );

        <span class="keywordflow">if</span> (!device)
                <span class="keywordflow">return</span>;
        <span class="comment">// load FPS weapon to Camera</span>
        Device = device;
        Mesh = mesh;
        MapParent = mapNode;

        ISceneManager *smgr = device-&gt;getSceneManager ();
        IVideoDriver * driver = device-&gt;getVideoDriver();

        ICameraSceneNode* camera = 0;

        SKeyMap keyMap[10];
        keyMap[0].Action = <a class="code" href="namespaceirr.html#a9946ac9f3142f9e790ce52d59fd6168f9ff845aa49060787ef81773eeaf1016">EKA_MOVE_FORWARD</a>;
        keyMap[0].KeyCode = <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb3e3341f66dcdd3d0cbce80ff741262395">KEY_UP</a>;
        keyMap[1].Action = <a class="code" href="namespaceirr.html#a9946ac9f3142f9e790ce52d59fd6168f9ff845aa49060787ef81773eeaf1016">EKA_MOVE_FORWARD</a>;
        keyMap[1].KeyCode = <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb3e559e3169016a3180c45c2828f391af2">KEY_KEY_W</a>;

        keyMap[2].Action = <a class="code" href="namespaceirr.html#a9946ac9f3142f9e790ce52d59fd6168f4c724e0a0923e497c7f8a48884e36d9">EKA_MOVE_BACKWARD</a>;
        keyMap[2].KeyCode = <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb3cbab6476bacfd1212c52aba7c1c82886">KEY_DOWN</a>;
        keyMap[3].Action = <a class="code" href="namespaceirr.html#a9946ac9f3142f9e790ce52d59fd6168f4c724e0a0923e497c7f8a48884e36d9">EKA_MOVE_BACKWARD</a>;
        keyMap[3].KeyCode = <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb3e52bafc112fc6c52f6b49cea42fa246e">KEY_KEY_S</a>;

        keyMap[4].Action = <a class="code" href="namespaceirr.html#a9946ac9f3142f9e790ce52d59fd616891cad59a86b88c0e6ab5aa75b936d9c7">EKA_STRAFE_LEFT</a>;
        keyMap[4].KeyCode = <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb371c43cf2c123fd75911fef5501a15241">KEY_LEFT</a>;
        keyMap[5].Action = <a class="code" href="namespaceirr.html#a9946ac9f3142f9e790ce52d59fd616891cad59a86b88c0e6ab5aa75b936d9c7">EKA_STRAFE_LEFT</a>;
        keyMap[5].KeyCode = <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb32fe10b4309013968b9cd14811c3d3c85">KEY_KEY_A</a>;

        keyMap[6].Action = <a class="code" href="namespaceirr.html#a9946ac9f3142f9e790ce52d59fd616857c4bd21c235bca312e547c6d1061df2">EKA_STRAFE_RIGHT</a>;
        keyMap[6].KeyCode = <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb3e89f39517a44c78a6602d1b12b478118">KEY_RIGHT</a>;
        keyMap[7].Action = <a class="code" href="namespaceirr.html#a9946ac9f3142f9e790ce52d59fd616857c4bd21c235bca312e547c6d1061df2">EKA_STRAFE_RIGHT</a>;
        keyMap[7].KeyCode = <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb3d20e7e220103e611752b90edeb6cbc9d">KEY_KEY_D</a>;

        keyMap[8].Action = <a class="code" href="namespaceirr.html#a9946ac9f3142f9e790ce52d59fd6168574c0935be6337a2e6bc97e8304a7400">EKA_JUMP_UP</a>;
        keyMap[8].KeyCode = <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb33231acd1573be6e4d121cc6c4ab6ccc4">KEY_KEY_J</a>;

        keyMap[9].Action = <a class="code" href="namespaceirr.html#a9946ac9f3142f9e790ce52d59fd6168ace30d0d2eef7a48f5f863a99dabfb84">EKA_CROUCH</a>;
        keyMap[9].KeyCode = <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb385a756fa6a3336312c5f32877a7185e5">KEY_KEY_C</a>;

        camera = smgr-&gt;addCameraSceneNodeFPS(0, 100.0f, 0.6f, -1, keyMap, 10, <span class="keyword">false</span>, 0.6f);
        camera-&gt;setName ( <span class="stringliteral">"First Person Camera"</span> );
        <span class="comment">//camera-&gt;setFOV ( 100.f * core::DEGTORAD );</span>
        camera-&gt;setFarValue( 20000.f );

        IAnimatedMeshMD2* weaponMesh = (IAnimatedMeshMD2*) smgr-&gt;getMesh(<span class="stringliteral">"gun.md2"</span>);
        <span class="keywordflow">if</span> ( 0 == weaponMesh )
                <span class="keywordflow">return</span>;

        <span class="keywordflow">if</span> ( weaponMesh-&gt;getMeshType() == <a class="code" href="namespaceirr_1_1scene.html#2fc85a64604521ca063f1881b5dd1c613b87f459cd5f287626c4fd9aaf729284" title="Quake 2 MD2 model file.">EAMT_MD2</a> )
        {
                <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> count = weaponMesh-&gt;getAnimationCount();
                <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> i = 0; i != count; ++i )
                {
                        snprintf ( buf, 64, <span class="stringliteral">"Animation: %s"</span>, weaponMesh-&gt;getAnimationName(i) );
                        device-&gt;getLogger()-&gt;log(buf, <a class="code" href="namespaceirr.html#a2d1cac68606a25ed24cfffccfa30a929d74de15737e326a91aec6f38c23f9cf" title="High log level, warnings, errors and important information texts are printed out...">ELL_INFORMATION</a>);
                }
        }

        WeaponNode = smgr-&gt;addAnimatedMeshSceneNode(
                                                weaponMesh,
                                                smgr-&gt;getActiveCamera(),
                                                10,
                                                <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>( 0, 0, 0),
                                                <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(-90,-90,90)
                                                );
        WeaponNode-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#8a3bc00ae8137535b9fbc5f40add70d3cea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">EMF_LIGHTING</a>, <span class="keyword">false</span>);
        WeaponNode-&gt;setMaterialTexture(0, driver-&gt;getTexture( <span class="stringliteral">"gun.jpg"</span>));
        WeaponNode-&gt;setLoopMode ( <span class="keyword">false</span> );
        WeaponNode-&gt;setName ( <span class="stringliteral">"tommi the gun man"</span> );

        <span class="comment">//create a collision auto response animator</span>
        ISceneNodeAnimator* anim =
                smgr-&gt;createCollisionResponseAnimator( meta, camera,
                        <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(30,45,30),
                        getGravity ( <span class="stringliteral">"earth"</span> ),
                        <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0,40,0),
                        0.0005f
                );

        camera-&gt;addAnimator( anim );
        anim-&gt;drop();

        <span class="keywordflow">if</span> ( meta )
        {
                meta-&gt;drop ();
        }

        respawn ();
        setAnim ( <span class="stringliteral">"idle"</span> );
}
</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" <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::respawn ()
{
        <span class="keywordflow">if</span> (!Device)
                <span class="keywordflow">return</span>;
        ICameraSceneNode* camera = Device-&gt;getSceneManager()-&gt;getActiveCamera();

        Device-&gt;getLogger()-&gt;log( <span class="stringliteral">"respawn"</span> );

        <span class="keywordflow">if</span> ( StartPositionCurrent &gt;= Q3StartPosition (
                        Mesh, camera,StartPositionCurrent++,
                        cam ()-&gt;getEllipsoidTranslation() )
                )
        {
                StartPositionCurrent = 0;
        }
}
</pre></div><p>
set Player position from saved coordinates <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::setpos ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> &amp;pos, <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> &amp;rotation )
{
        <span class="keywordflow">if</span> (!Device)
                <span class="keywordflow">return</span>;
        Device-&gt;getLogger()-&gt;log( <span class="stringliteral">"setpos"</span> );

        ICameraSceneNode* camera = Device-&gt;getSceneManager()-&gt;getActiveCamera();
        <span class="keywordflow">if</span> ( camera )
        {
                camera-&gt;setPosition ( pos );
                camera-&gt;setRotation ( rotation );
                camera-&gt;OnAnimate ( 0 );
        }
}
</pre></div> set the Animation of the player and weapon <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::setAnim ( <span class="keyword">const</span> <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *name )
{
        <span class="keywordflow">if</span> ( name )
        {
                snprintf ( animation, 64, <span class="stringliteral">"%s"</span>, name );
                <span class="keywordflow">if</span> ( WeaponNode )
                {
                        WeaponNode-&gt;setAnimationEndCallback ( <span class="keyword">this</span> );
                        WeaponNode-&gt;setMD2Animation ( animation );
                }
        }
        <span class="keywordflow">else</span>
        {
                animation[0] = 0;
                <span class="keywordflow">if</span> ( WeaponNode )
                {
                        WeaponNode-&gt;setAnimationEndCallback ( 0 );
                }
        }
}


<span class="comment">// Callback</span>
<span class="keywordtype">void</span> Q3Player::OnAnimationEnd(IAnimatedMeshSceneNode* node)
{
        setAnim ( 0 );
}
</pre></div> GUI Elements <div class="fragment"><pre class="fragment"><span class="keyword">struct </span>GUI
{
        GUI ()
        {
                memset ( <span class="keyword">this</span>, 0, <span class="keyword">sizeof</span> ( *<span class="keyword">this</span> ) );
        }

        <span class="keywordtype">void</span> drop()
        {
                dropElement ( Window );
                dropElement ( Logo );
        }

        IGUIComboBox* VideoDriver;
        IGUIComboBox* VideoMode;
        IGUICheckBox* FullScreen;
        IGUICheckBox* Bit32;
        IGUIScrollBar* MultiSample;
        IGUIButton* SetVideoMode;

        IGUIScrollBar* Tesselation;
        IGUIScrollBar* Gamma;
        IGUICheckBox* Collision;
        IGUICheckBox* Visible_Map;
        IGUICheckBox* Visible_Shader;
        IGUICheckBox* Visible_Fog;
        IGUICheckBox* Visible_Unresolved;
        IGUICheckBox* Visible_Skydome;
        IGUIButton* Respawn;

        IGUITable* ArchiveList;
        IGUIButton* ArchiveAdd;
        IGUIButton* ArchiveRemove;
        IGUIFileOpenDialog* ArchiveFileOpen;
        IGUIButton* ArchiveUp;
        IGUIButton* ArchiveDown;

        IGUIListBox* MapList;
        IGUITreeView* SceneTree;
        IGUIStaticText* StatusLine;
        IGUIImage* Logo;
        IGUIWindow* Window;
};
</pre></div><p>
CQuake3EventHandler controls the game <div class="fragment"><pre class="fragment"><span class="keyword">class </span>CQuake3EventHandler : <span class="keyword">public</span> IEventReceiver
{
<span class="keyword">public</span>:

        CQuake3EventHandler( GameData *gameData );
        <span class="keyword">virtual</span> ~CQuake3EventHandler ();

        <span class="keywordtype">void</span> Animate();
        <span class="keywordtype">void</span> Render();

        <span class="keywordtype">void</span> AddArchive ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#b1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a>&amp; archiveName );
        <span class="keywordtype">void</span> LoadMap ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#ef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>&amp; mapName, <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> collision );
        <span class="keywordtype">void</span> CreatePlayers();
        <span class="keywordtype">void</span> AddSky( <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> dome, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *texture );
        Q3Player *GetPlayer ( <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index ) { <span class="keywordflow">return</span> &amp;Player[index]; }

        <span class="keywordtype">void</span> CreateGUI();
        <span class="keywordtype">void</span> SetGUIActive( <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> command);

        <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent&amp; eve);


<span class="keyword">private</span>:

        GameData *Game;

        IQ3LevelMesh* Mesh;
        ISceneNode* MapParent;
        ISceneNode* ShaderParent;
        ISceneNode* ItemParent;
        ISceneNode* UnresolvedParent;
        ISceneNode* BulletParent;
        ISceneNode* FogParent;
        ISceneNode * SkyNode;
        IMetaTriangleSelector *Meta;

        <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[256];

        Q3Player Player[2];

        <span class="keyword">struct </span>SParticleImpact
        {
                <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> when;
                <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> pos;
                <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> outVector;
        };
        array&lt;SParticleImpact&gt; Impacts;
        <span class="keywordtype">void</span> useItem( Q3Player * player);
        <span class="keywordtype">void</span> createParticleImpacts( <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> now );

        <span class="keywordtype">void</span> createTextures ();
        <span class="keywordtype">void</span> addSceneTreeItem( ISceneNode * parent, IGUITreeViewNode* nodeParent);

        GUI gui;
        <span class="keywordtype">void</span> dropMap ();
};
</pre></div> Constructor <div class="fragment"><pre class="fragment">CQuake3EventHandler::CQuake3EventHandler( GameData *game )
: Game(game), Mesh(0), MapParent(0), ShaderParent(0), ItemParent(0), UnresolvedParent(0),
        BulletParent(0), FogParent(0), SkyNode(0), Meta(0)
{
        buf[0]=0;
        <span class="comment">// Also use 16 Bit Textures for 16 Bit RenderDevice</span>
        <span class="keywordflow">if</span> ( Game-&gt;deviceParam.Bits == 16 )
        {
                game-&gt;Device-&gt;getVideoDriver()-&gt;setTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#caf6f7414534f7d62bff18c5bf11876f4fe1c1b0f4b44ef4b5da219ce66a0ae8">ETCF_ALWAYS_16_BIT</a>, <span class="keyword">true</span>);
        }

        <span class="comment">// Quake3 Shader controls Z-Writing</span>
        game-&gt;Device-&gt;getSceneManager()-&gt;getParameters()-&gt;setAttribute(<a class="code" href="namespaceirr_1_1scene.html#b585d23bc2a3d02cd368d8bfd0b1414a" title="Name of the parameter for changing how Irrlicht handles the ZWrite flag for transparent...">scene::ALLOW_ZWRITE_ON_TRANSPARENT</a>, <span class="keyword">true</span>);

        <span class="comment">// create internal textures</span>
        createTextures ();

        sound_init ( game-&gt;Device );

        Game-&gt;Device-&gt;setEventReceiver ( <span class="keyword">this</span> );
}


<span class="comment">// destructor</span>
CQuake3EventHandler::~CQuake3EventHandler ()
{
        Player[0].shutdown ();
        sound_shutdown ();

        Game-&gt;save( <span class="stringliteral">"explorer.cfg"</span> );

        Game-&gt;Device-&gt;drop();
}


<span class="comment">// create runtime textures smog, fog</span>
<span class="keywordtype">void</span> CQuake3EventHandler::createTextures ()
{
        IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();

        <a class="code" href="namespaceirr_1_1core.html#d2e562e3219072e2f7fc7c2bba0ef0cb" title="Typedef for an unsigned integer dimension.">dimension2du</a> dim ( 64, 64 );

        video::ITexture* texture;
        video::IImage* image;
        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i;
        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> x;
        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> y;
        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> * data;
        <span class="keywordflow">for</span> ( i = 0; i != 8; ++i )
        {
                image = driver-&gt;createImage ( <a class="code" href="namespaceirr_1_1video.html#1d5e487888c32b1674a8f75116d829ed55c57d63efff39efe33ee733fe962df0" title="Default 32 bit color format. 8 bits are used for every component: red, green, blue...">video::ECF_A8R8G8B8</a>, dim);
                data = (<a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>*) image-&gt;lock ();
                <span class="keywordflow">for</span> ( y = 0; y != dim.Height; ++y )
                {
                        <span class="keywordflow">for</span> ( x = 0; x != dim.Width; ++x )
                        {
                                data [x] = 0xFFFFFFFF;
                        }
                        data = (<a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>*) ( (<a class="code" href="namespaceirr.html#646874f69af8ff87fc10201b0254a761" title="8 bit unsigned variable.">u8</a>*) data + image-&gt;getPitch() );
                }
                image-&gt;unlock();
                snprintf ( buf, 64, <span class="stringliteral">"smoke_%02d"</span>, i );
                texture = driver-&gt;addTexture( buf, image );
                image-&gt;drop ();
        }

        <span class="comment">// fog</span>
        <span class="keywordflow">for</span> ( i = 0; i != 1; ++i )
        {
                image = driver-&gt;createImage ( <a class="code" href="namespaceirr_1_1video.html#1d5e487888c32b1674a8f75116d829ed55c57d63efff39efe33ee733fe962df0" title="Default 32 bit color format. 8 bits are used for every component: red, green, blue...">video::ECF_A8R8G8B8</a>, dim);
                data = (<a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>*) image-&gt;lock ();
                <span class="keywordflow">for</span> ( y = 0; y != dim.Height; ++y )
                {
                        <span class="keywordflow">for</span> ( x = 0; x != dim.Width; ++x )
                        {
                                data [x] = 0xFFFFFFFF;
                        }
                        data = (<a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>*) ( (<a class="code" href="namespaceirr.html#646874f69af8ff87fc10201b0254a761" title="8 bit unsigned variable.">u8</a>*) data + image-&gt;getPitch() );
                }
                image-&gt;unlock();
                snprintf ( buf, 64, <span class="stringliteral">"fog_%02d"</span>, i );
                texture = driver-&gt;addTexture( buf, image );
                image-&gt;drop ();
        }

}
</pre></div><p>
create the GUI <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::CreateGUI()
{

        IGUIEnvironment *env = Game-&gt;Device-&gt;getGUIEnvironment();
        IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();

        gui.drop();

        <span class="comment">// set skin font</span>
        IGUIFont* font = env-&gt;getFont(<span class="stringliteral">"fontlucida.png"</span>);
        <span class="keywordflow">if</span> (font)
                env-&gt;getSkin()-&gt;setFont(font);
        env-&gt;getSkin()-&gt;setColor ( <a class="code" href="namespaceirr_1_1gui.html#bd15860fde29833c48daff5f95d5467a03e6e93fa9356e9d8d743e6928111185" title="Text on a button.">EGDC_BUTTON_TEXT</a>, video::SColor(240,0xAA,0xAA,0xAA) );
        env-&gt;getSkin()-&gt;setColor ( <a class="code" href="namespaceirr_1_1gui.html#bd15860fde29833c48daff5f95d5467a1227b2c3a809d139e1ead87aa29fa101" title="Highlight color for three-dimensional display elements (for edges facing the light...">EGDC_3D_HIGH_LIGHT</a>, video::SColor(240,0x22,0x22,0x22) );
        env-&gt;getSkin()-&gt;setColor ( <a class="code" href="namespaceirr_1_1gui.html#bd15860fde29833c48daff5f95d5467abeac28ca22e9f22dc84222d5f62a80eb" title="Face color for three-dimensional display elements and for dialog box backgrounds...">EGDC_3D_FACE</a>, video::SColor(240,0x44,0x44,0x44) );
        env-&gt;getSkin()-&gt;setColor ( <a class="code" href="namespaceirr_1_1gui.html#bd15860fde29833c48daff5f95d5467ab60eb00de0efde8c5a948ab15d9aa0a7" title="Window background.">EGDC_WINDOW</a>, video::SColor(240,0x66,0x66,0x66) );

        <span class="comment">// minimal gui size 800x600</span>
        dimension2d&lt;u32&gt; dim ( 800, 600 );
        dimension2d&lt;u32&gt; vdim ( Game-&gt;Device-&gt;getVideoDriver()-&gt;getScreenSize() );

        <span class="keywordflow">if</span> ( vdim.Height &gt;= dim.Height &amp;&amp; vdim.Width &gt;= dim.Width )
        {
                <span class="comment">//dim = vdim;</span>
        }
        <span class="keywordflow">else</span>
        {
        }

        gui.Window = env-&gt;addWindow ( rect&lt;s32&gt; ( 0, 0, dim.Width, dim.Height ), <span class="keyword">false</span>, L<span class="stringliteral">"Quake3 Explorer"</span> );
        gui.Window-&gt;setToolTipText ( L<span class="stringliteral">"Quake3Explorer. Loads and show various BSP File Format and Shaders."</span> );
        gui.Window-&gt;getCloseButton()-&gt;setToolTipText ( L<span class="stringliteral">"Quit Quake3 Explorer"</span> );

        <span class="comment">// add a status line help text</span>
        gui.StatusLine = env-&gt;addStaticText( 0, rect&lt;s32&gt;( 5,dim.Height - 30,dim.Width - 5,dim.Height - 10),
                                                                <span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">true</span>
                                                        );


        env-&gt;addStaticText ( L<span class="stringliteral">"VideoDriver:"</span>, rect&lt;s32&gt;( dim.Width - 400, 24, dim.Width - 310, 40 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
        gui.VideoDriver = env-&gt;addComboBox(rect&lt;s32&gt;( dim.Width - 300, 24, dim.Width - 10, 40 ),gui.Window);
        gui.VideoDriver-&gt;addItem(L<span class="stringliteral">"Direct3D 9.0c"</span>, <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d04691ca314f9018f508dcf2c57dcaacec" title="Direct3D 9 device, only available on Win32 platforms.">EDT_DIRECT3D9</a> );
        gui.VideoDriver-&gt;addItem(L<span class="stringliteral">"Direct3D 8.1"</span>, <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d08cc3807f6f28404f3424ad7e31b3142f" title="Direct3D8 device, only available on Win32 platforms.">EDT_DIRECT3D8</a> );
        gui.VideoDriver-&gt;addItem(L<span class="stringliteral">"OpenGL 1.5"</span>, <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d02715182a79f1cb8e2826fd68a8150a53" title="OpenGL device, available on most platforms.">EDT_OPENGL</a>);
        gui.VideoDriver-&gt;addItem(L<span class="stringliteral">"Software Renderer"</span>, <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d01598cd235a1a6bd052e2011b559e8995" title="The Irrlicht Engine Software renderer.">EDT_SOFTWARE</a>);
        gui.VideoDriver-&gt;addItem(L<span class="stringliteral">"Burning's Video (TM) Thomas Alten"</span>, <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d0e85481da26159b967191ccc6de1e4a05" title="The Burning&amp;#39;s Software Renderer, an alternative software renderer.">EDT_BURNINGSVIDEO</a>);
        gui.VideoDriver-&gt;setSelected ( gui.VideoDriver-&gt;getIndexForItemData ( Game-&gt;deviceParam.DriverType ) );
        gui.VideoDriver-&gt;setToolTipText ( L<span class="stringliteral">"Use a VideoDriver"</span> );

        env-&gt;addStaticText ( L<span class="stringliteral">"VideoMode:"</span>, rect&lt;s32&gt;( dim.Width - 400, 44, dim.Width - 310, 60 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
        gui.VideoMode = env-&gt;addComboBox(rect&lt;s32&gt;( dim.Width - 300, 44, dim.Width - 10, 60 ),gui.Window);
        gui.VideoMode-&gt;setToolTipText ( L<span class="stringliteral">"Supported Screenmodes"</span> );
        IVideoModeList *modeList = Game-&gt;Device-&gt;getVideoModeList();
        <span class="keywordflow">if</span> ( modeList )
        {
                <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> i;
                <span class="keywordflow">for</span> ( i = 0; i != modeList-&gt;getVideoModeCount (); ++i )
                {
                        <a class="code" href="namespaceirr.html#e9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> d = modeList-&gt;getVideoModeDepth ( i );
                        <span class="keywordflow">if</span> ( d &lt; 16 )
                                <span class="keywordflow">continue</span>;

                        <a class="code" href="namespaceirr.html#e9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> w = modeList-&gt;getVideoModeResolution ( i ).Width;
                        <a class="code" href="namespaceirr.html#e9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> h = modeList-&gt;getVideoModeResolution ( i ).Height;
                        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> val = w &lt;&lt; 16 | h;

                        <span class="keywordflow">if</span> ( gui.VideoMode-&gt;getIndexForItemData ( val ) &gt;= 0 )
                                <span class="keywordflow">continue</span>;

                        <a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> aspect = (<a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>) w / (<a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>) h;
                        <span class="keyword">const</span> <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *a = <span class="stringliteral">""</span>;
                        <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#bf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 1.3333333333f ) ) a = <span class="stringliteral">"4:3"</span>;
                        <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#bf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 1.6666666f ) ) a = <span class="stringliteral">"15:9 widescreen"</span>;
                        <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#bf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 1.7777777f ) ) a = <span class="stringliteral">"16:9 widescreen"</span>;
                        <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#bf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 1.6f ) ) a = <span class="stringliteral">"16:10 widescreen"</span>;
                        <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#bf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 2.133333f ) ) a = <span class="stringliteral">"20:9 widescreen"</span>;

                        snprintf ( buf, <span class="keyword">sizeof</span> ( buf ), <span class="stringliteral">"%d x %d, %s"</span>,w, h, a );
                        gui.VideoMode-&gt;addItem ( <a class="code" href="namespaceirr_1_1core.html#ef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> ( buf ).c_str(), val );
                }
        }
        gui.VideoMode-&gt;setSelected ( gui.VideoMode-&gt;getIndexForItemData (
                                                                        Game-&gt;deviceParam.WindowSize.Width &lt;&lt; 16 |
                                                                        Game-&gt;deviceParam.WindowSize.Height ) );

        gui.FullScreen = env-&gt;addCheckBox ( Game-&gt;deviceParam.Fullscreen, rect&lt;s32&gt;( dim.Width - 400, 64, dim.Width - 300, 80 ), gui.Window,-1, L<span class="stringliteral">"Fullscreen"</span> );
        gui.FullScreen-&gt;setToolTipText ( L<span class="stringliteral">"Set Fullscreen or Window Mode"</span> );

        gui.Bit32 = env-&gt;addCheckBox ( Game-&gt;deviceParam.Bits == 32, rect&lt;s32&gt;( dim.Width - 300, 64, dim.Width - 240, 80 ), gui.Window,-1, L<span class="stringliteral">"32Bit"</span> );
        gui.Bit32-&gt;setToolTipText ( L<span class="stringliteral">"Use 16 or 32 Bit"</span> );

        env-&gt;addStaticText ( L<span class="stringliteral">"MultiSample:"</span>, rect&lt;s32&gt;( dim.Width - 235, 64, dim.Width - 150, 80 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
        gui.MultiSample = env-&gt;addScrollBar( <span class="keyword">true</span>, rect&lt;s32&gt;( dim.Width - 150, 64, dim.Width - 70, 80 ), gui.Window,-1 );
        gui.MultiSample-&gt;setMin ( 0 );
        gui.MultiSample-&gt;setMax ( 8 );
        gui.MultiSample-&gt;setSmallStep ( 1 );
        gui.MultiSample-&gt;setLargeStep ( 1 );
        gui.MultiSample-&gt;setPos ( Game-&gt;deviceParam.AntiAlias );
        gui.MultiSample-&gt;setToolTipText ( L<span class="stringliteral">"Set the MultiSample (disable, 1x, 2x, 4x, 8x )"</span> );

        gui.SetVideoMode = env-&gt;addButton (rect&lt;s32&gt;( dim.Width - 60, 64, dim.Width - 10, 80 ), gui.Window, -1,L<span class="stringliteral">"set"</span> );
        gui.SetVideoMode-&gt;setToolTipText ( L<span class="stringliteral">"Set Video Mode with current values"</span> );

        env-&gt;addStaticText ( L<span class="stringliteral">"Gamma:"</span>, rect&lt;s32&gt;( dim.Width - 400, 104, dim.Width - 310, 120 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
        gui.Gamma = env-&gt;addScrollBar( <span class="keyword">true</span>, rect&lt;s32&gt;( dim.Width - 300, 104, dim.Width - 10, 120 ), gui.Window,-1 );
        gui.Gamma-&gt;setMin ( 50 );
        gui.Gamma-&gt;setMax ( 350 );
        gui.Gamma-&gt;setSmallStep ( 1 );
        gui.Gamma-&gt;setLargeStep ( 10 );
        gui.Gamma-&gt;setPos ( <a class="code" href="namespaceirr_1_1core.html#c230a392b15e3d27c6e2a07a6925a8c4">core::floor32</a> ( Game-&gt;GammaValue * 100.f ) );
        gui.Gamma-&gt;setToolTipText ( L<span class="stringliteral">"Adjust Gamma Ramp ( 0.5 - 3.5)"</span> );
        Game-&gt;Device-&gt;setGammaRamp ( Game-&gt;GammaValue, Game-&gt;GammaValue, Game-&gt;GammaValue, 0.f, 0.f );


        env-&gt;addStaticText ( L<span class="stringliteral">"Tesselation:"</span>, rect&lt;s32&gt;( dim.Width - 400, 124, dim.Width - 310, 140 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
        gui.Tesselation = env-&gt;addScrollBar( <span class="keyword">true</span>, rect&lt;s32&gt;( dim.Width - 300, 124, dim.Width - 10, 140 ), gui.Window,-1 );
        gui.Tesselation-&gt;setMin ( 2 );
        gui.Tesselation-&gt;setMax ( 12 );
        gui.Tesselation-&gt;setSmallStep ( 1 );
        gui.Tesselation-&gt;setLargeStep ( 1 );
        gui.Tesselation-&gt;setPos ( Game-&gt;loadParam.patchTesselation );
        gui.Tesselation-&gt;setToolTipText ( L<span class="stringliteral">"How smooth should curved surfaces be rendered"</span> );

        gui.Collision = env-&gt;addCheckBox ( <span class="keyword">true</span>, rect&lt;s32&gt;( dim.Width - 400, 150, dim.Width - 300, 166 ), gui.Window,-1, L<span class="stringliteral">"Collision"</span> );
        gui.Collision-&gt;setToolTipText ( L<span class="stringliteral">"Set collision on or off ( flythrough ). \nPress F7 on your Keyboard"</span> );
        gui.Visible_Map = env-&gt;addCheckBox ( <span class="keyword">true</span>, rect&lt;s32&gt;( dim.Width - 300, 150, dim.Width - 240, 166 ), gui.Window,-1, L<span class="stringliteral">"Map"</span> );
        gui.Visible_Map-&gt;setToolTipText ( L<span class="stringliteral">"Show or not show the static part the Level. \nPress F3 on your Keyboard"</span> );
        gui.Visible_Shader = env-&gt;addCheckBox ( <span class="keyword">true</span>, rect&lt;s32&gt;( dim.Width - 240, 150, dim.Width - 170, 166 ), gui.Window,-1, L<span class="stringliteral">"Shader"</span> );
        gui.Visible_Shader-&gt;setToolTipText ( L<span class="stringliteral">"Show or not show the Shader Nodes. \nPress F4 on your Keyboard"</span> );
        gui.Visible_Fog = env-&gt;addCheckBox ( <span class="keyword">true</span>, rect&lt;s32&gt;( dim.Width - 170, 150, dim.Width - 110, 166 ), gui.Window,-1, L<span class="stringliteral">"Fog"</span> );
        gui.Visible_Fog-&gt;setToolTipText ( L<span class="stringliteral">"Show or not show the Fog Nodes. \nPress F5 on your Keyboard"</span> );
        gui.Visible_Unresolved = env-&gt;addCheckBox ( <span class="keyword">true</span>, rect&lt;s32&gt;( dim.Width - 110, 150, dim.Width - 10, 166 ), gui.Window,-1, L<span class="stringliteral">"Unresolved"</span> );
        gui.Visible_Unresolved-&gt;setToolTipText ( L<span class="stringliteral">"Show the or not show the Nodes the Engine can't handle. \nPress F6 on your Keyboard"</span> );
        gui.Visible_Skydome = env-&gt;addCheckBox ( <span class="keyword">true</span>, rect&lt;s32&gt;( dim.Width - 110, 180, dim.Width - 10, 196 ), gui.Window,-1, L<span class="stringliteral">"Skydome"</span> );
        gui.Visible_Skydome-&gt;setToolTipText ( L<span class="stringliteral">"Show the or not show the Skydome."</span> );

        <span class="comment">//Respawn = env-&gt;addButton ( rect&lt;s32&gt;( dim.Width - 260, 90, dim.Width - 10, 106 ), 0,-1, L"Respawn" );</span>

        env-&gt;addStaticText ( L<span class="stringliteral">"Archives:"</span>, rect&lt;s32&gt;( 5, dim.Height - 530, dim.Width - 600,dim.Height - 514 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );

        gui.ArchiveAdd = env-&gt;addButton ( rect&lt;s32&gt;( dim.Width - 725, dim.Height - 530, dim.Width - 665, dim.Height - 514 ), gui.Window,-1, L<span class="stringliteral">"add"</span> );
        gui.ArchiveAdd-&gt;setToolTipText ( L<span class="stringliteral">"Add an archive, usually packed zip-archives (*.pk3) to the Filesystem"</span> );
        gui.ArchiveRemove = env-&gt;addButton ( rect&lt;s32&gt;( dim.Width - 660, dim.Height - 530, dim.Width - 600, dim.Height - 514 ), gui.Window,-1, L<span class="stringliteral">"del"</span> );
        gui.ArchiveRemove-&gt;setToolTipText ( L<span class="stringliteral">"Remove the selected archive from the FileSystem."</span> );
        gui.ArchiveUp = env-&gt;addButton ( rect&lt;s32&gt;( dim.Width - 575, dim.Height - 530, dim.Width - 515, dim.Height - 514 ), gui.Window,-1, L<span class="stringliteral">"up"</span> );
        gui.ArchiveUp-&gt;setToolTipText ( L<span class="stringliteral">"Arrange Archive Look-up Hirachy. Move the selected Archive up"</span> );
        gui.ArchiveDown = env-&gt;addButton ( rect&lt;s32&gt;( dim.Width - 510, dim.Height - 530, dim.Width - 440, dim.Height - 514 ), gui.Window,-1, L<span class="stringliteral">"down"</span> );
        gui.ArchiveDown-&gt;setToolTipText ( L<span class="stringliteral">"Arrange Archive Look-up Hirachy. Move the selected Archive down"</span> );


        gui.ArchiveList = env-&gt;addTable ( rect&lt;s32&gt;( 5,dim.Height - 510, dim.Width - 450,dim.Height - 410 ), gui.Window  );
        gui.ArchiveList-&gt;addColumn ( L<span class="stringliteral">"Type"</span>, 0 );
        gui.ArchiveList-&gt;addColumn ( L<span class="stringliteral">"Real File Path"</span>, 1 );
        gui.ArchiveList-&gt;setColumnWidth ( 0, 60 );
        gui.ArchiveList-&gt;setColumnWidth ( 1, 284 );
        gui.ArchiveList-&gt;setToolTipText ( L<span class="stringliteral">"Show the attached Archives"</span> );


        env-&gt;addStaticText ( L<span class="stringliteral">"Maps:"</span>, rect&lt;s32&gt;( 5, dim.Height - 400, dim.Width - 450,dim.Height - 380 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
        gui.MapList = env-&gt;addListBox ( rect&lt;s32&gt;( 5,dim.Height - 380, dim.Width - 450,dim.Height - 40  ), gui.Window, -1, <span class="keyword">true</span>  );
        gui.MapList-&gt;setToolTipText ( L<span class="stringliteral">"Show the current Maps in all Archives.\n Double-Click the Map to start the level"</span> );


        <span class="comment">// create a visible Scene Tree</span>
        env-&gt;addStaticText ( L<span class="stringliteral">"Scenegraph:"</span>, rect&lt;s32&gt;( dim.Width - 400, dim.Height - 400, dim.Width - 5,dim.Height - 380 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
        gui.SceneTree = env-&gt;addTreeView(       rect&lt;s32&gt;( dim.Width - 400, dim.Height - 380, dim.Width - 5, dim.Height - 40 ),
                                                                        gui.Window, -1, <span class="keyword">true</span>, <span class="keyword">true</span>, <span class="keyword">false</span> );
        gui.SceneTree-&gt;setToolTipText ( L<span class="stringliteral">"Show the current Scenegraph"</span> );
        gui.SceneTree-&gt;getRoot()-&gt;clearChilds();
        addSceneTreeItem ( Game-&gt;Device-&gt;getSceneManager()-&gt;getRootSceneNode(), gui.SceneTree-&gt;getRoot() );


        IGUIImageList* imageList = env-&gt;createImageList(        driver-&gt;getTexture ( <span class="stringliteral">"iconlist.png"</span> ),
                                                                                <a class="code" href="namespaceirr_1_1core.html#c79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>( 32, 32 ), true );

        <span class="keywordflow">if</span> ( imageList )
        {
                gui.SceneTree-&gt;setImageList( imageList );
                imageList-&gt;drop ();
        }


        <span class="comment">// load the engine logo</span>
        gui.Logo = env-&gt;addImage( driver-&gt;getTexture(<span class="stringliteral">"irrlichtlogo3.png"</span>), position2d&lt;s32&gt;(5, 16 ), <span class="keyword">true</span>, 0 );
        gui.Logo-&gt;setToolTipText ( L<span class="stringliteral">"The great Irrlicht Engine"</span> );

        AddArchive ( <span class="stringliteral">""</span> );
}
</pre></div><p>
Add an Archive to the FileSystems und updates the GUI <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::AddArchive ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#b1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a>&amp; archiveName )
{
        IFileSystem *fs = Game-&gt;Device-&gt;getFileSystem();
        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i;

        <span class="keywordflow">if</span> ( archiveName.size () )
        {
                <span class="keywordtype">bool</span> exists = <span class="keyword">false</span>;
                <span class="keywordflow">for</span> ( i = 0; i != fs-&gt;getFileArchiveCount(); ++i )
                {
                        <span class="keywordflow">if</span> ( fs-&gt;getFileArchive(i)-&gt;getFileList()-&gt;getPath() == archiveName )
                        {
                                exists = <span class="keyword">true</span>;
                                <span class="keywordflow">break</span>;
                        }
                }

                <span class="keywordflow">if</span> (!exists)
                {
                        fs-&gt;addFileArchive(archiveName, <span class="keyword">true</span>, <span class="keyword">false</span>);
                }
        }

        <span class="comment">// store the current archives in game data</span>
        <span class="comment">// show the attached Archive in proper order</span>
        <span class="keywordflow">if</span> ( gui.ArchiveList )
        {
                gui.ArchiveList-&gt;clearRows();

                <span class="keywordflow">for</span> ( i = 0; i != fs-&gt;getFileArchiveCount(); ++i )
                {
                        IFileArchive * archive = fs-&gt;getFileArchive ( i );

                        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index = gui.ArchiveList-&gt;addRow(i);

                        <a class="code" href="namespaceirr_1_1core.html#ef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> typeName;
                        <span class="keywordflow">switch</span>(archive-&gt;getType())
                        {
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#db3e3c445ec8e608ed1f0f93306da14f63010a52f2efb42f3c85b91ecf077004" title="A PKZIP archive.">io::EFAT_ZIP</a>:
                                typeName = <span class="stringliteral">"ZIP"</span>;
                                <span class="keywordflow">break</span>;
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#db3e3c445ec8e608ed1f0f93306da14f9d37ff1b229bb63f52d29ef65a35b6ce" title="A gzip archive.">io::EFAT_GZIP</a>:
                                typeName = <span class="stringliteral">"gzip"</span>;
                                <span class="keywordflow">break</span>;
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#db3e3c445ec8e608ed1f0f93306da14f1d1f159095f087da5647835b47cd85d4" title="A virtual directory.">io::EFAT_FOLDER</a>:
                                typeName = <span class="stringliteral">"Mount"</span>;
                                <span class="keywordflow">break</span>;
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#db3e3c445ec8e608ed1f0f93306da14fae9e1788acfc49c30a77f80f5ced7cf5" title="An ID Software PAK archive.">io::EFAT_PAK</a>:
                                typeName = <span class="stringliteral">"PAK"</span>;
                                <span class="keywordflow">break</span>;
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#db3e3c445ec8e608ed1f0f93306da14f0f36ce25d47b45f41a58e32b4c029cb6" title="A Tape ARchive.">io::EFAT_TAR</a>:
                                typeName = <span class="stringliteral">"TAR"</span>;
                                <span class="keywordflow">break</span>;
                        <span class="keywordflow">default</span>:
                                typeName = <span class="stringliteral">"archive"</span>;
                        }

                        gui.ArchiveList-&gt;setCellText ( index, 0, typeName );
                        gui.ArchiveList-&gt;setCellText ( index, 1, archive-&gt;getFileList()-&gt;getPath() );
                }
        }


        <span class="comment">// browse the archives for maps</span>
        <span class="keywordflow">if</span> ( gui.MapList )
        {
                gui.MapList-&gt;clear();

                IGUISpriteBank *bank = Game-&gt;Device-&gt;getGUIEnvironment()-&gt;getSpriteBank(<span class="stringliteral">"sprite_q3map"</span>);
                <span class="keywordflow">if</span> ( 0 == bank )
                        bank = Game-&gt;Device-&gt;getGUIEnvironment()-&gt;addEmptySpriteBank(<span class="stringliteral">"sprite_q3map"</span>);

                SGUISprite sprite;
                SGUISpriteFrame frame;
                core::rect&lt;s32&gt; r;

                bank-&gt;getSprites().clear();
                bank-&gt;getPositions().clear ();
                gui.MapList-&gt;setSpriteBank ( bank );

                <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> g = 0;
                <a class="code" href="namespaceirr_1_1core.html#ef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> s;

                <span class="comment">// browse the attached file system</span>
                fs-&gt;setFileListSystem ( <a class="code" href="namespaceirr_1_1io.html#22364f1caf06442a70f6198025af3fe994a9818df56a8fe16b1c7c6f44e8f9f3">FILESYSTEM_VIRTUAL</a> );
                fs-&gt;changeWorkingDirectoryTo ( <span class="stringliteral">"/maps/"</span> );
                IFileList *fileList = fs-&gt;createFileList ();
                fs-&gt;setFileListSystem ( <a class="code" href="namespaceirr_1_1io.html#22364f1caf06442a70f6198025af3fe9cfbc9e5e8773ec885f08eafd6c8d3c6f">FILESYSTEM_NATIVE</a> );

                <span class="keywordflow">for</span> ( i=0; i&lt; fileList-&gt;getFileCount(); ++i)
                {
                        s = fileList-&gt;getFullFileName(i);
                        <span class="keywordflow">if</span> ( s.find ( <span class="stringliteral">".bsp"</span> ) &gt;= 0 )
                        {
                                <span class="comment">// get level screenshot. reformat texture to 128x128</span>
                                <a class="code" href="namespaceirr_1_1io.html#b1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> c ( s );
                                <a class="code" href="namespaceirr_1_1core.html#e1cc66c353bdae2778348d6fd0d3cea6" title="delete path from filename">deletePathFromFilename</a> ( c );
                                <a class="code" href="namespaceirr_1_1core.html#62855628b4159f43e3d264d63832b6e1" title="cut the filename extension from a source string and stores in the dest string">cutFilenameExtension</a> ( c, c );
                                c = <a class="code" href="namespaceirr_1_1io.html#b1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> ( <span class="stringliteral">"levelshots/"</span> ) + c;

                                <a class="code" href="namespaceirr_1_1core.html#d2e562e3219072e2f7fc7c2bba0ef0cb" title="Typedef for an unsigned integer dimension.">dimension2du</a> dim ( 128, 128 );
                                IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();
                                IImage* image = 0;
                                ITexture *tex = 0;
                                <a class="code" href="namespaceirr_1_1io.html#b1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> filename;

                                filename = c + <span class="stringliteral">".jpg"</span>;
                                <span class="keywordflow">if</span> ( fs-&gt;existFile ( filename ) )
                                        image = driver-&gt;createImageFromFile( filename );
                                <span class="keywordflow">if</span> ( 0 == image )
                                {
                                        filename = c + <span class="stringliteral">".tga"</span>;
                                        <span class="keywordflow">if</span> ( fs-&gt;existFile ( filename ) )
                                                image = driver-&gt;createImageFromFile( filename );
                                }

                                <span class="keywordflow">if</span> ( image )
                                {
                                        IImage* filter = driver-&gt;createImage ( <a class="code" href="namespaceirr_1_1video.html#1d5e487888c32b1674a8f75116d829ed3f0380aafb1e1fd59f5419a95d630a6d" title="24 bit color, no alpha channel, but 8 bit for red, green and blue.">video::ECF_R8G8B8</a>, dim );
                                        image-&gt;copyToScalingBoxFilter ( filter, 0 );
                                        image-&gt;drop ();
                                        image = filter;
                                }

                                <span class="keywordflow">if</span> ( image )
                                {
                                        tex = driver-&gt;addTexture ( filename, image );
                                        image-&gt;drop ();
                                }


                                bank-&gt;setTexture ( g, tex );

                                r.LowerRightCorner.X = dim.Width;
                                r.LowerRightCorner.Y = dim.Height;
                                gui.MapList-&gt;setItemHeight ( r.LowerRightCorner.Y + 4 );
                                frame.rectNumber = bank-&gt;getPositions().size();
                                frame.textureNumber = g;

                                bank-&gt;getPositions().push_back(r);

                                sprite.Frames.set_used ( 0 );
                                sprite.Frames.push_back(frame);
                                sprite.frameTime = 0;
                                bank-&gt;getSprites().push_back(sprite);

                                gui.MapList-&gt;addItem ( s.c_str (), g );
                                g += 1;
                        }
                }
                fileList-&gt;drop ();

                gui.MapList-&gt;setSelected ( -1 );
                IGUIScrollBar * bar = (IGUIScrollBar*)gui.MapList-&gt;getElementFromId( 0 );
                <span class="keywordflow">if</span> ( bar )
                        bar-&gt;setPos ( 0 );

        }

}
</pre></div><p>
clears the Map in Memory <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::dropMap ()
{
        IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();

        driver-&gt;removeAllHardwareBuffers ();
        driver-&gt;removeAllTextures ();

        Player[0].shutdown ();


        dropElement ( ItemParent );
        dropElement ( ShaderParent );
        dropElement ( UnresolvedParent );
        dropElement ( FogParent );
        dropElement ( BulletParent );


        Impacts.clear();

        <span class="keywordflow">if</span> ( Meta )
        {
                Meta = 0;
        }

        dropElement ( MapParent );
        dropElement ( SkyNode );

        <span class="comment">// clean out meshes, because textures are invalid</span>
        <span class="comment">// TODO: better texture handling;-)</span>
        IMeshCache *cache = Game-&gt;Device-&gt;getSceneManager ()-&gt;getMeshCache();
        cache-&gt;clear ();
        Mesh = 0;
}
</pre></div> Load new map <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::LoadMap ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#ef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> &amp;mapName, <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> collision )
{
        <span class="keywordflow">if</span> ( 0 == mapName.size() )
                <span class="keywordflow">return</span>;

        dropMap ();

        IFileSystem *fs = Game-&gt;Device-&gt;getFileSystem();
        ISceneManager *smgr = Game-&gt;Device-&gt;getSceneManager ();

        IReadFile* file = fs-&gt;createMemoryReadFile ( &amp;Game-&gt;loadParam, sizeof ( Game-&gt;loadParam ),
                                                                                                        L<span class="stringliteral">"levelparameter.cfg"</span>, <span class="keyword">false</span>);

        smgr-&gt;getMesh( file );
        file-&gt;drop ();

        Mesh = (IQ3LevelMesh*) smgr-&gt;getMesh(mapName);
        <span class="keywordflow">if</span> ( 0 == Mesh )
                <span class="keywordflow">return</span>;
</pre></div><p>
add the geometry mesh to the Scene ( polygon &amp; patches ) The Geometry mesh is optimised for faster drawing <div class="fragment"><pre class="fragment">        IMesh *geometry = Mesh-&gt;getMesh(<a class="code" href="namespaceirr_1_1scene_1_1quake3.html#44a1a489a965cc9a0ad2c235bbb7bf3310a5968f2ec9c929bfbca721780a7ef6">E_Q3_MESH_GEOMETRY</a>);
        <span class="keywordflow">if</span> ( 0 == geometry || geometry-&gt;getMeshBufferCount() == 0)
                <span class="keywordflow">return</span>;

        Game-&gt;CurrentMapName = mapName;

        <span class="comment">//create a collision list</span>
        Meta = 0;

        ITriangleSelector * selector = 0;
        <span class="keywordflow">if</span> (collision)
                Meta = smgr-&gt;createMetaTriangleSelector();

        <span class="comment">//IMeshBuffer *b0 = geometry-&gt;getMeshBuffer(0);</span>
        <span class="comment">//s32 minimalNodes = b0 ? core::s32_max ( 2048, b0-&gt;getVertexCount() / 32 ) : 2048;</span>
        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> minimalNodes = 2048;

        MapParent = smgr-&gt;addMeshSceneNode( geometry );
        <span class="comment">//MapParent = smgr-&gt;addOctTreeSceneNode(geometry, 0, -1, minimalNodes);</span>
        MapParent-&gt;setName ( mapName );
        <span class="keywordflow">if</span> ( Meta )
        {
                selector = smgr-&gt;createOctTreeTriangleSelector( geometry,MapParent, minimalNodes);
                <span class="comment">//selector = smgr-&gt;createTriangleSelector ( geometry, MapParent );</span>
                Meta-&gt;addTriangleSelector( selector);
                selector-&gt;drop ();
        }

        <span class="comment">// logical parent for the items</span>
        ItemParent = smgr-&gt;addEmptySceneNode();
        <span class="keywordflow">if</span> ( ItemParent )
                ItemParent-&gt;setName ( <span class="stringliteral">"Item Container"</span> );

        ShaderParent = smgr-&gt;addEmptySceneNode();
        <span class="keywordflow">if</span> ( ShaderParent )
                ShaderParent-&gt;setName ( <span class="stringliteral">"Shader Container"</span> );

        UnresolvedParent = smgr-&gt;addEmptySceneNode();
        <span class="keywordflow">if</span> ( UnresolvedParent )
                UnresolvedParent-&gt;setName ( <span class="stringliteral">"Unresolved Container"</span> );

        FogParent = smgr-&gt;addEmptySceneNode();
        <span class="keywordflow">if</span> ( FogParent )
                FogParent-&gt;setName ( <span class="stringliteral">"Fog Container"</span> );

        <span class="comment">// logical parent for the bullets</span>
        BulletParent = smgr-&gt;addEmptySceneNode();
        <span class="keywordflow">if</span> ( BulletParent )
                BulletParent-&gt;setName ( <span class="stringliteral">"Bullet Container"</span> );
</pre></div><p>
now construct SceneNodes for each Shader The Objects are stored in the quake mesh E_Q3_MESH_ITEMS and the Shader ID is stored in the MaterialParameters mostly dark looking skulls and moving lava.. or green flashing tubes? <div class="fragment"><pre class="fragment">        Q3ShaderFactory ( Game-&gt;loadParam, Game-&gt;Device, Mesh, <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#44a1a489a965cc9a0ad2c235bbb7bf3315b1dd0b29d69900d070346d61f44319">E_Q3_MESH_ITEMS</a>,ShaderParent, Meta, <span class="keyword">false</span> );
        Q3ShaderFactory ( Game-&gt;loadParam, Game-&gt;Device, Mesh, <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#44a1a489a965cc9a0ad2c235bbb7bf338679450d9dcdd4d1b22f38bbd059740b">E_Q3_MESH_FOG</a>,FogParent, 0, <span class="keyword">false</span> );
        Q3ShaderFactory ( Game-&gt;loadParam, Game-&gt;Device, Mesh, <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#44a1a489a965cc9a0ad2c235bbb7bf339690978438eed9b5e39c7a87e9235b1d">E_Q3_MESH_UNRESOLVED</a>,UnresolvedParent, Meta, <span class="keyword">true</span> );
</pre></div><p>
Now construct Models from Entity List <div class="fragment"><pre class="fragment">        Q3ModelFactory ( Game-&gt;loadParam, Game-&gt;Device, Mesh, ItemParent, <span class="keyword">false</span> );

}
</pre></div><p>
Adds a SceneNode with an icon to the Scene Tree <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::addSceneTreeItem( ISceneNode * parent, IGUITreeViewNode* nodeParent)
{
        IGUITreeViewNode* node;
        <span class="keywordtype">wchar_t</span> msg[128];

        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> imageIndex;
        list&lt;ISceneNode*&gt;::ConstIterator it = parent-&gt;getChildren().begin();
        <span class="keywordflow">for</span> (; it != parent-&gt;getChildren().end(); ++it)
        {
                <span class="keywordflow">switch</span> ( (*it)-&gt;getType () )
                {
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#cad3d7ef92a9807d391ba29120f3b7bd240e6f8e61816ea8f0cdf840b457734c" title="Quake3 Shader Scene Node.">ESNT_Q3SHADER_SCENE_NODE</a>: imageIndex = 0; <span class="keywordflow">break</span>;
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#cad3d7ef92a9807d391ba29120f3b7bd117834c96690a72567a0a813708cf3b6" title="Camera Scene Node.">ESNT_CAMERA</a>: imageIndex = 1; <span class="keywordflow">break</span>;
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#cad3d7ef92a9807d391ba29120f3b7bd977d9500eeb4d4f23e5676a312367f57" title="Empty Scene Node.">ESNT_EMPTY</a>: imageIndex = 2; <span class="keywordflow">break</span>;
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#cad3d7ef92a9807d391ba29120f3b7bd25998267ed8640ca0c432df23f1b71fe" title="Mesh Scene Node.">ESNT_MESH</a>: imageIndex = 3; <span class="keywordflow">break</span>;
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#cad3d7ef92a9807d391ba29120f3b7bd4c5badb04555328f19aef514e077ca5a" title="OctTree Scene Node.">ESNT_OCT_TREE</a>: imageIndex = 3; <span class="keywordflow">break</span>;
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#cad3d7ef92a9807d391ba29120f3b7bd073d7fe9dfd49f24cb13bfae56d8d3b6" title="Animated Mesh Scene Node.">ESNT_ANIMATED_MESH</a>: imageIndex = 4; <span class="keywordflow">break</span>;
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#cad3d7ef92a9807d391ba29120f3b7bdc47a4c2ad206e916f080ad28faed7f3b" title="Sky Box Scene Node.">ESNT_SKY_BOX</a>: imageIndex = 5; <span class="keywordflow">break</span>;
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#cad3d7ef92a9807d391ba29120f3b7bd85e4b3fca8fceb3de9057e91926d2a5f" title="Billboard Scene Node.">ESNT_BILLBOARD</a>: imageIndex = 6; <span class="keywordflow">break</span>;
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#cad3d7ef92a9807d391ba29120f3b7bdb027cde22a402f6f7f19eb714acf26a4" title="Particle System Scene Node.">ESNT_PARTICLE_SYSTEM</a>: imageIndex = 7; <span class="keywordflow">break</span>;
                        <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#cad3d7ef92a9807d391ba29120f3b7bd65e7b71bf270e10f94d88bcab8cbf184" title="Text Scene Node.">ESNT_TEXT</a>: imageIndex = 8; <span class="keywordflow">break</span>;
                        <span class="keywordflow">default</span>:imageIndex = -1; <span class="keywordflow">break</span>;
                }

                <span class="keywordflow">if</span> ( imageIndex &lt; 0 )
                {
                        swprintf ( msg, 128, L<span class="stringliteral">"%hs,%hs"</span>,
                                Game-&gt;Device-&gt;getSceneManager ()-&gt;getSceneNodeTypeName ( (*it)-&gt;getType () ),
                                (*it)-&gt;getName()
                                );
                }
                <span class="keywordflow">else</span>
                {
                        swprintf ( msg, 128, L<span class="stringliteral">"%hs"</span>,(*it)-&gt;getName() );
                }

                node = nodeParent-&gt;addChildBack( msg, 0, imageIndex );

                <span class="comment">// Add all Animators</span>
                list&lt;ISceneNodeAnimator*&gt;::ConstIterator ait = (*it)-&gt;getAnimators().begin();
                <span class="keywordflow">for</span> (; ait != (*it)-&gt;getAnimators().end(); ++ait)
                {
                        imageIndex = -1;
                        swprintf ( msg, 128, L<span class="stringliteral">"%hs"</span>,
                                Game-&gt;Device-&gt;getSceneManager ()-&gt;getAnimatorTypeName ( (*ait)-&gt;getType () )
                                );

                        <span class="keywordflow">switch</span> ( (*ait)-&gt;getType () )
                        {
                                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#327a1e43872705cf8f3f3342fb307d19dd5f15ecd6c0209d4e3d81a287ae9a66" title="Fly circle scene node animator.">ESNAT_FLY_CIRCLE</a>:
                                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#327a1e43872705cf8f3f3342fb307d19f71dad2be8d964a88329d2727fb53b74" title="Fly straight scene node animator.">ESNAT_FLY_STRAIGHT</a>:
                                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#327a1e43872705cf8f3f3342fb307d19ddc7e3bb5180f7087546ccab14dcc4ad" title="Follow spline scene node animator.">ESNAT_FOLLOW_SPLINE</a>:
                                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#327a1e43872705cf8f3f3342fb307d19689aa5051e83b7f61a7abba85eb1be52" title="Rotation scene node animator.">ESNAT_ROTATION</a>:
                                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#327a1e43872705cf8f3f3342fb307d192f3e75035fbb3227189a0a3d8bcda993" title="Texture scene node animator.">ESNAT_TEXTURE</a>:
                                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#327a1e43872705cf8f3f3342fb307d19bbafee6e6a120e26a6e1ed6bd3cbdc86" title="Deletion scene node animator.">ESNAT_DELETION</a>:
                                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#327a1e43872705cf8f3f3342fb307d19f5889b6449faa50d3fabd005d4493490" title="Collision respose scene node animator.">ESNAT_COLLISION_RESPONSE</a>:
                                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#327a1e43872705cf8f3f3342fb307d19e40c836272ace5bf243baaca72dba55c" title="FPS camera animator.">ESNAT_CAMERA_FPS</a>:
                                <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#327a1e43872705cf8f3f3342fb307d19851338028c38a91643f70d2a2e5ff8c4" title="Maya camera animator.">ESNAT_CAMERA_MAYA</a>:
                                <span class="keywordflow">default</span>:
                                        <span class="keywordflow">break</span>;
                        }
                        node-&gt;addChildBack( msg, 0, imageIndex );
                }

                addSceneTreeItem ( *it, node );
        }

}


<span class="comment">// Adds life!</span>
<span class="keywordtype">void</span> CQuake3EventHandler::CreatePlayers()
{
        Player[0].create ( Game-&gt;Device, Mesh, MapParent, Meta );
}

<span class="comment">// Adds a skydome to the scene</span>
<span class="keywordtype">void</span> CQuake3EventHandler::AddSky( <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> dome, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *texture)
{
        ISceneManager *smgr = Game-&gt;Device-&gt;getSceneManager ();
        IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();

        <span class="keywordtype">bool</span> oldMipMapState = driver-&gt;getTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#caf6f7414534f7d62bff18c5bf11876f288b302e9d4faaba80c7796c7bc1682c">video::ETCF_CREATE_MIP_MAPS</a>);
        driver-&gt;setTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#caf6f7414534f7d62bff18c5bf11876f288b302e9d4faaba80c7796c7bc1682c">video::ETCF_CREATE_MIP_MAPS</a>, <span class="keyword">false</span>);

        <span class="keywordflow">if</span> ( 0 == dome )
        {
                <span class="comment">// irrlicht order</span>
                <span class="comment">//static const c8*p[] = { "ft", "lf", "bk", "rt", "up", "dn" };</span>
                <span class="comment">// quake3 order</span>
                <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a>*p[] = { <span class="stringliteral">"ft"</span>, <span class="stringliteral">"rt"</span>, <span class="stringliteral">"bk"</span>, <span class="stringliteral">"lf"</span>, <span class="stringliteral">"up"</span>, <span class="stringliteral">"dn"</span> };

                <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i = 0;
                snprintf ( buf, 64, <span class="stringliteral">"%s_%s.jpg"</span>, texture, p[i] );
                SkyNode = smgr-&gt;addSkyBoxSceneNode( driver-&gt;getTexture ( buf ), 0, 0, 0, 0, 0 );

                <span class="keywordflow">if</span> (SkyNode)
                {
                        <span class="keywordflow">for</span> ( i = 0; i &lt; 6; ++i )
                        {
                                snprintf ( buf, 64, <span class="stringliteral">"%s_%s.jpg"</span>, texture, p[i] );
                                SkyNode-&gt;getMaterial(i).setTexture ( 0, driver-&gt;getTexture ( buf ) );
                        }
                }
        }
        <span class="keywordflow">else</span>
        <span class="keywordflow">if</span> ( 1 == dome )
        {
                snprintf ( buf, 64, <span class="stringliteral">"%s.jpg"</span>, texture );
                SkyNode = smgr-&gt;addSkyDomeSceneNode(
                        driver-&gt;getTexture( buf ),
                        32,32,
                        1.f,
                        1.f,
                        1000.f,
                        0,
                        11
                        );
        }
        <span class="keywordflow">else</span>
        <span class="keywordflow">if</span> ( 2 == dome )
        {
                snprintf ( buf, 64, <span class="stringliteral">"%s.jpg"</span>, texture );
                SkyNode = smgr-&gt;addSkyDomeSceneNode(
                        driver-&gt;getTexture( buf ),
                        16,8,
                        0.95f,
                        2.f,
                        1000.f,
                        0,
                        11
                        );
        }

        <span class="keywordflow">if</span> (SkyNode)
                SkyNode-&gt;setName(<span class="stringliteral">"Skydome"</span>);
        <span class="comment">//SkyNode-&gt;getMaterial(0).ZBuffer = video::EMDF_DEPTH_LESS_EQUAL;</span>

        driver-&gt;setTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#caf6f7414534f7d62bff18c5bf11876f288b302e9d4faaba80c7796c7bc1682c">video::ETCF_CREATE_MIP_MAPS</a>, oldMipMapState);

}


<span class="comment">// enable GUI elements</span>
<span class="keywordtype">void</span> CQuake3EventHandler::SetGUIActive( <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> command)
{
        <span class="keywordtype">bool</span> inputState = <span class="keyword">false</span>;

        ICameraSceneNode * camera = Game-&gt;Device-&gt;getSceneManager()-&gt;getActiveCamera ();

        <span class="keywordflow">switch</span> ( command )
        {
                <span class="keywordflow">case</span> 0: Game-&gt;guiActive = 0; inputState = !Game-&gt;guiActive; <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 1: Game-&gt;guiActive = 1; inputState = !Game-&gt;guiActive;;<span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 2: Game-&gt;guiActive ^= 1; inputState = !Game-&gt;guiActive;<span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> 3:
                        <span class="keywordflow">if</span> ( camera )
                                inputState = !camera-&gt;isInputReceiverEnabled();
                        <span class="keywordflow">break</span>;
        }

        <span class="keywordflow">if</span> ( camera )
        {
                camera-&gt;setInputReceiverEnabled ( inputState );
                Game-&gt;Device-&gt;getCursorControl()-&gt;setVisible( !inputState );
        }

        <span class="keywordflow">if</span> ( gui.Window )
        {
                gui.Window-&gt;setVisible ( Game-&gt;guiActive != 0 );
        }

        <span class="keywordflow">if</span> ( Game-&gt;guiActive &amp;&amp;
                        gui.SceneTree &amp;&amp; Game-&gt;Device-&gt;getGUIEnvironment()-&gt;getFocus() != gui.SceneTree
                )
        {
                gui.SceneTree-&gt;getRoot()-&gt;clearChilds();
                addSceneTreeItem ( Game-&gt;Device-&gt;getSceneManager()-&gt;getRootSceneNode(), gui.SceneTree-&gt;getRoot() );
        }

        Game-&gt;Device-&gt;getGUIEnvironment()-&gt;setFocus ( Game-&gt;guiActive ? gui.Window: 0 );
}
</pre></div><p>
Handle game input <div class="fragment"><pre class="fragment"><span class="keywordtype">bool</span> CQuake3EventHandler::OnEvent(<span class="keyword">const</span> SEvent&amp; eve)
{
        <span class="keywordflow">if</span> ( eve.EventType == <a class="code" href="namespaceirr.html#c9eed96e06e85ce3c86fcbbbe9e48a0c8553b889c8da285c96b90116ae019952" title="A log event.">EET_LOG_TEXT_EVENT</a> )
        {
                <span class="keywordflow">return</span> <span class="keyword">false</span>;
        }

        <span class="keywordflow">if</span> ( Game-&gt;guiActive &amp;&amp; eve.EventType == <a class="code" href="namespaceirr.html#c9eed96e06e85ce3c86fcbbbe9e48a0ce85bb44dd09a29c879d64a05047fc1d2" title="An event of the graphical user interface.">EET_GUI_EVENT</a> )
        {
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.MapList &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d5768083f3c374a3c74405ee3eac6973e78345f" title="An item in the listbox was selected, which was already selected.">gui::EGET_LISTBOX_SELECTED_AGAIN</a> )
                {
                        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selected = gui.MapList-&gt;getSelected();
                        <span class="keywordflow">if</span> ( selected &gt;= 0 )
                        {
                                <a class="code" href="namespaceirr_1_1core.html#ef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> loadMap = gui.MapList-&gt;getListItem ( selected );
                                <span class="keywordflow">if</span> ( 0 == MapParent || loadMap != Game-&gt;CurrentMapName )
                                {
                                        printf ( <span class="stringliteral">"Loading map %ls\n"</span>, loadMap.c_str() );
                                        LoadMap ( loadMap , 1 );
                                        <span class="keywordflow">if</span> ( 0 == Game-&gt;loadParam.loadSkyShader )
                                        {
                                                AddSky ( 1, <span class="stringliteral">"skydome2"</span> );
                                        }
                                        CreatePlayers ();
                                        CreateGUI ();
                                        SetGUIActive ( 0 );
                                        <span class="keywordflow">return</span> <span class="keyword">true</span>;
                                }
                        }
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveRemove &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d576808308ee345c92444931f83e48354072d98" title="A button was clicked.">gui::EGET_BUTTON_CLICKED</a> )
                {
                        Game-&gt;Device-&gt;getFileSystem()-&gt;removeFileArchive( gui.ArchiveList-&gt;getSelected() );
                        Game-&gt;CurrentMapName = <span class="stringliteral">""</span>;
                        AddArchive ( <span class="stringliteral">""</span> );
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveAdd &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d576808308ee345c92444931f83e48354072d98" title="A button was clicked.">gui::EGET_BUTTON_CLICKED</a> )
                {
                        <span class="keywordflow">if</span> ( 0 == gui.ArchiveFileOpen )
                        {
                                Game-&gt;Device-&gt;getFileSystem()-&gt;setFileListSystem ( <a class="code" href="namespaceirr_1_1io.html#22364f1caf06442a70f6198025af3fe9cfbc9e5e8773ec885f08eafd6c8d3c6f">FILESYSTEM_NATIVE</a> );
                                gui.ArchiveFileOpen = Game-&gt;Device-&gt;getGUIEnvironment()-&gt;addFileOpenDialog ( L<span class="stringliteral">"Add Game Archive"</span> , <span class="keyword">false</span>,gui.Window  );
                        }
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveFileOpen &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d5768085b6504cf6b541d5ad95407c384632873" title="A file has been selected in the file dialog.">gui::EGET_FILE_SELECTED</a> )
                {
                        AddArchive ( gui.ArchiveFileOpen-&gt;getFileName() );
                        gui.ArchiveFileOpen = 0;
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveFileOpen &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d5768080c8a9e059bd8efe74e2f747e2e9187b3" title="A directory has been selected in the file dialog.">gui::EGET_DIRECTORY_SELECTED</a> )
                {
                        AddArchive ( gui.ArchiveFileOpen-&gt;getDirectoryName() );
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveFileOpen &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d576808e524b2c68bc8c3117c6ae7a2d2df7865" title="A file open dialog has been closed without choosing a file.">gui::EGET_FILE_CHOOSE_DIALOG_CANCELLED</a> )
                {
                        gui.ArchiveFileOpen = 0;
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( ( eve.GUIEvent.Caller == gui.ArchiveUp || eve.GUIEvent.Caller == gui.ArchiveDown ) &amp;&amp;
                        eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d576808308ee345c92444931f83e48354072d98" title="A button was clicked.">gui::EGET_BUTTON_CLICKED</a> )
                {
                        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> rel = eve.GUIEvent.Caller == gui.ArchiveUp ? -1 : 1;
                        <span class="keywordflow">if</span> ( Game-&gt;Device-&gt;getFileSystem()-&gt;moveFileArchive ( gui.ArchiveList-&gt;getSelected (), rel ) )
                        {
                                <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> newIndex = <a class="code" href="namespaceirr_1_1core.html#a7828c932a36c62a67fd0f2b972d8b21">core::s32_clamp</a> ( gui.ArchiveList-&gt;getSelected() + rel, 0, gui.ArchiveList-&gt;getRowCount() - 1 );
                                AddArchive ( <span class="stringliteral">""</span> );
                                gui.ArchiveList-&gt;setSelected ( newIndex );
                                Game-&gt;CurrentMapName = <span class="stringliteral">""</span>;
                        }
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.VideoDriver &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d576808ef7f9081622a71160e161c80eb07d436" title="The selection in a combo box has been changed.">gui::EGET_COMBO_BOX_CHANGED</a> )
                {
                        Game-&gt;deviceParam.DriverType = (<a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d0" title="An enum for all types of drivers the Irrlicht Engine supports.">E_DRIVER_TYPE</a>) gui.VideoDriver-&gt;getItemData ( gui.VideoDriver-&gt;getSelected() );
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.VideoMode &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d576808ef7f9081622a71160e161c80eb07d436" title="The selection in a combo box has been changed.">gui::EGET_COMBO_BOX_CHANGED</a> )
                {
                        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> val = gui.VideoMode-&gt;getItemData ( gui.VideoMode-&gt;getSelected() );
                        Game-&gt;deviceParam.WindowSize.Width = val &gt;&gt; 16;
                        Game-&gt;deviceParam.WindowSize.Height = val &amp; 0xFFFF;
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.FullScreen &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d57680816a1f6de4aeb2d7f34f7b7dbff0a7a0a" title="A checkbox has changed its check state.">gui::EGET_CHECKBOX_CHANGED</a> )
                {
                        Game-&gt;deviceParam.Fullscreen = gui.FullScreen-&gt;isChecked();
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Bit32 &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d57680816a1f6de4aeb2d7f34f7b7dbff0a7a0a" title="A checkbox has changed its check state.">gui::EGET_CHECKBOX_CHANGED</a> )
                {
                        Game-&gt;deviceParam.Bits = gui.Bit32-&gt;isChecked() ? 32 : 16;
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.MultiSample &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d5768082eea536494edcde2bb2608bda9d352b2" title="A scrollbar has changed its position.">gui::EGET_SCROLL_BAR_CHANGED</a> )
                {
                        Game-&gt;deviceParam.AntiAlias = gui.MultiSample-&gt;getPos();
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Tesselation &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d5768082eea536494edcde2bb2608bda9d352b2" title="A scrollbar has changed its position.">gui::EGET_SCROLL_BAR_CHANGED</a> )
                {
                        Game-&gt;loadParam.patchTesselation = gui.Tesselation-&gt;getPos ();
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Gamma &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d5768082eea536494edcde2bb2608bda9d352b2" title="A scrollbar has changed its position.">gui::EGET_SCROLL_BAR_CHANGED</a> )
                {
                        Game-&gt;GammaValue = gui.Gamma-&gt;getPos () * 0.01f;
                        Game-&gt;Device-&gt;setGammaRamp ( Game-&gt;GammaValue, Game-&gt;GammaValue, Game-&gt;GammaValue, 0.f, 0.f );
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.SetVideoMode &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d576808308ee345c92444931f83e48354072d98" title="A button was clicked.">gui::EGET_BUTTON_CLICKED</a> )
                {
                        Game-&gt;retVal = 2;
                        Game-&gt;Device-&gt;closeDevice();
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Window &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d5768089879e90ebeaf90f3ec7477acc1a46749" title="An element would like to close.">gui::EGET_ELEMENT_CLOSED</a> )
                {
                        Game-&gt;Device-&gt;closeDevice();
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Collision &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d57680816a1f6de4aeb2d7f34f7b7dbff0a7a0a" title="A checkbox has changed its check state.">gui::EGET_CHECKBOX_CHANGED</a> )
                {
                        <span class="comment">// set fly through active</span>
                        Game-&gt;flyTroughState ^= 1;
                        Player[0].cam()-&gt;setAnimateTarget ( Game-&gt;flyTroughState == 0 );

                        printf ( <span class="stringliteral">"collision %d\n"</span>, Game-&gt;flyTroughState == 0 );
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Visible_Map &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d57680816a1f6de4aeb2d7f34f7b7dbff0a7a0a" title="A checkbox has changed its check state.">gui::EGET_CHECKBOX_CHANGED</a> )
                {
                        <span class="keywordtype">bool</span> v = gui.Visible_Map-&gt;isChecked();

                        <span class="keywordflow">if</span> ( MapParent )
                        {
                                printf ( <span class="stringliteral">"static node set visible %d\n"</span>,v );
                                MapParent-&gt;setVisible ( v );
                        }
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Visible_Shader &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d57680816a1f6de4aeb2d7f34f7b7dbff0a7a0a" title="A checkbox has changed its check state.">gui::EGET_CHECKBOX_CHANGED</a> )
                {
                        <span class="keywordtype">bool</span> v = gui.Visible_Shader-&gt;isChecked();

                        <span class="keywordflow">if</span> ( ShaderParent )
                        {
                                printf ( <span class="stringliteral">"shader node set visible %d\n"</span>,v );
                                ShaderParent-&gt;setVisible ( v );
                        }
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Visible_Skydome &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d57680816a1f6de4aeb2d7f34f7b7dbff0a7a0a" title="A checkbox has changed its check state.">gui::EGET_CHECKBOX_CHANGED</a> )
                {
                        <span class="keywordflow">if</span> ( SkyNode )
                        {
                                <span class="keywordtype">bool</span> v = !SkyNode-&gt;isVisible();
                                printf ( <span class="stringliteral">"skynode set visible %d\n"</span>,v );
                                SkyNode-&gt;setVisible ( v );
                        }
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Respawn &amp;&amp; eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#eac71ad17341a4b6e9026ae11d576808308ee345c92444931f83e48354072d98" title="A button was clicked.">gui::EGET_BUTTON_CLICKED</a> )
                {
                        Player[0].respawn ();
                }

                <span class="keywordflow">return</span> <span class="keyword">false</span>;
        }

        <span class="comment">// fire</span>
        <span class="keywordflow">if</span> ((eve.EventType == <a class="code" href="namespaceirr.html#c9eed96e06e85ce3c86fcbbbe9e48a0c6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">EET_KEY_INPUT_EVENT</a> &amp;&amp; eve.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb352c3b1744ca8ae7b6da19fc00fbb8ee8">KEY_SPACE</a> &amp;&amp;
                eve.KeyInput.PressedDown == <span class="keyword">false</span>) ||
                (eve.EventType == <a class="code" href="namespaceirr.html#c9eed96e06e85ce3c86fcbbbe9e48a0ca230b748674e074aa67f661819ad5891" title="A mouse input event.">EET_MOUSE_INPUT_EVENT</a> &amp;&amp; eve.MouseInput.Event == <a class="code" href="namespaceirr.html#2dbf2a247aa17a9eeefbbf36ebd5739f26d91b99a8912ff622133f02c60f306a" title="Left mouse button was left up.">EMIE_LMOUSE_LEFT_UP</a>)
                )
        {
                ICameraSceneNode * camera = Game-&gt;Device-&gt;getSceneManager()-&gt;getActiveCamera ();
                <span class="keywordflow">if</span> ( camera &amp;&amp; camera-&gt;isInputReceiverEnabled () )
                {
                        useItem( Player + 0 );
                }
        }

        <span class="comment">// gui active</span>
        <span class="keywordflow">if</span> ((eve.EventType == <a class="code" href="namespaceirr.html#c9eed96e06e85ce3c86fcbbbe9e48a0c6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">EET_KEY_INPUT_EVENT</a> &amp;&amp; eve.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb35427274e34fd5587155fe8b3b12d96a8">KEY_F1</a> &amp;&amp;
                eve.KeyInput.PressedDown == <span class="keyword">false</span>) ||
                (eve.EventType == <a class="code" href="namespaceirr.html#c9eed96e06e85ce3c86fcbbbe9e48a0ca230b748674e074aa67f661819ad5891" title="A mouse input event.">EET_MOUSE_INPUT_EVENT</a> &amp;&amp; eve.MouseInput.Event == <a class="code" href="namespaceirr.html#2dbf2a247aa17a9eeefbbf36ebd5739fdb92d5c1011534b2b18065573182d9f4" title="Right mouse button was left up.">EMIE_RMOUSE_LEFT_UP</a>)
                )
        {
                SetGUIActive ( 2 );
        }

        <span class="comment">// check if user presses the key</span>
        <span class="keywordflow">if</span> ( eve.EventType == <a class="code" href="namespaceirr.html#c9eed96e06e85ce3c86fcbbbe9e48a0c6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">EET_KEY_INPUT_EVENT</a> &amp;&amp; eve.KeyInput.PressedDown == <span class="keyword">false</span>)
        {
                <span class="comment">// Escape toggles camera Input</span>
                <span class="keywordflow">if</span> ( eve.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb3ab32bfc194f119e5d5b9b39527bbcd61">irr::KEY_ESCAPE</a> )
                {
                        SetGUIActive ( 3 );
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb3f847cf3df62b0e23942f0bd2d226a9eb">KEY_F11</a>)
                {
                        <span class="comment">// screenshot are taken without gamma!</span>
                        IImage* image = Game-&gt;Device-&gt;getVideoDriver()-&gt;createScreenShot();
                        <span class="keywordflow">if</span> (image)
                        {
                                <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> pos;
                                <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> rot;
                                ICameraSceneNode * cam = Game-&gt;Device-&gt;getSceneManager()-&gt;getActiveCamera ();
                                <span class="keywordflow">if</span> ( cam )
                                {
                                        pos = cam-&gt;getPosition ();
                                        rot = cam-&gt;getRotation ();
                                }

                                <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *dName[] = { <span class="stringliteral">"null"</span>, <span class="stringliteral">"software"</span>, <span class="stringliteral">"burning"</span>,
                                        <span class="stringliteral">"d3d8"</span>, <span class="stringliteral">"d3d9"</span>, <span class="stringliteral">"opengl"</span> };

                                snprintf(buf, 256, <span class="stringliteral">"%s_%ls_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f.jpg"</span>,
                                                dName[Game-&gt;Device-&gt;getVideoDriver()-&gt;getDriverType()],
                                                Game-&gt;CurrentMapName.c_str(),
                                                pos.X, pos.Y, pos.Z,
                                                rot.X, rot.Y, rot.Z
                                                );
                                <a class="code" href="namespaceirr_1_1io.html#b1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> filename ( buf );
                                filename.replace ( <span class="charliteral">'/'</span>, <span class="charliteral">'_'</span> );
                                printf ( <span class="stringliteral">"screenshot : %s\n"</span>, filename.c_str() );
                                Game-&gt;Device-&gt;getVideoDriver()-&gt;writeImageToFile(image, filename, 100 );
                                image-&gt;drop();
                        }
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb35dfbe4e0c7c8d9d810717fc1331fd3c9">KEY_F9</a>)
                {
                        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> value = <a class="code" href="namespaceirr_1_1scene.html#52b664c4c988113735042b168fc32dbe25111b15f03bee9a99498737286916dc" title="No Debug Data ( Default ).">EDS_OFF</a>;

                        Game-&gt;debugState = ( Game-&gt;debugState + 1 ) &amp; 3;

                        <span class="keywordflow">switch</span> ( Game-&gt;debugState )
                        {
                                <span class="keywordflow">case</span> 1: value = <a class="code" href="namespaceirr_1_1scene.html#52b664c4c988113735042b168fc32dbe2713e470ee18ec9bfe40fdfb502f8b05" title="Show Vertex Normals.">EDS_NORMALS</a> | <a class="code" href="namespaceirr_1_1scene.html#52b664c4c988113735042b168fc32dbe349b086537ac770f09935af4e31d3f3e" title="Overlays Mesh Wireframe.">EDS_MESH_WIRE_OVERLAY</a> | <a class="code" href="namespaceirr_1_1scene.html#52b664c4c988113735042b168fc32dbe80f38e42f1b8cf169e83f44092367bfe" title="EDS_BBOX | EDS_BBOX_BUFFERS.">EDS_BBOX_ALL</a>; <span class="keywordflow">break</span>;
                                <span class="keywordflow">case</span> 2: value = <a class="code" href="namespaceirr_1_1scene.html#52b664c4c988113735042b168fc32dbe2713e470ee18ec9bfe40fdfb502f8b05" title="Show Vertex Normals.">EDS_NORMALS</a> | <a class="code" href="namespaceirr_1_1scene.html#52b664c4c988113735042b168fc32dbe349b086537ac770f09935af4e31d3f3e" title="Overlays Mesh Wireframe.">EDS_MESH_WIRE_OVERLAY</a> | <a class="code" href="namespaceirr_1_1scene.html#52b664c4c988113735042b168fc32dbea7664e189b8641ac54cf27f70f6d8144" title="Shows Skeleton/Tags.">EDS_SKELETON</a>; <span class="keywordflow">break</span>;
                        }
</pre></div><p>
set debug map data on/off debugState = debugState == EDS_OFF ? EDS_NORMALS | EDS_MESH_WIRE_OVERLAY | EDS_BBOX_ALL: EDS_OFF; <div class="fragment"><pre class="fragment">                        <span class="keywordflow">if</span> ( ItemParent )
                        {
                                list&lt;ISceneNode*&gt;::ConstIterator it = ItemParent-&gt;getChildren().begin();
                                <span class="keywordflow">for</span> (; it != ItemParent-&gt;getChildren().end(); ++it)
                                {
                                        (*it)-&gt;setDebugDataVisible ( value );
                                }
                        }

                        <span class="keywordflow">if</span> ( ShaderParent )
                        {
                                list&lt;ISceneNode*&gt;::ConstIterator it = ShaderParent-&gt;getChildren().begin();
                                <span class="keywordflow">for</span> (; it != ShaderParent-&gt;getChildren().end(); ++it)
                                {
                                        (*it)-&gt;setDebugDataVisible ( value );
                                }
                        }

                        <span class="keywordflow">if</span> ( UnresolvedParent )
                        {
                                list&lt;ISceneNode*&gt;::ConstIterator it = UnresolvedParent-&gt;getChildren().begin();
                                <span class="keywordflow">for</span> (; it != UnresolvedParent-&gt;getChildren().end(); ++it)
                                {
                                        (*it)-&gt;setDebugDataVisible ( value );
                                }
                        }

                        <span class="keywordflow">if</span> ( FogParent )
                        {
                                list&lt;ISceneNode*&gt;::ConstIterator it = FogParent-&gt;getChildren().begin();
                                <span class="keywordflow">for</span> (; it != FogParent-&gt;getChildren().end(); ++it)
                                {
                                        (*it)-&gt;setDebugDataVisible ( value );
                                }
                        }

                        <span class="keywordflow">if</span> ( SkyNode )
                        {
                                SkyNode-&gt;setDebugDataVisible ( value );
                        }

                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb35111be01fea6429912b3e497b2a85d73">KEY_F8</a>)
                {
                        <span class="comment">// set gravity on/off</span>
                        Game-&gt;gravityState ^= 1;
                        Player[0].cam()-&gt;setGravity ( getGravity ( Game-&gt;gravityState ? <span class="stringliteral">"earth"</span> : <span class="stringliteral">"none"</span> ) );
                        printf ( <span class="stringliteral">"gravity %s\n"</span>, Game-&gt;gravityState ? <span class="stringliteral">"earth"</span> : <span class="stringliteral">"none"</span> );
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb37f58cecbda71cea3043c026d3ba00456">KEY_F7</a>)
                {
                        <span class="comment">// set fly through active</span>
                        Game-&gt;flyTroughState ^= 1;
                        Player[0].cam()-&gt;setAnimateTarget ( Game-&gt;flyTroughState == 0 );
                        <span class="keywordflow">if</span> ( gui.Collision )
                                gui.Collision-&gt;setChecked ( Game-&gt;flyTroughState == 0 );

                        printf ( <span class="stringliteral">"collision %d\n"</span>, Game-&gt;flyTroughState == 0 );
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb3992b194a5b4b4809587db8a43c3e75dd">KEY_F2</a>)
                {
                        Player[0].respawn ();
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb32f017f7a3b6291e5d549ed4a09c03d4e">KEY_F3</a>)
                {
                        <span class="keywordflow">if</span> ( MapParent )
                        {
                                <span class="keywordtype">bool</span> v = !MapParent-&gt;isVisible ();
                                printf ( <span class="stringliteral">"static node set visible %d\n"</span>,v );
                                MapParent-&gt;setVisible ( v );
                                <span class="keywordflow">if</span> ( gui.Visible_Map )
                                        gui.Visible_Map-&gt;setChecked ( v );
                        }
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb38f49f2e6664716985551334f0b2c1b47">KEY_F4</a>)
                {
                        <span class="keywordflow">if</span> ( ShaderParent )
                        {
                                <span class="keywordtype">bool</span> v = !ShaderParent-&gt;isVisible ();
                                printf ( <span class="stringliteral">"shader node set visible %d\n"</span>,v );
                                ShaderParent-&gt;setVisible ( v );
                                <span class="keywordflow">if</span> ( gui.Visible_Shader )
                                        gui.Visible_Shader-&gt;setChecked ( v );
                        }
                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb36aecea6261588331b87093b4ab544b1a">KEY_F5</a>)
                {
                        <span class="keywordflow">if</span> ( FogParent )
                        {
                                <span class="keywordtype">bool</span> v = !FogParent-&gt;isVisible ();
                                printf ( <span class="stringliteral">"fog node set visible %d\n"</span>,v );
                                FogParent-&gt;setVisible ( v );
                                <span class="keywordflow">if</span> ( gui.Visible_Fog )
                                        gui.Visible_Fog-&gt;setChecked ( v );
                        }

                }
                <span class="keywordflow">else</span>
                <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb36c0530c3448c3274b137f97df44e2a44">KEY_F6</a>)
                {
                        <span class="keywordflow">if</span> ( UnresolvedParent )
                        {
                                <span class="keywordtype">bool</span> v = !UnresolvedParent-&gt;isVisible ();
                                printf ( <span class="stringliteral">"unresolved node set visible %d\n"</span>,v );
                                UnresolvedParent-&gt;setVisible ( v );
                                <span class="keywordflow">if</span> ( gui.Visible_Unresolved )
                                        gui.Visible_Unresolved-&gt;setChecked ( v );
                        }
                }
        }

        <span class="comment">// check if user presses the key C ( for crouch)</span>
        <span class="keywordflow">if</span> ( eve.EventType == <a class="code" href="namespaceirr.html#c9eed96e06e85ce3c86fcbbbe9e48a0c6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">EET_KEY_INPUT_EVENT</a> &amp;&amp; eve.KeyInput.Key == <a class="code" href="namespaceirr.html#54da2a0e231901735e3da1b0edf72eb385a756fa6a3336312c5f32877a7185e5">KEY_KEY_C</a> )
        {
                <span class="comment">// crouch</span>
                ISceneNodeAnimatorCollisionResponse *anim = Player[0].cam ();
                <span class="keywordflow">if</span> ( anim &amp;&amp; 0 == Game-&gt;flyTroughState )
                {
                        <span class="keywordflow">if</span> ( <span class="keyword">false</span> == eve.KeyInput.PressedDown )
                        {
                                <span class="comment">// stand up</span>
                                anim-&gt;setEllipsoidRadius (  <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(30,45,30) );
                                anim-&gt;setEllipsoidTranslation ( <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0,40,0));

                        }
                        <span class="keywordflow">else</span>
                        {
                                <span class="comment">// on your knees</span>
                                anim-&gt;setEllipsoidRadius (  <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(30,20,30) );
                                anim-&gt;setEllipsoidTranslation ( <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0,20,0));
                        }
                        <span class="keywordflow">return</span> <span class="keyword">true</span>;
                }
        }
        <span class="keywordflow">return</span> <span class="keyword">false</span>;
}
</pre></div><p>
useItem <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::useItem( Q3Player * player)
{
        ISceneManager* smgr = Game-&gt;Device-&gt;getSceneManager();
        ICameraSceneNode* camera = smgr-&gt;getActiveCamera();

        <span class="keywordflow">if</span> (!camera)
                <span class="keywordflow">return</span>;

        SParticleImpact imp;
        imp.when = 0;

        <span class="comment">// get line of camera</span>

        <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> start = camera-&gt;getPosition();

        <span class="keywordflow">if</span> ( player-&gt;WeaponNode )
        {
                start.X += 0.f;
                start.Y += 0.f;
                start.Z += 0.f;
        }

        <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> end = (camera-&gt;getTarget() - start);
        end.normalize();
        start += end*20.0f;

        end = start + (end * camera-&gt;getFarValue());

        <a class="code" href="namespaceirr_1_1core.html#1112835405bbec5dadf031dc7934e7d0" title="Typedef for a f32 3d triangle.">triangle3df</a> triangle;
        line3d&lt;f32&gt; line(start, end);

        <span class="comment">// get intersection point with map</span>
        <span class="keyword">const</span> scene::ISceneNode* hitNode;
        <span class="keywordflow">if</span> (smgr-&gt;getSceneCollisionManager()-&gt;getCollisionPoint(
                line, Meta, end, triangle,hitNode))
        {
                <span class="comment">// collides with wall</span>
                <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> out = triangle.getNormal();
                out.setLength(0.03f);

                imp.when = 1;
                imp.outVector = out;
                imp.pos = end;

                player-&gt;setAnim ( <span class="stringliteral">"pow"</span> );
                player-&gt;Anim[1].next += player-&gt;Anim[1].delta;
        }
        <span class="keywordflow">else</span>
        {
                <span class="comment">// doesnt collide with wall</span>
                <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> start = camera-&gt;getPosition();
                <span class="keywordflow">if</span> ( player-&gt;WeaponNode )
                {
                        <span class="comment">//start.X += 10.f;</span>
                        <span class="comment">//start.Y += -5.f;</span>
                        <span class="comment">//start.Z += 1.f;</span>
                }

                <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> end = (camera-&gt;getTarget() - start);
                end.normalize();
                start += end*20.0f;
                end = start + (end * camera-&gt;getFarValue());
        }

        <span class="comment">// create fire ball</span>
        ISceneNode* node = 0;
        node = smgr-&gt;addBillboardSceneNode( BulletParent,dimension2d&lt;f32&gt;(10,10), start);

        node-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#8a3bc00ae8137535b9fbc5f40add70d3cea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">EMF_LIGHTING</a>, <span class="keyword">false</span>);
        node-&gt;setMaterialTexture(0, Game-&gt;Device-&gt;getVideoDriver()-&gt;getTexture(<span class="stringliteral">"fireball.bmp"</span>));
        node-&gt;setMaterialType(<a class="code" href="namespaceirr_1_1video.html#c8e9b6c66f7cebabd1a6d30cbc5430f11b5a814c4466aca2943ff056003a50d1" title="A transparent material.">EMT_TRANSPARENT_ADD_COLOR</a>);

        <a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> length = (<a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)(end - start).getLength();
        <span class="keyword">const</span> <a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> speed = 5.8f;
        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> time = (<a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>)(length / speed);

        ISceneNodeAnimator* anim = 0;

        <span class="comment">// set flight line</span>

        anim = smgr-&gt;createFlyStraightAnimator(start, end, time);
        node-&gt;addAnimator(anim);
        anim-&gt;drop();

        snprintf ( buf, 64, <span class="stringliteral">"bullet: %s on %.1f,%1.f,%1.f"</span>,
                                imp.when ? <span class="stringliteral">"hit"</span> : <span class="stringliteral">"nohit"</span>, end.X, end.Y, end.Z );
        node-&gt;setName ( buf );


        anim = smgr-&gt;createDeleteAnimator(time);
        node-&gt;addAnimator(anim);
        anim-&gt;drop();

        <span class="keywordflow">if</span> (imp.when)
        {
                <span class="comment">// create impact note</span>
                imp.when = Game-&gt;Device-&gt;getTimer()-&gt;getTime() +
                        (time + (<a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) ( ( 1.f + Noiser::get() ) * 250.f ));
                Impacts.push_back(imp);
        }

        <span class="comment">// play sound</span>
}

<span class="comment">// rendered when bullets hit something</span>
<span class="keywordtype">void</span> CQuake3EventHandler::createParticleImpacts( <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> now )
{
        ISceneManager* sm = Game-&gt;Device-&gt;getSceneManager();

        <span class="keyword">struct </span>smokeLayer
        {
                <span class="keyword">const</span> <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> * texture;
                <a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> scale;
                <a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> minparticleSize;
                <a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> maxparticleSize;
                <a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> boxSize;
                <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> minParticle;
                <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> maxParticle;
                <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> fadeout;
                <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> lifetime;
        };

        smokeLayer smoke[] =
        {
                { <span class="stringliteral">"smoke2.jpg"</span>, 0.4f, 1.5f, 18.f, 20.f, 20, 50, 2000, 10000 },
                { <span class="stringliteral">"smoke3.jpg"</span>, 0.2f, 1.2f, 15.f, 20.f, 10, 30, 1000, 12000 }
        };


        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i;
        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> g;
        <a class="code" href="namespaceirr.html#c66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> factor = 1;
        <span class="keywordflow">for</span> ( g = 0; g != 2; ++g )
        {
                smoke[g].minParticle *= factor;
                smoke[g].maxParticle *= factor;
                smoke[g].lifetime *= factor;
                smoke[g].boxSize *= Noiser::get() * 0.5f;
        }

        <span class="keywordflow">for</span> ( i=0; i &lt; Impacts.size(); ++i)
        {
                <span class="keywordflow">if</span> (now &lt; Impacts[i].when)
                        <span class="keywordflow">continue</span>;

                <span class="comment">// create smoke particle system</span>
                IParticleSystemSceneNode* pas = 0;

                <span class="keywordflow">for</span> ( g = 0; g != 2; ++g )
                {
                        pas = sm-&gt;addParticleSystemSceneNode(<span class="keyword">false</span>, BulletParent, -1, Impacts[i].pos);

                        snprintf ( buf, 64, <span class="stringliteral">"bullet impact smoke at %.1f,%.1f,%1.f"</span>,
                                Impacts[i].pos.X,Impacts[i].pos.Y,Impacts[i].pos.Z);
                        pas-&gt;setName ( buf );

                        <span class="comment">// create a flat smoke</span>
                        <a class="code" href="namespaceirr_1_1core.html#06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> direction = Impacts[i].outVector;
                        direction *= smoke[g].scale;
                        IParticleEmitter* em = pas-&gt;createBoxEmitter(
                                aabbox3d&lt;f32&gt;(-4.f,0.f,-4.f,20.f,smoke[g].minparticleSize,20.f),
                                direction,smoke[g].minParticle, smoke[g].maxParticle,
                                video::SColor(0,0,0,0),video::SColor(0,128,128,128),
                                250,4000, 60);

                        em-&gt;setMinStartSize (dimension2d&lt;f32&gt;( smoke[g].minparticleSize, smoke[g].minparticleSize));
                        em-&gt;setMaxStartSize (dimension2d&lt;f32&gt;( smoke[g].maxparticleSize, smoke[g].maxparticleSize));

                        pas-&gt;setEmitter(em);
                        em-&gt;drop();

                        <span class="comment">// particles get invisible</span>
                        IParticleAffector* paf = pas-&gt;createFadeOutParticleAffector(
                                video::SColor ( 0, 0, 0, 0 ), smoke[g].fadeout);
                        pas-&gt;addAffector(paf);
                        paf-&gt;drop();

                        <span class="comment">// particle system life time</span>
                        ISceneNodeAnimator* anim = sm-&gt;createDeleteAnimator( smoke[g].lifetime);
                        pas-&gt;addAnimator(anim);
                        anim-&gt;drop();

                        pas-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#8a3bc00ae8137535b9fbc5f40add70d3cea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">video::EMF_LIGHTING</a>, <span class="keyword">false</span>);
                        pas-&gt;setMaterialType(<a class="code" href="namespaceirr_1_1video.html#c8e9b6c66f7cebabd1a6d30cbc5430f126529b1cf18ec4d8073809f6bd15ebbb" title="Makes the material transparent based on the vertex alpha value.">video::EMT_TRANSPARENT_VERTEX_ALPHA</a> );
                        pas-&gt;setMaterialTexture(0, Game-&gt;Device-&gt;getVideoDriver()-&gt;getTexture( smoke[g].texture ));
                }


                <span class="comment">// play impact sound</span>
<span class="preprocessor">                #ifdef USE_IRRKLANG</span>
</pre></div><p>
if (irrKlang) { audio::ISound* sound = irrKlang-&gt;play3D(impactSound, Impacts[i].pos, false, false, true);<p>
if (sound) { adjust max value a bit to make to sound of an impact louder sound-&gt;setMinDistance(400); sound-&gt;drop(); } } <div class="fragment"><pre class="fragment"><span class="preprocessor">                #endif</span>
<span class="preprocessor"></span>

                <span class="comment">// delete entry</span>
                Impacts.erase(i);
                i--;
        }
}
</pre></div><p>
render <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::Render()
{
        IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();
        <span class="keywordflow">if</span> ( 0 == driver )
                <span class="keywordflow">return</span>;

        driver-&gt;beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, SColor(0,0,0,0));
        Game-&gt;Device-&gt;getSceneManager ()-&gt;drawAll();
        Game-&gt;Device-&gt;getGUIEnvironment()-&gt;drawAll();
        driver-&gt;endScene();
}
</pre></div><p>
update the generic scene node <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::Animate()
{
        <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> now = Game-&gt;Device-&gt;getTimer()-&gt;getTime();

        Q3Player * player = Player + 0;

        checkTimeFire ( player-&gt;Anim, 4, now );

        <span class="comment">// Query Scene Manager attributes</span>
        <span class="keywordflow">if</span> ( player-&gt;Anim[0].flags &amp; FIRED )
        {
                ISceneManager *smgr = Game-&gt;Device-&gt;getSceneManager ();
                <span class="keywordtype">wchar_t</span> msg[128];
                IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();

                IAttributes * attr = smgr-&gt;getParameters();
                swprintf ( msg, 128,
                        L<span class="stringliteral">"Q3 %s [%ls], FPS:%03d Tri:%.03fm Cull %d/%d nodes (%d,%d,%d)"</span>,
                        Game-&gt;CurrentMapName.c_str(),
                        driver-&gt;getName(),
                        driver-&gt;getFPS (),
                        (<a class="code" href="namespaceirr.html#0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>) driver-&gt;getPrimitiveCountDrawn( 0 ) * ( 1.f / 1000000.f ),
                        attr-&gt;getAttributeAsInt ( <span class="stringliteral">"culled"</span> ),
                        attr-&gt;getAttributeAsInt ( <span class="stringliteral">"calls"</span> ),
                        attr-&gt;getAttributeAsInt ( <span class="stringliteral">"drawn_solid"</span> ),
                        attr-&gt;getAttributeAsInt ( <span class="stringliteral">"drawn_transparent"</span> ),
                        attr-&gt;getAttributeAsInt ( <span class="stringliteral">"drawn_transparent_effect"</span> )
                        );
                Game-&gt;Device-&gt;setWindowCaption( msg );

                swprintf ( msg, 128,
                                        L<span class="stringliteral">"%03d fps, F1 GUI on/off, F2 respawn, F3-F6 toggle Nodes, F7 Collision on/off"</span>
                                        L<span class="stringliteral">", F8 Gravity on/off, Right Mouse Toggle GUI"</span>,
                                        Game-&gt;Device-&gt;getVideoDriver()-&gt;getFPS ()
                                );
                <span class="keywordflow">if</span> ( gui.StatusLine )
                        gui.StatusLine-&gt;setText ( msg );
                player-&gt;Anim[0].flags &amp;= ~FIRED;
        }

        <span class="comment">// idle..</span>
        <span class="keywordflow">if</span> ( player-&gt;Anim[1].flags &amp; FIRED )
        {
                <span class="keywordflow">if</span> ( strcmp ( player-&gt;animation, <span class="stringliteral">"idle"</span> ) )
                        player-&gt;setAnim ( <span class="stringliteral">"idle"</span> );

                player-&gt;Anim[1].flags &amp;= ~FIRED;
        }

        createParticleImpacts ( now );

}
</pre></div> The main game states <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> runGame ( GameData *game )
{
        <span class="keywordflow">if</span> ( game-&gt;retVal &gt;= 3 )
                <span class="keywordflow">return</span>;

        game-&gt;Device = (*game-&gt;createExDevice) ( game-&gt;deviceParam );
        <span class="keywordflow">if</span> ( 0 == game-&gt;Device)
        {
                <span class="comment">// could not create selected driver.</span>
                game-&gt;retVal = 0;
                <span class="keywordflow">return</span>;
        }

        <span class="comment">// create an event receiver based on current game data</span>
        CQuake3EventHandler *eventHandler = <span class="keyword">new</span> CQuake3EventHandler( game );

        <span class="comment">// load stored config</span>
        game-&gt;load ( <span class="stringliteral">"explorer.cfg"</span> );

        <span class="comment">// add our media directory and archive to the file system</span>
        <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i = 0; i &lt; game-&gt;CurrentArchiveList.size(); ++i )
        {
                eventHandler-&gt;AddArchive ( game-&gt;CurrentArchiveList[i] );
        }

        <span class="comment">// Load a Map or startup to the GUI</span>
        <span class="keywordflow">if</span> ( game-&gt;CurrentMapName.size () )
        {
                eventHandler-&gt;LoadMap ( game-&gt;CurrentMapName, 1 );
                <span class="keywordflow">if</span> ( 0 == game-&gt;loadParam.loadSkyShader )
                        eventHandler-&gt;AddSky ( 1, <span class="stringliteral">"skydome2"</span> );
                eventHandler-&gt;CreatePlayers ();
                eventHandler-&gt;CreateGUI ();
                eventHandler-&gt;SetGUIActive ( 0 );

                <span class="comment">// set player to last position on restart</span>
                <span class="keywordflow">if</span> ( game-&gt;retVal == 2 )
                {
                        eventHandler-&gt;GetPlayer( 0 )-&gt;setpos ( game-&gt;PlayerPosition, game-&gt;PlayerRotation );
                }
        }
        <span class="keywordflow">else</span>
        {
                <span class="comment">// start up empty</span>
                eventHandler-&gt;AddSky ( 1, <span class="stringliteral">"skydome2"</span> );
                eventHandler-&gt;CreatePlayers ();
                eventHandler-&gt;CreateGUI ();
                eventHandler-&gt;SetGUIActive ( 1 );
                background_music ( <span class="stringliteral">"IrrlichtTheme.ogg"</span> );
        }


        game-&gt;retVal = 3;
        <span class="keywordflow">while</span>( game-&gt;Device-&gt;run() )
        {
                eventHandler-&gt;Animate ();
                eventHandler-&gt;Render ();
                <span class="comment">//if ( !game-&gt;Device-&gt;isWindowActive() )</span>
                        game-&gt;Device-&gt;yield();
        }

        game-&gt;Device-&gt;setGammaRamp ( 1.f, 1.f, 1.f, 0.f, 0.f );
        <span class="keyword">delete</span> eventHandler;
}

<span class="preprocessor">#if defined (_IRR_WINDOWS_) &amp;&amp; 0</span>
<span class="preprocessor"></span><span class="preprocessor">        #pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")</span>
<span class="preprocessor">#endif</span>
</pre></div> The main routine, doing all setup <div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> <a class="code" href="_irr_compile_config_8h.html#3f9bf2240c47d3f99b86f83f9123aa9d">IRRCALLCONV</a> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
{
        <a class="code" href="namespaceirr_1_1io.html#b1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> prgname(argv[0]);
        GameData game ( <a class="code" href="namespaceirr_1_1core.html#9215d20e34c12cb6c1522366389bfcce" title="trim paths">deletePathFromPath</a> ( prgname, 1 ) );

        <span class="comment">// dynamically load irrlicht</span>
        <span class="keyword">const</span> <a class="code" href="namespaceirr.html#9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> * dllName = argc &gt; 1 ? argv[1] : <span class="stringliteral">"irrlicht.dll"</span>;
        game.createExDevice = load_createDeviceEx ( dllName );
        <span class="keywordflow">if</span> ( 0 == game.createExDevice )
        {
                game.retVal = 3;
                printf ( <span class="stringliteral">"Could not load %s.\n"</span>, dllName );
                <span class="keywordflow">return</span> game.retVal; <span class="comment">// could not load dll</span>
        }

        <span class="comment">// start without asking for driver</span>
        game.retVal = 1;
        <span class="keywordflow">do</span>
        {
                <span class="comment">// if driver could not created, ask for another driver</span>
                <span class="keywordflow">if</span> ( game.retVal == 0 )
                {
                        game.setDefault ();
                        printf(<span class="stringliteral">"Please select the driver you want for this example:\n"</span>\
                                <span class="stringliteral">" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"</span>\
                                <span class="stringliteral">" (d) Software Renderer\n (e) Burning's Video (TM) Thomas Alten\n"</span>\
                                <span class="stringliteral">" (otherKey) exit\n\n"</span>);

                        <span class="keywordtype">char</span> i = <span class="charliteral">'a'</span>;
                        std::cin &gt;&gt; i;

                        <span class="keywordflow">switch</span>(i)
                        {
                                <span class="keywordflow">case</span> <span class="charliteral">'a'</span>: game.deviceParam.DriverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d04691ca314f9018f508dcf2c57dcaacec" title="Direct3D 9 device, only available on Win32 platforms.">EDT_DIRECT3D9</a>;<span class="keywordflow">break</span>;
                                <span class="keywordflow">case</span> <span class="charliteral">'b'</span>: game.deviceParam.DriverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d08cc3807f6f28404f3424ad7e31b3142f" title="Direct3D8 device, only available on Win32 platforms.">EDT_DIRECT3D8</a>;<span class="keywordflow">break</span>;
                                <span class="keywordflow">case</span> <span class="charliteral">'c'</span>: game.deviceParam.DriverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d02715182a79f1cb8e2826fd68a8150a53" title="OpenGL device, available on most platforms.">EDT_OPENGL</a>;   <span class="keywordflow">break</span>;
                                <span class="keywordflow">case</span> <span class="charliteral">'d'</span>: game.deviceParam.DriverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d01598cd235a1a6bd052e2011b559e8995" title="The Irrlicht Engine Software renderer.">EDT_SOFTWARE</a>; <span class="keywordflow">break</span>;
                                <span class="keywordflow">case</span> <span class="charliteral">'e'</span>: game.deviceParam.DriverType = <a class="code" href="namespaceirr_1_1video.html#e35a6de6d436c76107ad157fe42356d0e85481da26159b967191ccc6de1e4a05" title="The Burning&amp;#39;s Software Renderer, an alternative software renderer.">EDT_BURNINGSVIDEO</a>;<span class="keywordflow">break</span>;
                                <span class="keywordflow">default</span>: game.retVal = 3; <span class="keywordflow">break</span>;
                        }
                }
                runGame ( &amp;game );
        } <span class="keywordflow">while</span> ( game.retVal &lt; 3 );

        <span class="keywordflow">return</span> game.retVal;
}
</pre></div> </div>
<hr size="1">
<address style="align: right;">
<small> </small>
</address>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
  <tr> 
    <td width="0"> <div align="left"><small><a href="http://irrlicht.sourceforge.net" target="_blank"><img src="irrlicht.png" alt="The Irrlicht Engine" align="middle" border=0 width=88 height=31></a></small></div></td>
    <td> <div align="left"><small><em><font size="2">The <a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht 
        Engine</a> Documentation &copy; 2003-2009 by Nikolaus Gebhardt. Generated 
        on Sun Jan 10 09:24:08 2010 by <a href="http://www.doxygen.org" target="_blank">Doxygen</a> 
        (1.5.6)</font></em></small></div></td>
  </tr>
</table>
<address style="align: right;">
</address>
</body>
</html>