irrlicht/examples/21.Quake3Explorer/tutorial.html
cutealien 21302d038a Merging r6196 through r6248 from trunk to ogl-es branch
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6249 dfc29bdd-3216-0410-991c-e03cc46cb475
2021-08-26 21:57:27 +00:00

219 lines
149 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Tutorial 21: Quake3 Explorer</title>
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- Wanted to avoid copying .css to each folder, so copied default .css from doxyen in here, kicked out most stuff we don't need for examples and modified some a little bit.
Target was having a single html in each example folder which is created from the main.cpp files and needs no files besides some images below media folder.
Feel free to improve :)
-->
<style>
body, table, div, p, dl {
font: 400 14px/22px;
}
body {
background-color: #F0F0F0;
color: black;
margin-left: 5%;
margin-right: 5%;
}
p.reference, p.definition {
font: 400 14px/22px;
}
.title {
font: 400 14px/28px;
font-size: 150%;
font-weight: bold;
margin: 10px 2px;
}
h1, h2, h3, h4, h5, h6 {
-webkit-transition: text-shadow 0.5s linear;
-moz-transition: text-shadow 0.5s linear;
-ms-transition: text-shadow 0.5s linear;
-o-transition: text-shadow 0.5s linear;
transition: text-shadow 0.5s linear;
margin-right: 15px;
}
caption {
font-weight: bold;
}
h3.version {
font-size: 90%;
text-align: center;
}
a {
color: #3D578C;
font-weight: normal;
text-decoration: none;
}
.contents a:visited {
color: #4665A2;
}
a:hover {
text-decoration: underline;
}
a.el {
font-weight: bold;
}
a.code, a.code:visited, a.line, a.line:visited {
color: #4665A2;
}
a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited {
color: #4665A2;
}
pre.fragment {
border: 1px solid #C4CFE5;
background-color: #FBFCFD;
padding: 4px 6px;
margin: 4px 8px 4px 2px;
overflow: auto;
word-wrap: break-word;
font-size: 9pt;
line-height: 125%;
font-family: monospace, fixed;
font-size: 105%;
}
div.fragment {
padding: 0px;
margin: 4px 8px 4px 2px;
background-color: #FBFCFD;
border: 1px solid #C4CFE5;
}
div.line {
font-family: monospace, fixed;
font-size: 13px;
min-height: 13px;
line-height: 1.0;
text-wrap: unrestricted;
white-space: -moz-pre-wrap; /* Moz */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: pre-wrap; /* CSS3 */
word-wrap: break-word; /* IE 5.5+ */
text-indent: -53px;
padding-left: 53px;
padding-bottom: 0px;
margin: 0px;
-webkit-transition-property: background-color, box-shadow;
-webkit-transition-duration: 0.5s;
-moz-transition-property: background-color, box-shadow;
-moz-transition-duration: 0.5s;
-ms-transition-property: background-color, box-shadow;
-ms-transition-duration: 0.5s;
-o-transition-property: background-color, box-shadow;
-o-transition-duration: 0.5s;
transition-property: background-color, box-shadow;
transition-duration: 0.5s;
}
div.contents {
margin-top: 10px;
margin-left: 12px;
margin-right: 8px;
}
div.center {
text-align: center;
margin-top: 0px;
margin-bottom: 0px;
padding: 0px;
}
div.center img {
border: 0px;
}
span.keyword {
color: #008000
}
span.keywordtype {
color: #604020
}
span.keywordflow {
color: #e08000
}
span.comment {
color: #800000
}
span.preprocessor {
color: #806020
}
span.stringliteral {
color: #002080
}
span.charliteral {
color: #008080
}
blockquote {
background-color: #F7F8FB;
border-left: 2px solid #9CAFD4;
margin: 0 24px 0 4px;
padding: 0 12px 0 16px;
}
hr {
height: 0px;
border: none;
border-top: 1px solid #4A6AAA;
}
address {
font-style: normal;
color: #2A3D61;
}
div.header {
background-image:url('nav_h.png');
background-repeat:repeat-x;
background-color: #F9FAFC;
margin: 0px;
border-bottom: 1px solid #C4CFE5;
}
div.headertitle {
padding: 5px 5px 5px 10px;
}
.image {
text-align: center;
}
.caption {
font-weight: bold;
}
div.zoom {
border: 1px solid #90A5CE;
}
tr.heading h2 {
margin-top: 12px;
margin-bottom: 4px;
}
</style>
</head>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<!--END TITLEAREA-->
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">Tutorial 21: Quake3 Explorer </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><div class="image">
<img src="../../media/example_screenshots/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"><div class="line"><span class="preprocessor">#include &lt;irrlicht.h&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;driverChoice.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;exampleHelper.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;q3factory.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;sound.h&quot;</span></div></div><!-- fragment --><p> Game Data is used to hold Data which is needed to drive the game </p><div class="fragment"><div class="line"><span class="keyword">struct </span>GameData</div><div class="line">{</div><div class="line"> GameData ( <span class="keyword">const</span> path &amp;startupDir) :</div><div class="line"> retVal(0), StartupDir(startupDir), createExDevice(0), Device(0)</div><div class="line"> {</div><div class="line"> setDefault ();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> setDefault ();</div><div class="line"> s32 save ( <span class="keyword">const</span> path &amp;filename );</div><div class="line"> s32 load ( <span class="keyword">const</span> path &amp;filename );</div><div class="line"></div><div class="line"> s32 debugState;</div><div class="line"> s32 gravityState;</div><div class="line"> s32 flyTroughState;</div><div class="line"> s32 wireFrame;</div><div class="line"> s32 guiActive;</div><div class="line"> s32 guiInputActive;</div><div class="line"> f32 GammaValue;</div><div class="line"> s32 retVal;</div><div class="line"> s32 sound;</div><div class="line"></div><div class="line"> path StartupDir;</div><div class="line"> stringw CurrentMapName;</div><div class="line"> array&lt;path&gt; CurrentArchiveList;</div><div class="line"></div><div class="line"> vector3df PlayerPosition;</div><div class="line"> vector3df PlayerRotation;</div><div class="line"></div><div class="line"> tQ3EntityList Variable;</div><div class="line"></div><div class="line"> Q3LevelLoadParameter loadParam;</div><div class="line"> SIrrlichtCreationParameters deviceParam;</div><div class="line"> funcptr_createDeviceEx createExDevice;</div><div class="line"> IrrlichtDevice *Device;</div><div class="line">};</div></div><!-- fragment --><p> set default settings </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> GameData::setDefault ()</div><div class="line">{</div><div class="line"> debugState = EDS_OFF;</div><div class="line"> gravityState = 1;</div><div class="line"> flyTroughState = 0;</div><div class="line"> wireFrame = 0;</div><div class="line"> guiActive = 1;</div><div class="line"> guiInputActive = 0;</div><div class="line"> GammaValue = 1.f;</div><div class="line"></div><div class="line"> <span class="comment">// default deviceParam;</span></div><div class="line"><span class="preprocessor">#if defined ( _IRR_WINDOWS_ )</span></div><div class="line"> deviceParam.DriverType = EDT_DIRECT3D9;</div><div class="line"><span class="preprocessor">#else</span></div><div class="line"> deviceParam.DriverType = EDT_OPENGL;</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"> deviceParam.WindowSize.Width = 800;</div><div class="line"> deviceParam.WindowSize.Height = 600;</div><div class="line"> deviceParam.Fullscreen = <span class="keyword">false</span>;</div><div class="line"> deviceParam.Bits = 24;</div><div class="line"> deviceParam.ZBufferBits = 16;</div><div class="line"> deviceParam.Vsync = <span class="keyword">false</span>;</div><div class="line"> deviceParam.AntiAlias = <span class="keyword">false</span>;</div><div class="line"></div><div class="line"> <span class="comment">// default Quake3 loadParam</span></div><div class="line"> loadParam.defaultLightMapMaterial = EMT_LIGHTMAP;</div><div class="line"> loadParam.defaultModulate = EMFN_MODULATE_1X;</div><div class="line"> loadParam.defaultFilter = EMF_ANISOTROPIC_FILTER;</div><div class="line"> loadParam.verbose = 2;</div><div class="line"> loadParam.mergeShaderBuffer = 1; <span class="comment">// merge meshbuffers with same material</span></div><div class="line"> loadParam.cleanUnResolvedMeshes = 1; <span class="comment">// should unresolved meshes be cleaned. otherwise blue texture</span></div><div class="line"> loadParam.loadAllShaders = 1; <span class="comment">// load all scripts in the script directory</span></div><div class="line"> loadParam.loadSkyShader = 0; <span class="comment">// load sky Shader</span></div><div class="line"> loadParam.alpharef = 1;</div><div class="line"></div><div class="line"> sound = 0;</div><div class="line"></div><div class="line"> CurrentMapName = <span class="stringliteral">&quot;&quot;</span>;</div><div class="line"> CurrentArchiveList.clear ();</div><div class="line"></div><div class="line"> <span class="keyword">const</span> io::path mediaPath = getExampleMediaPath();</div><div class="line"></div><div class="line"> <span class="comment">// Explorer Media directory</span></div><div class="line"> CurrentArchiveList.push_back ( StartupDir + mediaPath );</div><div class="line"></div><div class="line"> <span class="comment">// Add the original quake3 files before you load your custom map</span></div><div class="line"> <span class="comment">// Most mods are using the original shaders, models&amp;items&amp;weapons</span></div><div class="line"> CurrentArchiveList.push_back(<span class="stringliteral">&quot;/q/baseq3/&quot;</span>);</div><div class="line"></div><div class="line"> CurrentArchiveList.push_back(StartupDir + mediaPath + <span class="stringliteral">&quot;map-20kdm2.pk3&quot;</span>);</div><div class="line">}</div></div><!-- fragment --><p> Load the current game State from a typical quake3 cfg file </p><div class="fragment"><div class="line">s32 GameData::load ( <span class="keyword">const</span> path &amp;filename )</div><div class="line">{</div><div class="line"> <span class="keywordflow">if</span> (!Device)</div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line"></div><div class="line"> <span class="comment">// the quake3 mesh loader can also handle *.shader and *.cfg file</span></div><div class="line"> IQ3LevelMesh* mesh = (IQ3LevelMesh*) Device-&gt;getSceneManager()-&gt;getMesh ( filename );</div><div class="line"> <span class="keywordflow">if</span> (!mesh)</div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line"></div><div class="line"> tQ3EntityList &amp;entityList = mesh-&gt;getEntityList ();</div><div class="line"></div><div class="line"> stringc s;</div><div class="line"> u32 pos;</div><div class="line"></div><div class="line"> <span class="keywordflow">for</span> ( u32 e = 0; e != entityList.size (); ++e )</div><div class="line"> {</div><div class="line"> <span class="comment">//dumpShader ( s, &amp;entityList[e], false );</span></div><div class="line"> <span class="comment">//printf ( s.c_str () );</span></div><div class="line"></div><div class="line"> <span class="keywordflow">for</span> ( u32 g = 0; g != entityList[e].getGroupSize (); ++g )</div><div class="line"> {</div><div class="line"> <span class="keyword">const</span> SVarGroup *group = entityList[e].getGroup ( g );</div><div class="line"></div><div class="line"> <span class="keywordflow">for</span> ( u32 index = 0; index &lt; group-&gt;Variable.size (); ++index )</div><div class="line"> {</div><div class="line"> <span class="keyword">const</span> SVariable &amp;v = group-&gt;Variable[index];</div><div class="line"> pos = 0;</div><div class="line"> <span class="keywordflow">if</span> ( v.name == <span class="stringliteral">&quot;playerposition&quot;</span> )</div><div class="line"> {</div><div class="line"> PlayerPosition = getAsVector3df ( v.content, pos );</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( v.name == <span class="stringliteral">&quot;playerrotation&quot;</span> )</div><div class="line"> {</div><div class="line"> PlayerRotation = getAsVector3df ( v.content, pos );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> 1;</div><div class="line">}</div></div><!-- fragment --><p> Store the current game State in a quake3 configuration file </p><div class="fragment"><div class="line">s32 GameData::save ( <span class="keyword">const</span> path &amp;filename )</div><div class="line">{</div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line"> <span class="keywordflow">if</span> (!Device)</div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line"></div><div class="line"> c8 buf[128];</div><div class="line"> u32 i;</div><div class="line"></div><div class="line"> <span class="comment">// Store current Archive for restart</span></div><div class="line"> CurrentArchiveList.clear();</div><div class="line"> IFileSystem *fs = Device-&gt;getFileSystem();</div><div class="line"> <span class="keywordflow">for</span> ( i = 0; i != fs-&gt;getFileArchiveCount(); ++i )</div><div class="line"> {</div><div class="line"> CurrentArchiveList.push_back ( fs-&gt;getFileArchive(i)-&gt;getFileList()-&gt;getPath() );</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Store Player Position and Rotation</span></div><div class="line"> ICameraSceneNode * camera = Device-&gt;getSceneManager()-&gt;getActiveCamera ();</div><div class="line"> <span class="keywordflow">if</span> ( camera )</div><div class="line"> {</div><div class="line"> PlayerPosition = camera-&gt;getPosition ();</div><div class="line"> PlayerRotation = camera-&gt;getRotation ();</div><div class="line"> }</div><div class="line"></div><div class="line"> IWriteFile *file = fs-&gt;createAndWriteFile ( filename );</div><div class="line"> <span class="keywordflow">if</span> (!file)</div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line"></div><div class="line"> snprintf_irr ( buf, 128, <span class="stringliteral">&quot;playerposition %.f %.f %.f\nplayerrotation %.f %.f %.f\n&quot;</span>,</div><div class="line"> PlayerPosition.X, PlayerPosition.Z, PlayerPosition.Y,</div><div class="line"> PlayerRotation.X, PlayerRotation.Z, PlayerRotation.Y);</div><div class="line"> file-&gt;write ( buf, (s32) strlen ( buf ) );</div><div class="line"> <span class="keywordflow">for</span> ( i = 0; i != fs-&gt;getFileArchiveCount(); ++i )</div><div class="line"> {</div><div class="line"> snprintf_irr ( buf, 128, <span class="stringliteral">&quot;archive %s\n&quot;</span>,stringc ( fs-&gt;getFileArchive(i)-&gt;getFileList()-&gt;getPath() ).c_str () );</div><div class="line"> file-&gt;write ( buf, (s32) strlen ( buf ) );</div><div class="line"> }</div><div class="line"></div><div class="line"> file-&gt;drop ();</div><div class="line"> <span class="keywordflow">return</span> 1;</div><div class="line">}</div></div><!-- fragment --><p> Representing a player </p><div class="fragment"><div class="line"><span class="keyword">struct </span>Q3Player : <span class="keyword">public</span> IAnimationEndCallBack</div><div class="line">{</div><div class="line"> Q3Player ()</div><div class="line"> : Device(0), MapParent(0), Mesh(0), WeaponNode(0), StartPositionCurrent(0)</div><div class="line"> {</div><div class="line"> animation[0] = 0;</div><div class="line"> memset(Anim, 0, <span class="keyword">sizeof</span>(TimeFire)*4);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">void</span> OnAnimationEnd(IAnimatedMeshSceneNode* node);</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> create ( IrrlichtDevice *device,</div><div class="line"> IQ3LevelMesh* mesh,</div><div class="line"> ISceneNode *mapNode,</div><div class="line"> IMetaTriangleSelector *meta</div><div class="line"> );</div><div class="line"> <span class="keywordtype">void</span> shutdown ();</div><div class="line"> <span class="keywordtype">void</span> setAnim ( <span class="keyword">const</span> c8 *name );</div><div class="line"> <span class="keywordtype">void</span> respawn ();</div><div class="line"> <span class="keywordtype">void</span> setpos ( <span class="keyword">const</span> vector3df &amp;pos, <span class="keyword">const</span> vector3df&amp; rotation );</div><div class="line"></div><div class="line"> ISceneNodeAnimatorCollisionResponse * cam() { <span class="keywordflow">return</span> camCollisionResponse ( Device ); }</div><div class="line"></div><div class="line"> IrrlichtDevice *Device;</div><div class="line"> ISceneNode* MapParent;</div><div class="line"> IQ3LevelMesh* Mesh;</div><div class="line"> IAnimatedMeshSceneNode* WeaponNode;</div><div class="line"> s32 StartPositionCurrent;</div><div class="line"> TimeFire Anim[4];</div><div class="line"> c8 animation[64];</div><div class="line"> c8 buf[64];</div><div class="line">};</div></div><!-- fragment --><p> End player </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> Q3Player::shutdown ()</div><div class="line">{</div><div class="line"> setAnim ( 0 );</div><div class="line"></div><div class="line"> dropElement (WeaponNode);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( Device )</div><div class="line"> {</div><div class="line"> ICameraSceneNode* camera = Device-&gt;getSceneManager()-&gt;getActiveCamera();</div><div class="line"> dropElement ( camera );</div><div class="line"> Device = 0;</div><div class="line"> }</div><div class="line"></div><div class="line"> MapParent = 0;</div><div class="line"> Mesh = 0;</div><div class="line">}</div></div><!-- fragment --><p> create a new player </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> Q3Player::create ( IrrlichtDevice *device, IQ3LevelMesh* mesh, ISceneNode *mapNode, IMetaTriangleSelector *meta )</div><div class="line">{</div><div class="line"> setTimeFire ( Anim + 0, 200, FIRED );</div><div class="line"> setTimeFire ( Anim + 1, 5000 );</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (!device)</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"> <span class="comment">// load FPS weapon to Camera</span></div><div class="line"> Device = device;</div><div class="line"> Mesh = mesh;</div><div class="line"> MapParent = mapNode;</div><div class="line"></div><div class="line"> ISceneManager *smgr = device-&gt;getSceneManager ();</div><div class="line"> IVideoDriver * driver = device-&gt;getVideoDriver();</div><div class="line"></div><div class="line"> ICameraSceneNode* camera = 0;</div><div class="line"></div><div class="line"> core::array&lt;SKeyMap&gt; keyMap;</div><div class="line"> keyMap.set_used(12);</div><div class="line"> keyMap[0].Action = EKA_MOVE_FORWARD;</div><div class="line"> keyMap[0].KeyCode = KEY_UP;</div><div class="line"> keyMap[1].Action = EKA_MOVE_FORWARD;</div><div class="line"> keyMap[1].KeyCode = KEY_KEY_W;</div><div class="line"></div><div class="line"> keyMap[2].Action = EKA_MOVE_BACKWARD;</div><div class="line"> keyMap[2].KeyCode = KEY_DOWN;</div><div class="line"> keyMap[3].Action = EKA_MOVE_BACKWARD;</div><div class="line"> keyMap[3].KeyCode = KEY_KEY_S;</div><div class="line"></div><div class="line"> keyMap[4].Action = EKA_STRAFE_LEFT;</div><div class="line"> keyMap[4].KeyCode = KEY_LEFT;</div><div class="line"> keyMap[5].Action = EKA_STRAFE_LEFT;</div><div class="line"> keyMap[5].KeyCode = KEY_KEY_A;</div><div class="line"></div><div class="line"> keyMap[6].Action = EKA_STRAFE_RIGHT;</div><div class="line"> keyMap[6].KeyCode = KEY_RIGHT;</div><div class="line"> keyMap[7].Action = EKA_STRAFE_RIGHT;</div><div class="line"> keyMap[7].KeyCode = KEY_KEY_D;</div><div class="line"></div><div class="line"> keyMap[8].Action = EKA_JUMP_UP;</div><div class="line"> keyMap[8].KeyCode = KEY_KEY_J;</div><div class="line"></div><div class="line"> keyMap[9].Action = EKA_CROUCH;</div><div class="line"> keyMap[9].KeyCode = KEY_KEY_C;</div><div class="line"></div><div class="line"> keyMap[10].Action = EKA_ROTATE_LEFT;</div><div class="line"> keyMap[10].KeyCode = KEY_KEY_Q;</div><div class="line"></div><div class="line"> keyMap[11].Action = EKA_ROTATE_RIGHT;</div><div class="line"> keyMap[11].KeyCode = KEY_KEY_E;</div><div class="line"></div><div class="line"> camera = smgr-&gt;addCameraSceneNodeFPS(0, 100.0f, 0.6f, -1, keyMap.pointer(), keyMap.size(), <span class="keyword">false</span>, 600.f);</div><div class="line"> camera-&gt;setName ( <span class="stringliteral">&quot;First Person Camera&quot;</span> );</div><div class="line"> <span class="comment">//camera-&gt;setFOV ( 100.f * core::DEGTORAD );</span></div><div class="line"> camera-&gt;setFarValue( 20000.f );</div><div class="line"></div><div class="line"> IAnimatedMeshMD2* weaponMesh = (IAnimatedMeshMD2*) smgr-&gt;getMesh(<span class="stringliteral">&quot;gun.md2&quot;</span>);</div><div class="line"> <span class="keywordflow">if</span> ( 0 == weaponMesh )</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( weaponMesh-&gt;getMeshType() == EAMT_MD2 )</div><div class="line"> {</div><div class="line"> s32 count = weaponMesh-&gt;getAnimationCount();</div><div class="line"> <span class="keywordflow">for</span> ( s32 i = 0; i != count; ++i )</div><div class="line"> {</div><div class="line"> snprintf_irr ( buf, 64, <span class="stringliteral">&quot;Animation: %s&quot;</span>, weaponMesh-&gt;getAnimationName(i) );</div><div class="line"> device-&gt;getLogger()-&gt;log(buf, ELL_INFORMATION);</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> WeaponNode = smgr-&gt;addAnimatedMeshSceneNode(</div><div class="line"> weaponMesh,</div><div class="line"> smgr-&gt;getActiveCamera(),</div><div class="line"> 10,</div><div class="line"> vector3df( 0, 0, 0),</div><div class="line"> vector3df(-90,-90,90)</div><div class="line"> );</div><div class="line"> WeaponNode-&gt;setMaterialFlag(EMF_LIGHTING, <span class="keyword">false</span>);</div><div class="line"> WeaponNode-&gt;setMaterialTexture(0, driver-&gt;getTexture( <span class="stringliteral">&quot;gun.jpg&quot;</span>));</div><div class="line"> WeaponNode-&gt;setLoopMode ( <span class="keyword">false</span> );</div><div class="line"> WeaponNode-&gt;setName ( <span class="stringliteral">&quot;tommi the gun man&quot;</span> );</div><div class="line"></div><div class="line"> <span class="comment">//create a collision auto response animator</span></div><div class="line"> ISceneNodeAnimator* anim =</div><div class="line"> smgr-&gt;createCollisionResponseAnimator( meta, camera,</div><div class="line"> vector3df(30,45,30),</div><div class="line"> getGravity ( <span class="stringliteral">&quot;earth&quot;</span> ),</div><div class="line"> vector3df(0,40,0),</div><div class="line"> 0.0005f</div><div class="line"> );</div><div class="line"></div><div class="line"> camera-&gt;addAnimator( anim );</div><div class="line"> anim-&gt;drop();</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( meta )</div><div class="line"> {</div><div class="line"> meta-&gt;drop ();</div><div class="line"> }</div><div class="line"></div><div class="line"> respawn ();</div><div class="line"> setAnim ( <span class="stringliteral">&quot;idle&quot;</span> );</div><div class="line">}</div></div><!-- fragment --><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"><div class="line"><span class="keywordtype">void</span> Q3Player::respawn ()</div><div class="line">{</div><div class="line"> <span class="keywordflow">if</span> (!Device)</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"> ICameraSceneNode* camera = Device-&gt;getSceneManager()-&gt;getActiveCamera();</div><div class="line"></div><div class="line"> Device-&gt;getLogger()-&gt;log( <span class="stringliteral">&quot;respawn&quot;</span> );</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (StartPositionCurrent &gt;= Q3StartPosition(Mesh, camera,</div><div class="line"> StartPositionCurrent, cam()-&gt;getEllipsoidTranslation()))</div><div class="line"> StartPositionCurrent = 0;</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> ++StartPositionCurrent;</div><div class="line">}</div></div><!-- fragment --><p> set Player position from saved coordinates </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> Q3Player::setpos ( <span class="keyword">const</span> vector3df &amp;pos, <span class="keyword">const</span> vector3df &amp;rotation )</div><div class="line">{</div><div class="line"> <span class="keywordflow">if</span> (!Device)</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"> Device-&gt;getLogger()-&gt;log( <span class="stringliteral">&quot;setpos&quot;</span> );</div><div class="line"></div><div class="line"> ICameraSceneNode* camera = Device-&gt;getSceneManager()-&gt;getActiveCamera();</div><div class="line"> <span class="keywordflow">if</span> ( camera )</div><div class="line"> {</div><div class="line"> camera-&gt;setPosition ( pos );</div><div class="line"> camera-&gt;setRotation ( rotation );</div><div class="line"> camera-&gt;OnAnimate ( 0 );</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p> set the Animation of the player and weapon </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> Q3Player::setAnim ( <span class="keyword">const</span> c8 *name )</div><div class="line">{</div><div class="line"> <span class="keywordflow">if</span> ( name )</div><div class="line"> {</div><div class="line"> snprintf_irr ( animation, 64, <span class="stringliteral">&quot;%s&quot;</span>, name );</div><div class="line"> <span class="keywordflow">if</span> ( WeaponNode )</div><div class="line"> {</div><div class="line"> WeaponNode-&gt;setAnimationEndCallback ( <span class="keyword">this</span> );</div><div class="line"> WeaponNode-&gt;setMD2Animation ( animation );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> animation[0] = 0;</div><div class="line"> <span class="keywordflow">if</span> ( WeaponNode )</div><div class="line"> {</div><div class="line"> WeaponNode-&gt;setAnimationEndCallback ( 0 );</div><div class="line"> }</div><div class="line"> }</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// Callback</span></div><div class="line"><span class="keywordtype">void</span> Q3Player::OnAnimationEnd(IAnimatedMeshSceneNode* node)</div><div class="line">{</div><div class="line"> setAnim ( 0 );</div><div class="line">}</div></div><!-- fragment --><p> GUI Elements </p><div class="fragment"><div class="line"><span class="keyword">struct </span>GUI</div><div class="line">{</div><div class="line"> GUI ()</div><div class="line"> {</div><div class="line"> memset ( <span class="keyword">this</span>, 0, <span class="keyword">sizeof</span> ( *<span class="keyword">this</span> ) );</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> drop()</div><div class="line"> {</div><div class="line"> dropElement ( Window );</div><div class="line"> dropElement ( Logo );</div><div class="line"> }</div><div class="line"></div><div class="line"> IGUIComboBox* VideoDriver;</div><div class="line"> IGUIComboBox* VideoMode;</div><div class="line"> IGUICheckBox* FullScreen;</div><div class="line"> IGUICheckBox* Bit32;</div><div class="line"> IGUIScrollBar* MultiSample;</div><div class="line"> IGUIButton* SetVideoMode;</div><div class="line"></div><div class="line"> IGUIScrollBar* Tesselation;</div><div class="line"> IGUIScrollBar* Gamma;</div><div class="line"> IGUICheckBox* Collision;</div><div class="line"> IGUICheckBox* Visible_Map;</div><div class="line"> IGUICheckBox* Visible_Shader;</div><div class="line"> IGUICheckBox* Visible_Fog;</div><div class="line"> IGUICheckBox* Visible_Unresolved;</div><div class="line"> IGUICheckBox* Visible_Skydome;</div><div class="line"> IGUIButton* Respawn;</div><div class="line"></div><div class="line"> IGUITable* ArchiveList;</div><div class="line"> IGUIButton* ArchiveAdd;</div><div class="line"> IGUIButton* ArchiveRemove;</div><div class="line"> IGUIFileOpenDialog* ArchiveFileOpen;</div><div class="line"> IGUIButton* ArchiveUp;</div><div class="line"> IGUIButton* ArchiveDown;</div><div class="line"></div><div class="line"> IGUIListBox* MapList;</div><div class="line"> IGUITreeView* SceneTree;</div><div class="line"> IGUIStaticText* StatusLine;</div><div class="line"> IGUIImage* Logo;</div><div class="line"> IGUIWindow* Window;</div><div class="line">};</div></div><!-- fragment --><p> CQuake3EventHandler controls the game </p><div class="fragment"><div class="line"><span class="keyword">class </span>CQuake3EventHandler : <span class="keyword">public</span> IEventReceiver</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line"></div><div class="line"> CQuake3EventHandler( GameData *gameData );</div><div class="line"> <span class="keyword">virtual</span> ~CQuake3EventHandler ();</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> Animate();</div><div class="line"> <span class="keywordtype">void</span> Render();</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> AddArchive ( <span class="keyword">const</span> path&amp; archiveName );</div><div class="line"> <span class="keywordtype">void</span> LoadMap ( <span class="keyword">const</span> stringw&amp; mapName, s32 collision );</div><div class="line"> <span class="keywordtype">void</span> CreatePlayers();</div><div class="line"> <span class="keywordtype">void</span> AddSky( u32 dome, <span class="keyword">const</span> c8 *texture );</div><div class="line"> Q3Player *GetPlayer ( u32 index ) { <span class="keywordflow">return</span> &amp;Player[index]; }</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> CreateGUI();</div><div class="line"> <span class="keywordtype">void</span> SetGUIActive( s32 command);</div><div class="line"></div><div class="line"> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent&amp; eve);</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">private</span>:</div><div class="line"></div><div class="line"> GameData *Game;</div><div class="line"></div><div class="line"> IQ3LevelMesh* Mesh;</div><div class="line"> ISceneNode* MapParent;</div><div class="line"> ISceneNode* ShaderParent;</div><div class="line"> ISceneNode* ItemParent;</div><div class="line"> ISceneNode* UnresolvedParent;</div><div class="line"> ISceneNode* BulletParent;</div><div class="line"> ISceneNode* FogParent;</div><div class="line"> ISceneNode * SkyNode;</div><div class="line"> IMetaTriangleSelector *Meta;</div><div class="line"></div><div class="line"> c8 buf[256];</div><div class="line"></div><div class="line"> Q3Player Player[2];</div><div class="line"></div><div class="line"> <span class="keyword">struct </span>SParticleImpact</div><div class="line"> {</div><div class="line"> u32 when;</div><div class="line"> vector3df pos;</div><div class="line"> vector3df outVector;</div><div class="line"> };</div><div class="line"> array&lt;SParticleImpact&gt; Impacts;</div><div class="line"> <span class="keywordtype">void</span> useItem( Q3Player * player);</div><div class="line"> <span class="keywordtype">void</span> createParticleImpacts( u32 now );</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> createTextures ();</div><div class="line"> <span class="keywordtype">void</span> addSceneTreeItem( ISceneNode * parent, IGUITreeViewNode* nodeParent);</div><div class="line"></div><div class="line"> GUI gui;</div><div class="line"> <span class="keywordtype">void</span> dropMap ();</div><div class="line">};</div></div><!-- fragment --><p> Constructor </p><div class="fragment"><div class="line">CQuake3EventHandler::CQuake3EventHandler( GameData *game )</div><div class="line">: Game(game), Mesh(0), MapParent(0), ShaderParent(0), ItemParent(0), UnresolvedParent(0),</div><div class="line"> BulletParent(0), FogParent(0), SkyNode(0), Meta(0)</div><div class="line">{</div><div class="line"> buf[0]=0;</div><div class="line"> <span class="comment">// Also use 16 Bit Textures for 16 Bit RenderDevice</span></div><div class="line"> <span class="keywordflow">if</span> ( Game-&gt;deviceParam.Bits == 16 )</div><div class="line"> {</div><div class="line"> game-&gt;Device-&gt;getVideoDriver()-&gt;setTextureCreationFlag(ETCF_ALWAYS_16_BIT, <span class="keyword">true</span>);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Quake3 Shader controls Z-Writing</span></div><div class="line"> game-&gt;Device-&gt;getSceneManager()-&gt;getParameters()-&gt;setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, <span class="keyword">true</span>);</div><div class="line"></div><div class="line"> <span class="comment">// create internal textures</span></div><div class="line"> createTextures ();</div><div class="line"></div><div class="line"> sound_init ( game-&gt;Device );</div><div class="line"></div><div class="line"> Game-&gt;Device-&gt;setEventReceiver ( <span class="keyword">this</span> );</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// destructor</span></div><div class="line">CQuake3EventHandler::~CQuake3EventHandler ()</div><div class="line">{</div><div class="line"> Player[0].shutdown ();</div><div class="line"> sound_shutdown ();</div><div class="line"></div><div class="line"> Game-&gt;save( <span class="stringliteral">&quot;explorer.cfg&quot;</span> );</div><div class="line"></div><div class="line"> Game-&gt;Device-&gt;drop();</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// create runtime textures smog, fog</span></div><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::createTextures()</div><div class="line">{</div><div class="line"> IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();</div><div class="line"></div><div class="line"> dimension2du dim(64, 64);</div><div class="line"></div><div class="line"> video::IImage* image;</div><div class="line"> u32 i;</div><div class="line"> u32 x;</div><div class="line"> u32 y;</div><div class="line"> u32 * data;</div><div class="line"> <span class="keywordflow">for</span> ( i = 0; i != 8; ++i )</div><div class="line"> {</div><div class="line"> image = driver-&gt;createImage ( video::ECF_A8R8G8B8, dim);</div><div class="line"> data = (u32*) image-&gt;getData ();</div><div class="line"> <span class="keywordflow">for</span> ( y = 0; y != dim.Height; ++y )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">for</span> ( x = 0; x != dim.Width; ++x )</div><div class="line"> {</div><div class="line"> data [x] = 0xFFFFFFFF;</div><div class="line"> }</div><div class="line"> data = (u32*) ( (u8*) data + image-&gt;getPitch() );</div><div class="line"> }</div><div class="line"> snprintf_irr ( buf, 64, <span class="stringliteral">&quot;smoke_%02d&quot;</span>, i );</div><div class="line"> driver-&gt;addTexture( buf, image );</div><div class="line"> image-&gt;drop ();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// fog</span></div><div class="line"> <span class="keywordflow">for</span> ( i = 0; i != 1; ++i )</div><div class="line"> {</div><div class="line"> image = driver-&gt;createImage ( video::ECF_A8R8G8B8, dim);</div><div class="line"> data = (u32*) image-&gt;getData ();</div><div class="line"> <span class="keywordflow">for</span> ( y = 0; y != dim.Height; ++y )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">for</span> ( x = 0; x != dim.Width; ++x )</div><div class="line"> {</div><div class="line"> data [x] = 0xFFFFFFFF;</div><div class="line"> }</div><div class="line"> data = (u32*) ( (u8*) data + image-&gt;getPitch() );</div><div class="line"> }</div><div class="line"> snprintf_irr ( buf, 64, <span class="stringliteral">&quot;fog_%02d&quot;</span>, i );</div><div class="line"> driver-&gt;addTexture( buf, image );</div><div class="line"> image-&gt;drop ();</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p> create the GUI </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::CreateGUI()</div><div class="line">{</div><div class="line"></div><div class="line"> IGUIEnvironment *env = Game-&gt;Device-&gt;getGUIEnvironment();</div><div class="line"> IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();</div><div class="line"></div><div class="line"> gui.drop();</div><div class="line"></div><div class="line"> <span class="comment">// set skin font</span></div><div class="line"> IGUIFont* font = env-&gt;getFont(<span class="stringliteral">&quot;fontlucida.png&quot;</span>);</div><div class="line"> <span class="keywordflow">if</span> (font)</div><div class="line"> env-&gt;getSkin()-&gt;setFont(font);</div><div class="line"> env-&gt;getSkin()-&gt;setColor ( EGDC_BUTTON_TEXT, video::SColor(240,0xAA,0xAA,0xAA) );</div><div class="line"> env-&gt;getSkin()-&gt;setColor ( EGDC_3D_HIGH_LIGHT, video::SColor(240,0x22,0x22,0x22) );</div><div class="line"> env-&gt;getSkin()-&gt;setColor ( EGDC_3D_FACE, video::SColor(240,0x44,0x44,0x44) );</div><div class="line"> env-&gt;getSkin()-&gt;setColor ( EGDC_EDITABLE, video::SColor(240,0x44,0x44,0x44) );</div><div class="line"> env-&gt;getSkin()-&gt;setColor ( EGDC_FOCUSED_EDITABLE, video::SColor(240,0x54,0x54,0x54) );</div><div class="line"> env-&gt;getSkin()-&gt;setColor ( EGDC_WINDOW, video::SColor(240,0x66,0x66,0x66) );</div><div class="line"></div><div class="line"> <span class="comment">// minimal gui size 800x600</span></div><div class="line"> dimension2d&lt;u32&gt; dim ( 800, 600 );</div><div class="line"> dimension2d&lt;u32&gt; vdim ( Game-&gt;Device-&gt;getVideoDriver()-&gt;getScreenSize() );</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( vdim.Height &gt;= dim.Height &amp;&amp; vdim.Width &gt;= dim.Width )</div><div class="line"> {</div><div class="line"> <span class="comment">//dim = vdim;</span></div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> }</div><div class="line"></div><div class="line"> 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> );</div><div class="line"> gui.Window-&gt;setToolTipText ( L<span class="stringliteral">&quot;Quake3Explorer. Loads and show various BSP File Format and Shaders.&quot;</span> );</div><div class="line"> gui.Window-&gt;getCloseButton()-&gt;setToolTipText ( L<span class="stringliteral">&quot;Quit Quake3 Explorer&quot;</span> );</div><div class="line"></div><div class="line"> <span class="comment">// add a status line help text</span></div><div class="line"> gui.StatusLine = env-&gt;addStaticText( 0, rect&lt;s32&gt;( 5,dim.Height - 30,dim.Width - 5,dim.Height - 10),</div><div class="line"> <span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">true</span></div><div class="line"> );</div><div class="line"></div><div class="line"></div><div class="line"> 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> );</div><div class="line"> gui.VideoDriver = env-&gt;addComboBox(rect&lt;s32&gt;( dim.Width - 300, 24, dim.Width - 10, 40 ),gui.Window);</div><div class="line"> gui.VideoDriver-&gt;addItem(L<span class="stringliteral">&quot;Direct3D 9.0c&quot;</span>, EDT_DIRECT3D9 );</div><div class="line"> gui.VideoDriver-&gt;addItem(L<span class="stringliteral">&quot;OpenGL 1.5&quot;</span>, EDT_OPENGL);</div><div class="line"> gui.VideoDriver-&gt;addItem(L<span class="stringliteral">&quot;Software Renderer&quot;</span>, EDT_SOFTWARE);</div><div class="line"> gui.VideoDriver-&gt;addItem(L<span class="stringliteral">&quot;Burning&#39;s Video (TM) Thomas Alten&quot;</span>, EDT_BURNINGSVIDEO);</div><div class="line"> gui.VideoDriver-&gt;setSelected ( gui.VideoDriver-&gt;getIndexForItemData ( Game-&gt;deviceParam.DriverType ) );</div><div class="line"> gui.VideoDriver-&gt;setToolTipText ( L<span class="stringliteral">&quot;Use a VideoDriver&quot;</span> );</div><div class="line"></div><div class="line"> 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> );</div><div class="line"> gui.VideoMode = env-&gt;addComboBox(rect&lt;s32&gt;( dim.Width - 300, 44, dim.Width - 10, 60 ),gui.Window);</div><div class="line"> gui.VideoMode-&gt;setToolTipText ( L<span class="stringliteral">&quot;Supported Screenmodes&quot;</span> );</div><div class="line"> IVideoModeList *modeList = Game-&gt;Device-&gt;getVideoModeList();</div><div class="line"> <span class="keywordflow">if</span> ( modeList )</div><div class="line"> {</div><div class="line"> s32 i;</div><div class="line"> <span class="keywordflow">for</span> ( i = 0; i != modeList-&gt;getVideoModeCount (); ++i )</div><div class="line"> {</div><div class="line"> u16 d = modeList-&gt;getVideoModeDepth ( i );</div><div class="line"> <span class="keywordflow">if</span> ( d &lt; 16 )</div><div class="line"> <span class="keywordflow">continue</span>;</div><div class="line"></div><div class="line"> u16 w = modeList-&gt;getVideoModeResolution ( i ).Width;</div><div class="line"> u16 h = modeList-&gt;getVideoModeResolution ( i ).Height;</div><div class="line"> u32 val = w &lt;&lt; 16 | h;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( gui.VideoMode-&gt;getIndexForItemData ( val ) &gt;= 0 )</div><div class="line"> <span class="keywordflow">continue</span>;</div><div class="line"></div><div class="line"> f32 aspect = (f32) w / (f32) h;</div><div class="line"> <span class="keyword">const</span> c8 *a = <span class="stringliteral">&quot;&quot;</span>;</div><div class="line"> <span class="keywordflow">if</span> ( core::equals ( aspect, 1.3333333333f ) ) a = <span class="stringliteral">&quot;4:3&quot;</span>;</div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( core::equals ( aspect, 1.6666666f ) ) a = <span class="stringliteral">&quot;15:9 widescreen&quot;</span>;</div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( core::equals ( aspect, 1.7777777f ) ) a = <span class="stringliteral">&quot;16:9 widescreen&quot;</span>;</div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( core::equals ( aspect, 1.6f ) ) a = <span class="stringliteral">&quot;16:10 widescreen&quot;</span>;</div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( core::equals ( aspect, 2.133333f ) ) a = <span class="stringliteral">&quot;20:9 widescreen&quot;</span>;</div><div class="line"></div><div class="line"> snprintf_irr ( buf, <span class="keyword">sizeof</span> ( buf ), <span class="stringliteral">&quot;%d x %d, %s&quot;</span>,w, h, a );</div><div class="line"> gui.VideoMode-&gt;addItem ( stringw ( buf ).c_str(), val );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> gui.VideoMode-&gt;setSelected ( gui.VideoMode-&gt;getIndexForItemData (</div><div class="line"> Game-&gt;deviceParam.WindowSize.Width &lt;&lt; 16 |</div><div class="line"> Game-&gt;deviceParam.WindowSize.Height ) );</div><div class="line"></div><div class="line"> 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> );</div><div class="line"> gui.FullScreen-&gt;setToolTipText ( L<span class="stringliteral">&quot;Set Fullscreen or Window Mode&quot;</span> );</div><div class="line"></div><div class="line"> 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> );</div><div class="line"> gui.Bit32-&gt;setToolTipText ( L<span class="stringliteral">&quot;Use 16 or 32 Bit&quot;</span> );</div><div class="line"></div><div class="line"> 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> );</div><div class="line"> 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 );</div><div class="line"> gui.MultiSample-&gt;setMin ( 0 );</div><div class="line"> gui.MultiSample-&gt;setMax ( 8 );</div><div class="line"> gui.MultiSample-&gt;setSmallStep ( 1 );</div><div class="line"> gui.MultiSample-&gt;setLargeStep ( 1 );</div><div class="line"> gui.MultiSample-&gt;setPos ( Game-&gt;deviceParam.AntiAlias );</div><div class="line"> gui.MultiSample-&gt;setToolTipText ( L<span class="stringliteral">&quot;Set the MultiSample (disable, 1x, 2x, 4x, 8x )&quot;</span> );</div><div class="line"></div><div class="line"> 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> );</div><div class="line"> gui.SetVideoMode-&gt;setToolTipText ( L<span class="stringliteral">&quot;Set Video Mode with current values&quot;</span> );</div><div class="line"></div><div class="line"> 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> );</div><div class="line"> 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 );</div><div class="line"> gui.Gamma-&gt;setMin ( 50 );</div><div class="line"> gui.Gamma-&gt;setMax ( 350 );</div><div class="line"> gui.Gamma-&gt;setSmallStep ( 1 );</div><div class="line"> gui.Gamma-&gt;setLargeStep ( 10 );</div><div class="line"> gui.Gamma-&gt;setPos ( core::floor32 ( Game-&gt;GammaValue * 100.f ) );</div><div class="line"> gui.Gamma-&gt;setToolTipText ( L<span class="stringliteral">&quot;Adjust Gamma Ramp ( 0.5 - 3.5)&quot;</span> );</div><div class="line"> Game-&gt;Device-&gt;setGammaRamp ( Game-&gt;GammaValue, Game-&gt;GammaValue, Game-&gt;GammaValue, 0.f, 0.f );</div><div class="line"></div><div class="line"></div><div class="line"> 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> );</div><div class="line"> 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 );</div><div class="line"> gui.Tesselation-&gt;setMin ( 2 );</div><div class="line"> gui.Tesselation-&gt;setMax ( 12 );</div><div class="line"> gui.Tesselation-&gt;setSmallStep ( 1 );</div><div class="line"> gui.Tesselation-&gt;setLargeStep ( 1 );</div><div class="line"> gui.Tesselation-&gt;setPos ( Game-&gt;loadParam.patchTesselation );</div><div class="line"> gui.Tesselation-&gt;setToolTipText ( L<span class="stringliteral">&quot;How smooth should curved surfaces be rendered&quot;</span> );</div><div class="line"></div><div class="line"> 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> );</div><div class="line"> gui.Collision-&gt;setToolTipText ( L<span class="stringliteral">&quot;Set collision on or off ( flythrough ). \nPress F7 on your Keyboard&quot;</span> );</div><div class="line"> 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> );</div><div class="line"> 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> );</div><div class="line"> 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> );</div><div class="line"> gui.Visible_Shader-&gt;setToolTipText ( L<span class="stringliteral">&quot;Show or not show the Shader Nodes. \nPress F4 on your Keyboard&quot;</span> );</div><div class="line"> 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> );</div><div class="line"> gui.Visible_Fog-&gt;setToolTipText ( L<span class="stringliteral">&quot;Show or not show the Fog Nodes. \nPress F5 on your Keyboard&quot;</span> );</div><div class="line"> 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> );</div><div class="line"> 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> );</div><div class="line"> 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> );</div><div class="line"> gui.Visible_Skydome-&gt;setToolTipText ( L<span class="stringliteral">&quot;Show the or not show the Skydome.&quot;</span> );</div><div class="line"></div><div class="line"> <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></div><div class="line"></div><div class="line"> 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> );</div><div class="line"></div><div class="line"> 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> );</div><div class="line"> gui.ArchiveAdd-&gt;setToolTipText ( L<span class="stringliteral">&quot;Add an archive, usually packed zip-archives (*.pk3) to the Filesystem&quot;</span> );</div><div class="line"> 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> );</div><div class="line"> gui.ArchiveRemove-&gt;setToolTipText ( L<span class="stringliteral">&quot;Remove the selected archive from the FileSystem.&quot;</span> );</div><div class="line"> 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> );</div><div class="line"> gui.ArchiveUp-&gt;setToolTipText ( L<span class="stringliteral">&quot;Arrange Archive Look-up Hirachy. Move the selected Archive up&quot;</span> );</div><div class="line"> 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> );</div><div class="line"> gui.ArchiveDown-&gt;setToolTipText ( L<span class="stringliteral">&quot;Arrange Archive Look-up Hirachy. Move the selected Archive down&quot;</span> );</div><div class="line"></div><div class="line"></div><div class="line"> gui.ArchiveList = env-&gt;addTable ( rect&lt;s32&gt;( 5,dim.Height - 510, dim.Width - 450,dim.Height - 410 ), gui.Window );</div><div class="line"> gui.ArchiveList-&gt;addColumn ( L<span class="stringliteral">&quot;Type&quot;</span>, 0 );</div><div class="line"> gui.ArchiveList-&gt;addColumn ( L<span class="stringliteral">&quot;Real File Path&quot;</span>, 1 );</div><div class="line"> gui.ArchiveList-&gt;setColumnWidth ( 0, 60 );</div><div class="line"> gui.ArchiveList-&gt;setColumnWidth ( 1, 284 );</div><div class="line"> gui.ArchiveList-&gt;setToolTipText ( L<span class="stringliteral">&quot;Show the attached Archives&quot;</span> );</div><div class="line"></div><div class="line"></div><div class="line"> 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> );</div><div class="line"> 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> );</div><div class="line"> 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> );</div><div class="line"></div><div class="line"></div><div class="line"> <span class="comment">// create a visible Scene Tree</span></div><div class="line"> 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> );</div><div class="line"> gui.SceneTree = env-&gt;addTreeView( rect&lt;s32&gt;( dim.Width - 400, dim.Height - 380, dim.Width - 5, dim.Height - 40 ),</div><div class="line"> gui.Window, -1, <span class="keyword">true</span>, <span class="keyword">true</span>, <span class="keyword">false</span> );</div><div class="line"> gui.SceneTree-&gt;setToolTipText ( L<span class="stringliteral">&quot;Show the current Scenegraph&quot;</span> );</div><div class="line"> gui.SceneTree-&gt;getRoot()-&gt;clearChildren();</div><div class="line"> addSceneTreeItem ( Game-&gt;Device-&gt;getSceneManager()-&gt;getRootSceneNode(), gui.SceneTree-&gt;getRoot() );</div><div class="line"></div><div class="line"></div><div class="line"> IGUIImageList* imageList = env-&gt;createImageList( driver-&gt;getTexture ( <span class="stringliteral">&quot;iconlist.png&quot;</span> ),</div><div class="line"> dimension2di( 32, 32 ), true );</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( imageList )</div><div class="line"> {</div><div class="line"> gui.SceneTree-&gt;setImageList( imageList );</div><div class="line"> imageList-&gt;drop ();</div><div class="line"> }</div><div class="line"></div><div class="line"></div><div class="line"> <span class="comment">// load the engine logo</span></div><div class="line"> 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 );</div><div class="line"> gui.Logo-&gt;setToolTipText ( L<span class="stringliteral">&quot;The great Irrlicht Engine&quot;</span> );</div><div class="line"></div><div class="line"> AddArchive ( <span class="stringliteral">&quot;&quot;</span> );</div><div class="line">}</div></div><!-- fragment --><p> Add an Archive to the FileSystems and updates the GUI </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::AddArchive ( <span class="keyword">const</span> path&amp; archiveName )</div><div class="line">{</div><div class="line"> IFileSystem *fs = Game-&gt;Device-&gt;getFileSystem();</div><div class="line"> u32 i;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( archiveName.size () )</div><div class="line"> {</div><div class="line"> <span class="keywordtype">bool</span> exists = <span class="keyword">false</span>;</div><div class="line"> <span class="keywordflow">for</span> ( i = 0; i != fs-&gt;getFileArchiveCount(); ++i )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( fs-&gt;getFileArchive(i)-&gt;getFileList()-&gt;getPath() == archiveName )</div><div class="line"> {</div><div class="line"> exists = <span class="keyword">true</span>;</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (!exists)</div><div class="line"> {</div><div class="line"> fs-&gt;addFileArchive(archiveName, <span class="keyword">true</span>, <span class="keyword">false</span>);</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// store the current archives in game data</span></div><div class="line"> <span class="comment">// show the attached Archive in proper order</span></div><div class="line"> <span class="keywordflow">if</span> ( gui.ArchiveList )</div><div class="line"> {</div><div class="line"> gui.ArchiveList-&gt;clearRows();</div><div class="line"></div><div class="line"> <span class="keywordflow">for</span> ( i = 0; i != fs-&gt;getFileArchiveCount(); ++i )</div><div class="line"> {</div><div class="line"> IFileArchive * archive = fs-&gt;getFileArchive ( i );</div><div class="line"></div><div class="line"> u32 index = gui.ArchiveList-&gt;addRow(i);</div><div class="line"></div><div class="line"> core::stringw typeName;</div><div class="line"> <span class="keywordflow">switch</span>(archive-&gt;getType())</div><div class="line"> {</div><div class="line"> <span class="keywordflow">case</span> io::EFAT_ZIP:</div><div class="line"> typeName = <span class="stringliteral">&quot;ZIP&quot;</span>;</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> io::EFAT_GZIP:</div><div class="line"> typeName = <span class="stringliteral">&quot;gzip&quot;</span>;</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> io::EFAT_FOLDER:</div><div class="line"> typeName = <span class="stringliteral">&quot;Mount&quot;</span>;</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> io::EFAT_PAK:</div><div class="line"> typeName = <span class="stringliteral">&quot;PAK&quot;</span>;</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> io::EFAT_TAR:</div><div class="line"> typeName = <span class="stringliteral">&quot;TAR&quot;</span>;</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">default</span>:</div><div class="line"> typeName = <span class="stringliteral">&quot;archive&quot;</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> gui.ArchiveList-&gt;setCellText ( index, 0, typeName );</div><div class="line"> gui.ArchiveList-&gt;setCellText ( index, 1, archive-&gt;getFileList()-&gt;getPath() );</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"></div><div class="line"> <span class="comment">// browse the archives for maps</span></div><div class="line"> <span class="keywordflow">if</span> ( gui.MapList )</div><div class="line"> {</div><div class="line"> gui.MapList-&gt;clear();</div><div class="line"></div><div class="line"> IGUISpriteBank *bank = Game-&gt;Device-&gt;getGUIEnvironment()-&gt;getSpriteBank(<span class="stringliteral">&quot;sprite_q3map&quot;</span>);</div><div class="line"> <span class="keywordflow">if</span> ( 0 == bank )</div><div class="line"> bank = Game-&gt;Device-&gt;getGUIEnvironment()-&gt;addEmptySpriteBank(<span class="stringliteral">&quot;sprite_q3map&quot;</span>);</div><div class="line"></div><div class="line"> SGUISprite sprite;</div><div class="line"> SGUISpriteFrame frame;</div><div class="line"> core::rect&lt;s32&gt; r;</div><div class="line"></div><div class="line"> bank-&gt;getSprites().clear();</div><div class="line"> bank-&gt;getPositions().clear ();</div><div class="line"> gui.MapList-&gt;setSpriteBank ( bank );</div><div class="line"></div><div class="line"> u32 g = 0;</div><div class="line"> core::stringw s;</div><div class="line"></div><div class="line"> <span class="comment">// browse the attached file system</span></div><div class="line"> fs-&gt;setFileListSystem ( FILESYSTEM_VIRTUAL );</div><div class="line"> fs-&gt;changeWorkingDirectoryTo ( <span class="stringliteral">&quot;/maps/&quot;</span> );</div><div class="line"> IFileList *fileList = fs-&gt;createFileList ();</div><div class="line"> fs-&gt;setFileListSystem ( FILESYSTEM_NATIVE );</div><div class="line"></div><div class="line"> <span class="keywordflow">for</span> ( i=0; i&lt; fileList-&gt;getFileCount(); ++i)</div><div class="line"> {</div><div class="line"> s = fileList-&gt;getFullFileName(i);</div><div class="line"> <span class="keywordflow">if</span> ( s.find ( <span class="stringliteral">&quot;.bsp&quot;</span> ) &gt;= 0 )</div><div class="line"> {</div><div class="line"> <span class="comment">// get level screenshot. reformat texture to 128x128</span></div><div class="line"> path c ( s );</div><div class="line"> deletePathFromFilename ( c );</div><div class="line"> cutFilenameExtension ( c, c );</div><div class="line"> c = path ( <span class="stringliteral">&quot;levelshots/&quot;</span> ) + c;</div><div class="line"></div><div class="line"> dimension2du dim ( 128, 128 );</div><div class="line"> IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();</div><div class="line"> IImage* image = 0;</div><div class="line"> ITexture *tex = 0;</div><div class="line"> path filename;</div><div class="line"></div><div class="line"> filename = c + <span class="stringliteral">&quot;.jpg&quot;</span>;</div><div class="line"> <span class="keywordflow">if</span> ( fs-&gt;existFile ( filename ) )</div><div class="line"> image = driver-&gt;createImageFromFile( filename );</div><div class="line"> <span class="keywordflow">if</span> ( 0 == image )</div><div class="line"> {</div><div class="line"> filename = c + <span class="stringliteral">&quot;.tga&quot;</span>;</div><div class="line"> <span class="keywordflow">if</span> ( fs-&gt;existFile ( filename ) )</div><div class="line"> image = driver-&gt;createImageFromFile( filename );</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( image )</div><div class="line"> {</div><div class="line"> IImage* filter = driver-&gt;createImage ( video::ECF_R8G8B8, dim );</div><div class="line"> image-&gt;copyToScalingBoxFilter ( filter, 0 );</div><div class="line"> image-&gt;drop ();</div><div class="line"> image = filter;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( image )</div><div class="line"> {</div><div class="line"> tex = driver-&gt;addTexture ( filename, image );</div><div class="line"> image-&gt;drop ();</div><div class="line"> }</div><div class="line"></div><div class="line"></div><div class="line"> bank-&gt;setTexture ( g, tex );</div><div class="line"></div><div class="line"> r.LowerRightCorner.X = dim.Width;</div><div class="line"> r.LowerRightCorner.Y = dim.Height;</div><div class="line"> gui.MapList-&gt;setItemHeight ( r.LowerRightCorner.Y + 4 );</div><div class="line"> frame.rectNumber = bank-&gt;getPositions().size();</div><div class="line"> frame.textureNumber = g;</div><div class="line"></div><div class="line"> bank-&gt;getPositions().push_back(r);</div><div class="line"></div><div class="line"> sprite.Frames.set_used ( 0 );</div><div class="line"> sprite.Frames.push_back(frame);</div><div class="line"> sprite.frameTime = 0;</div><div class="line"> bank-&gt;getSprites().push_back(sprite);</div><div class="line"></div><div class="line"> gui.MapList-&gt;addItem ( s.c_str (), g );</div><div class="line"> g += 1;</div><div class="line"> }</div><div class="line"> }</div><div class="line"> fileList-&gt;drop ();</div><div class="line"></div><div class="line"> gui.MapList-&gt;setSelected ( -1 );</div><div class="line"> IGUIScrollBar * bar = (IGUIScrollBar*)gui.MapList-&gt;getElementFromId( 0 );</div><div class="line"> <span class="keywordflow">if</span> ( bar )</div><div class="line"> bar-&gt;setPos ( 0 );</div><div class="line"></div><div class="line"> }</div><div class="line"></div><div class="line">}</div></div><!-- fragment --><p> clears the Map in Memory </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::dropMap ()</div><div class="line">{</div><div class="line"> IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();</div><div class="line"></div><div class="line"> driver-&gt;removeAllHardwareBuffers ();</div><div class="line"> driver-&gt;removeAllTextures ();</div><div class="line"></div><div class="line"> Player[0].shutdown ();</div><div class="line"></div><div class="line"></div><div class="line"> dropElement ( ItemParent );</div><div class="line"> dropElement ( ShaderParent );</div><div class="line"> dropElement ( UnresolvedParent );</div><div class="line"> dropElement ( FogParent );</div><div class="line"> dropElement ( BulletParent );</div><div class="line"></div><div class="line"></div><div class="line"> Impacts.clear();</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( Meta )</div><div class="line"> {</div><div class="line"> Meta = 0;</div><div class="line"> }</div><div class="line"></div><div class="line"> dropElement ( MapParent );</div><div class="line"> dropElement ( SkyNode );</div><div class="line"></div><div class="line"> <span class="comment">// clean out meshes, because textures are invalid</span></div><div class="line"> <span class="comment">// TODO: better texture handling;-)</span></div><div class="line"> IMeshCache *cache = Game-&gt;Device-&gt;getSceneManager ()-&gt;getMeshCache();</div><div class="line"> cache-&gt;clear ();</div><div class="line"> Mesh = 0;</div><div class="line">}</div></div><!-- fragment --><p> Load new map </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::LoadMap ( <span class="keyword">const</span> stringw &amp;mapName, s32 collision )</div><div class="line">{</div><div class="line"> <span class="keywordflow">if</span> ( 0 == mapName.size() )</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"></div><div class="line"> dropMap ();</div><div class="line"></div><div class="line"> IFileSystem *fs = Game-&gt;Device-&gt;getFileSystem();</div><div class="line"> ISceneManager *smgr = Game-&gt;Device-&gt;getSceneManager ();</div><div class="line"></div><div class="line"> IReadFile* file = fs-&gt;createMemoryReadFile(&amp;Game-&gt;loadParam,</div><div class="line"> <span class="keyword">sizeof</span>(Game-&gt;loadParam), L<span class="stringliteral">&quot;levelparameter.cfg&quot;</span>, <span class="keyword">false</span>);</div><div class="line"></div><div class="line"> <span class="comment">// load cfg file</span></div><div class="line"> smgr-&gt;getMesh( file );</div><div class="line"> file-&gt;drop ();</div><div class="line"></div><div class="line"> <span class="comment">// load the actual map</span></div><div class="line"> Mesh = (IQ3LevelMesh*) smgr-&gt;getMesh(mapName);</div><div class="line"> <span class="keywordflow">if</span> ( 0 == Mesh )</div><div class="line"> <span class="keywordflow">return</span>;</div></div><!-- fragment --><p> add the geometry mesh to the Scene ( polygon &amp; patches ) The Geometry mesh is optimised for faster drawing </p><div class="fragment"><div class="line">IMesh *geometry = Mesh-&gt;getMesh(E_Q3_MESH_GEOMETRY);</div><div class="line"><span class="keywordflow">if</span> ( 0 == geometry || geometry-&gt;getMeshBufferCount() == 0)</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"></div><div class="line">Game-&gt;CurrentMapName = mapName;</div><div class="line"></div><div class="line"><span class="comment">//create a collision list</span></div><div class="line">Meta = 0;</div><div class="line"></div><div class="line">ITriangleSelector * selector = 0;</div><div class="line"><span class="keywordflow">if</span> (collision)</div><div class="line"> Meta = smgr-&gt;createMetaTriangleSelector();</div><div class="line"></div><div class="line"><span class="comment">//IMeshBuffer *b0 = geometry-&gt;getMeshBuffer(0);</span></div><div class="line"><span class="comment">//s32 minimalNodes = b0 ? core::s32_max ( 2048, b0-&gt;getVertexCount() / 32 ) : 2048;</span></div><div class="line">s32 minimalNodes = 2048;</div><div class="line"></div><div class="line">MapParent = smgr-&gt;addOctreeSceneNode(geometry, 0, -1, minimalNodes);</div><div class="line">MapParent-&gt;setName ( mapName );</div><div class="line"><span class="keywordflow">if</span> ( Meta )</div><div class="line">{</div><div class="line"> selector = smgr-&gt;createOctreeTriangleSelector( geometry,MapParent, minimalNodes);</div><div class="line"> <span class="comment">//selector = smgr-&gt;createTriangleSelector ( geometry, MapParent );</span></div><div class="line"> Meta-&gt;addTriangleSelector( selector);</div><div class="line"> selector-&gt;drop ();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// logical parent for the items</span></div><div class="line">ItemParent = smgr-&gt;addEmptySceneNode();</div><div class="line"><span class="keywordflow">if</span> ( ItemParent )</div><div class="line"> ItemParent-&gt;setName ( <span class="stringliteral">&quot;Item Container&quot;</span> );</div><div class="line"></div><div class="line">ShaderParent = smgr-&gt;addEmptySceneNode();</div><div class="line"><span class="keywordflow">if</span> ( ShaderParent )</div><div class="line"> ShaderParent-&gt;setName ( <span class="stringliteral">&quot;Shader Container&quot;</span> );</div><div class="line"></div><div class="line">UnresolvedParent = smgr-&gt;addEmptySceneNode();</div><div class="line"><span class="keywordflow">if</span> ( UnresolvedParent )</div><div class="line"> UnresolvedParent-&gt;setName ( <span class="stringliteral">&quot;Unresolved Container&quot;</span> );</div><div class="line"></div><div class="line">FogParent = smgr-&gt;addEmptySceneNode();</div><div class="line"><span class="keywordflow">if</span> ( FogParent )</div><div class="line"> FogParent-&gt;setName ( <span class="stringliteral">&quot;Fog Container&quot;</span> );</div><div class="line"></div><div class="line"><span class="comment">// logical parent for the bullets</span></div><div class="line">BulletParent = smgr-&gt;addEmptySceneNode();</div><div class="line"><span class="keywordflow">if</span> ( BulletParent )</div><div class="line"> BulletParent-&gt;setName ( <span class="stringliteral">&quot;Bullet Container&quot;</span> );</div></div><!-- fragment --><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"><div class="line">Q3ShaderFactory ( Game-&gt;loadParam, Game-&gt;Device, Mesh, E_Q3_MESH_ITEMS,ShaderParent, Meta, <span class="keyword">false</span> );</div><div class="line">Q3ShaderFactory ( Game-&gt;loadParam, Game-&gt;Device, Mesh, E_Q3_MESH_FOG,FogParent, 0, <span class="keyword">false</span> );</div><div class="line">Q3ShaderFactory ( Game-&gt;loadParam, Game-&gt;Device, Mesh, E_Q3_MESH_UNRESOLVED,UnresolvedParent, Meta, <span class="keyword">true</span> );</div></div><!-- fragment --><p> Now construct Models from Entity List </p><div class="fragment"><div class="line"> Q3ModelFactory ( Game-&gt;loadParam, Game-&gt;Device, Mesh, ItemParent, <span class="keyword">false</span> );</div><div class="line">}</div></div><!-- fragment --><p> Adds a SceneNode with an icon to the Scene Tree </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::addSceneTreeItem( ISceneNode * parent, IGUITreeViewNode* nodeParent)</div><div class="line">{</div><div class="line"> IGUITreeViewNode* node;</div><div class="line"> <span class="keywordtype">wchar_t</span> msg[128];</div><div class="line"></div><div class="line"> s32 imageIndex;</div><div class="line"> list&lt;ISceneNode*&gt;::ConstIterator it = parent-&gt;getChildren().begin();</div><div class="line"> <span class="keywordflow">for</span> (; it != parent-&gt;getChildren().end(); ++it)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">switch</span> ( (*it)-&gt;getType () )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">case</span> ESNT_Q3SHADER_SCENE_NODE: imageIndex = 0; <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> ESNT_CAMERA: imageIndex = 1; <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> ESNT_EMPTY: imageIndex = 2; <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> ESNT_MESH: imageIndex = 3; <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> ESNT_OCTREE: imageIndex = 3; <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> ESNT_ANIMATED_MESH: imageIndex = 4; <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> ESNT_SKY_BOX: imageIndex = 5; <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> ESNT_BILLBOARD: imageIndex = 6; <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> ESNT_PARTICLE_SYSTEM: imageIndex = 7; <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> ESNT_TEXT: imageIndex = 8; <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">default</span>:imageIndex = -1; <span class="keywordflow">break</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( imageIndex &lt; 0 )</div><div class="line"> {</div><div class="line"> swprintf_irr ( msg, 128, L<span class="stringliteral">&quot;%hs,%hs&quot;</span>,</div><div class="line"> Game-&gt;Device-&gt;getSceneManager ()-&gt;getSceneNodeTypeName ( (*it)-&gt;getType () ),</div><div class="line"> (*it)-&gt;getName()</div><div class="line"> );</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> swprintf_irr ( msg, 128, L<span class="stringliteral">&quot;%hs&quot;</span>,(*it)-&gt;getName() );</div><div class="line"> }</div><div class="line"></div><div class="line"> node = nodeParent-&gt;addChildBack( msg, 0, imageIndex );</div><div class="line"></div><div class="line"> <span class="comment">// Add all Animators</span></div><div class="line"> list&lt;ISceneNodeAnimator*&gt;::ConstIterator ait = (*it)-&gt;getAnimators().begin();</div><div class="line"> <span class="keywordflow">for</span> (; ait != (*it)-&gt;getAnimators().end(); ++ait)</div><div class="line"> {</div><div class="line"> imageIndex = -1;</div><div class="line"> swprintf_irr ( msg, 128, L<span class="stringliteral">&quot;%hs&quot;</span>,</div><div class="line"> Game-&gt;Device-&gt;getSceneManager ()-&gt;getAnimatorTypeName ( (*ait)-&gt;getType () )</div><div class="line"> );</div><div class="line"></div><div class="line"> <span class="keywordflow">switch</span> ( (*ait)-&gt;getType () )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">case</span> ESNAT_FLY_CIRCLE:</div><div class="line"> <span class="keywordflow">case</span> ESNAT_FLY_STRAIGHT:</div><div class="line"> <span class="keywordflow">case</span> ESNAT_FOLLOW_SPLINE:</div><div class="line"> <span class="keywordflow">case</span> ESNAT_ROTATION:</div><div class="line"> <span class="keywordflow">case</span> ESNAT_TEXTURE:</div><div class="line"> <span class="keywordflow">case</span> ESNAT_DELETION:</div><div class="line"> <span class="keywordflow">case</span> ESNAT_COLLISION_RESPONSE:</div><div class="line"> <span class="keywordflow">case</span> ESNAT_CAMERA_FPS:</div><div class="line"> <span class="keywordflow">case</span> ESNAT_CAMERA_MAYA:</div><div class="line"> <span class="keywordflow">default</span>:</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> }</div><div class="line"> node-&gt;addChildBack( msg, 0, imageIndex );</div><div class="line"> }</div><div class="line"></div><div class="line"> addSceneTreeItem ( *it, node );</div><div class="line"> }</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// Adds life!</span></div><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::CreatePlayers()</div><div class="line">{</div><div class="line"> Player[0].create ( Game-&gt;Device, Mesh, MapParent, Meta );</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// Adds a skydome to the scene</span></div><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::AddSky( u32 dome, <span class="keyword">const</span> c8 *texture)</div><div class="line">{</div><div class="line"> ISceneManager *smgr = Game-&gt;Device-&gt;getSceneManager ();</div><div class="line"> IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();</div><div class="line"></div><div class="line"> <span class="keywordtype">bool</span> oldMipMapState = driver-&gt;getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);</div><div class="line"> driver-&gt;setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, <span class="keyword">false</span>);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( 0 == dome )</div><div class="line"> {</div><div class="line"> <span class="comment">// irrlicht order</span></div><div class="line"> <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></div><div class="line"> <span class="comment">// quake3 order</span></div><div class="line"> <span class="keyword">static</span> <span class="keyword">const</span> c8*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> };</div><div class="line"></div><div class="line"> u32 i = 0;</div><div class="line"> snprintf_irr ( buf, 64, <span class="stringliteral">&quot;%s_%s.jpg&quot;</span>, texture, p[i] );</div><div class="line"> SkyNode = smgr-&gt;addSkyBoxSceneNode( driver-&gt;getTexture ( buf ), 0, 0, 0, 0, 0 );</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (SkyNode)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">for</span> ( i = 0; i &lt; 6; ++i )</div><div class="line"> {</div><div class="line"> snprintf_irr ( buf, 64, <span class="stringliteral">&quot;%s_%s.jpg&quot;</span>, texture, p[i] );</div><div class="line"> SkyNode-&gt;getMaterial(i).setTexture ( 0, driver-&gt;getTexture ( buf ) );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( 1 == dome )</div><div class="line"> {</div><div class="line"> snprintf_irr ( buf, 64, <span class="stringliteral">&quot;%s.jpg&quot;</span>, texture );</div><div class="line"> SkyNode = smgr-&gt;addSkyDomeSceneNode(</div><div class="line"> driver-&gt;getTexture( buf ), 32,32,</div><div class="line"> 1.f, 1.f, 1000.f, 0, 11);</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( 2 == dome )</div><div class="line"> {</div><div class="line"> snprintf_irr ( buf, 64, <span class="stringliteral">&quot;%s.jpg&quot;</span>, texture );</div><div class="line"> SkyNode = smgr-&gt;addSkyDomeSceneNode(</div><div class="line"> driver-&gt;getTexture( buf ), 16,8,</div><div class="line"> 0.95f, 2.f, 1000.f, 0, 11);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (SkyNode)</div><div class="line"> SkyNode-&gt;setName(<span class="stringliteral">&quot;Skydome&quot;</span>);</div><div class="line"> <span class="comment">//SkyNode-&gt;getMaterial(0).ZBuffer = video::EMDF_DEPTH_LESS_EQUAL;</span></div><div class="line"></div><div class="line"> driver-&gt;setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// enable GUI elements</span></div><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::SetGUIActive( s32 command)</div><div class="line">{</div><div class="line"> <span class="keywordtype">bool</span> inputState = <span class="keyword">false</span>;</div><div class="line"></div><div class="line"> ICameraSceneNode * camera = Game-&gt;Device-&gt;getSceneManager()-&gt;getActiveCamera ();</div><div class="line"></div><div class="line"> <span class="keywordflow">switch</span> ( command )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">case</span> 0: Game-&gt;guiActive = 0; inputState = !Game-&gt;guiActive; <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> 1: Game-&gt;guiActive = 1; inputState = !Game-&gt;guiActive;;<span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> 2: Game-&gt;guiActive ^= 1; inputState = !Game-&gt;guiActive;<span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> 3:</div><div class="line"> <span class="keywordflow">if</span> ( camera )</div><div class="line"> inputState = !camera-&gt;isInputReceiverEnabled();</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( camera )</div><div class="line"> {</div><div class="line"> camera-&gt;setInputReceiverEnabled ( inputState );</div><div class="line"> Game-&gt;Device-&gt;getCursorControl()-&gt;setVisible( !inputState );</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( gui.Window )</div><div class="line"> {</div><div class="line"> gui.Window-&gt;setVisible ( Game-&gt;guiActive != 0 );</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( Game-&gt;guiActive &amp;&amp;</div><div class="line"> gui.SceneTree &amp;&amp; Game-&gt;Device-&gt;getGUIEnvironment()-&gt;getFocus() != gui.SceneTree</div><div class="line"> )</div><div class="line"> {</div><div class="line"> gui.SceneTree-&gt;getRoot()-&gt;clearChildren();</div><div class="line"> addSceneTreeItem ( Game-&gt;Device-&gt;getSceneManager()-&gt;getRootSceneNode(), gui.SceneTree-&gt;getRoot() );</div><div class="line"> }</div><div class="line"></div><div class="line"> Game-&gt;Device-&gt;getGUIEnvironment()-&gt;setFocus ( Game-&gt;guiActive ? gui.Window: 0 );</div><div class="line">}</div></div><!-- fragment --><p> Handle game input </p><div class="fragment"><div class="line"><span class="keywordtype">bool</span> CQuake3EventHandler::OnEvent(<span class="keyword">const</span> SEvent&amp; eve)</div><div class="line">{</div><div class="line"> <span class="keywordflow">if</span> ( eve.EventType == EET_LOG_TEXT_EVENT )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( Game-&gt;guiActive &amp;&amp; eve.EventType == EET_GUI_EVENT )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.MapList &amp;&amp; eve.GUIEvent.EventType == gui::EGET_LISTBOX_SELECTED_AGAIN )</div><div class="line"> {</div><div class="line"> s32 selected = gui.MapList-&gt;getSelected();</div><div class="line"> <span class="keywordflow">if</span> ( selected &gt;= 0 )</div><div class="line"> {</div><div class="line"> stringw loadMap = gui.MapList-&gt;getListItem ( selected );</div><div class="line"> <span class="keywordflow">if</span> ( 0 == MapParent || loadMap != Game-&gt;CurrentMapName )</div><div class="line"> {</div><div class="line"> printf ( <span class="stringliteral">&quot;Loading map %ls\n&quot;</span>, loadMap.c_str() );</div><div class="line"> LoadMap ( loadMap , 1 );</div><div class="line"> <span class="keywordflow">if</span> ( 0 == Game-&gt;loadParam.loadSkyShader )</div><div class="line"> {</div><div class="line"> AddSky ( 1, <span class="stringliteral">&quot;skydome2&quot;</span> );</div><div class="line"> }</div><div class="line"> CreatePlayers ();</div><div class="line"> CreateGUI ();</div><div class="line"> SetGUIActive ( 0 );</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"> }</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveRemove &amp;&amp; eve.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED )</div><div class="line"> {</div><div class="line"> Game-&gt;Device-&gt;getFileSystem()-&gt;removeFileArchive( gui.ArchiveList-&gt;getSelected() );</div><div class="line"> Game-&gt;CurrentMapName = <span class="stringliteral">&quot;&quot;</span>;</div><div class="line"> AddArchive ( <span class="stringliteral">&quot;&quot;</span> );</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveAdd &amp;&amp; eve.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( 0 == gui.ArchiveFileOpen )</div><div class="line"> {</div><div class="line"> Game-&gt;Device-&gt;getFileSystem()-&gt;setFileListSystem ( FILESYSTEM_NATIVE );</div><div class="line"> 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 );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveFileOpen &amp;&amp; eve.GUIEvent.EventType == gui::EGET_FILE_SELECTED )</div><div class="line"> {</div><div class="line"> AddArchive ( gui.ArchiveFileOpen-&gt;getFileNameP() );</div><div class="line"> gui.ArchiveFileOpen = 0;</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveFileOpen &amp;&amp; eve.GUIEvent.EventType == gui::EGET_DIRECTORY_SELECTED )</div><div class="line"> {</div><div class="line"> AddArchive ( gui.ArchiveFileOpen-&gt;getDirectoryName() );</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveFileOpen &amp;&amp; eve.GUIEvent.EventType == gui::EGET_FILE_CHOOSE_DIALOG_CANCELLED )</div><div class="line"> {</div><div class="line"> gui.ArchiveFileOpen = 0;</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( ( eve.GUIEvent.Caller == gui.ArchiveUp || eve.GUIEvent.Caller == gui.ArchiveDown ) &amp;&amp;</div><div class="line"> eve.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED )</div><div class="line"> {</div><div class="line"> s32 rel = eve.GUIEvent.Caller == gui.ArchiveUp ? -1 : 1;</div><div class="line"> <span class="keywordflow">if</span> ( Game-&gt;Device-&gt;getFileSystem()-&gt;moveFileArchive ( gui.ArchiveList-&gt;getSelected (), rel ) )</div><div class="line"> {</div><div class="line"> s32 newIndex = core::s32_clamp ( gui.ArchiveList-&gt;getSelected() + rel, 0, gui.ArchiveList-&gt;getRowCount() - 1 );</div><div class="line"> AddArchive ( <span class="stringliteral">&quot;&quot;</span> );</div><div class="line"> gui.ArchiveList-&gt;setSelected ( newIndex );</div><div class="line"> Game-&gt;CurrentMapName = <span class="stringliteral">&quot;&quot;</span>;</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.VideoDriver &amp;&amp; eve.GUIEvent.EventType == gui::EGET_COMBO_BOX_CHANGED )</div><div class="line"> {</div><div class="line"> Game-&gt;deviceParam.DriverType = (E_DRIVER_TYPE) gui.VideoDriver-&gt;getItemData ( gui.VideoDriver-&gt;getSelected() );</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.VideoMode &amp;&amp; eve.GUIEvent.EventType == gui::EGET_COMBO_BOX_CHANGED )</div><div class="line"> {</div><div class="line"> u32 val = gui.VideoMode-&gt;getItemData ( gui.VideoMode-&gt;getSelected() );</div><div class="line"> Game-&gt;deviceParam.WindowSize.Width = val &gt;&gt; 16;</div><div class="line"> Game-&gt;deviceParam.WindowSize.Height = val &amp; 0xFFFF;</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.FullScreen &amp;&amp; eve.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED )</div><div class="line"> {</div><div class="line"> Game-&gt;deviceParam.Fullscreen = gui.FullScreen-&gt;isChecked();</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Bit32 &amp;&amp; eve.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED )</div><div class="line"> {</div><div class="line"> Game-&gt;deviceParam.Bits = gui.Bit32-&gt;isChecked() ? 32 : 16;</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.MultiSample &amp;&amp; eve.GUIEvent.EventType == gui::EGET_SCROLL_BAR_CHANGED )</div><div class="line"> {</div><div class="line"> Game-&gt;deviceParam.AntiAlias = gui.MultiSample-&gt;getPos();</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Tesselation &amp;&amp; eve.GUIEvent.EventType == gui::EGET_SCROLL_BAR_CHANGED )</div><div class="line"> {</div><div class="line"> Game-&gt;loadParam.patchTesselation = gui.Tesselation-&gt;getPos ();</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Gamma &amp;&amp; eve.GUIEvent.EventType == gui::EGET_SCROLL_BAR_CHANGED )</div><div class="line"> {</div><div class="line"> Game-&gt;GammaValue = gui.Gamma-&gt;getPos () * 0.01f;</div><div class="line"> Game-&gt;Device-&gt;setGammaRamp ( Game-&gt;GammaValue, Game-&gt;GammaValue, Game-&gt;GammaValue, 0.f, 0.f );</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.SetVideoMode &amp;&amp; eve.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED )</div><div class="line"> {</div><div class="line"> Game-&gt;retVal = 2;</div><div class="line"> Game-&gt;Device-&gt;closeDevice();</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Window &amp;&amp; eve.GUIEvent.EventType == gui::EGET_ELEMENT_CLOSED )</div><div class="line"> {</div><div class="line"> Game-&gt;Device-&gt;closeDevice();</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Collision &amp;&amp; eve.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED )</div><div class="line"> {</div><div class="line"> <span class="comment">// set fly through active</span></div><div class="line"> Game-&gt;flyTroughState ^= 1;</div><div class="line"> Player[0].cam()-&gt;setAnimateTarget ( Game-&gt;flyTroughState == 0 );</div><div class="line"></div><div class="line"> printf ( <span class="stringliteral">&quot;collision %d\n&quot;</span>, Game-&gt;flyTroughState == 0 );</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Visible_Map &amp;&amp; eve.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED )</div><div class="line"> {</div><div class="line"> <span class="keywordtype">bool</span> v = gui.Visible_Map-&gt;isChecked();</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( MapParent )</div><div class="line"> {</div><div class="line"> printf ( <span class="stringliteral">&quot;static node set visible %d\n&quot;</span>,v );</div><div class="line"> MapParent-&gt;setVisible ( v );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Visible_Shader &amp;&amp; eve.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED )</div><div class="line"> {</div><div class="line"> <span class="keywordtype">bool</span> v = gui.Visible_Shader-&gt;isChecked();</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( ShaderParent )</div><div class="line"> {</div><div class="line"> printf ( <span class="stringliteral">&quot;shader node set visible %d\n&quot;</span>,v );</div><div class="line"> ShaderParent-&gt;setVisible ( v );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Visible_Skydome &amp;&amp; eve.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( SkyNode )</div><div class="line"> {</div><div class="line"> <span class="keywordtype">bool</span> v = !SkyNode-&gt;isVisible();</div><div class="line"> printf ( <span class="stringliteral">&quot;skynode set visible %d\n&quot;</span>,v );</div><div class="line"> SkyNode-&gt;setVisible ( v );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Respawn &amp;&amp; eve.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED )</div><div class="line"> {</div><div class="line"> Player[0].respawn ();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// fire</span></div><div class="line"> <span class="keywordflow">if</span> ((eve.EventType == EET_KEY_INPUT_EVENT &amp;&amp; eve.KeyInput.Key == KEY_SPACE &amp;&amp;</div><div class="line"> eve.KeyInput.PressedDown == <span class="keyword">false</span>) ||</div><div class="line"> (eve.EventType == EET_MOUSE_INPUT_EVENT &amp;&amp; eve.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)</div><div class="line"> )</div><div class="line"> {</div><div class="line"> ICameraSceneNode * camera = Game-&gt;Device-&gt;getSceneManager()-&gt;getActiveCamera ();</div><div class="line"> <span class="keywordflow">if</span> ( camera &amp;&amp; camera-&gt;isInputReceiverEnabled () )</div><div class="line"> {</div><div class="line"> useItem( Player + 0 );</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// gui active</span></div><div class="line"> <span class="keywordflow">if</span> ((eve.EventType == EET_KEY_INPUT_EVENT &amp;&amp; eve.KeyInput.Key == KEY_F1 &amp;&amp;</div><div class="line"> eve.KeyInput.PressedDown == <span class="keyword">false</span>) ||</div><div class="line"> (eve.EventType == EET_MOUSE_INPUT_EVENT &amp;&amp; eve.MouseInput.Event == EMIE_RMOUSE_LEFT_UP)</div><div class="line"> )</div><div class="line"> {</div><div class="line"> SetGUIActive ( 2 );</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// check if user presses the key</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.EventType == EET_KEY_INPUT_EVENT &amp;&amp; eve.KeyInput.PressedDown == <span class="keyword">false</span>)</div><div class="line"> {</div><div class="line"> <span class="comment">// Escape toggles camera Input</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.KeyInput.Key == irr::KEY_ESCAPE )</div><div class="line"> {</div><div class="line"> SetGUIActive ( 3 );</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> (eve.KeyInput.Key == KEY_F11)</div><div class="line"> {</div><div class="line"> <span class="comment">// screenshot are taken without gamma!</span></div><div class="line"> IImage* image = Game-&gt;Device-&gt;getVideoDriver()-&gt;createScreenShot();</div><div class="line"> <span class="keywordflow">if</span> (image)</div><div class="line"> {</div><div class="line"> core::vector3df pos;</div><div class="line"> core::vector3df rot;</div><div class="line"> ICameraSceneNode * cam = Game-&gt;Device-&gt;getSceneManager()-&gt;getActiveCamera ();</div><div class="line"> <span class="keywordflow">if</span> ( cam )</div><div class="line"> {</div><div class="line"> pos = cam-&gt;getPosition ();</div><div class="line"> rot = cam-&gt;getRotation ();</div><div class="line"> }</div><div class="line"></div><div class="line"> snprintf_irr(buf, 256, <span class="stringliteral">&quot;%s_%ls_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f.jpg&quot;</span>,</div><div class="line"> DRIVER_TYPE_NAMES_SHORT[Game-&gt;Device-&gt;getVideoDriver()-&gt;getDriverType()],</div><div class="line"> Game-&gt;CurrentMapName.c_str(),</div><div class="line"> pos.X, pos.Y, pos.Z,</div><div class="line"> rot.X, rot.Y, rot.Z</div><div class="line"> );</div><div class="line"> path filename ( buf );</div><div class="line"> filename.replace ( <span class="charliteral">&#39;/&#39;</span>, <span class="charliteral">&#39;_&#39;</span> );</div><div class="line"> printf ( <span class="stringliteral">&quot;screenshot : %s\n&quot;</span>, filename.c_str() );</div><div class="line"> Game-&gt;Device-&gt;getVideoDriver()-&gt;writeImageToFile(image, filename, 100 );</div><div class="line"> image-&gt;drop();</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> (eve.KeyInput.Key == KEY_F9)</div><div class="line"> {</div><div class="line"> s32 value = EDS_OFF;</div><div class="line"></div><div class="line"> Game-&gt;debugState = ( Game-&gt;debugState + 1 ) &amp; 3;</div><div class="line"></div><div class="line"> <span class="keywordflow">switch</span> ( Game-&gt;debugState )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">case</span> 1: value = EDS_NORMALS | EDS_MESH_WIRE_OVERLAY | EDS_BBOX_ALL; <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> 2: value = EDS_NORMALS | EDS_MESH_WIRE_OVERLAY | EDS_SKELETON; <span class="keywordflow">break</span>;</div><div class="line"> }</div></div><!-- fragment --><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"><div class="line"> <span class="keywordflow">if</span> ( ItemParent )</div><div class="line"> {</div><div class="line"> list&lt;ISceneNode*&gt;::ConstIterator it = ItemParent-&gt;getChildren().begin();</div><div class="line"> <span class="keywordflow">for</span> (; it != ItemParent-&gt;getChildren().end(); ++it)</div><div class="line"> {</div><div class="line"> (*it)-&gt;setDebugDataVisible ( value );</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( ShaderParent )</div><div class="line"> {</div><div class="line"> list&lt;ISceneNode*&gt;::ConstIterator it = ShaderParent-&gt;getChildren().begin();</div><div class="line"> <span class="keywordflow">for</span> (; it != ShaderParent-&gt;getChildren().end(); ++it)</div><div class="line"> {</div><div class="line"> (*it)-&gt;setDebugDataVisible ( value );</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( UnresolvedParent )</div><div class="line"> {</div><div class="line"> list&lt;ISceneNode*&gt;::ConstIterator it = UnresolvedParent-&gt;getChildren().begin();</div><div class="line"> <span class="keywordflow">for</span> (; it != UnresolvedParent-&gt;getChildren().end(); ++it)</div><div class="line"> {</div><div class="line"> (*it)-&gt;setDebugDataVisible ( value );</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( FogParent )</div><div class="line"> {</div><div class="line"> list&lt;ISceneNode*&gt;::ConstIterator it = FogParent-&gt;getChildren().begin();</div><div class="line"> <span class="keywordflow">for</span> (; it != FogParent-&gt;getChildren().end(); ++it)</div><div class="line"> {</div><div class="line"> (*it)-&gt;setDebugDataVisible ( value );</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( SkyNode )</div><div class="line"> {</div><div class="line"> SkyNode-&gt;setDebugDataVisible ( value );</div><div class="line"> }</div><div class="line"></div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> (eve.KeyInput.Key == KEY_F8)</div><div class="line"> {</div><div class="line"> <span class="comment">// set gravity on/off</span></div><div class="line"> Game-&gt;gravityState ^= 1;</div><div class="line"> Player[0].cam()-&gt;setGravity ( getGravity ( Game-&gt;gravityState ? <span class="stringliteral">&quot;earth&quot;</span> : <span class="stringliteral">&quot;none&quot;</span> ) );</div><div class="line"> 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> );</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> (eve.KeyInput.Key == KEY_F7)</div><div class="line"> {</div><div class="line"> <span class="comment">// set fly through active</span></div><div class="line"> Game-&gt;flyTroughState ^= 1;</div><div class="line"> Player[0].cam()-&gt;setAnimateTarget ( Game-&gt;flyTroughState == 0 );</div><div class="line"> <span class="keywordflow">if</span> ( gui.Collision )</div><div class="line"> gui.Collision-&gt;setChecked ( Game-&gt;flyTroughState == 0 );</div><div class="line"></div><div class="line"> printf ( <span class="stringliteral">&quot;collision %d\n&quot;</span>, Game-&gt;flyTroughState == 0 );</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> (eve.KeyInput.Key == KEY_F2)</div><div class="line"> {</div><div class="line"> Player[0].respawn ();</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> (eve.KeyInput.Key == KEY_F3)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( MapParent )</div><div class="line"> {</div><div class="line"> <span class="keywordtype">bool</span> v = !MapParent-&gt;isVisible ();</div><div class="line"> printf ( <span class="stringliteral">&quot;static node set visible %d\n&quot;</span>,v );</div><div class="line"> MapParent-&gt;setVisible ( v );</div><div class="line"> <span class="keywordflow">if</span> ( gui.Visible_Map )</div><div class="line"> gui.Visible_Map-&gt;setChecked ( v );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> (eve.KeyInput.Key == KEY_F4)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( ShaderParent )</div><div class="line"> {</div><div class="line"> <span class="keywordtype">bool</span> v = !ShaderParent-&gt;isVisible ();</div><div class="line"> printf ( <span class="stringliteral">&quot;shader node set visible %d\n&quot;</span>,v );</div><div class="line"> ShaderParent-&gt;setVisible ( v );</div><div class="line"> <span class="keywordflow">if</span> ( gui.Visible_Shader )</div><div class="line"> gui.Visible_Shader-&gt;setChecked ( v );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> (eve.KeyInput.Key == KEY_F5)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( FogParent )</div><div class="line"> {</div><div class="line"> <span class="keywordtype">bool</span> v = !FogParent-&gt;isVisible ();</div><div class="line"> printf ( <span class="stringliteral">&quot;fog node set visible %d\n&quot;</span>,v );</div><div class="line"> FogParent-&gt;setVisible ( v );</div><div class="line"> <span class="keywordflow">if</span> ( gui.Visible_Fog )</div><div class="line"> gui.Visible_Fog-&gt;setChecked ( v );</div><div class="line"> }</div><div class="line"></div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <span class="keywordflow">if</span> (eve.KeyInput.Key == KEY_F6)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( UnresolvedParent )</div><div class="line"> {</div><div class="line"> <span class="keywordtype">bool</span> v = !UnresolvedParent-&gt;isVisible ();</div><div class="line"> printf ( <span class="stringliteral">&quot;unresolved node set visible %d\n&quot;</span>,v );</div><div class="line"> UnresolvedParent-&gt;setVisible ( v );</div><div class="line"> <span class="keywordflow">if</span> ( gui.Visible_Unresolved )</div><div class="line"> gui.Visible_Unresolved-&gt;setChecked ( v );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// check if user presses the key C ( for crouch)</span></div><div class="line"> <span class="keywordflow">if</span> ( eve.EventType == EET_KEY_INPUT_EVENT &amp;&amp; eve.KeyInput.Key == KEY_KEY_C )</div><div class="line"> {</div><div class="line"> <span class="comment">// crouch</span></div><div class="line"> ISceneNodeAnimatorCollisionResponse *anim = Player[0].cam ();</div><div class="line"> <span class="keywordflow">if</span> ( anim &amp;&amp; 0 == Game-&gt;flyTroughState )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( <span class="keyword">false</span> == eve.KeyInput.PressedDown )</div><div class="line"> {</div><div class="line"> <span class="comment">// stand up</span></div><div class="line"> anim-&gt;setEllipsoidRadius ( vector3df(30,45,30) );</div><div class="line"> anim-&gt;setEllipsoidTranslation ( vector3df(0,40,0));</div><div class="line"></div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> <span class="comment">// on your knees</span></div><div class="line"> anim-&gt;setEllipsoidRadius ( vector3df(30,20,30) );</div><div class="line"> anim-&gt;setEllipsoidTranslation ( vector3df(0,20,0));</div><div class="line"> }</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line">}</div></div><!-- fragment --><p> useItem </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::useItem( Q3Player * player)</div><div class="line">{</div><div class="line"> ISceneManager* smgr = Game-&gt;Device-&gt;getSceneManager();</div><div class="line"> ICameraSceneNode* camera = smgr-&gt;getActiveCamera();</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (!camera)</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"></div><div class="line"> SParticleImpact imp;</div><div class="line"> imp.when = 0;</div><div class="line"></div><div class="line"> <span class="comment">// get line of camera</span></div><div class="line"></div><div class="line"> vector3df start = camera-&gt;getPosition();</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( player-&gt;WeaponNode )</div><div class="line"> {</div><div class="line"> start.X += 0.f;</div><div class="line"> start.Y += 0.f;</div><div class="line"> start.Z += 0.f;</div><div class="line"> }</div><div class="line"></div><div class="line"> vector3df end = (camera-&gt;getTarget() - start);</div><div class="line"> end.normalize();</div><div class="line"> start += end*20.0f;</div><div class="line"></div><div class="line"> end = start + (end * camera-&gt;getFarValue());</div><div class="line"></div><div class="line"> triangle3df triangle;</div><div class="line"> line3d&lt;f32&gt; line(start, end);</div><div class="line"></div><div class="line"> <span class="comment">// get intersection point with map</span></div><div class="line"> scene::ISceneNode* hitNode;</div><div class="line"> <span class="keywordflow">if</span> (smgr-&gt;getSceneCollisionManager()-&gt;getCollisionPoint(</div><div class="line"> line, Meta, end, triangle,hitNode))</div><div class="line"> {</div><div class="line"> <span class="comment">// collides with wall</span></div><div class="line"> vector3df out = triangle.getNormal();</div><div class="line"> out.setLength(0.03f);</div><div class="line"></div><div class="line"> imp.when = 1;</div><div class="line"> imp.outVector = out;</div><div class="line"> imp.pos = end;</div><div class="line"></div><div class="line"> player-&gt;setAnim ( <span class="stringliteral">&quot;pow&quot;</span> );</div><div class="line"> player-&gt;Anim[1].next += player-&gt;Anim[1].delta;</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> <span class="comment">// doesnt collide with wall</span></div><div class="line"> vector3df start = camera-&gt;getPosition();</div><div class="line"> <span class="keywordflow">if</span> ( player-&gt;WeaponNode )</div><div class="line"> {</div><div class="line"> <span class="comment">//start.X += 10.f;</span></div><div class="line"> <span class="comment">//start.Y += -5.f;</span></div><div class="line"> <span class="comment">//start.Z += 1.f;</span></div><div class="line"> }</div><div class="line"></div><div class="line"> vector3df end = (camera-&gt;getTarget() - start);</div><div class="line"> end.normalize();</div><div class="line"> start += end*20.0f;</div><div class="line"> end = start + (end * camera-&gt;getFarValue());</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// create fire ball</span></div><div class="line"> ISceneNode* node = 0;</div><div class="line"> node = smgr-&gt;addBillboardSceneNode( BulletParent,dimension2d&lt;f32&gt;(10,10), start);</div><div class="line"></div><div class="line"> node-&gt;setMaterialFlag(EMF_LIGHTING, <span class="keyword">false</span>);</div><div class="line"> node-&gt;setMaterialTexture(0, Game-&gt;Device-&gt;getVideoDriver()-&gt;getTexture(<span class="stringliteral">&quot;fireball.bmp&quot;</span>));</div><div class="line"> node-&gt;setMaterialFlag(video::EMF_ZWRITE_ENABLE, <span class="keyword">false</span>);</div><div class="line"> node-&gt;setMaterialType(EMT_TRANSPARENT_ADD_COLOR);</div><div class="line"></div><div class="line"> f32 length = (f32)(end - start).getLength();</div><div class="line"> <span class="keyword">const</span> f32 speed = 5.8f;</div><div class="line"> u32 time = (u32)(length / speed);</div><div class="line"></div><div class="line"> ISceneNodeAnimator* anim = 0;</div><div class="line"></div><div class="line"> <span class="comment">// set flight line</span></div><div class="line"></div><div class="line"> anim = smgr-&gt;createFlyStraightAnimator(start, end, time);</div><div class="line"> node-&gt;addAnimator(anim);</div><div class="line"> anim-&gt;drop();</div><div class="line"></div><div class="line"> snprintf_irr ( buf, 64, <span class="stringliteral">&quot;bullet: %s on %.1f,%1.f,%1.f&quot;</span>,</div><div class="line"> imp.when ? <span class="stringliteral">&quot;hit&quot;</span> : <span class="stringliteral">&quot;nohit&quot;</span>, end.X, end.Y, end.Z );</div><div class="line"> node-&gt;setName ( buf );</div><div class="line"></div><div class="line"></div><div class="line"> anim = smgr-&gt;createDeleteAnimator(time);</div><div class="line"> node-&gt;addAnimator(anim);</div><div class="line"> anim-&gt;drop();</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (imp.when)</div><div class="line"> {</div><div class="line"> <span class="comment">// create impact note</span></div><div class="line"> imp.when = Game-&gt;Device-&gt;getTimer()-&gt;getTime() +</div><div class="line"> (time + (s32) ( ( 1.f + Noiser::get() ) * 250.f ));</div><div class="line"> Impacts.push_back(imp);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// play sound</span></div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// rendered when bullets hit something</span></div><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::createParticleImpacts( u32 now )</div><div class="line">{</div><div class="line"> ISceneManager* sm = Game-&gt;Device-&gt;getSceneManager();</div><div class="line"></div><div class="line"> <span class="keyword">struct </span>smokeLayer</div><div class="line"> {</div><div class="line"> <span class="keyword">const</span> c8 * texture;</div><div class="line"> f32 scale;</div><div class="line"> f32 minparticleSize;</div><div class="line"> f32 maxparticleSize;</div><div class="line"> f32 boxSize;</div><div class="line"> u32 minParticle;</div><div class="line"> u32 maxParticle;</div><div class="line"> u32 fadeout;</div><div class="line"> u32 lifetime;</div><div class="line"> };</div><div class="line"></div><div class="line"> smokeLayer smoke[] =</div><div class="line"> {</div><div class="line"> { <span class="stringliteral">&quot;smoke2.jpg&quot;</span>, 0.4f, 1.5f, 18.f, 20.f, 20, 50, 2000, 10000 },</div><div class="line"> { <span class="stringliteral">&quot;smoke3.jpg&quot;</span>, 0.2f, 1.2f, 15.f, 20.f, 10, 30, 1000, 12000 }</div><div class="line"> };</div><div class="line"></div><div class="line"></div><div class="line"> u32 i;</div><div class="line"> u32 g;</div><div class="line"> s32 factor = 1;</div><div class="line"> <span class="keywordflow">for</span> ( g = 0; g != 2; ++g )</div><div class="line"> {</div><div class="line"> smoke[g].minParticle *= factor;</div><div class="line"> smoke[g].maxParticle *= factor;</div><div class="line"> smoke[g].lifetime *= factor;</div><div class="line"> smoke[g].boxSize *= Noiser::get() * 0.5f;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">for</span> ( i=0; i &lt; Impacts.size(); ++i)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> (now &lt; Impacts[i].when)</div><div class="line"> <span class="keywordflow">continue</span>;</div><div class="line"></div><div class="line"> <span class="comment">// create smoke particle system</span></div><div class="line"> IParticleSystemSceneNode* pas = 0;</div><div class="line"></div><div class="line"> <span class="keywordflow">for</span> ( g = 0; g != 2; ++g )</div><div class="line"> {</div><div class="line"> pas = sm-&gt;addParticleSystemSceneNode(<span class="keyword">false</span>, BulletParent, -1, Impacts[i].pos);</div><div class="line"></div><div class="line"> snprintf_irr ( buf, 64, <span class="stringliteral">&quot;bullet impact smoke at %.1f,%.1f,%1.f&quot;</span>,</div><div class="line"> Impacts[i].pos.X,Impacts[i].pos.Y,Impacts[i].pos.Z);</div><div class="line"> pas-&gt;setName ( buf );</div><div class="line"></div><div class="line"> <span class="comment">// create a flat smoke</span></div><div class="line"> vector3df direction = Impacts[i].outVector;</div><div class="line"> direction *= smoke[g].scale;</div><div class="line"> IParticleEmitter* em = pas-&gt;createBoxEmitter(</div><div class="line"> aabbox3d&lt;f32&gt;(-4.f,0.f,-4.f,20.f,smoke[g].minparticleSize,20.f),</div><div class="line"> direction,smoke[g].minParticle, smoke[g].maxParticle,</div><div class="line"> video::SColor(0,0,0,0),video::SColor(0,128,128,128),</div><div class="line"> 250,4000, 60);</div><div class="line"></div><div class="line"> em-&gt;setMinStartSize (dimension2d&lt;f32&gt;( smoke[g].minparticleSize, smoke[g].minparticleSize));</div><div class="line"> em-&gt;setMaxStartSize (dimension2d&lt;f32&gt;( smoke[g].maxparticleSize, smoke[g].maxparticleSize));</div><div class="line"></div><div class="line"> pas-&gt;setEmitter(em);</div><div class="line"> em-&gt;drop();</div><div class="line"></div><div class="line"> <span class="comment">// particles get invisible</span></div><div class="line"> IParticleAffector* paf = pas-&gt;createFadeOutParticleAffector(</div><div class="line"> video::SColor ( 0, 0, 0, 0 ), smoke[g].fadeout);</div><div class="line"> pas-&gt;addAffector(paf);</div><div class="line"> paf-&gt;drop();</div><div class="line"></div><div class="line"> <span class="comment">// particle system life time</span></div><div class="line"> ISceneNodeAnimator* anim = sm-&gt;createDeleteAnimator( smoke[g].lifetime);</div><div class="line"> pas-&gt;addAnimator(anim);</div><div class="line"> anim-&gt;drop();</div><div class="line"></div><div class="line"> pas-&gt;setMaterialFlag(video::EMF_LIGHTING, <span class="keyword">false</span>);</div><div class="line"> pas-&gt;setMaterialFlag(video::EMF_ZWRITE_ENABLE, <span class="keyword">false</span>);</div><div class="line"> pas-&gt;setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );</div><div class="line"> pas-&gt;setMaterialTexture(0, Game-&gt;Device-&gt;getVideoDriver()-&gt;getTexture( smoke[g].texture ));</div><div class="line"> }</div><div class="line"></div><div class="line"></div><div class="line"> <span class="comment">// play impact sound</span></div><div class="line"><span class="preprocessor"> #ifdef USE_IRRKLANG</span></div></div><!-- fragment --><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"><div class="line"><span class="preprocessor"> #endif</span></div><div class="line"></div><div class="line"></div><div class="line"> <span class="comment">// delete entry</span></div><div class="line"> Impacts.erase(i);</div><div class="line"> i--;</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p> render </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::Render()</div><div class="line">{</div><div class="line"> IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();</div><div class="line"> <span class="keywordflow">if</span> ( 0 == driver )</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"></div><div class="line"> <span class="comment">// TODO: This does not work, yet.</span></div><div class="line"> <span class="keyword">const</span> <span class="keywordtype">bool</span> anaglyph=<span class="keyword">false</span>;</div><div class="line"> <span class="keywordflow">if</span> (anaglyph)</div><div class="line"> {</div><div class="line"> scene::ICameraSceneNode* cameraOld = Game-&gt;Device-&gt;getSceneManager()-&gt;getActiveCamera();</div><div class="line"> driver-&gt;beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(0,0,0,0));</div><div class="line"> driver-&gt;getOverrideMaterial().Material.ColorMask = ECP_NONE;</div><div class="line"> driver-&gt;getOverrideMaterial().EnableFlags = EMF_COLOR_MASK;</div><div class="line"> driver-&gt;getOverrideMaterial().EnablePasses = ESNRP_SKY_BOX +</div><div class="line"> ESNRP_SOLID +</div><div class="line"> ESNRP_TRANSPARENT +</div><div class="line"> ESNRP_TRANSPARENT_EFFECT +</div><div class="line"> ESNRP_SHADOW;</div><div class="line"> Game-&gt;Device-&gt;getSceneManager()-&gt;drawAll();</div><div class="line"> driver-&gt;clearBuffers(video::ECBF_DEPTH, video::SColor(255,0,0,0));</div><div class="line"></div><div class="line"> <span class="keyword">const</span> vector3df oldPosition = cameraOld-&gt;getPosition();</div><div class="line"> <span class="keyword">const</span> vector3df oldTarget = cameraOld-&gt;getTarget();</div><div class="line"> <span class="keyword">const</span> matrix4 startMatrix = cameraOld-&gt;getAbsoluteTransformation();</div><div class="line"> <span class="keyword">const</span> vector3df focusPoint = (oldTarget -</div><div class="line"> cameraOld-&gt;getAbsolutePosition()).setLength(10000) +</div><div class="line"> cameraOld-&gt;getAbsolutePosition() ;</div><div class="line"></div><div class="line"> scene::ICameraSceneNode* camera = cameraOld;<span class="comment">//Game-&gt;Device-&gt;getSceneManager()-&gt;addCameraSceneNode();</span></div><div class="line"></div><div class="line"> <span class="comment">//Left eye...</span></div><div class="line"> vector3df pos;</div><div class="line"> matrix4 move;</div><div class="line"></div><div class="line"> move.setTranslation( vector3df(-1.5f,0.0f,0.0f) );</div><div class="line"> pos=(startMatrix*move).getTranslation();</div><div class="line"></div><div class="line"> driver-&gt;getOverrideMaterial().Material.ColorMask = ECP_RED;</div><div class="line"> driver-&gt;getOverrideMaterial().EnableFlags = EMF_COLOR_MASK;</div><div class="line"> driver-&gt;getOverrideMaterial().EnablePasses =</div><div class="line"> ESNRP_SKY_BOX|ESNRP_SOLID|ESNRP_TRANSPARENT|</div><div class="line"> ESNRP_TRANSPARENT_EFFECT|ESNRP_SHADOW;</div><div class="line"></div><div class="line"> camera-&gt;setPosition(pos);</div><div class="line"> camera-&gt;setTarget(focusPoint);</div><div class="line"></div><div class="line"> Game-&gt;Device-&gt;getSceneManager()-&gt;drawAll();</div><div class="line"> driver-&gt;clearBuffers(video::ECBF_DEPTH, video::SColor(255, 0, 0, 0));</div><div class="line"></div><div class="line"> <span class="comment">//Right eye...</span></div><div class="line"> move.setTranslation( vector3df(1.5f,0.0f,0.0f) );</div><div class="line"> pos=(startMatrix*move).getTranslation();</div><div class="line"></div><div class="line"> driver-&gt;getOverrideMaterial().Material.ColorMask = ECP_GREEN + ECP_BLUE;</div><div class="line"> driver-&gt;getOverrideMaterial().EnableFlags = EMF_COLOR_MASK;</div><div class="line"> driver-&gt;getOverrideMaterial().EnablePasses =</div><div class="line"> ESNRP_SKY_BOX|ESNRP_SOLID|ESNRP_TRANSPARENT|</div><div class="line"> ESNRP_TRANSPARENT_EFFECT|ESNRP_SHADOW;</div><div class="line"></div><div class="line"> camera-&gt;setPosition(pos);</div><div class="line"> camera-&gt;setTarget(focusPoint);</div><div class="line"></div><div class="line"> Game-&gt;Device-&gt;getSceneManager()-&gt;drawAll();</div><div class="line"></div><div class="line"> driver-&gt;getOverrideMaterial().Material.ColorMask=ECP_ALL;</div><div class="line"> driver-&gt;getOverrideMaterial().EnableFlags=0;</div><div class="line"> driver-&gt;getOverrideMaterial().EnablePasses=0;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (camera != cameraOld)</div><div class="line"> {</div><div class="line"> Game-&gt;Device-&gt;getSceneManager()-&gt;setActiveCamera(cameraOld);</div><div class="line"> camera-&gt;remove();</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> camera-&gt;setPosition(oldPosition);</div><div class="line"> camera-&gt;setTarget(oldTarget);</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> driver-&gt;beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(0,0,0,0));</div><div class="line"> Game-&gt;Device-&gt;getSceneManager()-&gt;drawAll();</div><div class="line"> }</div><div class="line"> Game-&gt;Device-&gt;getGUIEnvironment()-&gt;drawAll();</div><div class="line"> driver-&gt;endScene();</div><div class="line">}</div></div><!-- fragment --><p> update the generic scene node </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::Animate()</div><div class="line">{</div><div class="line"> u32 now = Game-&gt;Device-&gt;getTimer()-&gt;getTime();</div><div class="line"></div><div class="line"> Q3Player * player = Player + 0;</div><div class="line"></div><div class="line"> checkTimeFire ( player-&gt;Anim, 4, now );</div><div class="line"></div><div class="line"> <span class="comment">// Query Scene Manager attributes</span></div><div class="line"> <span class="keywordflow">if</span> ( player-&gt;Anim[0].flags &amp; FIRED )</div><div class="line"> {</div><div class="line"> <span class="keywordtype">wchar_t</span> msg[128];</div><div class="line"> IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();</div><div class="line"></div><div class="line"><span class="preprocessor">#ifdef _IRR_SCENEMANAGER_DEBUG</span></div><div class="line"> IAttributes * attr = Game-&gt;Device-&gt;getSceneManager()-&gt;getParameters();</div><div class="line"> swprintf_irr ( msg, 128,</div><div class="line"> L<span class="stringliteral">&quot;Q3 %s [%ls], FPS:%03d Tri:%.03fm Cull %d/%d nodes (%d,%d,%d)&quot;</span>,</div><div class="line"> Game-&gt;CurrentMapName.c_str(),</div><div class="line"> driver-&gt;getName(),</div><div class="line"> driver-&gt;getFPS (),</div><div class="line"> (f32) driver-&gt;getPrimitiveCountDrawn( 0 ) * ( 1.f / 1000000.f ),</div><div class="line"> attr-&gt;getAttributeAsInt ( <span class="stringliteral">&quot;culled&quot;</span> ),</div><div class="line"> attr-&gt;getAttributeAsInt ( <span class="stringliteral">&quot;calls&quot;</span> ),</div><div class="line"> attr-&gt;getAttributeAsInt ( <span class="stringliteral">&quot;drawn_solid&quot;</span> ),</div><div class="line"> attr-&gt;getAttributeAsInt ( <span class="stringliteral">&quot;drawn_transparent&quot;</span> ),</div><div class="line"> attr-&gt;getAttributeAsInt ( <span class="stringliteral">&quot;drawn_transparent_effect&quot;</span> )</div><div class="line"> );</div><div class="line"><span class="preprocessor">#else</span></div><div class="line">swprintf_irr ( msg, 128,</div><div class="line"> L<span class="stringliteral">&quot;Q3 %s [%ls], FPS:%03d Tri:%.03fm&quot;</span>,</div><div class="line"> Game-&gt;CurrentMapName.c_str(),</div><div class="line"> driver-&gt;getName(),</div><div class="line"> driver-&gt;getFPS (),</div><div class="line"> (f32) driver-&gt;getPrimitiveCountDrawn( 0 ) * ( 1.f / 1000000.f )</div><div class="line"> );</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"> Game-&gt;Device-&gt;setWindowCaption( msg );</div><div class="line"></div><div class="line"> swprintf_irr ( msg, 128,</div><div class="line"> L<span class="stringliteral">&quot;%03d fps, F1 GUI on/off, F2 respawn, F3-F6 toggle Nodes, F7 Collision on/off&quot;</span></div><div class="line"> L<span class="stringliteral">&quot;, F8 Gravity on/off, Right Mouse Toggle GUI&quot;</span>,</div><div class="line"> Game-&gt;Device-&gt;getVideoDriver()-&gt;getFPS ()</div><div class="line"> );</div><div class="line"> <span class="keywordflow">if</span> ( gui.StatusLine )</div><div class="line"> gui.StatusLine-&gt;setText ( msg );</div><div class="line"> player-&gt;Anim[0].flags &amp;= ~FIRED;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// idle..</span></div><div class="line"> <span class="keywordflow">if</span> ( player-&gt;Anim[1].flags &amp; FIRED )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( strcmp ( player-&gt;animation, <span class="stringliteral">&quot;idle&quot;</span> ) )</div><div class="line"> player-&gt;setAnim ( <span class="stringliteral">&quot;idle&quot;</span> );</div><div class="line"></div><div class="line"> player-&gt;Anim[1].flags &amp;= ~FIRED;</div><div class="line"> }</div><div class="line"></div><div class="line"> createParticleImpacts ( now );</div><div class="line"></div><div class="line">}</div></div><!-- fragment --><p> The main game states </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> runGame ( GameData *game )</div><div class="line">{</div><div class="line"> <span class="keywordflow">if</span> ( game-&gt;retVal &gt;= 3 )</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"></div><div class="line"> game-&gt;Device = (*game-&gt;createExDevice) ( game-&gt;deviceParam );</div><div class="line"> <span class="keywordflow">if</span> ( 0 == game-&gt;Device)</div><div class="line"> {</div><div class="line"> <span class="comment">// could not create selected driver.</span></div><div class="line"> game-&gt;retVal = 0;</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// create an event receiver based on current game data</span></div><div class="line"> CQuake3EventHandler *eventHandler = <span class="keyword">new</span> CQuake3EventHandler( game );</div><div class="line"></div><div class="line"> <span class="comment">// load stored config</span></div><div class="line"> game-&gt;load ( <span class="stringliteral">&quot;explorer.cfg&quot;</span> );</div><div class="line"></div><div class="line"> <span class="comment">// add our media directory and archive to the file system</span></div><div class="line"> <span class="keywordflow">for</span> ( u32 i = 0; i &lt; game-&gt;CurrentArchiveList.size(); ++i )</div><div class="line"> {</div><div class="line"> eventHandler-&gt;AddArchive ( game-&gt;CurrentArchiveList[i] );</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Load a Map or startup to the GUI</span></div><div class="line"> <span class="keywordflow">if</span> ( game-&gt;CurrentMapName.size () )</div><div class="line"> {</div><div class="line"> eventHandler-&gt;LoadMap ( game-&gt;CurrentMapName, 1 );</div><div class="line"> <span class="keywordflow">if</span> ( 0 == game-&gt;loadParam.loadSkyShader )</div><div class="line"> eventHandler-&gt;AddSky ( 1, <span class="stringliteral">&quot;skydome2&quot;</span> );</div><div class="line"> eventHandler-&gt;CreatePlayers ();</div><div class="line"> eventHandler-&gt;CreateGUI ();</div><div class="line"> eventHandler-&gt;SetGUIActive ( 0 );</div><div class="line"></div><div class="line"> <span class="comment">// set player to last position on restart</span></div><div class="line"> <span class="keywordflow">if</span> ( game-&gt;retVal == 2 )</div><div class="line"> {</div><div class="line"> eventHandler-&gt;GetPlayer( 0 )-&gt;setpos ( game-&gt;PlayerPosition, game-&gt;PlayerRotation );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> <span class="comment">// start up empty</span></div><div class="line"> eventHandler-&gt;AddSky ( 1, <span class="stringliteral">&quot;skydome2&quot;</span> );</div><div class="line"> eventHandler-&gt;CreatePlayers ();</div><div class="line"> eventHandler-&gt;CreateGUI ();</div><div class="line"> eventHandler-&gt;SetGUIActive ( 1 );</div><div class="line"> background_music ( <span class="stringliteral">&quot;IrrlichtTheme.ogg&quot;</span> );</div><div class="line"> }</div><div class="line"></div><div class="line"></div><div class="line"> game-&gt;retVal = 3;</div><div class="line"> <span class="keywordflow">while</span>( game-&gt;Device-&gt;run() )</div><div class="line"> {</div><div class="line"> eventHandler-&gt;Animate ();</div><div class="line"> eventHandler-&gt;Render ();</div><div class="line"> <span class="comment">//if ( !game-&gt;Device-&gt;isWindowActive() )</span></div><div class="line"> game-&gt;Device-&gt;yield();</div><div class="line"> }</div><div class="line"></div><div class="line"> game-&gt;Device-&gt;setGammaRamp ( 1.f, 1.f, 1.f, 0.f, 0.f );</div><div class="line"> <span class="keyword">delete</span> eventHandler;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="preprocessor">#if defined (_IRR_WINDOWS_) &amp;&amp; 0</span></div><div class="line"><span class="preprocessor"> #pragma comment(linker, &quot;/subsystem:windows /ENTRY:mainCRTStartup&quot;)</span></div><div class="line"><span class="preprocessor">#endif</span></div></div><!-- fragment --><p> The main routine, doing all setup </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> IRRCALLCONV main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])</div><div class="line">{</div><div class="line"> path prgname(argv[0]);</div><div class="line"> GameData game ( deletePathFromPath ( prgname, 1 ) );</div><div class="line"></div><div class="line"> <span class="comment">// dynamically load irrlicht</span></div><div class="line"> <span class="keyword">const</span> c8 * dllName = argc &gt; 1 ? argv[1] : <span class="stringliteral">&quot;irrlicht.dll&quot;</span>;</div><div class="line"> game.createExDevice = load_createDeviceEx ( dllName );</div><div class="line"> <span class="keywordflow">if</span> ( 0 == game.createExDevice )</div><div class="line"> {</div><div class="line"> game.retVal = 3;</div><div class="line"> printf ( <span class="stringliteral">&quot;Could not load %s.\n&quot;</span>, dllName );</div><div class="line"> <span class="keywordflow">return</span> game.retVal; <span class="comment">// could not load dll</span></div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// start without asking for driver</span></div><div class="line"> game.retVal = 1;</div><div class="line"> <span class="keywordflow">do</span></div><div class="line"> {</div><div class="line"> <span class="comment">// if driver could not created, ask for another driver</span></div><div class="line"> <span class="keywordflow">if</span> ( game.retVal == 0 )</div><div class="line"> {</div><div class="line"> game.setDefault ();</div><div class="line"> <span class="comment">// ask user for driver</span></div><div class="line"> game.deviceParam.DriverType=driverChoiceConsole();</div><div class="line"> <span class="keywordflow">if</span> (game.deviceParam.DriverType==video::EDT_COUNT)</div><div class="line"> game.retVal = 3;</div><div class="line"> }</div><div class="line"> runGame ( &amp;game );</div><div class="line"> } <span class="keywordflow">while</span> ( game.retVal &lt; 3 );</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> game.retVal;</div><div class="line">}</div></div><!-- fragment --> </div></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.13-->
<!-- start footer part -->
<p>&nbsp;</p>
</body>
</html>