irrlicht/doc/docu/example021.html
2020-05-16 23:31:28 +02:00

2191 lines
150 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Irrlicht 3D Engine: Tutorial 21: Quake3 Explorer</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td>
<td style="padding-left: 0.5em;">
<div id="projectname">Irrlicht 3D Engine
</div>
</td>
<td> <div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="dynsections.js"></script>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
initNavTree('example021.html','');
</script>
<div id="doc-content">
<div class="header">
<div class="headertitle">
<div class="title">Tutorial 21: Quake3 Explorer </div> </div>
</div>
<div class="contents">
<div class="textblock"><div class="image">
<img src="021shot.jpg" alt="021shot.jpg"/>
</div>
<p>This Tutorial shows how to load different Quake 3 maps.</p>
<p>Features:</p>
<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 Collision Response</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>
<p>Copyright 2006-2011 Burningwater, Thomas Alten </p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &quot;<a class="code" href="driver_choice_8h.html">driverChoice.h</a>&quot;</span>
<span class="preprocessor">#include &lt;<a class="code" href="irrlicht_8h.html" title="Main header file of the irrlicht, the only file needed to include.">irrlicht.h</a>&gt;</span>
<span class="preprocessor">#include &quot;q3factory.h&quot;</span>
<span class="preprocessor">#include &quot;sound.h&quot;</span>
</pre></div><p>Game Data is used to hold Data which is needed to drive the game </p>
<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#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> &amp;startupDir) :
retVal(0), StartupDir(startupDir), createExDevice(0), Device(0)
{
setDefault ();
}
<span class="keywordtype">void</span> setDefault ();
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> save ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> &amp;filename );
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> load ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> &amp;filename );
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> debugState;
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> gravityState;
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> flyTroughState;
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> wireFrame;
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> guiActive;
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> guiInputActive;
<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> GammaValue;
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> retVal;
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> sound;
<a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> StartupDir;
<a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> CurrentMapName;
array&lt;path&gt; CurrentArchiveList;
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> PlayerPosition;
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> PlayerRotation;
<a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a312f35a37540d810fcb14b75fd449c9e">tQ3EntityList</a> Variable;
Q3LevelLoadParameter loadParam;
SIrrlichtCreationParameters deviceParam;
<a class="code" href="namespaceirr.html#a5137701377b2241305607fc37a27e9f8" title="typedef for Function Pointer">funcptr_createDeviceEx</a> createExDevice;
IrrlichtDevice *Device;
};
</pre></div><p>set default settings </p>
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> GameData::setDefault ()
{
debugState = <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea25111b15f03bee9a99498737286916dc" 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#ae35a6de6d436c76107ad157fe42356d0a4691ca314f9018f508dcf2c57dcaacec" 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#ae35a6de6d436c76107ad157fe42356d0a2715182a79f1cb8e2826fd68a8150a53" 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 = 24;
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#ac8e9b6c66f7cebabd1a6d30cbc5430f1a5dc90a3b4a8d82f10503ddf834a3143f" title="Material type with standard lightmap technique.">EMT_LIGHTMAP</a>;
loadParam.defaultModulate = <a class="code" href="namespaceirr_1_1video.html#a1402e9045137ae232fafbdf385800843a58cc346f344fb488d403a3783675e5d7">EMFN_MODULATE_1X</a>;
loadParam.defaultFilter = <a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a941c0756b9dc3f987a183a401c6fd4ad" 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">&quot;&quot;</span>;
CurrentArchiveList.clear ();
<span class="comment">// Explorer Media directory</span>
CurrentArchiveList.push_back ( StartupDir + <span class="stringliteral">&quot;../../media/&quot;</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">&quot;/q/baseq3/&quot;</span>);
CurrentArchiveList.push_back(StartupDir + <span class="stringliteral">&quot;../../media/map-20kdm2.pk3&quot;</span>);
}
</pre></div><p>Load the current game State from a typical quake3 cfg file </p>
<div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> GameData::load ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" 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#a312f35a37540d810fcb14b75fd449c9e">tQ3EntityList</a> &amp;entityList = mesh-&gt;getEntityList ();
<a class="code" href="namespaceirr_1_1core.html#ade1071a878633f2f6d8a75c5d11fec19" title="Typedef for character strings.">stringc</a> s;
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> pos;
<span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" 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#a0416a53257075833e7002efd0a18e804" 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#a0416a53257075833e7002efd0a18e804" 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">&quot;playerposition&quot;</span> )
{
PlayerPosition = <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a6163d5a7fba9950a2f390a42fe354c3f" 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">&quot;playerrotation&quot;</span> )
{
PlayerRotation = <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a6163d5a7fba9950a2f390a42fe354c3f" 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 </p>
<div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> GameData::save ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" 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#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[128];
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" 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">&quot;playerposition %.f %.f %.f\nplayerrotation %.f %.f %.f\n&quot;</span>,
PlayerPosition.X, PlayerPosition.Z, PlayerPosition.Y,
PlayerRotation.X, PlayerRotation.Z, PlayerRotation.Y);
file-&gt;write ( buf, (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" 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">&quot;archive %s\n&quot;</span>,<a class="code" href="namespaceirr_1_1core.html#ade1071a878633f2f6d8a75c5d11fec19" 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#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) strlen ( buf ) );
}
file-&gt;drop ();
<span class="keywordflow">return</span> 1;
}
</pre></div><p>Representing a player </p>
<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#a9395eaea339bcb546b319e9c96bf7410" 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#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> &amp;pos, <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" 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#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> StartPositionCurrent;
TimeFire Anim[4];
<a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> animation[64];
<a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[64];
};
</pre></div><p> End player </p>
<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><p> create a new player </p>
<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#aa9946ac9f3142f9e790ce52d59fd6168af9ff845aa49060787ef81773eeaf1016">EKA_MOVE_FORWARD</a>;
keyMap[0].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae3341f66dcdd3d0cbce80ff741262395">KEY_UP</a>;
keyMap[1].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168af9ff845aa49060787ef81773eeaf1016">EKA_MOVE_FORWARD</a>;
keyMap[1].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae559e3169016a3180c45c2828f391af2">KEY_KEY_W</a>;
keyMap[2].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168af4c724e0a0923e497c7f8a48884e36d9">EKA_MOVE_BACKWARD</a>;
keyMap[2].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3acbab6476bacfd1212c52aba7c1c82886">KEY_DOWN</a>;
keyMap[3].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168af4c724e0a0923e497c7f8a48884e36d9">EKA_MOVE_BACKWARD</a>;
keyMap[3].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae52bafc112fc6c52f6b49cea42fa246e">KEY_KEY_S</a>;
keyMap[4].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a91cad59a86b88c0e6ab5aa75b936d9c7">EKA_STRAFE_LEFT</a>;
keyMap[4].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a71c43cf2c123fd75911fef5501a15241">KEY_LEFT</a>;
keyMap[5].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a91cad59a86b88c0e6ab5aa75b936d9c7">EKA_STRAFE_LEFT</a>;
keyMap[5].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a2fe10b4309013968b9cd14811c3d3c85">KEY_KEY_A</a>;
keyMap[6].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a57c4bd21c235bca312e547c6d1061df2">EKA_STRAFE_RIGHT</a>;
keyMap[6].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae89f39517a44c78a6602d1b12b478118">KEY_RIGHT</a>;
keyMap[7].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a57c4bd21c235bca312e547c6d1061df2">EKA_STRAFE_RIGHT</a>;
keyMap[7].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ad20e7e220103e611752b90edeb6cbc9d">KEY_KEY_D</a>;
keyMap[8].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a574c0935be6337a2e6bc97e8304a7400">EKA_JUMP_UP</a>;
keyMap[8].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a3231acd1573be6e4d121cc6c4ab6ccc4">KEY_KEY_J</a>;
keyMap[9].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168aace30d0d2eef7a48f5f863a99dabfb84">EKA_CROUCH</a>;
keyMap[9].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a85a756fa6a3336312c5f32877a7185e5">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">&quot;First Person Camera&quot;</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">&quot;gun.md2&quot;</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#a2fc85a64604521ca063f1881b5dd1c61a3b87f459cd5f287626c4fd9aaf729284" title="Quake 2 MD2 model file.">EAMT_MD2</a> )
{
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> count = weaponMesh-&gt;getAnimationCount();
<span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> i = 0; i != count; ++i )
{
snprintf ( buf, 64, <span class="stringliteral">&quot;Animation: %s&quot;</span>, weaponMesh-&gt;getAnimationName(i) );
device-&gt;getLogger()-&gt;log(buf, <a class="code" href="namespaceirr.html#aa2d1cac68606a25ed24cfffccfa30a92a9d74de15737e326a91aec6f38c23f9cf" title="Useful information to print. For example hardware infos or something started/stopped.">ELL_INFORMATION</a>);
}
}
WeaponNode = smgr-&gt;addAnimatedMeshSceneNode(
weaponMesh,
smgr-&gt;getActiveCamera(),
10,
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>( 0, 0, 0),
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(-90,-90,90)
);
WeaponNode-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3acea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">EMF_LIGHTING</a>, <span class="keyword">false</span>);
WeaponNode-&gt;setMaterialTexture(0, driver-&gt;getTexture( <span class="stringliteral">&quot;gun.jpg&quot;</span>));
WeaponNode-&gt;setLoopMode ( <span class="keyword">false</span> );
WeaponNode-&gt;setName ( <span class="stringliteral">&quot;tommi the gun man&quot;</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#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(30,45,30),
getGravity ( <span class="stringliteral">&quot;earth&quot;</span> ),
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" 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">&quot;idle&quot;</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" </p>
<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">&quot;respawn&quot;</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 </p>
<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#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> &amp;pos, <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" 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">&quot;setpos&quot;</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><p> set the Animation of the player and weapon </p>
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::setAnim ( <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *name )
{
<span class="keywordflow">if</span> ( name )
{
snprintf ( animation, 64, <span class="stringliteral">&quot;%s&quot;</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><p> GUI Elements </p>
<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 </p>
<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#ab1bdc45edb3f94d8319c02bc0f840ee1" 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#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>&amp; mapName, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" 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#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> dome, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *texture );
Q3Player *GetPlayer ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" 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#ac66849b7a6ed16e30ebede579f9b47c6" 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#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[256];
Q3Player Player[2];
<span class="keyword">struct </span>SParticleImpact
{
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> when;
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> pos;
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" 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#a0416a53257075833e7002efd0a18e804" 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><p> Constructor </p>
<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#acaf6f7414534f7d62bff18c5bf11876fa4fe1c1b0f4b44ef4b5da219ce66a0ae8">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#ab585d23bc2a3d02cd368d8bfd0b1414a" title="Name of the parameter for changing how Irrlicht handles the ZWrite flag for transparent (blending) ma...">scene::ALLOW_ZWRITE_ON_TRANSPARENT</a>, <span class="keyword">true</span>);
<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">&quot;explorer.cfg&quot;</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#ad2e562e3219072e2f7fc7c2bba0ef0cb" title="Typedef for an unsigned integer dimension.">dimension2du</a> dim(64, 64);
video::IImage* image;
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i;
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> x;
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> y;
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" 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#a1d5e487888c32b1674a8f75116d829eda55c57d63efff39efe33ee733fe962df0" title="Default 32 bit color format. 8 bits are used for every component: red, green, blue and alpha...">video::ECF_A8R8G8B8</a>, dim);
data = (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" 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#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>*) ( (<a class="code" href="namespaceirr.html#a646874f69af8ff87fc10201b0254a761" title="8 bit unsigned variable.">u8</a>*) data + image-&gt;getPitch() );
}
image-&gt;unlock();
snprintf ( buf, 64, <span class="stringliteral">&quot;smoke_%02d&quot;</span>, i );
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#a1d5e487888c32b1674a8f75116d829eda55c57d63efff39efe33ee733fe962df0" title="Default 32 bit color format. 8 bits are used for every component: red, green, blue and alpha...">video::ECF_A8R8G8B8</a>, dim);
data = (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" 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#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>*) ( (<a class="code" href="namespaceirr.html#a646874f69af8ff87fc10201b0254a761" title="8 bit unsigned variable.">u8</a>*) data + image-&gt;getPitch() );
}
image-&gt;unlock();
snprintf ( buf, 64, <span class="stringliteral">&quot;fog_%02d&quot;</span>, i );
driver-&gt;addTexture( buf, image );
image-&gt;drop ();
}
}
</pre></div><p>create the GUI </p>
<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">&quot;fontlucida.png&quot;</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#abd15860fde29833c48daff5f95d5467aa03e6e93fa9356e9d8d743e6928111185" 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#abd15860fde29833c48daff5f95d5467aa1227b2c3a809d139e1ead87aa29fa101" title="Highlight color for three-dimensional display elements (for edges facing the light source...">EGDC_3D_HIGH_LIGHT</a>, video::SColor(240,0x22,0x22,0x22) );
env-&gt;getSkin()-&gt;setColor ( <a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aabeac28ca22e9f22dc84222d5f62a80eb" 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#abd15860fde29833c48daff5f95d5467aa94ea28795bc78153e40739db9ece3b6b" title="Window background for editable field (editbox, checkbox-field)">EGDC_EDITABLE</a>, video::SColor(240,0x44,0x44,0x44) );
env-&gt;getSkin()-&gt;setColor ( <a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aa393dd9513e3c54fdfd5006bd9f853253" title="Show focus of window background for editable field (editbox or when checkbox-field is pressed)...">EGDC_FOCUSED_EDITABLE</a>, video::SColor(240,0x54,0x54,0x54) );
env-&gt;getSkin()-&gt;setColor ( <a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aab60eb00de0efde8c5a948ab15d9aa0a7" 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">&quot;Quake3 Explorer&quot;</span> );
gui.Window-&gt;setToolTipText ( L<span class="stringliteral">&quot;Quake3Explorer. Loads and show various BSP File Format and Shaders.&quot;</span> );
gui.Window-&gt;getCloseButton()-&gt;setToolTipText ( L<span class="stringliteral">&quot;Quit Quake3 Explorer&quot;</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">&quot;VideoDriver:&quot;</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">&quot;Direct3D 9.0c&quot;</span>, <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a4691ca314f9018f508dcf2c57dcaacec" title="Direct3D 9 device, only available on Win32 platforms.">EDT_DIRECT3D9</a> );
gui.VideoDriver-&gt;addItem(L<span class="stringliteral">&quot;Direct3D 8.1&quot;</span>, <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a8cc3807f6f28404f3424ad7e31b3142f" title="Direct3D8 device, only available on Win32 platforms.">EDT_DIRECT3D8</a> );
gui.VideoDriver-&gt;addItem(L<span class="stringliteral">&quot;OpenGL 1.5&quot;</span>, <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a2715182a79f1cb8e2826fd68a8150a53" title="OpenGL device, available on most platforms.">EDT_OPENGL</a>);
gui.VideoDriver-&gt;addItem(L<span class="stringliteral">&quot;Software Renderer&quot;</span>, <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a1598cd235a1a6bd052e2011b559e8995" title="The Irrlicht Engine Software renderer.">EDT_SOFTWARE</a>);
gui.VideoDriver-&gt;addItem(L<span class="stringliteral">&quot;Burning&#39;s Video (TM) Thomas Alten&quot;</span>, <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0ae85481da26159b967191ccc6de1e4a05" title="The Burning&#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">&quot;Use a VideoDriver&quot;</span> );
env-&gt;addStaticText ( L<span class="stringliteral">&quot;VideoMode:&quot;</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">&quot;Supported Screenmodes&quot;</span> );
IVideoModeList *modeList = Game-&gt;Device-&gt;getVideoModeList();
<span class="keywordflow">if</span> ( modeList )
{
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" 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#ae9f8ec82692ad3b83c21f555bfa70bcc" 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#ae9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> w = modeList-&gt;getVideoModeResolution ( i ).Width;
<a class="code" href="namespaceirr.html#ae9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> h = modeList-&gt;getVideoModeResolution ( i ).Height;
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" 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#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> aspect = (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>) w / (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>) h;
<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *a = <span class="stringliteral">&quot;&quot;</span>;
<span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 1.3333333333f ) ) a = <span class="stringliteral">&quot;4:3&quot;</span>;
<span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 1.6666666f ) ) a = <span class="stringliteral">&quot;15:9 widescreen&quot;</span>;
<span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 1.7777777f ) ) a = <span class="stringliteral">&quot;16:9 widescreen&quot;</span>;
<span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 1.6f ) ) a = <span class="stringliteral">&quot;16:10 widescreen&quot;</span>;
<span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 2.133333f ) ) a = <span class="stringliteral">&quot;20:9 widescreen&quot;</span>;
snprintf ( buf, <span class="keyword">sizeof</span> ( buf ), <span class="stringliteral">&quot;%d x %d, %s&quot;</span>,w, h, a );
gui.VideoMode-&gt;addItem ( <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" 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">&quot;Fullscreen&quot;</span> );
gui.FullScreen-&gt;setToolTipText ( L<span class="stringliteral">&quot;Set Fullscreen or Window Mode&quot;</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">&quot;32Bit&quot;</span> );
gui.Bit32-&gt;setToolTipText ( L<span class="stringliteral">&quot;Use 16 or 32 Bit&quot;</span> );
env-&gt;addStaticText ( L<span class="stringliteral">&quot;MultiSample:&quot;</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">&quot;Set the MultiSample (disable, 1x, 2x, 4x, 8x )&quot;</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">&quot;set&quot;</span> );
gui.SetVideoMode-&gt;setToolTipText ( L<span class="stringliteral">&quot;Set Video Mode with current values&quot;</span> );
env-&gt;addStaticText ( L<span class="stringliteral">&quot;Gamma:&quot;</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#ac230a392b15e3d27c6e2a07a6925a8c4">core::floor32</a> ( Game-&gt;GammaValue * 100.f ) );
gui.Gamma-&gt;setToolTipText ( L<span class="stringliteral">&quot;Adjust Gamma Ramp ( 0.5 - 3.5)&quot;</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">&quot;Tesselation:&quot;</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">&quot;How smooth should curved surfaces be rendered&quot;</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">&quot;Collision&quot;</span> );
gui.Collision-&gt;setToolTipText ( L<span class="stringliteral">&quot;Set collision on or off ( flythrough ). \nPress F7 on your Keyboard&quot;</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">&quot;Map&quot;</span> );
gui.Visible_Map-&gt;setToolTipText ( L<span class="stringliteral">&quot;Show or not show the static part the Level. \nPress F3 on your Keyboard&quot;</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">&quot;Shader&quot;</span> );
gui.Visible_Shader-&gt;setToolTipText ( L<span class="stringliteral">&quot;Show or not show the Shader Nodes. \nPress F4 on your Keyboard&quot;</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">&quot;Fog&quot;</span> );
gui.Visible_Fog-&gt;setToolTipText ( L<span class="stringliteral">&quot;Show or not show the Fog Nodes. \nPress F5 on your Keyboard&quot;</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">&quot;Unresolved&quot;</span> );
gui.Visible_Unresolved-&gt;setToolTipText ( L<span class="stringliteral">&quot;Show the or not show the Nodes the Engine can&#39;t handle. \nPress F6 on your Keyboard&quot;</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">&quot;Skydome&quot;</span> );
gui.Visible_Skydome-&gt;setToolTipText ( L<span class="stringliteral">&quot;Show the or not show the Skydome.&quot;</span> );
<span class="comment">//Respawn = env-&gt;addButton ( rect&lt;s32&gt;( dim.Width - 260, 90, dim.Width - 10, 106 ), 0,-1, L&quot;Respawn&quot; );</span>
env-&gt;addStaticText ( L<span class="stringliteral">&quot;Archives:&quot;</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">&quot;add&quot;</span> );
gui.ArchiveAdd-&gt;setToolTipText ( L<span class="stringliteral">&quot;Add an archive, usually packed zip-archives (*.pk3) to the Filesystem&quot;</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">&quot;del&quot;</span> );
gui.ArchiveRemove-&gt;setToolTipText ( L<span class="stringliteral">&quot;Remove the selected archive from the FileSystem.&quot;</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">&quot;up&quot;</span> );
gui.ArchiveUp-&gt;setToolTipText ( L<span class="stringliteral">&quot;Arrange Archive Look-up Hirachy. Move the selected Archive up&quot;</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">&quot;down&quot;</span> );
gui.ArchiveDown-&gt;setToolTipText ( L<span class="stringliteral">&quot;Arrange Archive Look-up Hirachy. Move the selected Archive down&quot;</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">&quot;Type&quot;</span>, 0 );
gui.ArchiveList-&gt;addColumn ( L<span class="stringliteral">&quot;Real File Path&quot;</span>, 1 );
gui.ArchiveList-&gt;setColumnWidth ( 0, 60 );
gui.ArchiveList-&gt;setColumnWidth ( 1, 284 );
gui.ArchiveList-&gt;setToolTipText ( L<span class="stringliteral">&quot;Show the attached Archives&quot;</span> );
env-&gt;addStaticText ( L<span class="stringliteral">&quot;Maps:&quot;</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">&quot;Show the current Maps in all Archives.\n Double-Click the Map to start the level&quot;</span> );
<span class="comment">// create a visible Scene Tree</span>
env-&gt;addStaticText ( L<span class="stringliteral">&quot;Scenegraph:&quot;</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">&quot;Show the current Scenegraph&quot;</span> );
gui.SceneTree-&gt;getRoot()-&gt;clearChildren();
addSceneTreeItem ( Game-&gt;Device-&gt;getSceneManager()-&gt;getRootSceneNode(), gui.SceneTree-&gt;getRoot() );
IGUIImageList* imageList = env-&gt;createImageList( driver-&gt;getTexture ( <span class="stringliteral">&quot;iconlist.png&quot;</span> ),
<a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" 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">&quot;irrlichtlogo3.png&quot;</span>), position2d&lt;s32&gt;(5, 16 ), <span class="keyword">true</span>, 0 );
gui.Logo-&gt;setToolTipText ( L<span class="stringliteral">&quot;The great Irrlicht Engine&quot;</span> );
AddArchive ( <span class="stringliteral">&quot;&quot;</span> );
}
</pre></div><p>Add an Archive to the FileSystems and updates the GUI </p>
<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#ab1bdc45edb3f94d8319c02bc0f840ee1" 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#a0416a53257075833e7002efd0a18e804" 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#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index = gui.ArchiveList-&gt;addRow(i);
<a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" 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#adb3e3c445ec8e608ed1f0f93306da14fa63010a52f2efb42f3c85b91ecf077004" title="A PKZIP archive.">io::EFAT_ZIP</a>:
typeName = <span class="stringliteral">&quot;ZIP&quot;</span>;
<span class="keywordflow">break</span>;
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14fa9d37ff1b229bb63f52d29ef65a35b6ce" title="A gzip archive.">io::EFAT_GZIP</a>:
typeName = <span class="stringliteral">&quot;gzip&quot;</span>;
<span class="keywordflow">break</span>;
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14fa1d1f159095f087da5647835b47cd85d4" title="A virtual directory.">io::EFAT_FOLDER</a>:
typeName = <span class="stringliteral">&quot;Mount&quot;</span>;
<span class="keywordflow">break</span>;
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14faae9e1788acfc49c30a77f80f5ced7cf5" title="An ID Software PAK archive.">io::EFAT_PAK</a>:
typeName = <span class="stringliteral">&quot;PAK&quot;</span>;
<span class="keywordflow">break</span>;
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14fa0f36ce25d47b45f41a58e32b4c029cb6" title="A Tape ARchive.">io::EFAT_TAR</a>:
typeName = <span class="stringliteral">&quot;TAR&quot;</span>;
<span class="keywordflow">break</span>;
<span class="keywordflow">default</span>:
typeName = <span class="stringliteral">&quot;archive&quot;</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">&quot;sprite_q3map&quot;</span>);
<span class="keywordflow">if</span> ( 0 == bank )
bank = Game-&gt;Device-&gt;getGUIEnvironment()-&gt;addEmptySpriteBank(<span class="stringliteral">&quot;sprite_q3map&quot;</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#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> g = 0;
<a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" 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#a22364f1caf06442a70f6198025af3fe9a94a9818df56a8fe16b1c7c6f44e8f9f3">FILESYSTEM_VIRTUAL</a> );
fs-&gt;changeWorkingDirectoryTo ( <span class="stringliteral">&quot;/maps/&quot;</span> );
IFileList *fileList = fs-&gt;createFileList ();
fs-&gt;setFileListSystem ( <a class="code" href="namespaceirr_1_1io.html#a22364f1caf06442a70f6198025af3fe9acfbc9e5e8773ec885f08eafd6c8d3c6f">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">&quot;.bsp&quot;</span> ) &gt;= 0 )
{
<span class="comment">// get level screenshot. reformat texture to 128x128</span>
<a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> c ( s );
<a class="code" href="namespaceirr_1_1core.html#a905c95bab4a7e8d5360a19b0726383a9" title="delete path from filename">deletePathFromFilename</a> ( c );
<a class="code" href="namespaceirr_1_1core.html#a188da2e914c6d4a6535bee08565d877b" title="cut the filename extension from a source file path and store it in a dest file path">cutFilenameExtension</a> ( c, c );
c = <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> ( <span class="stringliteral">&quot;levelshots/&quot;</span> ) + c;
<a class="code" href="namespaceirr_1_1core.html#ad2e562e3219072e2f7fc7c2bba0ef0cb" 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#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> filename;
filename = c + <span class="stringliteral">&quot;.jpg&quot;</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">&quot;.tga&quot;</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#a1d5e487888c32b1674a8f75116d829eda3f0380aafb1e1fd59f5419a95d630a6d" 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 </p>
<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><p> Load new map </p>
<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#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> &amp;mapName, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" 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,
<span class="keyword">sizeof</span>(Game-&gt;loadParam), L<span class="stringliteral">&quot;levelparameter.cfg&quot;</span>, <span class="keyword">false</span>);
<span class="comment">// load cfg file</span>
smgr-&gt;getMesh( file );
file-&gt;drop ();
<span class="comment">// load the actual map</span>
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 </p>
<div class="fragment"><pre class="fragment"> IMesh *geometry = Mesh-&gt;getMesh(<a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a44a1a489a965cc9a0ad2c235bbb7bf33a10a5968f2ec9c929bfbca721780a7ef6">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#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> minimalNodes = 2048;
MapParent = smgr-&gt;addOctreeSceneNode(geometry, 0, -1, minimalNodes);
MapParent-&gt;setName ( mapName );
<span class="keywordflow">if</span> ( Meta )
{
selector = smgr-&gt;createOctreeTriangleSelector( 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">&quot;Item Container&quot;</span> );
ShaderParent = smgr-&gt;addEmptySceneNode();
<span class="keywordflow">if</span> ( ShaderParent )
ShaderParent-&gt;setName ( <span class="stringliteral">&quot;Shader Container&quot;</span> );
UnresolvedParent = smgr-&gt;addEmptySceneNode();
<span class="keywordflow">if</span> ( UnresolvedParent )
UnresolvedParent-&gt;setName ( <span class="stringliteral">&quot;Unresolved Container&quot;</span> );
FogParent = smgr-&gt;addEmptySceneNode();
<span class="keywordflow">if</span> ( FogParent )
FogParent-&gt;setName ( <span class="stringliteral">&quot;Fog Container&quot;</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">&quot;Bullet Container&quot;</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? </p>
<div class="fragment"><pre class="fragment"> Q3ShaderFactory ( Game-&gt;loadParam, Game-&gt;Device, Mesh, <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a44a1a489a965cc9a0ad2c235bbb7bf33a15b1dd0b29d69900d070346d61f44319">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#a44a1a489a965cc9a0ad2c235bbb7bf33a8679450d9dcdd4d1b22f38bbd059740b">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#a44a1a489a965cc9a0ad2c235bbb7bf33a9690978438eed9b5e39c7a87e9235b1d">E_Q3_MESH_UNRESOLVED</a>,UnresolvedParent, Meta, <span class="keyword">true</span> );
</pre></div><p>Now construct Models from Entity List </p>
<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 </p>
<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#ac66849b7a6ed16e30ebede579f9b47c6" 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#acad3d7ef92a9807d391ba29120f3b7bda240e6f8e61816ea8f0cdf840b457734c" 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#acad3d7ef92a9807d391ba29120f3b7bda117834c96690a72567a0a813708cf3b6" 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#acad3d7ef92a9807d391ba29120f3b7bda977d9500eeb4d4f23e5676a312367f57" 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#acad3d7ef92a9807d391ba29120f3b7bda25998267ed8640ca0c432df23f1b71fe" 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#acad3d7ef92a9807d391ba29120f3b7bda1cbab0e001b2df07ef2a253434532a52" title="Octree Scene Node.">ESNT_OCTREE</a>: imageIndex = 3; <span class="keywordflow">break</span>;
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#acad3d7ef92a9807d391ba29120f3b7bda073d7fe9dfd49f24cb13bfae56d8d3b6" 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#acad3d7ef92a9807d391ba29120f3b7bdac47a4c2ad206e916f080ad28faed7f3b" 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#acad3d7ef92a9807d391ba29120f3b7bda85e4b3fca8fceb3de9057e91926d2a5f" 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#acad3d7ef92a9807d391ba29120f3b7bdab027cde22a402f6f7f19eb714acf26a4" 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#acad3d7ef92a9807d391ba29120f3b7bda65e7b71bf270e10f94d88bcab8cbf184" 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">&quot;%hs,%hs&quot;</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">&quot;%hs&quot;</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">&quot;%hs&quot;</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#a327a1e43872705cf8f3f3342fb307d19add5f15ecd6c0209d4e3d81a287ae9a66" title="Fly circle scene node animator.">ESNAT_FLY_CIRCLE</a>:
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19af71dad2be8d964a88329d2727fb53b74" title="Fly straight scene node animator.">ESNAT_FLY_STRAIGHT</a>:
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19addc7e3bb5180f7087546ccab14dcc4ad" title="Follow spline scene node animator.">ESNAT_FOLLOW_SPLINE</a>:
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19a689aa5051e83b7f61a7abba85eb1be52" title="Rotation scene node animator.">ESNAT_ROTATION</a>:
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19a2f3e75035fbb3227189a0a3d8bcda993" title="Texture scene node animator.">ESNAT_TEXTURE</a>:
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19abbafee6e6a120e26a6e1ed6bd3cbdc86" title="Deletion scene node animator.">ESNAT_DELETION</a>:
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19af5889b6449faa50d3fabd005d4493490" title="Collision respose scene node animator.">ESNAT_COLLISION_RESPONSE</a>:
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19ae40c836272ace5bf243baaca72dba55c" title="FPS camera animator.">ESNAT_CAMERA_FPS</a>:
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19a851338028c38a91643f70d2a2e5ff8c4" 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#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> dome, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" 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#acaf6f7414534f7d62bff18c5bf11876fa288b302e9d4faaba80c7796c7bc1682c">video::ETCF_CREATE_MIP_MAPS</a>);
driver-&gt;setTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#acaf6f7414534f7d62bff18c5bf11876fa288b302e9d4faaba80c7796c7bc1682c">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[] = { &quot;ft&quot;, &quot;lf&quot;, &quot;bk&quot;, &quot;rt&quot;, &quot;up&quot;, &quot;dn&quot; };</span>
<span class="comment">// quake3 order</span>
<span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a>*p[] = { <span class="stringliteral">&quot;ft&quot;</span>, <span class="stringliteral">&quot;rt&quot;</span>, <span class="stringliteral">&quot;bk&quot;</span>, <span class="stringliteral">&quot;lf&quot;</span>, <span class="stringliteral">&quot;up&quot;</span>, <span class="stringliteral">&quot;dn&quot;</span> };
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i = 0;
snprintf ( buf, 64, <span class="stringliteral">&quot;%s_%s.jpg&quot;</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">&quot;%s_%s.jpg&quot;</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">&quot;%s.jpg&quot;</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">&quot;%s.jpg&quot;</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">&quot;Skydome&quot;</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#acaf6f7414534f7d62bff18c5bf11876fa288b302e9d4faaba80c7796c7bc1682c">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#ac66849b7a6ed16e30ebede579f9b47c6" 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;clearChildren();
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 </p>
<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#ac9eed96e06e85ce3c86fcbbbe9e48a0ca8553b889c8da285c96b90116ae019952" 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#ac9eed96e06e85ce3c86fcbbbe9e48a0cae85bb44dd09a29c879d64a05047fc1d2" 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#aeac71ad17341a4b6e9026ae11d576808a3f3c374a3c74405ee3eac6973e78345f" title="An item in the listbox was selected, which was already selected.">gui::EGET_LISTBOX_SELECTED_AGAIN</a> )
{
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" 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#aef83fafbb1b36fcce44c07c9be23a7f2" 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">&quot;Loading map %ls\n&quot;</span>, loadMap.c_str() );
LoadMap ( loadMap , 1 );
<span class="keywordflow">if</span> ( 0 == Game-&gt;loadParam.loadSkyShader )
{
AddSky ( 1, <span class="stringliteral">&quot;skydome2&quot;</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#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" 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">&quot;&quot;</span>;
AddArchive ( <span class="stringliteral">&quot;&quot;</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#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" 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#a22364f1caf06442a70f6198025af3fe9acfbc9e5e8773ec885f08eafd6c8d3c6f">FILESYSTEM_NATIVE</a> );
gui.ArchiveFileOpen = Game-&gt;Device-&gt;getGUIEnvironment()-&gt;addFileOpenDialog ( L<span class="stringliteral">&quot;Add Game Archive&quot;</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#aeac71ad17341a4b6e9026ae11d576808a5b6504cf6b541d5ad95407c384632873" 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#aeac71ad17341a4b6e9026ae11d576808a0c8a9e059bd8efe74e2f747e2e9187b3" 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#aeac71ad17341a4b6e9026ae11d576808ae524b2c68bc8c3117c6ae7a2d2df7865" 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#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" title="A button was clicked.">gui::EGET_BUTTON_CLICKED</a> )
{
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" 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#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> newIndex = <a class="code" href="namespaceirr_1_1core.html#aa7828c932a36c62a67fd0f2b972d8b21">core::s32_clamp</a> ( gui.ArchiveList-&gt;getSelected() + rel, 0, gui.ArchiveList-&gt;getRowCount() - 1 );
AddArchive ( <span class="stringliteral">&quot;&quot;</span> );
gui.ArchiveList-&gt;setSelected ( newIndex );
Game-&gt;CurrentMapName = <span class="stringliteral">&quot;&quot;</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#aeac71ad17341a4b6e9026ae11d576808aef7f9081622a71160e161c80eb07d436" 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#ae35a6de6d436c76107ad157fe42356d0" 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#aeac71ad17341a4b6e9026ae11d576808aef7f9081622a71160e161c80eb07d436" title="The selection in a combo box has been changed.">gui::EGET_COMBO_BOX_CHANGED</a> )
{
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" 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#aeac71ad17341a4b6e9026ae11d576808a16a1f6de4aeb2d7f34f7b7dbff0a7a0a" 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#aeac71ad17341a4b6e9026ae11d576808a16a1f6de4aeb2d7f34f7b7dbff0a7a0a" 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#aeac71ad17341a4b6e9026ae11d576808a2eea536494edcde2bb2608bda9d352b2" 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#aeac71ad17341a4b6e9026ae11d576808a2eea536494edcde2bb2608bda9d352b2" 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#aeac71ad17341a4b6e9026ae11d576808a2eea536494edcde2bb2608bda9d352b2" 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#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" 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#aeac71ad17341a4b6e9026ae11d576808a9879e90ebeaf90f3ec7477acc1a46749" 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#aeac71ad17341a4b6e9026ae11d576808a16a1f6de4aeb2d7f34f7b7dbff0a7a0a" 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">&quot;collision %d\n&quot;</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#aeac71ad17341a4b6e9026ae11d576808a16a1f6de4aeb2d7f34f7b7dbff0a7a0a" 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">&quot;static node set visible %d\n&quot;</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#aeac71ad17341a4b6e9026ae11d576808a16a1f6de4aeb2d7f34f7b7dbff0a7a0a" 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">&quot;shader node set visible %d\n&quot;</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#aeac71ad17341a4b6e9026ae11d576808a16a1f6de4aeb2d7f34f7b7dbff0a7a0a" 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">&quot;skynode set visible %d\n&quot;</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#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" 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#ac9eed96e06e85ce3c86fcbbbe9e48a0ca6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">EET_KEY_INPUT_EVENT</a> &amp;&amp; eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a52c3b1744ca8ae7b6da19fc00fbb8ee8">KEY_SPACE</a> &amp;&amp;
eve.KeyInput.PressedDown == <span class="keyword">false</span>) ||
(eve.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0caa230b748674e074aa67f661819ad5891" title="A mouse input event.">EET_MOUSE_INPUT_EVENT</a> &amp;&amp; eve.MouseInput.Event == <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa26d91b99a8912ff622133f02c60f306a" 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#ac9eed96e06e85ce3c86fcbbbe9e48a0ca6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">EET_KEY_INPUT_EVENT</a> &amp;&amp; eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a5427274e34fd5587155fe8b3b12d96a8">KEY_F1</a> &amp;&amp;
eve.KeyInput.PressedDown == <span class="keyword">false</span>) ||
(eve.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0caa230b748674e074aa67f661819ad5891" title="A mouse input event.">EET_MOUSE_INPUT_EVENT</a> &amp;&amp; eve.MouseInput.Event == <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fadb92d5c1011534b2b18065573182d9f4" 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#ac9eed96e06e85ce3c86fcbbbe9e48a0ca6f90390f3147a1693e5e2e3422d6ca09" 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#a54da2a0e231901735e3da1b0edf72eb3aab32bfc194f119e5d5b9b39527bbcd61">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#a54da2a0e231901735e3da1b0edf72eb3af847cf3df62b0e23942f0bd2d226a9eb">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#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> pos;
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" 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#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *dName[] = { <span class="stringliteral">&quot;null&quot;</span>, <span class="stringliteral">&quot;software&quot;</span>, <span class="stringliteral">&quot;burning&quot;</span>,
<span class="stringliteral">&quot;d3d8&quot;</span>, <span class="stringliteral">&quot;d3d9&quot;</span>, <span class="stringliteral">&quot;opengl&quot;</span> };
snprintf(buf, 256, <span class="stringliteral">&quot;%s_%ls_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f.jpg&quot;</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#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> filename ( buf );
filename.replace ( <span class="charliteral">&#39;/&#39;</span>, <span class="charliteral">&#39;_&#39;</span> );
printf ( <span class="stringliteral">&quot;screenshot : %s\n&quot;</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#a54da2a0e231901735e3da1b0edf72eb3a5dfbe4e0c7c8d9d810717fc1331fd3c9">KEY_F9</a>)
{
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> value = <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea25111b15f03bee9a99498737286916dc" 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#a52b664c4c988113735042b168fc32dbea2713e470ee18ec9bfe40fdfb502f8b05" title="Show Vertex Normals.">EDS_NORMALS</a> | <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea349b086537ac770f09935af4e31d3f3e" title="Overlays Mesh Wireframe.">EDS_MESH_WIRE_OVERLAY</a> | <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea80f38e42f1b8cf169e83f44092367bfe" 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#a52b664c4c988113735042b168fc32dbea2713e470ee18ec9bfe40fdfb502f8b05" title="Show Vertex Normals.">EDS_NORMALS</a> | <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea349b086537ac770f09935af4e31d3f3e" title="Overlays Mesh Wireframe.">EDS_MESH_WIRE_OVERLAY</a> | <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbeaa7664e189b8641ac54cf27f70f6d8144" 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; </p>
<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#a54da2a0e231901735e3da1b0edf72eb3a5111be01fea6429912b3e497b2a85d73">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">&quot;earth&quot;</span> : <span class="stringliteral">&quot;none&quot;</span> ) );
printf ( <span class="stringliteral">&quot;gravity %s\n&quot;</span>, Game-&gt;gravityState ? <span class="stringliteral">&quot;earth&quot;</span> : <span class="stringliteral">&quot;none&quot;</span> );
}
<span class="keywordflow">else</span>
<span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a7f58cecbda71cea3043c026d3ba00456">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">&quot;collision %d\n&quot;</span>, Game-&gt;flyTroughState == 0 );
}
<span class="keywordflow">else</span>
<span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a992b194a5b4b4809587db8a43c3e75dd">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#a54da2a0e231901735e3da1b0edf72eb3a2f017f7a3b6291e5d549ed4a09c03d4e">KEY_F3</a>)
{
<span class="keywordflow">if</span> ( MapParent )
{
<span class="keywordtype">bool</span> v = !MapParent-&gt;isVisible ();
printf ( <span class="stringliteral">&quot;static node set visible %d\n&quot;</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#a54da2a0e231901735e3da1b0edf72eb3a8f49f2e6664716985551334f0b2c1b47">KEY_F4</a>)
{
<span class="keywordflow">if</span> ( ShaderParent )
{
<span class="keywordtype">bool</span> v = !ShaderParent-&gt;isVisible ();
printf ( <span class="stringliteral">&quot;shader node set visible %d\n&quot;</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#a54da2a0e231901735e3da1b0edf72eb3a6aecea6261588331b87093b4ab544b1a">KEY_F5</a>)
{
<span class="keywordflow">if</span> ( FogParent )
{
<span class="keywordtype">bool</span> v = !FogParent-&gt;isVisible ();
printf ( <span class="stringliteral">&quot;fog node set visible %d\n&quot;</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#a54da2a0e231901735e3da1b0edf72eb3a6c0530c3448c3274b137f97df44e2a44">KEY_F6</a>)
{
<span class="keywordflow">if</span> ( UnresolvedParent )
{
<span class="keywordtype">bool</span> v = !UnresolvedParent-&gt;isVisible ();
printf ( <span class="stringliteral">&quot;unresolved node set visible %d\n&quot;</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#ac9eed96e06e85ce3c86fcbbbe9e48a0ca6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">EET_KEY_INPUT_EVENT</a> &amp;&amp; eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a85a756fa6a3336312c5f32877a7185e5">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#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(30,45,30) );
anim-&gt;setEllipsoidTranslation ( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" 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#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(30,20,30) );
anim-&gt;setEllipsoidTranslation ( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" 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 </p>
<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#a06f169d08b5c429f5575acb7edbad811" 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#a06f169d08b5c429f5575acb7edbad811" 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#a1112835405bbec5dadf031dc7934e7d0" 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>
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#a06f169d08b5c429f5575acb7edbad811" 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">&quot;pow&quot;</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#a06f169d08b5c429f5575acb7edbad811" 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#a06f169d08b5c429f5575acb7edbad811" 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#a8a3bc00ae8137535b9fbc5f40add70d3acea597a2692b8415486a464a7f954d34" 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">&quot;fireball.bmp&quot;</span>));
node-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a4bc03b7b9dd19e577bf909313ea62510" title="May be written to the zbuffer or is it readonly. Default: true.">video::EMF_ZWRITE_ENABLE</a>, <span class="keyword">false</span>);
node-&gt;setMaterialType(<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a1b5a814c4466aca2943ff056003a50d1" title="A transparent material.">EMT_TRANSPARENT_ADD_COLOR</a>);
<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> length = (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)(end - start).getLength();
<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> speed = 5.8f;
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> time = (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" 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">&quot;bullet: %s on %.1f,%1.f,%1.f&quot;</span>,
imp.when ? <span class="stringliteral">&quot;hit&quot;</span> : <span class="stringliteral">&quot;nohit&quot;</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#ac66849b7a6ed16e30ebede579f9b47c6" 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#a0416a53257075833e7002efd0a18e804" 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#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> * texture;
<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> scale;
<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> minparticleSize;
<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> maxparticleSize;
<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> boxSize;
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> minParticle;
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> maxParticle;
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> fadeout;
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> lifetime;
};
smokeLayer smoke[] =
{
{ <span class="stringliteral">&quot;smoke2.jpg&quot;</span>, 0.4f, 1.5f, 18.f, 20.f, 20, 50, 2000, 10000 },
{ <span class="stringliteral">&quot;smoke3.jpg&quot;</span>, 0.2f, 1.2f, 15.f, 20.f, 10, 30, 1000, 12000 }
};
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i;
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> g;
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" 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">&quot;bullet impact smoke at %.1f,%.1f,%1.f&quot;</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#a06f169d08b5c429f5575acb7edbad811" 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#a8a3bc00ae8137535b9fbc5f40add70d3acea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">video::EMF_LIGHTING</a>, <span class="keyword">false</span>);
pas-&gt;setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a4bc03b7b9dd19e577bf909313ea62510" title="May be written to the zbuffer or is it readonly. Default: true.">video::EMF_ZWRITE_ENABLE</a>, <span class="keyword">false</span>);
pas-&gt;setMaterialType(<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a1b5a814c4466aca2943ff056003a50d1" title="A transparent material.">video::EMT_TRANSPARENT_ADD_COLOR</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>
<p>if (sound) { adjust max value a bit to make to sound of an impact louder sound-&gt;setMinDistance(400); sound-&gt;drop(); } } </p>
<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 </p>
<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>;
<span class="comment">// TODO: This does not work, yet.</span>
<span class="keyword">const</span> <span class="keywordtype">bool</span> anaglyph=<span class="keyword">false</span>;
<span class="keywordflow">if</span> (anaglyph)
{
scene::ICameraSceneNode* cameraOld = Game-&gt;Device-&gt;getSceneManager()-&gt;getActiveCamera();
driver-&gt;beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, SColor(0,0,0,0));
driver-&gt;getOverrideMaterial().Material.ColorMask = <a class="code" href="namespaceirr_1_1video.html#aa9f25191ae536c1a4b08ec5334866a21aa5afe366b19c967f884d0bd4ca083df9" title="No color enabled.">ECP_NONE</a>;
driver-&gt;getOverrideMaterial().EnableFlags = <a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a72ede4598946d81f12aa407fb680fc40" title="ColorMask bits, for enabling the color planes.">EMF_COLOR_MASK</a>;
driver-&gt;getOverrideMaterial().EnablePasses = <a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fac41f4cb4900e84b9e55462089d0e3cb8" title="This is used for sky boxes.">ESNRP_SKY_BOX</a> +
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fad058b020ab42ad745cc03fe379148e1f" title="Solid scene nodes or special scene nodes without materials.">ESNRP_SOLID</a> +
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fad3a1300505d0ab06133e25256b893b2b" title="Transparent scene nodes, drawn after solid nodes. They are sorted from back to front and drawn in tha...">ESNRP_TRANSPARENT</a> +
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fa3d134d3f703e328ab5798e5ff4a5c186" title="Transparent effect scene nodes, drawn after Transparent nodes. They are sorted from back to front and...">ESNRP_TRANSPARENT_EFFECT</a> +
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fadbc7353e3092974abaa4d063faa22421" title="Drawn after the solid nodes, before the transparent nodes, the time for drawing shadow volumes...">ESNRP_SHADOW</a>;
Game-&gt;Device-&gt;getSceneManager()-&gt;drawAll();
driver-&gt;clearZBuffer();
<span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> oldPosition = cameraOld-&gt;getPosition();
<span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> oldTarget = cameraOld-&gt;getTarget();
<span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a73fa92e638c5ca97efd72da307cc9b65" title="Typedef for f32 matrix.">matrix4</a> startMatrix = cameraOld-&gt;getAbsoluteTransformation();
<span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> focusPoint = (oldTarget -
cameraOld-&gt;getAbsolutePosition()).setLength(10000) +
cameraOld-&gt;getAbsolutePosition() ;
scene::ICameraSceneNode* camera = cameraOld;<span class="comment">//Game-&gt;Device-&gt;getSceneManager()-&gt;addCameraSceneNode();</span>
<span class="comment">//Left eye...</span>
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> pos;
<a class="code" href="namespaceirr_1_1core.html#a73fa92e638c5ca97efd72da307cc9b65" title="Typedef for f32 matrix.">matrix4</a> move;
move.setTranslation( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(-1.5f,0.0f,0.0f) );
pos=(startMatrix*move).getTranslation();
driver-&gt;getOverrideMaterial().Material.ColorMask = <a class="code" href="namespaceirr_1_1video.html#aa9f25191ae536c1a4b08ec5334866a21a36263a436337ff10be86fc9b5ae2f6d0" title="Red enabled.">ECP_RED</a>;
driver-&gt;getOverrideMaterial().EnableFlags = <a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a72ede4598946d81f12aa407fb680fc40" title="ColorMask bits, for enabling the color planes.">EMF_COLOR_MASK</a>;
driver-&gt;getOverrideMaterial().EnablePasses =
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fac41f4cb4900e84b9e55462089d0e3cb8" title="This is used for sky boxes.">ESNRP_SKY_BOX</a>|<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fad058b020ab42ad745cc03fe379148e1f" title="Solid scene nodes or special scene nodes without materials.">ESNRP_SOLID</a>|<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fad3a1300505d0ab06133e25256b893b2b" title="Transparent scene nodes, drawn after solid nodes. They are sorted from back to front and drawn in tha...">ESNRP_TRANSPARENT</a>|
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fa3d134d3f703e328ab5798e5ff4a5c186" title="Transparent effect scene nodes, drawn after Transparent nodes. They are sorted from back to front and...">ESNRP_TRANSPARENT_EFFECT</a>|<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fadbc7353e3092974abaa4d063faa22421" title="Drawn after the solid nodes, before the transparent nodes, the time for drawing shadow volumes...">ESNRP_SHADOW</a>;
camera-&gt;setPosition(pos);
camera-&gt;setTarget(focusPoint);
Game-&gt;Device-&gt;getSceneManager()-&gt;drawAll();
driver-&gt;clearZBuffer();
<span class="comment">//Right eye...</span>
move.setTranslation( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(1.5f,0.0f,0.0f) );
pos=(startMatrix*move).getTranslation();
driver-&gt;getOverrideMaterial().Material.ColorMask = <a class="code" href="namespaceirr_1_1video.html#aa9f25191ae536c1a4b08ec5334866a21a1e712fd8781a461da6f0a293a3e7180f" title="Green enabled.">ECP_GREEN</a> + <a class="code" href="namespaceirr_1_1video.html#aa9f25191ae536c1a4b08ec5334866a21a31e270dab7c29a6e642ac491b172d16d" title="Blue enabled.">ECP_BLUE</a>;
driver-&gt;getOverrideMaterial().EnableFlags = <a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a72ede4598946d81f12aa407fb680fc40" title="ColorMask bits, for enabling the color planes.">EMF_COLOR_MASK</a>;
driver-&gt;getOverrideMaterial().EnablePasses =
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fac41f4cb4900e84b9e55462089d0e3cb8" title="This is used for sky boxes.">ESNRP_SKY_BOX</a>|<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fad058b020ab42ad745cc03fe379148e1f" title="Solid scene nodes or special scene nodes without materials.">ESNRP_SOLID</a>|<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fad3a1300505d0ab06133e25256b893b2b" title="Transparent scene nodes, drawn after solid nodes. They are sorted from back to front and drawn in tha...">ESNRP_TRANSPARENT</a>|
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fa3d134d3f703e328ab5798e5ff4a5c186" title="Transparent effect scene nodes, drawn after Transparent nodes. They are sorted from back to front and...">ESNRP_TRANSPARENT_EFFECT</a>|<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fadbc7353e3092974abaa4d063faa22421" title="Drawn after the solid nodes, before the transparent nodes, the time for drawing shadow volumes...">ESNRP_SHADOW</a>;
camera-&gt;setPosition(pos);
camera-&gt;setTarget(focusPoint);
Game-&gt;Device-&gt;getSceneManager()-&gt;drawAll();
driver-&gt;getOverrideMaterial().Material.ColorMask=<a class="code" href="namespaceirr_1_1video.html#aa9f25191ae536c1a4b08ec5334866a21a674ec773096b1b504b38ed78213e1e38" title="All planes enabled.">ECP_ALL</a>;
driver-&gt;getOverrideMaterial().EnableFlags=0;
driver-&gt;getOverrideMaterial().EnablePasses=0;
<span class="keywordflow">if</span> (camera != cameraOld)
{
Game-&gt;Device-&gt;getSceneManager()-&gt;setActiveCamera(cameraOld);
camera-&gt;remove();
}
<span class="keywordflow">else</span>
{
camera-&gt;setPosition(oldPosition);
camera-&gt;setTarget(oldTarget);
}
}
<span class="keywordflow">else</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 </p>
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::Animate()
{
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" 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();
<span class="preprocessor">#ifdef _IRR_SCENEMANAGER_DEBUG </span>
<span class="preprocessor"></span> swprintf ( msg, 128,
L<span class="stringliteral">&quot;Q3 %s [%ls], FPS:%03d Tri:%.03fm Cull %d/%d nodes (%d,%d,%d)&quot;</span>,
Game-&gt;CurrentMapName.c_str(),
driver-&gt;getName(),
driver-&gt;getFPS (),
(<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>) driver-&gt;getPrimitiveCountDrawn( 0 ) * ( 1.f / 1000000.f ),
attr-&gt;getAttributeAsInt ( <span class="stringliteral">&quot;culled&quot;</span> ),
attr-&gt;getAttributeAsInt ( <span class="stringliteral">&quot;calls&quot;</span> ),
attr-&gt;getAttributeAsInt ( <span class="stringliteral">&quot;drawn_solid&quot;</span> ),
attr-&gt;getAttributeAsInt ( <span class="stringliteral">&quot;drawn_transparent&quot;</span> ),
attr-&gt;getAttributeAsInt ( <span class="stringliteral">&quot;drawn_transparent_effect&quot;</span> )
);
<span class="preprocessor">#else</span>
<span class="preprocessor"></span>swprintf ( msg, 128,
L<span class="stringliteral">&quot;Q3 %s [%ls], FPS:%03d Tri:%.03fm&quot;</span>,
Game-&gt;CurrentMapName.c_str(),
driver-&gt;getName(),
driver-&gt;getFPS (),
(<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>) driver-&gt;getPrimitiveCountDrawn( 0 ) * ( 1.f / 1000000.f )
);
<span class="preprocessor">#endif </span>
<span class="preprocessor"></span> Game-&gt;Device-&gt;setWindowCaption( msg );
swprintf ( msg, 128,
L<span class="stringliteral">&quot;%03d fps, F1 GUI on/off, F2 respawn, F3-F6 toggle Nodes, F7 Collision on/off&quot;</span>
L<span class="stringliteral">&quot;, F8 Gravity on/off, Right Mouse Toggle GUI&quot;</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">&quot;idle&quot;</span> ) )
player-&gt;setAnim ( <span class="stringliteral">&quot;idle&quot;</span> );
player-&gt;Anim[1].flags &amp;= ~FIRED;
}
createParticleImpacts ( now );
}
</pre></div><p> The main game states </p>
<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">&quot;explorer.cfg&quot;</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#a0416a53257075833e7002efd0a18e804" 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">&quot;skydome2&quot;</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">&quot;skydome2&quot;</span> );
eventHandler-&gt;CreatePlayers ();
eventHandler-&gt;CreateGUI ();
eventHandler-&gt;SetGUIActive ( 1 );
background_music ( <span class="stringliteral">&quot;IrrlichtTheme.ogg&quot;</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, &quot;/subsystem:windows /ENTRY:mainCRTStartup&quot;)</span>
<span class="preprocessor">#endif</span>
</pre></div><p> The main routine, doing all setup </p>
<div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> <a class="code" href="_irr_compile_config_8h.html#a3f9bf2240c47d3f99b86f83f9123aa9d">IRRCALLCONV</a> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
{
<a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> prgname(argv[0]);
GameData game ( <a class="code" href="namespaceirr_1_1core.html#a9215d20e34c12cb6c1522366389bfcce" 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#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> * dllName = argc &gt; 1 ? argv[1] : <span class="stringliteral">&quot;irrlicht.dll&quot;</span>;
game.createExDevice = load_createDeviceEx ( dllName );
<span class="keywordflow">if</span> ( 0 == game.createExDevice )
{
game.retVal = 3;
printf ( <span class="stringliteral">&quot;Could not load %s.\n&quot;</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 ();
<span class="comment">// ask user for driver</span>
game.deviceParam.DriverType=driverChoiceConsole();
<span class="keywordflow">if</span> (game.deviceParam.DriverType==<a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0ae685cada50f8c100403134d932d0414c" title="No driver, just for counting the elements.">video::EDT_COUNT</a>)
game.retVal = 3;
}
runGame ( &amp;game );
} <span class="keywordflow">while</span> ( game.retVal &lt; 3 );
<span class="keywordflow">return</span> game.retVal;
}
</pre></div> </div></div>
</div>
<div id="nav-path" class="navpath">
<ul>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<li class="footer">
<a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht
Engine</a> Documentation &copy; 2003-2012 by Nikolaus Gebhardt. Generated on Tue Jan 19 2016 16:08:47 for Irrlicht 3D Engine by
<a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li>
</ul>
</div>
</body>
</html>