mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-11 21:00:35 +01:00
2191 lines
150 KiB
HTML
2191 lines
150 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||
|
<title>Irrlicht 3D Engine: Tutorial 21: Quake3 Explorer</title>
|
||
|
|
||
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
||
|
<script type="text/javascript" src="jquery.js"></script>
|
||
|
<script type="text/javascript" src="resize.js"></script>
|
||
|
<script type="text/javascript" src="navtree.js"></script>
|
||
|
<script type="text/javascript">
|
||
|
$(document).ready(initResizable);
|
||
|
</script>
|
||
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
||
|
<script type="text/javascript" src="search/search.js"></script>
|
||
|
<script type="text/javascript">
|
||
|
$(document).ready(function() { searchBox.OnSelectItem(0); });
|
||
|
</script>
|
||
|
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id="top"><!-- do not remove this div! -->
|
||
|
|
||
|
|
||
|
<div id="titlearea">
|
||
|
<table cellspacing="0" cellpadding="0">
|
||
|
<tbody>
|
||
|
<tr style="height: 56px;">
|
||
|
|
||
|
<td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td>
|
||
|
|
||
|
|
||
|
<td style="padding-left: 0.5em;">
|
||
|
<div id="projectname">Irrlicht 3D Engine
|
||
|
|
||
|
</div>
|
||
|
|
||
|
</td>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<td> <div id="MSearchBox" class="MSearchBoxInactive">
|
||
|
<span class="left">
|
||
|
<img id="MSearchSelect" src="search/mag_sel.png"
|
||
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
||
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
||
|
alt=""/>
|
||
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
||
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
||
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
||
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
||
|
</span><span class="right">
|
||
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
||
|
</span>
|
||
|
</div>
|
||
|
</td>
|
||
|
|
||
|
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
|
||
|
<!-- Generated by Doxygen 1.7.5.1 -->
|
||
|
<script type="text/javascript">
|
||
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||
|
</script>
|
||
|
<script type="text/javascript" src="dynsections.js"></script>
|
||
|
</div>
|
||
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||
|
<div id="nav-tree">
|
||
|
<div id="nav-tree-contents">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div id="splitbar" style="-moz-user-select:none;"
|
||
|
class="ui-resizable-handle">
|
||
|
</div>
|
||
|
</div>
|
||
|
<script type="text/javascript">
|
||
|
initNavTree('example021.html','');
|
||
|
</script>
|
||
|
<div id="doc-content">
|
||
|
<div class="header">
|
||
|
<div class="headertitle">
|
||
|
<div class="title">Tutorial 21: Quake3 Explorer </div> </div>
|
||
|
</div>
|
||
|
<div class="contents">
|
||
|
<div class="textblock"><div class="image">
|
||
|
<img src="021shot.jpg" alt="021shot.jpg"/>
|
||
|
</div>
|
||
|
<p>This Tutorial shows how to load different Quake 3 maps.</p>
|
||
|
<p>Features:</p>
|
||
|
<ul>
|
||
|
<li>Load BSP Archives at Runtime from the menu</li>
|
||
|
<li>Load a Map from the menu. Showing with Screenshot</li>
|
||
|
<li>Set the VideoDriver at runtime from menu</li>
|
||
|
<li>Adjust GammaLevel at runtime</li>
|
||
|
<li>Create SceneNodes for the Shaders</li>
|
||
|
<li>Load EntityList and create Entity SceneNodes</li>
|
||
|
<li>Create Players with Weapons and with Collision Response</li>
|
||
|
<li>Play music</li>
|
||
|
</ul>
|
||
|
<p>You can download the Quake III Arena demo ( copyright id software ) at the following location: <a href="ftp://ftp.idsoftware.com/idstuff/quake3/win32/q3ademo.exe">ftp://ftp.idsoftware.com/idstuff/quake3/win32/q3ademo.exe</a></p>
|
||
|
<p>Copyright 2006-2011 Burningwater, Thomas Alten </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include "<a class="code" href="driver_choice_8h.html">driverChoice.h</a>"</span>
|
||
|
<span class="preprocessor">#include <<a class="code" href="irrlicht_8h.html" title="Main header file of the irrlicht, the only file needed to include.">irrlicht.h</a>></span>
|
||
|
<span class="preprocessor">#include "q3factory.h"</span>
|
||
|
<span class="preprocessor">#include "sound.h"</span>
|
||
|
</pre></div><p>Game Data is used to hold Data which is needed to drive the game </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keyword">struct </span>GameData
|
||
|
{
|
||
|
GameData ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> &startupDir) :
|
||
|
retVal(0), StartupDir(startupDir), createExDevice(0), Device(0)
|
||
|
{
|
||
|
setDefault ();
|
||
|
}
|
||
|
|
||
|
<span class="keywordtype">void</span> setDefault ();
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> save ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> &filename );
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> load ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> &filename );
|
||
|
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> debugState;
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> gravityState;
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> flyTroughState;
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> wireFrame;
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> guiActive;
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> guiInputActive;
|
||
|
<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> GammaValue;
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> retVal;
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> sound;
|
||
|
|
||
|
<a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> StartupDir;
|
||
|
<a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> CurrentMapName;
|
||
|
array<path> CurrentArchiveList;
|
||
|
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> PlayerPosition;
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> PlayerRotation;
|
||
|
|
||
|
<a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a312f35a37540d810fcb14b75fd449c9e">tQ3EntityList</a> Variable;
|
||
|
|
||
|
Q3LevelLoadParameter loadParam;
|
||
|
SIrrlichtCreationParameters deviceParam;
|
||
|
<a class="code" href="namespaceirr.html#a5137701377b2241305607fc37a27e9f8" title="typedef for Function Pointer">funcptr_createDeviceEx</a> createExDevice;
|
||
|
IrrlichtDevice *Device;
|
||
|
};
|
||
|
</pre></div><p>set default settings </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> GameData::setDefault ()
|
||
|
{
|
||
|
debugState = <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea25111b15f03bee9a99498737286916dc" title="No Debug Data ( Default )">EDS_OFF</a>;
|
||
|
gravityState = 1;
|
||
|
flyTroughState = 0;
|
||
|
wireFrame = 0;
|
||
|
guiActive = 1;
|
||
|
guiInputActive = 0;
|
||
|
GammaValue = 1.f;
|
||
|
|
||
|
<span class="comment">// default deviceParam;</span>
|
||
|
<span class="preprocessor">#if defined ( _IRR_WINDOWS_ )</span>
|
||
|
<span class="preprocessor"></span> deviceParam.DriverType = <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a4691ca314f9018f508dcf2c57dcaacec" title="Direct3D 9 device, only available on Win32 platforms.">EDT_DIRECT3D9</a>;
|
||
|
<span class="preprocessor">#else</span>
|
||
|
<span class="preprocessor"></span> deviceParam.DriverType = <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a2715182a79f1cb8e2826fd68a8150a53" title="OpenGL device, available on most platforms.">EDT_OPENGL</a>;
|
||
|
<span class="preprocessor">#endif</span>
|
||
|
<span class="preprocessor"></span> deviceParam.WindowSize.Width = 800;
|
||
|
deviceParam.WindowSize.Height = 600;
|
||
|
deviceParam.Fullscreen = <span class="keyword">false</span>;
|
||
|
deviceParam.Bits = 24;
|
||
|
deviceParam.ZBufferBits = 16;
|
||
|
deviceParam.Vsync = <span class="keyword">false</span>;
|
||
|
deviceParam.AntiAlias = <span class="keyword">false</span>;
|
||
|
|
||
|
<span class="comment">// default Quake3 loadParam</span>
|
||
|
loadParam.defaultLightMapMaterial = <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a5dc90a3b4a8d82f10503ddf834a3143f" title="Material type with standard lightmap technique.">EMT_LIGHTMAP</a>;
|
||
|
loadParam.defaultModulate = <a class="code" href="namespaceirr_1_1video.html#a1402e9045137ae232fafbdf385800843a58cc346f344fb488d403a3783675e5d7">EMFN_MODULATE_1X</a>;
|
||
|
loadParam.defaultFilter = <a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a941c0756b9dc3f987a183a401c6fd4ad" title="Is anisotropic filtering? Default: false.">EMF_ANISOTROPIC_FILTER</a>;
|
||
|
loadParam.verbose = 2;
|
||
|
loadParam.mergeShaderBuffer = 1; <span class="comment">// merge meshbuffers with same material</span>
|
||
|
loadParam.cleanUnResolvedMeshes = 1; <span class="comment">// should unresolved meshes be cleaned. otherwise blue texture</span>
|
||
|
loadParam.loadAllShaders = 1; <span class="comment">// load all scripts in the script directory</span>
|
||
|
loadParam.loadSkyShader = 0; <span class="comment">// load sky Shader</span>
|
||
|
loadParam.alpharef = 1;
|
||
|
|
||
|
sound = 0;
|
||
|
|
||
|
CurrentMapName = <span class="stringliteral">""</span>;
|
||
|
CurrentArchiveList.clear ();
|
||
|
|
||
|
<span class="comment">// Explorer Media directory</span>
|
||
|
CurrentArchiveList.push_back ( StartupDir + <span class="stringliteral">"../../media/"</span> );
|
||
|
|
||
|
<span class="comment">// Add the original quake3 files before you load your custom map</span>
|
||
|
<span class="comment">// Most mods are using the original shaders, models&items&weapons</span>
|
||
|
CurrentArchiveList.push_back(<span class="stringliteral">"/q/baseq3/"</span>);
|
||
|
|
||
|
CurrentArchiveList.push_back(StartupDir + <span class="stringliteral">"../../media/map-20kdm2.pk3"</span>);
|
||
|
}
|
||
|
</pre></div><p>Load the current game State from a typical quake3 cfg file </p>
|
||
|
<div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> GameData::load ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> &filename )
|
||
|
{
|
||
|
<span class="keywordflow">if</span> (!Device)
|
||
|
<span class="keywordflow">return</span> 0;
|
||
|
|
||
|
<span class="comment">// the quake3 mesh loader can also handle *.shader and *.cfg file</span>
|
||
|
IQ3LevelMesh* mesh = (IQ3LevelMesh*) Device->getSceneManager()->getMesh ( filename );
|
||
|
<span class="keywordflow">if</span> (!mesh)
|
||
|
<span class="keywordflow">return</span> 0;
|
||
|
|
||
|
<a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a312f35a37540d810fcb14b75fd449c9e">tQ3EntityList</a> &entityList = mesh->getEntityList ();
|
||
|
|
||
|
<a class="code" href="namespaceirr_1_1core.html#ade1071a878633f2f6d8a75c5d11fec19" title="Typedef for character strings.">stringc</a> s;
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> pos;
|
||
|
|
||
|
<span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> e = 0; e != entityList.size (); ++e )
|
||
|
{
|
||
|
<span class="comment">//dumpShader ( s, &entityList[e], false );</span>
|
||
|
<span class="comment">//printf ( s.c_str () );</span>
|
||
|
|
||
|
<span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> g = 0; g != entityList[e].getGroupSize (); ++g )
|
||
|
{
|
||
|
<span class="keyword">const</span> SVarGroup *group = entityList[e].getGroup ( g );
|
||
|
|
||
|
<span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index = 0; index < group->Variable.size (); ++index )
|
||
|
{
|
||
|
<span class="keyword">const</span> SVariable &v = group->Variable[index];
|
||
|
pos = 0;
|
||
|
<span class="keywordflow">if</span> ( v.name == <span class="stringliteral">"playerposition"</span> )
|
||
|
{
|
||
|
PlayerPosition = <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a6163d5a7fba9950a2f390a42fe354c3f" title="get a quake3 vector translated to irrlicht position (x,-z,y )">getAsVector3df</a> ( v.content, pos );
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( v.name == <span class="stringliteral">"playerrotation"</span> )
|
||
|
{
|
||
|
PlayerRotation = <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a6163d5a7fba9950a2f390a42fe354c3f" title="get a quake3 vector translated to irrlicht position (x,-z,y )">getAsVector3df</a> ( v.content, pos );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">return</span> 1;
|
||
|
}
|
||
|
</pre></div><p>Store the current game State in a quake3 configuration file </p>
|
||
|
<div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> GameData::save ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> &filename )
|
||
|
{
|
||
|
<span class="keywordflow">return</span> 0;
|
||
|
<span class="keywordflow">if</span> (!Device)
|
||
|
<span class="keywordflow">return</span> 0;
|
||
|
|
||
|
<a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[128];
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i;
|
||
|
|
||
|
<span class="comment">// Store current Archive for restart</span>
|
||
|
CurrentArchiveList.clear();
|
||
|
IFileSystem *fs = Device->getFileSystem();
|
||
|
<span class="keywordflow">for</span> ( i = 0; i != fs->getFileArchiveCount(); ++i )
|
||
|
{
|
||
|
CurrentArchiveList.push_back ( fs->getFileArchive(i)->getFileList()->getPath() );
|
||
|
}
|
||
|
|
||
|
<span class="comment">// Store Player Position and Rotation</span>
|
||
|
ICameraSceneNode * camera = Device->getSceneManager()->getActiveCamera ();
|
||
|
<span class="keywordflow">if</span> ( camera )
|
||
|
{
|
||
|
PlayerPosition = camera->getPosition ();
|
||
|
PlayerRotation = camera->getRotation ();
|
||
|
}
|
||
|
|
||
|
IWriteFile *file = fs->createAndWriteFile ( filename );
|
||
|
<span class="keywordflow">if</span> (!file)
|
||
|
<span class="keywordflow">return</span> 0;
|
||
|
|
||
|
snprintf ( buf, 128, <span class="stringliteral">"playerposition %.f %.f %.f\nplayerrotation %.f %.f %.f\n"</span>,
|
||
|
PlayerPosition.X, PlayerPosition.Z, PlayerPosition.Y,
|
||
|
PlayerRotation.X, PlayerRotation.Z, PlayerRotation.Y);
|
||
|
file->write ( buf, (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) strlen ( buf ) );
|
||
|
<span class="keywordflow">for</span> ( i = 0; i != fs->getFileArchiveCount(); ++i )
|
||
|
{
|
||
|
snprintf ( buf, 128, <span class="stringliteral">"archive %s\n"</span>,<a class="code" href="namespaceirr_1_1core.html#ade1071a878633f2f6d8a75c5d11fec19" title="Typedef for character strings.">stringc</a> ( fs->getFileArchive(i)->getFileList()->getPath() ).c_str () );
|
||
|
file->write ( buf, (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) strlen ( buf ) );
|
||
|
}
|
||
|
|
||
|
file->drop ();
|
||
|
<span class="keywordflow">return</span> 1;
|
||
|
}
|
||
|
</pre></div><p>Representing a player </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keyword">struct </span>Q3Player : <span class="keyword">public</span> IAnimationEndCallBack
|
||
|
{
|
||
|
Q3Player ()
|
||
|
: Device(0), MapParent(0), Mesh(0), WeaponNode(0), StartPositionCurrent(0)
|
||
|
{
|
||
|
animation[0] = 0;
|
||
|
memset(Anim, 0, <span class="keyword">sizeof</span>(TimeFire)*4);
|
||
|
}
|
||
|
|
||
|
<span class="keyword">virtual</span> <span class="keywordtype">void</span> OnAnimationEnd(IAnimatedMeshSceneNode* node);
|
||
|
|
||
|
<span class="keywordtype">void</span> create ( IrrlichtDevice *device,
|
||
|
IQ3LevelMesh* mesh,
|
||
|
ISceneNode *mapNode,
|
||
|
IMetaTriangleSelector *meta
|
||
|
);
|
||
|
<span class="keywordtype">void</span> shutdown ();
|
||
|
<span class="keywordtype">void</span> setAnim ( <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *name );
|
||
|
<span class="keywordtype">void</span> respawn ();
|
||
|
<span class="keywordtype">void</span> setpos ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> &pos, <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>& rotation );
|
||
|
|
||
|
ISceneNodeAnimatorCollisionResponse * cam() { <span class="keywordflow">return</span> camCollisionResponse ( Device ); }
|
||
|
|
||
|
IrrlichtDevice *Device;
|
||
|
ISceneNode* MapParent;
|
||
|
IQ3LevelMesh* Mesh;
|
||
|
IAnimatedMeshSceneNode* WeaponNode;
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> StartPositionCurrent;
|
||
|
TimeFire Anim[4];
|
||
|
<a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> animation[64];
|
||
|
<a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[64];
|
||
|
};
|
||
|
</pre></div><p> End player </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::shutdown ()
|
||
|
{
|
||
|
setAnim ( 0 );
|
||
|
|
||
|
dropElement (WeaponNode);
|
||
|
|
||
|
<span class="keywordflow">if</span> ( Device )
|
||
|
{
|
||
|
ICameraSceneNode* camera = Device->getSceneManager()->getActiveCamera();
|
||
|
dropElement ( camera );
|
||
|
Device = 0;
|
||
|
}
|
||
|
|
||
|
MapParent = 0;
|
||
|
Mesh = 0;
|
||
|
}
|
||
|
</pre></div><p> create a new player </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::create ( IrrlichtDevice *device, IQ3LevelMesh* mesh, ISceneNode *mapNode, IMetaTriangleSelector *meta )
|
||
|
{
|
||
|
setTimeFire ( Anim + 0, 200, FIRED );
|
||
|
setTimeFire ( Anim + 1, 5000 );
|
||
|
|
||
|
<span class="keywordflow">if</span> (!device)
|
||
|
<span class="keywordflow">return</span>;
|
||
|
<span class="comment">// load FPS weapon to Camera</span>
|
||
|
Device = device;
|
||
|
Mesh = mesh;
|
||
|
MapParent = mapNode;
|
||
|
|
||
|
ISceneManager *smgr = device->getSceneManager ();
|
||
|
IVideoDriver * driver = device->getVideoDriver();
|
||
|
|
||
|
ICameraSceneNode* camera = 0;
|
||
|
|
||
|
SKeyMap keyMap[10];
|
||
|
keyMap[0].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168af9ff845aa49060787ef81773eeaf1016">EKA_MOVE_FORWARD</a>;
|
||
|
keyMap[0].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae3341f66dcdd3d0cbce80ff741262395">KEY_UP</a>;
|
||
|
keyMap[1].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168af9ff845aa49060787ef81773eeaf1016">EKA_MOVE_FORWARD</a>;
|
||
|
keyMap[1].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae559e3169016a3180c45c2828f391af2">KEY_KEY_W</a>;
|
||
|
|
||
|
keyMap[2].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168af4c724e0a0923e497c7f8a48884e36d9">EKA_MOVE_BACKWARD</a>;
|
||
|
keyMap[2].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3acbab6476bacfd1212c52aba7c1c82886">KEY_DOWN</a>;
|
||
|
keyMap[3].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168af4c724e0a0923e497c7f8a48884e36d9">EKA_MOVE_BACKWARD</a>;
|
||
|
keyMap[3].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae52bafc112fc6c52f6b49cea42fa246e">KEY_KEY_S</a>;
|
||
|
|
||
|
keyMap[4].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a91cad59a86b88c0e6ab5aa75b936d9c7">EKA_STRAFE_LEFT</a>;
|
||
|
keyMap[4].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a71c43cf2c123fd75911fef5501a15241">KEY_LEFT</a>;
|
||
|
keyMap[5].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a91cad59a86b88c0e6ab5aa75b936d9c7">EKA_STRAFE_LEFT</a>;
|
||
|
keyMap[5].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a2fe10b4309013968b9cd14811c3d3c85">KEY_KEY_A</a>;
|
||
|
|
||
|
keyMap[6].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a57c4bd21c235bca312e547c6d1061df2">EKA_STRAFE_RIGHT</a>;
|
||
|
keyMap[6].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae89f39517a44c78a6602d1b12b478118">KEY_RIGHT</a>;
|
||
|
keyMap[7].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a57c4bd21c235bca312e547c6d1061df2">EKA_STRAFE_RIGHT</a>;
|
||
|
keyMap[7].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ad20e7e220103e611752b90edeb6cbc9d">KEY_KEY_D</a>;
|
||
|
|
||
|
keyMap[8].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a574c0935be6337a2e6bc97e8304a7400">EKA_JUMP_UP</a>;
|
||
|
keyMap[8].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a3231acd1573be6e4d121cc6c4ab6ccc4">KEY_KEY_J</a>;
|
||
|
|
||
|
keyMap[9].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168aace30d0d2eef7a48f5f863a99dabfb84">EKA_CROUCH</a>;
|
||
|
keyMap[9].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a85a756fa6a3336312c5f32877a7185e5">KEY_KEY_C</a>;
|
||
|
|
||
|
camera = smgr->addCameraSceneNodeFPS(0, 100.0f, 0.6f, -1, keyMap, 10, <span class="keyword">false</span>, 0.6f);
|
||
|
camera->setName ( <span class="stringliteral">"First Person Camera"</span> );
|
||
|
<span class="comment">//camera->setFOV ( 100.f * core::DEGTORAD );</span>
|
||
|
camera->setFarValue( 20000.f );
|
||
|
|
||
|
IAnimatedMeshMD2* weaponMesh = (IAnimatedMeshMD2*) smgr->getMesh(<span class="stringliteral">"gun.md2"</span>);
|
||
|
<span class="keywordflow">if</span> ( 0 == weaponMesh )
|
||
|
<span class="keywordflow">return</span>;
|
||
|
|
||
|
<span class="keywordflow">if</span> ( weaponMesh->getMeshType() == <a class="code" href="namespaceirr_1_1scene.html#a2fc85a64604521ca063f1881b5dd1c61a3b87f459cd5f287626c4fd9aaf729284" title="Quake 2 MD2 model file.">EAMT_MD2</a> )
|
||
|
{
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> count = weaponMesh->getAnimationCount();
|
||
|
<span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> i = 0; i != count; ++i )
|
||
|
{
|
||
|
snprintf ( buf, 64, <span class="stringliteral">"Animation: %s"</span>, weaponMesh->getAnimationName(i) );
|
||
|
device->getLogger()->log(buf, <a class="code" href="namespaceirr.html#aa2d1cac68606a25ed24cfffccfa30a92a9d74de15737e326a91aec6f38c23f9cf" title="Useful information to print. For example hardware infos or something started/stopped.">ELL_INFORMATION</a>);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
WeaponNode = smgr->addAnimatedMeshSceneNode(
|
||
|
weaponMesh,
|
||
|
smgr->getActiveCamera(),
|
||
|
10,
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>( 0, 0, 0),
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(-90,-90,90)
|
||
|
);
|
||
|
WeaponNode->setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3acea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">EMF_LIGHTING</a>, <span class="keyword">false</span>);
|
||
|
WeaponNode->setMaterialTexture(0, driver->getTexture( <span class="stringliteral">"gun.jpg"</span>));
|
||
|
WeaponNode->setLoopMode ( <span class="keyword">false</span> );
|
||
|
WeaponNode->setName ( <span class="stringliteral">"tommi the gun man"</span> );
|
||
|
|
||
|
<span class="comment">//create a collision auto response animator</span>
|
||
|
ISceneNodeAnimator* anim =
|
||
|
smgr->createCollisionResponseAnimator( meta, camera,
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(30,45,30),
|
||
|
getGravity ( <span class="stringliteral">"earth"</span> ),
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0,40,0),
|
||
|
0.0005f
|
||
|
);
|
||
|
|
||
|
camera->addAnimator( anim );
|
||
|
anim->drop();
|
||
|
|
||
|
<span class="keywordflow">if</span> ( meta )
|
||
|
{
|
||
|
meta->drop ();
|
||
|
}
|
||
|
|
||
|
respawn ();
|
||
|
setAnim ( <span class="stringliteral">"idle"</span> );
|
||
|
}
|
||
|
</pre></div><p>so we need a good starting Position in the level. we can ask the Quake3 Loader for all entities with class_name "info_player_deathmatch" </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::respawn ()
|
||
|
{
|
||
|
<span class="keywordflow">if</span> (!Device)
|
||
|
<span class="keywordflow">return</span>;
|
||
|
ICameraSceneNode* camera = Device->getSceneManager()->getActiveCamera();
|
||
|
|
||
|
Device->getLogger()->log( <span class="stringliteral">"respawn"</span> );
|
||
|
|
||
|
<span class="keywordflow">if</span> ( StartPositionCurrent >= Q3StartPosition (
|
||
|
Mesh, camera,StartPositionCurrent++,
|
||
|
cam ()->getEllipsoidTranslation() )
|
||
|
)
|
||
|
{
|
||
|
StartPositionCurrent = 0;
|
||
|
}
|
||
|
}
|
||
|
</pre></div><p>set Player position from saved coordinates </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::setpos ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> &pos, <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> &rotation )
|
||
|
{
|
||
|
<span class="keywordflow">if</span> (!Device)
|
||
|
<span class="keywordflow">return</span>;
|
||
|
Device->getLogger()->log( <span class="stringliteral">"setpos"</span> );
|
||
|
|
||
|
ICameraSceneNode* camera = Device->getSceneManager()->getActiveCamera();
|
||
|
<span class="keywordflow">if</span> ( camera )
|
||
|
{
|
||
|
camera->setPosition ( pos );
|
||
|
camera->setRotation ( rotation );
|
||
|
camera->OnAnimate ( 0 );
|
||
|
}
|
||
|
}
|
||
|
</pre></div><p> set the Animation of the player and weapon </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::setAnim ( <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *name )
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( name )
|
||
|
{
|
||
|
snprintf ( animation, 64, <span class="stringliteral">"%s"</span>, name );
|
||
|
<span class="keywordflow">if</span> ( WeaponNode )
|
||
|
{
|
||
|
WeaponNode->setAnimationEndCallback ( <span class="keyword">this</span> );
|
||
|
WeaponNode->setMD2Animation ( animation );
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
{
|
||
|
animation[0] = 0;
|
||
|
<span class="keywordflow">if</span> ( WeaponNode )
|
||
|
{
|
||
|
WeaponNode->setAnimationEndCallback ( 0 );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
<span class="comment">// Callback</span>
|
||
|
<span class="keywordtype">void</span> Q3Player::OnAnimationEnd(IAnimatedMeshSceneNode* node)
|
||
|
{
|
||
|
setAnim ( 0 );
|
||
|
}
|
||
|
</pre></div><p> GUI Elements </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keyword">struct </span>GUI
|
||
|
{
|
||
|
GUI ()
|
||
|
{
|
||
|
memset ( <span class="keyword">this</span>, 0, <span class="keyword">sizeof</span> ( *<span class="keyword">this</span> ) );
|
||
|
}
|
||
|
|
||
|
<span class="keywordtype">void</span> drop()
|
||
|
{
|
||
|
dropElement ( Window );
|
||
|
dropElement ( Logo );
|
||
|
}
|
||
|
|
||
|
IGUIComboBox* VideoDriver;
|
||
|
IGUIComboBox* VideoMode;
|
||
|
IGUICheckBox* FullScreen;
|
||
|
IGUICheckBox* Bit32;
|
||
|
IGUIScrollBar* MultiSample;
|
||
|
IGUIButton* SetVideoMode;
|
||
|
|
||
|
IGUIScrollBar* Tesselation;
|
||
|
IGUIScrollBar* Gamma;
|
||
|
IGUICheckBox* Collision;
|
||
|
IGUICheckBox* Visible_Map;
|
||
|
IGUICheckBox* Visible_Shader;
|
||
|
IGUICheckBox* Visible_Fog;
|
||
|
IGUICheckBox* Visible_Unresolved;
|
||
|
IGUICheckBox* Visible_Skydome;
|
||
|
IGUIButton* Respawn;
|
||
|
|
||
|
IGUITable* ArchiveList;
|
||
|
IGUIButton* ArchiveAdd;
|
||
|
IGUIButton* ArchiveRemove;
|
||
|
IGUIFileOpenDialog* ArchiveFileOpen;
|
||
|
IGUIButton* ArchiveUp;
|
||
|
IGUIButton* ArchiveDown;
|
||
|
|
||
|
IGUIListBox* MapList;
|
||
|
IGUITreeView* SceneTree;
|
||
|
IGUIStaticText* StatusLine;
|
||
|
IGUIImage* Logo;
|
||
|
IGUIWindow* Window;
|
||
|
};
|
||
|
</pre></div><p>CQuake3EventHandler controls the game </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keyword">class </span>CQuake3EventHandler : <span class="keyword">public</span> IEventReceiver
|
||
|
{
|
||
|
<span class="keyword">public</span>:
|
||
|
|
||
|
CQuake3EventHandler( GameData *gameData );
|
||
|
<span class="keyword">virtual</span> ~CQuake3EventHandler ();
|
||
|
|
||
|
<span class="keywordtype">void</span> Animate();
|
||
|
<span class="keywordtype">void</span> Render();
|
||
|
|
||
|
<span class="keywordtype">void</span> AddArchive ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a>& archiveName );
|
||
|
<span class="keywordtype">void</span> LoadMap ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>& mapName, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> collision );
|
||
|
<span class="keywordtype">void</span> CreatePlayers();
|
||
|
<span class="keywordtype">void</span> AddSky( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> dome, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *texture );
|
||
|
Q3Player *GetPlayer ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index ) { <span class="keywordflow">return</span> &Player[index]; }
|
||
|
|
||
|
<span class="keywordtype">void</span> CreateGUI();
|
||
|
<span class="keywordtype">void</span> SetGUIActive( <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> command);
|
||
|
|
||
|
<span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent& eve);
|
||
|
|
||
|
|
||
|
<span class="keyword">private</span>:
|
||
|
|
||
|
GameData *Game;
|
||
|
|
||
|
IQ3LevelMesh* Mesh;
|
||
|
ISceneNode* MapParent;
|
||
|
ISceneNode* ShaderParent;
|
||
|
ISceneNode* ItemParent;
|
||
|
ISceneNode* UnresolvedParent;
|
||
|
ISceneNode* BulletParent;
|
||
|
ISceneNode* FogParent;
|
||
|
ISceneNode * SkyNode;
|
||
|
IMetaTriangleSelector *Meta;
|
||
|
|
||
|
<a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[256];
|
||
|
|
||
|
Q3Player Player[2];
|
||
|
|
||
|
<span class="keyword">struct </span>SParticleImpact
|
||
|
{
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> when;
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> pos;
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> outVector;
|
||
|
};
|
||
|
array<SParticleImpact> Impacts;
|
||
|
<span class="keywordtype">void</span> useItem( Q3Player * player);
|
||
|
<span class="keywordtype">void</span> createParticleImpacts( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> now );
|
||
|
|
||
|
<span class="keywordtype">void</span> createTextures ();
|
||
|
<span class="keywordtype">void</span> addSceneTreeItem( ISceneNode * parent, IGUITreeViewNode* nodeParent);
|
||
|
|
||
|
GUI gui;
|
||
|
<span class="keywordtype">void</span> dropMap ();
|
||
|
};
|
||
|
</pre></div><p> Constructor </p>
|
||
|
<div class="fragment"><pre class="fragment">CQuake3EventHandler::CQuake3EventHandler( GameData *game )
|
||
|
: Game(game), Mesh(0), MapParent(0), ShaderParent(0), ItemParent(0), UnresolvedParent(0),
|
||
|
BulletParent(0), FogParent(0), SkyNode(0), Meta(0)
|
||
|
{
|
||
|
buf[0]=0;
|
||
|
<span class="comment">// Also use 16 Bit Textures for 16 Bit RenderDevice</span>
|
||
|
<span class="keywordflow">if</span> ( Game->deviceParam.Bits == 16 )
|
||
|
{
|
||
|
game->Device->getVideoDriver()->setTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#acaf6f7414534f7d62bff18c5bf11876fa4fe1c1b0f4b44ef4b5da219ce66a0ae8">ETCF_ALWAYS_16_BIT</a>, <span class="keyword">true</span>);
|
||
|
}
|
||
|
|
||
|
<span class="comment">// Quake3 Shader controls Z-Writing</span>
|
||
|
game->Device->getSceneManager()->getParameters()->setAttribute(<a class="code" href="namespaceirr_1_1scene.html#ab585d23bc2a3d02cd368d8bfd0b1414a" title="Name of the parameter for changing how Irrlicht handles the ZWrite flag for transparent (blending) ma...">scene::ALLOW_ZWRITE_ON_TRANSPARENT</a>, <span class="keyword">true</span>);
|
||
|
|
||
|
<span class="comment">// create internal textures</span>
|
||
|
createTextures ();
|
||
|
|
||
|
sound_init ( game->Device );
|
||
|
|
||
|
Game->Device->setEventReceiver ( <span class="keyword">this</span> );
|
||
|
}
|
||
|
|
||
|
|
||
|
<span class="comment">// destructor</span>
|
||
|
CQuake3EventHandler::~CQuake3EventHandler ()
|
||
|
{
|
||
|
Player[0].shutdown ();
|
||
|
sound_shutdown ();
|
||
|
|
||
|
Game->save( <span class="stringliteral">"explorer.cfg"</span> );
|
||
|
|
||
|
Game->Device->drop();
|
||
|
}
|
||
|
|
||
|
|
||
|
<span class="comment">// create runtime textures smog, fog</span>
|
||
|
<span class="keywordtype">void</span> CQuake3EventHandler::createTextures()
|
||
|
{
|
||
|
IVideoDriver * driver = Game->Device->getVideoDriver();
|
||
|
|
||
|
<a class="code" href="namespaceirr_1_1core.html#ad2e562e3219072e2f7fc7c2bba0ef0cb" title="Typedef for an unsigned integer dimension.">dimension2du</a> dim(64, 64);
|
||
|
|
||
|
video::IImage* image;
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i;
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> x;
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> y;
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> * data;
|
||
|
<span class="keywordflow">for</span> ( i = 0; i != 8; ++i )
|
||
|
{
|
||
|
image = driver->createImage ( <a class="code" href="namespaceirr_1_1video.html#a1d5e487888c32b1674a8f75116d829eda55c57d63efff39efe33ee733fe962df0" title="Default 32 bit color format. 8 bits are used for every component: red, green, blue and alpha...">video::ECF_A8R8G8B8</a>, dim);
|
||
|
data = (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>*) image->lock ();
|
||
|
<span class="keywordflow">for</span> ( y = 0; y != dim.Height; ++y )
|
||
|
{
|
||
|
<span class="keywordflow">for</span> ( x = 0; x != dim.Width; ++x )
|
||
|
{
|
||
|
data [x] = 0xFFFFFFFF;
|
||
|
}
|
||
|
data = (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>*) ( (<a class="code" href="namespaceirr.html#a646874f69af8ff87fc10201b0254a761" title="8 bit unsigned variable.">u8</a>*) data + image->getPitch() );
|
||
|
}
|
||
|
image->unlock();
|
||
|
snprintf ( buf, 64, <span class="stringliteral">"smoke_%02d"</span>, i );
|
||
|
driver->addTexture( buf, image );
|
||
|
image->drop ();
|
||
|
}
|
||
|
|
||
|
<span class="comment">// fog</span>
|
||
|
<span class="keywordflow">for</span> ( i = 0; i != 1; ++i )
|
||
|
{
|
||
|
image = driver->createImage ( <a class="code" href="namespaceirr_1_1video.html#a1d5e487888c32b1674a8f75116d829eda55c57d63efff39efe33ee733fe962df0" title="Default 32 bit color format. 8 bits are used for every component: red, green, blue and alpha...">video::ECF_A8R8G8B8</a>, dim);
|
||
|
data = (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>*) image->lock ();
|
||
|
<span class="keywordflow">for</span> ( y = 0; y != dim.Height; ++y )
|
||
|
{
|
||
|
<span class="keywordflow">for</span> ( x = 0; x != dim.Width; ++x )
|
||
|
{
|
||
|
data [x] = 0xFFFFFFFF;
|
||
|
}
|
||
|
data = (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>*) ( (<a class="code" href="namespaceirr.html#a646874f69af8ff87fc10201b0254a761" title="8 bit unsigned variable.">u8</a>*) data + image->getPitch() );
|
||
|
}
|
||
|
image->unlock();
|
||
|
snprintf ( buf, 64, <span class="stringliteral">"fog_%02d"</span>, i );
|
||
|
driver->addTexture( buf, image );
|
||
|
image->drop ();
|
||
|
}
|
||
|
}
|
||
|
</pre></div><p>create the GUI </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::CreateGUI()
|
||
|
{
|
||
|
|
||
|
IGUIEnvironment *env = Game->Device->getGUIEnvironment();
|
||
|
IVideoDriver * driver = Game->Device->getVideoDriver();
|
||
|
|
||
|
gui.drop();
|
||
|
|
||
|
<span class="comment">// set skin font</span>
|
||
|
IGUIFont* font = env->getFont(<span class="stringliteral">"fontlucida.png"</span>);
|
||
|
<span class="keywordflow">if</span> (font)
|
||
|
env->getSkin()->setFont(font);
|
||
|
env->getSkin()->setColor ( <a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aa03e6e93fa9356e9d8d743e6928111185" title="Text on a button.">EGDC_BUTTON_TEXT</a>, video::SColor(240,0xAA,0xAA,0xAA) );
|
||
|
env->getSkin()->setColor ( <a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aa1227b2c3a809d139e1ead87aa29fa101" title="Highlight color for three-dimensional display elements (for edges facing the light source...">EGDC_3D_HIGH_LIGHT</a>, video::SColor(240,0x22,0x22,0x22) );
|
||
|
env->getSkin()->setColor ( <a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aabeac28ca22e9f22dc84222d5f62a80eb" title="Face color for three-dimensional display elements and for dialog box backgrounds.">EGDC_3D_FACE</a>, video::SColor(240,0x44,0x44,0x44) );
|
||
|
env->getSkin()->setColor ( <a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aa94ea28795bc78153e40739db9ece3b6b" title="Window background for editable field (editbox, checkbox-field)">EGDC_EDITABLE</a>, video::SColor(240,0x44,0x44,0x44) );
|
||
|
env->getSkin()->setColor ( <a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aa393dd9513e3c54fdfd5006bd9f853253" title="Show focus of window background for editable field (editbox or when checkbox-field is pressed)...">EGDC_FOCUSED_EDITABLE</a>, video::SColor(240,0x54,0x54,0x54) );
|
||
|
env->getSkin()->setColor ( <a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aab60eb00de0efde8c5a948ab15d9aa0a7" title="Window background.">EGDC_WINDOW</a>, video::SColor(240,0x66,0x66,0x66) );
|
||
|
|
||
|
<span class="comment">// minimal gui size 800x600</span>
|
||
|
dimension2d<u32> dim ( 800, 600 );
|
||
|
dimension2d<u32> vdim ( Game->Device->getVideoDriver()->getScreenSize() );
|
||
|
|
||
|
<span class="keywordflow">if</span> ( vdim.Height >= dim.Height && vdim.Width >= dim.Width )
|
||
|
{
|
||
|
<span class="comment">//dim = vdim;</span>
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
{
|
||
|
}
|
||
|
|
||
|
gui.Window = env->addWindow ( rect<s32> ( 0, 0, dim.Width, dim.Height ), <span class="keyword">false</span>, L<span class="stringliteral">"Quake3 Explorer"</span> );
|
||
|
gui.Window->setToolTipText ( L<span class="stringliteral">"Quake3Explorer. Loads and show various BSP File Format and Shaders."</span> );
|
||
|
gui.Window->getCloseButton()->setToolTipText ( L<span class="stringliteral">"Quit Quake3 Explorer"</span> );
|
||
|
|
||
|
<span class="comment">// add a status line help text</span>
|
||
|
gui.StatusLine = env->addStaticText( 0, rect<s32>( 5,dim.Height - 30,dim.Width - 5,dim.Height - 10),
|
||
|
<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">true</span>
|
||
|
);
|
||
|
|
||
|
|
||
|
env->addStaticText ( L<span class="stringliteral">"VideoDriver:"</span>, rect<s32>( dim.Width - 400, 24, dim.Width - 310, 40 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
|
||
|
gui.VideoDriver = env->addComboBox(rect<s32>( dim.Width - 300, 24, dim.Width - 10, 40 ),gui.Window);
|
||
|
gui.VideoDriver->addItem(L<span class="stringliteral">"Direct3D 9.0c"</span>, <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a4691ca314f9018f508dcf2c57dcaacec" title="Direct3D 9 device, only available on Win32 platforms.">EDT_DIRECT3D9</a> );
|
||
|
gui.VideoDriver->addItem(L<span class="stringliteral">"Direct3D 8.1"</span>, <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a8cc3807f6f28404f3424ad7e31b3142f" title="Direct3D8 device, only available on Win32 platforms.">EDT_DIRECT3D8</a> );
|
||
|
gui.VideoDriver->addItem(L<span class="stringliteral">"OpenGL 1.5"</span>, <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a2715182a79f1cb8e2826fd68a8150a53" title="OpenGL device, available on most platforms.">EDT_OPENGL</a>);
|
||
|
gui.VideoDriver->addItem(L<span class="stringliteral">"Software Renderer"</span>, <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0a1598cd235a1a6bd052e2011b559e8995" title="The Irrlicht Engine Software renderer.">EDT_SOFTWARE</a>);
|
||
|
gui.VideoDriver->addItem(L<span class="stringliteral">"Burning's Video (TM) Thomas Alten"</span>, <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0ae85481da26159b967191ccc6de1e4a05" title="The Burning's Software Renderer, an alternative software renderer.">EDT_BURNINGSVIDEO</a>);
|
||
|
gui.VideoDriver->setSelected ( gui.VideoDriver->getIndexForItemData ( Game->deviceParam.DriverType ) );
|
||
|
gui.VideoDriver->setToolTipText ( L<span class="stringliteral">"Use a VideoDriver"</span> );
|
||
|
|
||
|
env->addStaticText ( L<span class="stringliteral">"VideoMode:"</span>, rect<s32>( dim.Width - 400, 44, dim.Width - 310, 60 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
|
||
|
gui.VideoMode = env->addComboBox(rect<s32>( dim.Width - 300, 44, dim.Width - 10, 60 ),gui.Window);
|
||
|
gui.VideoMode->setToolTipText ( L<span class="stringliteral">"Supported Screenmodes"</span> );
|
||
|
IVideoModeList *modeList = Game->Device->getVideoModeList();
|
||
|
<span class="keywordflow">if</span> ( modeList )
|
||
|
{
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> i;
|
||
|
<span class="keywordflow">for</span> ( i = 0; i != modeList->getVideoModeCount (); ++i )
|
||
|
{
|
||
|
<a class="code" href="namespaceirr.html#ae9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> d = modeList->getVideoModeDepth ( i );
|
||
|
<span class="keywordflow">if</span> ( d < 16 )
|
||
|
<span class="keywordflow">continue</span>;
|
||
|
|
||
|
<a class="code" href="namespaceirr.html#ae9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> w = modeList->getVideoModeResolution ( i ).Width;
|
||
|
<a class="code" href="namespaceirr.html#ae9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> h = modeList->getVideoModeResolution ( i ).Height;
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> val = w << 16 | h;
|
||
|
|
||
|
<span class="keywordflow">if</span> ( gui.VideoMode->getIndexForItemData ( val ) >= 0 )
|
||
|
<span class="keywordflow">continue</span>;
|
||
|
|
||
|
<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> aspect = (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>) w / (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>) h;
|
||
|
<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *a = <span class="stringliteral">""</span>;
|
||
|
<span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 1.3333333333f ) ) a = <span class="stringliteral">"4:3"</span>;
|
||
|
<span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 1.6666666f ) ) a = <span class="stringliteral">"15:9 widescreen"</span>;
|
||
|
<span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 1.7777777f ) ) a = <span class="stringliteral">"16:9 widescreen"</span>;
|
||
|
<span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 1.6f ) ) a = <span class="stringliteral">"16:10 widescreen"</span>;
|
||
|
<span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">core::equals</a> ( aspect, 2.133333f ) ) a = <span class="stringliteral">"20:9 widescreen"</span>;
|
||
|
|
||
|
snprintf ( buf, <span class="keyword">sizeof</span> ( buf ), <span class="stringliteral">"%d x %d, %s"</span>,w, h, a );
|
||
|
gui.VideoMode->addItem ( <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> ( buf ).c_str(), val );
|
||
|
}
|
||
|
}
|
||
|
gui.VideoMode->setSelected ( gui.VideoMode->getIndexForItemData (
|
||
|
Game->deviceParam.WindowSize.Width << 16 |
|
||
|
Game->deviceParam.WindowSize.Height ) );
|
||
|
|
||
|
gui.FullScreen = env->addCheckBox ( Game->deviceParam.Fullscreen, rect<s32>( dim.Width - 400, 64, dim.Width - 300, 80 ), gui.Window,-1, L<span class="stringliteral">"Fullscreen"</span> );
|
||
|
gui.FullScreen->setToolTipText ( L<span class="stringliteral">"Set Fullscreen or Window Mode"</span> );
|
||
|
|
||
|
gui.Bit32 = env->addCheckBox ( Game->deviceParam.Bits == 32, rect<s32>( dim.Width - 300, 64, dim.Width - 240, 80 ), gui.Window,-1, L<span class="stringliteral">"32Bit"</span> );
|
||
|
gui.Bit32->setToolTipText ( L<span class="stringliteral">"Use 16 or 32 Bit"</span> );
|
||
|
|
||
|
env->addStaticText ( L<span class="stringliteral">"MultiSample:"</span>, rect<s32>( dim.Width - 235, 64, dim.Width - 150, 80 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
|
||
|
gui.MultiSample = env->addScrollBar( <span class="keyword">true</span>, rect<s32>( dim.Width - 150, 64, dim.Width - 70, 80 ), gui.Window,-1 );
|
||
|
gui.MultiSample->setMin ( 0 );
|
||
|
gui.MultiSample->setMax ( 8 );
|
||
|
gui.MultiSample->setSmallStep ( 1 );
|
||
|
gui.MultiSample->setLargeStep ( 1 );
|
||
|
gui.MultiSample->setPos ( Game->deviceParam.AntiAlias );
|
||
|
gui.MultiSample->setToolTipText ( L<span class="stringliteral">"Set the MultiSample (disable, 1x, 2x, 4x, 8x )"</span> );
|
||
|
|
||
|
gui.SetVideoMode = env->addButton (rect<s32>( dim.Width - 60, 64, dim.Width - 10, 80 ), gui.Window, -1,L<span class="stringliteral">"set"</span> );
|
||
|
gui.SetVideoMode->setToolTipText ( L<span class="stringliteral">"Set Video Mode with current values"</span> );
|
||
|
|
||
|
env->addStaticText ( L<span class="stringliteral">"Gamma:"</span>, rect<s32>( dim.Width - 400, 104, dim.Width - 310, 120 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
|
||
|
gui.Gamma = env->addScrollBar( <span class="keyword">true</span>, rect<s32>( dim.Width - 300, 104, dim.Width - 10, 120 ), gui.Window,-1 );
|
||
|
gui.Gamma->setMin ( 50 );
|
||
|
gui.Gamma->setMax ( 350 );
|
||
|
gui.Gamma->setSmallStep ( 1 );
|
||
|
gui.Gamma->setLargeStep ( 10 );
|
||
|
gui.Gamma->setPos ( <a class="code" href="namespaceirr_1_1core.html#ac230a392b15e3d27c6e2a07a6925a8c4">core::floor32</a> ( Game->GammaValue * 100.f ) );
|
||
|
gui.Gamma->setToolTipText ( L<span class="stringliteral">"Adjust Gamma Ramp ( 0.5 - 3.5)"</span> );
|
||
|
Game->Device->setGammaRamp ( Game->GammaValue, Game->GammaValue, Game->GammaValue, 0.f, 0.f );
|
||
|
|
||
|
|
||
|
env->addStaticText ( L<span class="stringliteral">"Tesselation:"</span>, rect<s32>( dim.Width - 400, 124, dim.Width - 310, 140 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
|
||
|
gui.Tesselation = env->addScrollBar( <span class="keyword">true</span>, rect<s32>( dim.Width - 300, 124, dim.Width - 10, 140 ), gui.Window,-1 );
|
||
|
gui.Tesselation->setMin ( 2 );
|
||
|
gui.Tesselation->setMax ( 12 );
|
||
|
gui.Tesselation->setSmallStep ( 1 );
|
||
|
gui.Tesselation->setLargeStep ( 1 );
|
||
|
gui.Tesselation->setPos ( Game->loadParam.patchTesselation );
|
||
|
gui.Tesselation->setToolTipText ( L<span class="stringliteral">"How smooth should curved surfaces be rendered"</span> );
|
||
|
|
||
|
gui.Collision = env->addCheckBox ( <span class="keyword">true</span>, rect<s32>( dim.Width - 400, 150, dim.Width - 300, 166 ), gui.Window,-1, L<span class="stringliteral">"Collision"</span> );
|
||
|
gui.Collision->setToolTipText ( L<span class="stringliteral">"Set collision on or off ( flythrough ). \nPress F7 on your Keyboard"</span> );
|
||
|
gui.Visible_Map = env->addCheckBox ( <span class="keyword">true</span>, rect<s32>( dim.Width - 300, 150, dim.Width - 240, 166 ), gui.Window,-1, L<span class="stringliteral">"Map"</span> );
|
||
|
gui.Visible_Map->setToolTipText ( L<span class="stringliteral">"Show or not show the static part the Level. \nPress F3 on your Keyboard"</span> );
|
||
|
gui.Visible_Shader = env->addCheckBox ( <span class="keyword">true</span>, rect<s32>( dim.Width - 240, 150, dim.Width - 170, 166 ), gui.Window,-1, L<span class="stringliteral">"Shader"</span> );
|
||
|
gui.Visible_Shader->setToolTipText ( L<span class="stringliteral">"Show or not show the Shader Nodes. \nPress F4 on your Keyboard"</span> );
|
||
|
gui.Visible_Fog = env->addCheckBox ( <span class="keyword">true</span>, rect<s32>( dim.Width - 170, 150, dim.Width - 110, 166 ), gui.Window,-1, L<span class="stringliteral">"Fog"</span> );
|
||
|
gui.Visible_Fog->setToolTipText ( L<span class="stringliteral">"Show or not show the Fog Nodes. \nPress F5 on your Keyboard"</span> );
|
||
|
gui.Visible_Unresolved = env->addCheckBox ( <span class="keyword">true</span>, rect<s32>( dim.Width - 110, 150, dim.Width - 10, 166 ), gui.Window,-1, L<span class="stringliteral">"Unresolved"</span> );
|
||
|
gui.Visible_Unresolved->setToolTipText ( L<span class="stringliteral">"Show the or not show the Nodes the Engine can't handle. \nPress F6 on your Keyboard"</span> );
|
||
|
gui.Visible_Skydome = env->addCheckBox ( <span class="keyword">true</span>, rect<s32>( dim.Width - 110, 180, dim.Width - 10, 196 ), gui.Window,-1, L<span class="stringliteral">"Skydome"</span> );
|
||
|
gui.Visible_Skydome->setToolTipText ( L<span class="stringliteral">"Show the or not show the Skydome."</span> );
|
||
|
|
||
|
<span class="comment">//Respawn = env->addButton ( rect<s32>( dim.Width - 260, 90, dim.Width - 10, 106 ), 0,-1, L"Respawn" );</span>
|
||
|
|
||
|
env->addStaticText ( L<span class="stringliteral">"Archives:"</span>, rect<s32>( 5, dim.Height - 530, dim.Width - 600,dim.Height - 514 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
|
||
|
|
||
|
gui.ArchiveAdd = env->addButton ( rect<s32>( dim.Width - 725, dim.Height - 530, dim.Width - 665, dim.Height - 514 ), gui.Window,-1, L<span class="stringliteral">"add"</span> );
|
||
|
gui.ArchiveAdd->setToolTipText ( L<span class="stringliteral">"Add an archive, usually packed zip-archives (*.pk3) to the Filesystem"</span> );
|
||
|
gui.ArchiveRemove = env->addButton ( rect<s32>( dim.Width - 660, dim.Height - 530, dim.Width - 600, dim.Height - 514 ), gui.Window,-1, L<span class="stringliteral">"del"</span> );
|
||
|
gui.ArchiveRemove->setToolTipText ( L<span class="stringliteral">"Remove the selected archive from the FileSystem."</span> );
|
||
|
gui.ArchiveUp = env->addButton ( rect<s32>( dim.Width - 575, dim.Height - 530, dim.Width - 515, dim.Height - 514 ), gui.Window,-1, L<span class="stringliteral">"up"</span> );
|
||
|
gui.ArchiveUp->setToolTipText ( L<span class="stringliteral">"Arrange Archive Look-up Hirachy. Move the selected Archive up"</span> );
|
||
|
gui.ArchiveDown = env->addButton ( rect<s32>( dim.Width - 510, dim.Height - 530, dim.Width - 440, dim.Height - 514 ), gui.Window,-1, L<span class="stringliteral">"down"</span> );
|
||
|
gui.ArchiveDown->setToolTipText ( L<span class="stringliteral">"Arrange Archive Look-up Hirachy. Move the selected Archive down"</span> );
|
||
|
|
||
|
|
||
|
gui.ArchiveList = env->addTable ( rect<s32>( 5,dim.Height - 510, dim.Width - 450,dim.Height - 410 ), gui.Window );
|
||
|
gui.ArchiveList->addColumn ( L<span class="stringliteral">"Type"</span>, 0 );
|
||
|
gui.ArchiveList->addColumn ( L<span class="stringliteral">"Real File Path"</span>, 1 );
|
||
|
gui.ArchiveList->setColumnWidth ( 0, 60 );
|
||
|
gui.ArchiveList->setColumnWidth ( 1, 284 );
|
||
|
gui.ArchiveList->setToolTipText ( L<span class="stringliteral">"Show the attached Archives"</span> );
|
||
|
|
||
|
|
||
|
env->addStaticText ( L<span class="stringliteral">"Maps:"</span>, rect<s32>( 5, dim.Height - 400, dim.Width - 450,dim.Height - 380 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
|
||
|
gui.MapList = env->addListBox ( rect<s32>( 5,dim.Height - 380, dim.Width - 450,dim.Height - 40 ), gui.Window, -1, <span class="keyword">true</span> );
|
||
|
gui.MapList->setToolTipText ( L<span class="stringliteral">"Show the current Maps in all Archives.\n Double-Click the Map to start the level"</span> );
|
||
|
|
||
|
|
||
|
<span class="comment">// create a visible Scene Tree</span>
|
||
|
env->addStaticText ( L<span class="stringliteral">"Scenegraph:"</span>, rect<s32>( dim.Width - 400, dim.Height - 400, dim.Width - 5,dim.Height - 380 ),<span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">false</span> );
|
||
|
gui.SceneTree = env->addTreeView( rect<s32>( dim.Width - 400, dim.Height - 380, dim.Width - 5, dim.Height - 40 ),
|
||
|
gui.Window, -1, <span class="keyword">true</span>, <span class="keyword">true</span>, <span class="keyword">false</span> );
|
||
|
gui.SceneTree->setToolTipText ( L<span class="stringliteral">"Show the current Scenegraph"</span> );
|
||
|
gui.SceneTree->getRoot()->clearChildren();
|
||
|
addSceneTreeItem ( Game->Device->getSceneManager()->getRootSceneNode(), gui.SceneTree->getRoot() );
|
||
|
|
||
|
|
||
|
IGUIImageList* imageList = env->createImageList( driver->getTexture ( <span class="stringliteral">"iconlist.png"</span> ),
|
||
|
<a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>( 32, 32 ), true );
|
||
|
|
||
|
<span class="keywordflow">if</span> ( imageList )
|
||
|
{
|
||
|
gui.SceneTree->setImageList( imageList );
|
||
|
imageList->drop ();
|
||
|
}
|
||
|
|
||
|
|
||
|
<span class="comment">// load the engine logo</span>
|
||
|
gui.Logo = env->addImage( driver->getTexture(<span class="stringliteral">"irrlichtlogo3.png"</span>), position2d<s32>(5, 16 ), <span class="keyword">true</span>, 0 );
|
||
|
gui.Logo->setToolTipText ( L<span class="stringliteral">"The great Irrlicht Engine"</span> );
|
||
|
|
||
|
AddArchive ( <span class="stringliteral">""</span> );
|
||
|
}
|
||
|
</pre></div><p>Add an Archive to the FileSystems and updates the GUI </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::AddArchive ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a>& archiveName )
|
||
|
{
|
||
|
IFileSystem *fs = Game->Device->getFileSystem();
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i;
|
||
|
|
||
|
<span class="keywordflow">if</span> ( archiveName.size () )
|
||
|
{
|
||
|
<span class="keywordtype">bool</span> exists = <span class="keyword">false</span>;
|
||
|
<span class="keywordflow">for</span> ( i = 0; i != fs->getFileArchiveCount(); ++i )
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( fs->getFileArchive(i)->getFileList()->getPath() == archiveName )
|
||
|
{
|
||
|
exists = <span class="keyword">true</span>;
|
||
|
<span class="keywordflow">break</span>;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">if</span> (!exists)
|
||
|
{
|
||
|
fs->addFileArchive(archiveName, <span class="keyword">true</span>, <span class="keyword">false</span>);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
<span class="comment">// store the current archives in game data</span>
|
||
|
<span class="comment">// show the attached Archive in proper order</span>
|
||
|
<span class="keywordflow">if</span> ( gui.ArchiveList )
|
||
|
{
|
||
|
gui.ArchiveList->clearRows();
|
||
|
|
||
|
<span class="keywordflow">for</span> ( i = 0; i != fs->getFileArchiveCount(); ++i )
|
||
|
{
|
||
|
IFileArchive * archive = fs->getFileArchive ( i );
|
||
|
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index = gui.ArchiveList->addRow(i);
|
||
|
|
||
|
<a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> typeName;
|
||
|
<span class="keywordflow">switch</span>(archive->getType())
|
||
|
{
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14fa63010a52f2efb42f3c85b91ecf077004" title="A PKZIP archive.">io::EFAT_ZIP</a>:
|
||
|
typeName = <span class="stringliteral">"ZIP"</span>;
|
||
|
<span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14fa9d37ff1b229bb63f52d29ef65a35b6ce" title="A gzip archive.">io::EFAT_GZIP</a>:
|
||
|
typeName = <span class="stringliteral">"gzip"</span>;
|
||
|
<span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14fa1d1f159095f087da5647835b47cd85d4" title="A virtual directory.">io::EFAT_FOLDER</a>:
|
||
|
typeName = <span class="stringliteral">"Mount"</span>;
|
||
|
<span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14faae9e1788acfc49c30a77f80f5ced7cf5" title="An ID Software PAK archive.">io::EFAT_PAK</a>:
|
||
|
typeName = <span class="stringliteral">"PAK"</span>;
|
||
|
<span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14fa0f36ce25d47b45f41a58e32b4c029cb6" title="A Tape ARchive.">io::EFAT_TAR</a>:
|
||
|
typeName = <span class="stringliteral">"TAR"</span>;
|
||
|
<span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">default</span>:
|
||
|
typeName = <span class="stringliteral">"archive"</span>;
|
||
|
}
|
||
|
|
||
|
gui.ArchiveList->setCellText ( index, 0, typeName );
|
||
|
gui.ArchiveList->setCellText ( index, 1, archive->getFileList()->getPath() );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
<span class="comment">// browse the archives for maps</span>
|
||
|
<span class="keywordflow">if</span> ( gui.MapList )
|
||
|
{
|
||
|
gui.MapList->clear();
|
||
|
|
||
|
IGUISpriteBank *bank = Game->Device->getGUIEnvironment()->getSpriteBank(<span class="stringliteral">"sprite_q3map"</span>);
|
||
|
<span class="keywordflow">if</span> ( 0 == bank )
|
||
|
bank = Game->Device->getGUIEnvironment()->addEmptySpriteBank(<span class="stringliteral">"sprite_q3map"</span>);
|
||
|
|
||
|
SGUISprite sprite;
|
||
|
SGUISpriteFrame frame;
|
||
|
core::rect<s32> r;
|
||
|
|
||
|
bank->getSprites().clear();
|
||
|
bank->getPositions().clear ();
|
||
|
gui.MapList->setSpriteBank ( bank );
|
||
|
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> g = 0;
|
||
|
<a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> s;
|
||
|
|
||
|
<span class="comment">// browse the attached file system</span>
|
||
|
fs->setFileListSystem ( <a class="code" href="namespaceirr_1_1io.html#a22364f1caf06442a70f6198025af3fe9a94a9818df56a8fe16b1c7c6f44e8f9f3">FILESYSTEM_VIRTUAL</a> );
|
||
|
fs->changeWorkingDirectoryTo ( <span class="stringliteral">"/maps/"</span> );
|
||
|
IFileList *fileList = fs->createFileList ();
|
||
|
fs->setFileListSystem ( <a class="code" href="namespaceirr_1_1io.html#a22364f1caf06442a70f6198025af3fe9acfbc9e5e8773ec885f08eafd6c8d3c6f">FILESYSTEM_NATIVE</a> );
|
||
|
|
||
|
<span class="keywordflow">for</span> ( i=0; i< fileList->getFileCount(); ++i)
|
||
|
{
|
||
|
s = fileList->getFullFileName(i);
|
||
|
<span class="keywordflow">if</span> ( s.find ( <span class="stringliteral">".bsp"</span> ) >= 0 )
|
||
|
{
|
||
|
<span class="comment">// get level screenshot. reformat texture to 128x128</span>
|
||
|
<a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> c ( s );
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a905c95bab4a7e8d5360a19b0726383a9" title="delete path from filename">deletePathFromFilename</a> ( c );
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a188da2e914c6d4a6535bee08565d877b" title="cut the filename extension from a source file path and store it in a dest file path">cutFilenameExtension</a> ( c, c );
|
||
|
c = <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> ( <span class="stringliteral">"levelshots/"</span> ) + c;
|
||
|
|
||
|
<a class="code" href="namespaceirr_1_1core.html#ad2e562e3219072e2f7fc7c2bba0ef0cb" title="Typedef for an unsigned integer dimension.">dimension2du</a> dim ( 128, 128 );
|
||
|
IVideoDriver * driver = Game->Device->getVideoDriver();
|
||
|
IImage* image = 0;
|
||
|
ITexture *tex = 0;
|
||
|
<a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> filename;
|
||
|
|
||
|
filename = c + <span class="stringliteral">".jpg"</span>;
|
||
|
<span class="keywordflow">if</span> ( fs->existFile ( filename ) )
|
||
|
image = driver->createImageFromFile( filename );
|
||
|
<span class="keywordflow">if</span> ( 0 == image )
|
||
|
{
|
||
|
filename = c + <span class="stringliteral">".tga"</span>;
|
||
|
<span class="keywordflow">if</span> ( fs->existFile ( filename ) )
|
||
|
image = driver->createImageFromFile( filename );
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">if</span> ( image )
|
||
|
{
|
||
|
IImage* filter = driver->createImage ( <a class="code" href="namespaceirr_1_1video.html#a1d5e487888c32b1674a8f75116d829eda3f0380aafb1e1fd59f5419a95d630a6d" title="24 bit color, no alpha channel, but 8 bit for red, green and blue.">video::ECF_R8G8B8</a>, dim );
|
||
|
image->copyToScalingBoxFilter ( filter, 0 );
|
||
|
image->drop ();
|
||
|
image = filter;
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">if</span> ( image )
|
||
|
{
|
||
|
tex = driver->addTexture ( filename, image );
|
||
|
image->drop ();
|
||
|
}
|
||
|
|
||
|
|
||
|
bank->setTexture ( g, tex );
|
||
|
|
||
|
r.LowerRightCorner.X = dim.Width;
|
||
|
r.LowerRightCorner.Y = dim.Height;
|
||
|
gui.MapList->setItemHeight ( r.LowerRightCorner.Y + 4 );
|
||
|
frame.rectNumber = bank->getPositions().size();
|
||
|
frame.textureNumber = g;
|
||
|
|
||
|
bank->getPositions().push_back(r);
|
||
|
|
||
|
sprite.Frames.set_used ( 0 );
|
||
|
sprite.Frames.push_back(frame);
|
||
|
sprite.frameTime = 0;
|
||
|
bank->getSprites().push_back(sprite);
|
||
|
|
||
|
gui.MapList->addItem ( s.c_str (), g );
|
||
|
g += 1;
|
||
|
}
|
||
|
}
|
||
|
fileList->drop ();
|
||
|
|
||
|
gui.MapList->setSelected ( -1 );
|
||
|
IGUIScrollBar * bar = (IGUIScrollBar*)gui.MapList->getElementFromId( 0 );
|
||
|
<span class="keywordflow">if</span> ( bar )
|
||
|
bar->setPos ( 0 );
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
</pre></div><p>clears the Map in Memory </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::dropMap ()
|
||
|
{
|
||
|
IVideoDriver * driver = Game->Device->getVideoDriver();
|
||
|
|
||
|
driver->removeAllHardwareBuffers ();
|
||
|
driver->removeAllTextures ();
|
||
|
|
||
|
Player[0].shutdown ();
|
||
|
|
||
|
|
||
|
dropElement ( ItemParent );
|
||
|
dropElement ( ShaderParent );
|
||
|
dropElement ( UnresolvedParent );
|
||
|
dropElement ( FogParent );
|
||
|
dropElement ( BulletParent );
|
||
|
|
||
|
|
||
|
Impacts.clear();
|
||
|
|
||
|
<span class="keywordflow">if</span> ( Meta )
|
||
|
{
|
||
|
Meta = 0;
|
||
|
}
|
||
|
|
||
|
dropElement ( MapParent );
|
||
|
dropElement ( SkyNode );
|
||
|
|
||
|
<span class="comment">// clean out meshes, because textures are invalid</span>
|
||
|
<span class="comment">// TODO: better texture handling;-)</span>
|
||
|
IMeshCache *cache = Game->Device->getSceneManager ()->getMeshCache();
|
||
|
cache->clear ();
|
||
|
Mesh = 0;
|
||
|
}
|
||
|
</pre></div><p> Load new map </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::LoadMap ( <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> &mapName, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> collision )
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( 0 == mapName.size() )
|
||
|
<span class="keywordflow">return</span>;
|
||
|
|
||
|
dropMap ();
|
||
|
|
||
|
IFileSystem *fs = Game->Device->getFileSystem();
|
||
|
ISceneManager *smgr = Game->Device->getSceneManager ();
|
||
|
|
||
|
IReadFile* file = fs->createMemoryReadFile(&Game->loadParam,
|
||
|
<span class="keyword">sizeof</span>(Game->loadParam), L<span class="stringliteral">"levelparameter.cfg"</span>, <span class="keyword">false</span>);
|
||
|
|
||
|
<span class="comment">// load cfg file</span>
|
||
|
smgr->getMesh( file );
|
||
|
file->drop ();
|
||
|
|
||
|
<span class="comment">// load the actual map</span>
|
||
|
Mesh = (IQ3LevelMesh*) smgr->getMesh(mapName);
|
||
|
<span class="keywordflow">if</span> ( 0 == Mesh )
|
||
|
<span class="keywordflow">return</span>;
|
||
|
</pre></div><p>add the geometry mesh to the Scene ( polygon & patches ) The Geometry mesh is optimised for faster drawing </p>
|
||
|
<div class="fragment"><pre class="fragment"> IMesh *geometry = Mesh->getMesh(<a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a44a1a489a965cc9a0ad2c235bbb7bf33a10a5968f2ec9c929bfbca721780a7ef6">E_Q3_MESH_GEOMETRY</a>);
|
||
|
<span class="keywordflow">if</span> ( 0 == geometry || geometry->getMeshBufferCount() == 0)
|
||
|
<span class="keywordflow">return</span>;
|
||
|
|
||
|
Game->CurrentMapName = mapName;
|
||
|
|
||
|
<span class="comment">//create a collision list</span>
|
||
|
Meta = 0;
|
||
|
|
||
|
ITriangleSelector * selector = 0;
|
||
|
<span class="keywordflow">if</span> (collision)
|
||
|
Meta = smgr->createMetaTriangleSelector();
|
||
|
|
||
|
<span class="comment">//IMeshBuffer *b0 = geometry->getMeshBuffer(0);</span>
|
||
|
<span class="comment">//s32 minimalNodes = b0 ? core::s32_max ( 2048, b0->getVertexCount() / 32 ) : 2048;</span>
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> minimalNodes = 2048;
|
||
|
|
||
|
MapParent = smgr->addOctreeSceneNode(geometry, 0, -1, minimalNodes);
|
||
|
MapParent->setName ( mapName );
|
||
|
<span class="keywordflow">if</span> ( Meta )
|
||
|
{
|
||
|
selector = smgr->createOctreeTriangleSelector( geometry,MapParent, minimalNodes);
|
||
|
<span class="comment">//selector = smgr->createTriangleSelector ( geometry, MapParent );</span>
|
||
|
Meta->addTriangleSelector( selector);
|
||
|
selector->drop ();
|
||
|
}
|
||
|
|
||
|
<span class="comment">// logical parent for the items</span>
|
||
|
ItemParent = smgr->addEmptySceneNode();
|
||
|
<span class="keywordflow">if</span> ( ItemParent )
|
||
|
ItemParent->setName ( <span class="stringliteral">"Item Container"</span> );
|
||
|
|
||
|
ShaderParent = smgr->addEmptySceneNode();
|
||
|
<span class="keywordflow">if</span> ( ShaderParent )
|
||
|
ShaderParent->setName ( <span class="stringliteral">"Shader Container"</span> );
|
||
|
|
||
|
UnresolvedParent = smgr->addEmptySceneNode();
|
||
|
<span class="keywordflow">if</span> ( UnresolvedParent )
|
||
|
UnresolvedParent->setName ( <span class="stringliteral">"Unresolved Container"</span> );
|
||
|
|
||
|
FogParent = smgr->addEmptySceneNode();
|
||
|
<span class="keywordflow">if</span> ( FogParent )
|
||
|
FogParent->setName ( <span class="stringliteral">"Fog Container"</span> );
|
||
|
|
||
|
<span class="comment">// logical parent for the bullets</span>
|
||
|
BulletParent = smgr->addEmptySceneNode();
|
||
|
<span class="keywordflow">if</span> ( BulletParent )
|
||
|
BulletParent->setName ( <span class="stringliteral">"Bullet Container"</span> );
|
||
|
</pre></div><p>now construct SceneNodes for each Shader The Objects are stored in the quake mesh E_Q3_MESH_ITEMS and the Shader ID is stored in the MaterialParameters mostly dark looking skulls and moving lava.. or green flashing tubes? </p>
|
||
|
<div class="fragment"><pre class="fragment"> Q3ShaderFactory ( Game->loadParam, Game->Device, Mesh, <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a44a1a489a965cc9a0ad2c235bbb7bf33a15b1dd0b29d69900d070346d61f44319">E_Q3_MESH_ITEMS</a>,ShaderParent, Meta, <span class="keyword">false</span> );
|
||
|
Q3ShaderFactory ( Game->loadParam, Game->Device, Mesh, <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a44a1a489a965cc9a0ad2c235bbb7bf33a8679450d9dcdd4d1b22f38bbd059740b">E_Q3_MESH_FOG</a>,FogParent, 0, <span class="keyword">false</span> );
|
||
|
Q3ShaderFactory ( Game->loadParam, Game->Device, Mesh, <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a44a1a489a965cc9a0ad2c235bbb7bf33a9690978438eed9b5e39c7a87e9235b1d">E_Q3_MESH_UNRESOLVED</a>,UnresolvedParent, Meta, <span class="keyword">true</span> );
|
||
|
</pre></div><p>Now construct Models from Entity List </p>
|
||
|
<div class="fragment"><pre class="fragment"> Q3ModelFactory ( Game->loadParam, Game->Device, Mesh, ItemParent, <span class="keyword">false</span> );
|
||
|
}
|
||
|
</pre></div><p>Adds a SceneNode with an icon to the Scene Tree </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::addSceneTreeItem( ISceneNode * parent, IGUITreeViewNode* nodeParent)
|
||
|
{
|
||
|
IGUITreeViewNode* node;
|
||
|
<span class="keywordtype">wchar_t</span> msg[128];
|
||
|
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> imageIndex;
|
||
|
list<ISceneNode*>::ConstIterator it = parent->getChildren().begin();
|
||
|
<span class="keywordflow">for</span> (; it != parent->getChildren().end(); ++it)
|
||
|
{
|
||
|
<span class="keywordflow">switch</span> ( (*it)->getType () )
|
||
|
{
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#acad3d7ef92a9807d391ba29120f3b7bda240e6f8e61816ea8f0cdf840b457734c" title="Quake3 Shader Scene Node.">ESNT_Q3SHADER_SCENE_NODE</a>: imageIndex = 0; <span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#acad3d7ef92a9807d391ba29120f3b7bda117834c96690a72567a0a813708cf3b6" title="Camera Scene Node.">ESNT_CAMERA</a>: imageIndex = 1; <span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#acad3d7ef92a9807d391ba29120f3b7bda977d9500eeb4d4f23e5676a312367f57" title="Empty Scene Node.">ESNT_EMPTY</a>: imageIndex = 2; <span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#acad3d7ef92a9807d391ba29120f3b7bda25998267ed8640ca0c432df23f1b71fe" title="Mesh Scene Node.">ESNT_MESH</a>: imageIndex = 3; <span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#acad3d7ef92a9807d391ba29120f3b7bda1cbab0e001b2df07ef2a253434532a52" title="Octree Scene Node.">ESNT_OCTREE</a>: imageIndex = 3; <span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#acad3d7ef92a9807d391ba29120f3b7bda073d7fe9dfd49f24cb13bfae56d8d3b6" title="Animated Mesh Scene Node.">ESNT_ANIMATED_MESH</a>: imageIndex = 4; <span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#acad3d7ef92a9807d391ba29120f3b7bdac47a4c2ad206e916f080ad28faed7f3b" title="Sky Box Scene Node.">ESNT_SKY_BOX</a>: imageIndex = 5; <span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#acad3d7ef92a9807d391ba29120f3b7bda85e4b3fca8fceb3de9057e91926d2a5f" title="Billboard Scene Node.">ESNT_BILLBOARD</a>: imageIndex = 6; <span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#acad3d7ef92a9807d391ba29120f3b7bdab027cde22a402f6f7f19eb714acf26a4" title="Particle System Scene Node.">ESNT_PARTICLE_SYSTEM</a>: imageIndex = 7; <span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#acad3d7ef92a9807d391ba29120f3b7bda65e7b71bf270e10f94d88bcab8cbf184" title="Text Scene Node.">ESNT_TEXT</a>: imageIndex = 8; <span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">default</span>:imageIndex = -1; <span class="keywordflow">break</span>;
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">if</span> ( imageIndex < 0 )
|
||
|
{
|
||
|
swprintf ( msg, 128, L<span class="stringliteral">"%hs,%hs"</span>,
|
||
|
Game->Device->getSceneManager ()->getSceneNodeTypeName ( (*it)->getType () ),
|
||
|
(*it)->getName()
|
||
|
);
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
{
|
||
|
swprintf ( msg, 128, L<span class="stringliteral">"%hs"</span>,(*it)->getName() );
|
||
|
}
|
||
|
|
||
|
node = nodeParent->addChildBack( msg, 0, imageIndex );
|
||
|
|
||
|
<span class="comment">// Add all Animators</span>
|
||
|
list<ISceneNodeAnimator*>::ConstIterator ait = (*it)->getAnimators().begin();
|
||
|
<span class="keywordflow">for</span> (; ait != (*it)->getAnimators().end(); ++ait)
|
||
|
{
|
||
|
imageIndex = -1;
|
||
|
swprintf ( msg, 128, L<span class="stringliteral">"%hs"</span>,
|
||
|
Game->Device->getSceneManager ()->getAnimatorTypeName ( (*ait)->getType () )
|
||
|
);
|
||
|
|
||
|
<span class="keywordflow">switch</span> ( (*ait)->getType () )
|
||
|
{
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19add5f15ecd6c0209d4e3d81a287ae9a66" title="Fly circle scene node animator.">ESNAT_FLY_CIRCLE</a>:
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19af71dad2be8d964a88329d2727fb53b74" title="Fly straight scene node animator.">ESNAT_FLY_STRAIGHT</a>:
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19addc7e3bb5180f7087546ccab14dcc4ad" title="Follow spline scene node animator.">ESNAT_FOLLOW_SPLINE</a>:
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19a689aa5051e83b7f61a7abba85eb1be52" title="Rotation scene node animator.">ESNAT_ROTATION</a>:
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19a2f3e75035fbb3227189a0a3d8bcda993" title="Texture scene node animator.">ESNAT_TEXTURE</a>:
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19abbafee6e6a120e26a6e1ed6bd3cbdc86" title="Deletion scene node animator.">ESNAT_DELETION</a>:
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19af5889b6449faa50d3fabd005d4493490" title="Collision respose scene node animator.">ESNAT_COLLISION_RESPONSE</a>:
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19ae40c836272ace5bf243baaca72dba55c" title="FPS camera animator.">ESNAT_CAMERA_FPS</a>:
|
||
|
<span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19a851338028c38a91643f70d2a2e5ff8c4" title="Maya camera animator.">ESNAT_CAMERA_MAYA</a>:
|
||
|
<span class="keywordflow">default</span>:
|
||
|
<span class="keywordflow">break</span>;
|
||
|
}
|
||
|
node->addChildBack( msg, 0, imageIndex );
|
||
|
}
|
||
|
|
||
|
addSceneTreeItem ( *it, node );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
<span class="comment">// Adds life!</span>
|
||
|
<span class="keywordtype">void</span> CQuake3EventHandler::CreatePlayers()
|
||
|
{
|
||
|
Player[0].create ( Game->Device, Mesh, MapParent, Meta );
|
||
|
}
|
||
|
|
||
|
|
||
|
<span class="comment">// Adds a skydome to the scene</span>
|
||
|
<span class="keywordtype">void</span> CQuake3EventHandler::AddSky( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> dome, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *texture)
|
||
|
{
|
||
|
ISceneManager *smgr = Game->Device->getSceneManager ();
|
||
|
IVideoDriver * driver = Game->Device->getVideoDriver();
|
||
|
|
||
|
<span class="keywordtype">bool</span> oldMipMapState = driver->getTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#acaf6f7414534f7d62bff18c5bf11876fa288b302e9d4faaba80c7796c7bc1682c">video::ETCF_CREATE_MIP_MAPS</a>);
|
||
|
driver->setTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#acaf6f7414534f7d62bff18c5bf11876fa288b302e9d4faaba80c7796c7bc1682c">video::ETCF_CREATE_MIP_MAPS</a>, <span class="keyword">false</span>);
|
||
|
|
||
|
<span class="keywordflow">if</span> ( 0 == dome )
|
||
|
{
|
||
|
<span class="comment">// irrlicht order</span>
|
||
|
<span class="comment">//static const c8*p[] = { "ft", "lf", "bk", "rt", "up", "dn" };</span>
|
||
|
<span class="comment">// quake3 order</span>
|
||
|
<span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a>*p[] = { <span class="stringliteral">"ft"</span>, <span class="stringliteral">"rt"</span>, <span class="stringliteral">"bk"</span>, <span class="stringliteral">"lf"</span>, <span class="stringliteral">"up"</span>, <span class="stringliteral">"dn"</span> };
|
||
|
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i = 0;
|
||
|
snprintf ( buf, 64, <span class="stringliteral">"%s_%s.jpg"</span>, texture, p[i] );
|
||
|
SkyNode = smgr->addSkyBoxSceneNode( driver->getTexture ( buf ), 0, 0, 0, 0, 0 );
|
||
|
|
||
|
<span class="keywordflow">if</span> (SkyNode)
|
||
|
{
|
||
|
<span class="keywordflow">for</span> ( i = 0; i < 6; ++i )
|
||
|
{
|
||
|
snprintf ( buf, 64, <span class="stringliteral">"%s_%s.jpg"</span>, texture, p[i] );
|
||
|
SkyNode->getMaterial(i).setTexture ( 0, driver->getTexture ( buf ) );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( 1 == dome )
|
||
|
{
|
||
|
snprintf ( buf, 64, <span class="stringliteral">"%s.jpg"</span>, texture );
|
||
|
SkyNode = smgr->addSkyDomeSceneNode(
|
||
|
driver->getTexture( buf ), 32,32,
|
||
|
1.f, 1.f, 1000.f, 0, 11);
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( 2 == dome )
|
||
|
{
|
||
|
snprintf ( buf, 64, <span class="stringliteral">"%s.jpg"</span>, texture );
|
||
|
SkyNode = smgr->addSkyDomeSceneNode(
|
||
|
driver->getTexture( buf ), 16,8,
|
||
|
0.95f, 2.f, 1000.f, 0, 11);
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">if</span> (SkyNode)
|
||
|
SkyNode->setName(<span class="stringliteral">"Skydome"</span>);
|
||
|
<span class="comment">//SkyNode->getMaterial(0).ZBuffer = video::EMDF_DEPTH_LESS_EQUAL;</span>
|
||
|
|
||
|
driver->setTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#acaf6f7414534f7d62bff18c5bf11876fa288b302e9d4faaba80c7796c7bc1682c">video::ETCF_CREATE_MIP_MAPS</a>, oldMipMapState);
|
||
|
}
|
||
|
|
||
|
|
||
|
<span class="comment">// enable GUI elements</span>
|
||
|
<span class="keywordtype">void</span> CQuake3EventHandler::SetGUIActive( <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> command)
|
||
|
{
|
||
|
<span class="keywordtype">bool</span> inputState = <span class="keyword">false</span>;
|
||
|
|
||
|
ICameraSceneNode * camera = Game->Device->getSceneManager()->getActiveCamera ();
|
||
|
|
||
|
<span class="keywordflow">switch</span> ( command )
|
||
|
{
|
||
|
<span class="keywordflow">case</span> 0: Game->guiActive = 0; inputState = !Game->guiActive; <span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> 1: Game->guiActive = 1; inputState = !Game->guiActive;;<span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> 2: Game->guiActive ^= 1; inputState = !Game->guiActive;<span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> 3:
|
||
|
<span class="keywordflow">if</span> ( camera )
|
||
|
inputState = !camera->isInputReceiverEnabled();
|
||
|
<span class="keywordflow">break</span>;
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">if</span> ( camera )
|
||
|
{
|
||
|
camera->setInputReceiverEnabled ( inputState );
|
||
|
Game->Device->getCursorControl()->setVisible( !inputState );
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">if</span> ( gui.Window )
|
||
|
{
|
||
|
gui.Window->setVisible ( Game->guiActive != 0 );
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">if</span> ( Game->guiActive &&
|
||
|
gui.SceneTree && Game->Device->getGUIEnvironment()->getFocus() != gui.SceneTree
|
||
|
)
|
||
|
{
|
||
|
gui.SceneTree->getRoot()->clearChildren();
|
||
|
addSceneTreeItem ( Game->Device->getSceneManager()->getRootSceneNode(), gui.SceneTree->getRoot() );
|
||
|
}
|
||
|
|
||
|
Game->Device->getGUIEnvironment()->setFocus ( Game->guiActive ? gui.Window: 0 );
|
||
|
}
|
||
|
</pre></div><p>Handle game input </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">bool</span> CQuake3EventHandler::OnEvent(<span class="keyword">const</span> SEvent& eve)
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( eve.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0ca8553b889c8da285c96b90116ae019952" title="A log event.">EET_LOG_TEXT_EVENT</a> )
|
||
|
{
|
||
|
<span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">if</span> ( Game->guiActive && eve.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0cae85bb44dd09a29c879d64a05047fc1d2" title="An event of the graphical user interface.">EET_GUI_EVENT</a> )
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.MapList && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a3f3c374a3c74405ee3eac6973e78345f" title="An item in the listbox was selected, which was already selected.">gui::EGET_LISTBOX_SELECTED_AGAIN</a> )
|
||
|
{
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selected = gui.MapList->getSelected();
|
||
|
<span class="keywordflow">if</span> ( selected >= 0 )
|
||
|
{
|
||
|
<a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> loadMap = gui.MapList->getListItem ( selected );
|
||
|
<span class="keywordflow">if</span> ( 0 == MapParent || loadMap != Game->CurrentMapName )
|
||
|
{
|
||
|
printf ( <span class="stringliteral">"Loading map %ls\n"</span>, loadMap.c_str() );
|
||
|
LoadMap ( loadMap , 1 );
|
||
|
<span class="keywordflow">if</span> ( 0 == Game->loadParam.loadSkyShader )
|
||
|
{
|
||
|
AddSky ( 1, <span class="stringliteral">"skydome2"</span> );
|
||
|
}
|
||
|
CreatePlayers ();
|
||
|
CreateGUI ();
|
||
|
SetGUIActive ( 0 );
|
||
|
<span class="keywordflow">return</span> <span class="keyword">true</span>;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveRemove && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" title="A button was clicked.">gui::EGET_BUTTON_CLICKED</a> )
|
||
|
{
|
||
|
Game->Device->getFileSystem()->removeFileArchive( gui.ArchiveList->getSelected() );
|
||
|
Game->CurrentMapName = <span class="stringliteral">""</span>;
|
||
|
AddArchive ( <span class="stringliteral">""</span> );
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveAdd && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" title="A button was clicked.">gui::EGET_BUTTON_CLICKED</a> )
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( 0 == gui.ArchiveFileOpen )
|
||
|
{
|
||
|
Game->Device->getFileSystem()->setFileListSystem ( <a class="code" href="namespaceirr_1_1io.html#a22364f1caf06442a70f6198025af3fe9acfbc9e5e8773ec885f08eafd6c8d3c6f">FILESYSTEM_NATIVE</a> );
|
||
|
gui.ArchiveFileOpen = Game->Device->getGUIEnvironment()->addFileOpenDialog ( L<span class="stringliteral">"Add Game Archive"</span> , <span class="keyword">false</span>,gui.Window );
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveFileOpen && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a5b6504cf6b541d5ad95407c384632873" title="A file has been selected in the file dialog.">gui::EGET_FILE_SELECTED</a> )
|
||
|
{
|
||
|
AddArchive ( gui.ArchiveFileOpen->getFileName() );
|
||
|
gui.ArchiveFileOpen = 0;
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveFileOpen && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a0c8a9e059bd8efe74e2f747e2e9187b3" title="A directory has been selected in the file dialog.">gui::EGET_DIRECTORY_SELECTED</a> )
|
||
|
{
|
||
|
AddArchive ( gui.ArchiveFileOpen->getDirectoryName() );
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.ArchiveFileOpen && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808ae524b2c68bc8c3117c6ae7a2d2df7865" title="A file open dialog has been closed without choosing a file.">gui::EGET_FILE_CHOOSE_DIALOG_CANCELLED</a> )
|
||
|
{
|
||
|
gui.ArchiveFileOpen = 0;
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( ( eve.GUIEvent.Caller == gui.ArchiveUp || eve.GUIEvent.Caller == gui.ArchiveDown ) &&
|
||
|
eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" title="A button was clicked.">gui::EGET_BUTTON_CLICKED</a> )
|
||
|
{
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> rel = eve.GUIEvent.Caller == gui.ArchiveUp ? -1 : 1;
|
||
|
<span class="keywordflow">if</span> ( Game->Device->getFileSystem()->moveFileArchive ( gui.ArchiveList->getSelected (), rel ) )
|
||
|
{
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> newIndex = <a class="code" href="namespaceirr_1_1core.html#aa7828c932a36c62a67fd0f2b972d8b21">core::s32_clamp</a> ( gui.ArchiveList->getSelected() + rel, 0, gui.ArchiveList->getRowCount() - 1 );
|
||
|
AddArchive ( <span class="stringliteral">""</span> );
|
||
|
gui.ArchiveList->setSelected ( newIndex );
|
||
|
Game->CurrentMapName = <span class="stringliteral">""</span>;
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.VideoDriver && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808aef7f9081622a71160e161c80eb07d436" title="The selection in a combo box has been changed.">gui::EGET_COMBO_BOX_CHANGED</a> )
|
||
|
{
|
||
|
Game->deviceParam.DriverType = (<a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0" title="An enum for all types of drivers the Irrlicht Engine supports.">E_DRIVER_TYPE</a>) gui.VideoDriver->getItemData ( gui.VideoDriver->getSelected() );
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.VideoMode && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808aef7f9081622a71160e161c80eb07d436" title="The selection in a combo box has been changed.">gui::EGET_COMBO_BOX_CHANGED</a> )
|
||
|
{
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> val = gui.VideoMode->getItemData ( gui.VideoMode->getSelected() );
|
||
|
Game->deviceParam.WindowSize.Width = val >> 16;
|
||
|
Game->deviceParam.WindowSize.Height = val & 0xFFFF;
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.FullScreen && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a16a1f6de4aeb2d7f34f7b7dbff0a7a0a" title="A checkbox has changed its check state.">gui::EGET_CHECKBOX_CHANGED</a> )
|
||
|
{
|
||
|
Game->deviceParam.Fullscreen = gui.FullScreen->isChecked();
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Bit32 && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a16a1f6de4aeb2d7f34f7b7dbff0a7a0a" title="A checkbox has changed its check state.">gui::EGET_CHECKBOX_CHANGED</a> )
|
||
|
{
|
||
|
Game->deviceParam.Bits = gui.Bit32->isChecked() ? 32 : 16;
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.MultiSample && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a2eea536494edcde2bb2608bda9d352b2" title="A scrollbar has changed its position.">gui::EGET_SCROLL_BAR_CHANGED</a> )
|
||
|
{
|
||
|
Game->deviceParam.AntiAlias = gui.MultiSample->getPos();
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Tesselation && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a2eea536494edcde2bb2608bda9d352b2" title="A scrollbar has changed its position.">gui::EGET_SCROLL_BAR_CHANGED</a> )
|
||
|
{
|
||
|
Game->loadParam.patchTesselation = gui.Tesselation->getPos ();
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Gamma && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a2eea536494edcde2bb2608bda9d352b2" title="A scrollbar has changed its position.">gui::EGET_SCROLL_BAR_CHANGED</a> )
|
||
|
{
|
||
|
Game->GammaValue = gui.Gamma->getPos () * 0.01f;
|
||
|
Game->Device->setGammaRamp ( Game->GammaValue, Game->GammaValue, Game->GammaValue, 0.f, 0.f );
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.SetVideoMode && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" title="A button was clicked.">gui::EGET_BUTTON_CLICKED</a> )
|
||
|
{
|
||
|
Game->retVal = 2;
|
||
|
Game->Device->closeDevice();
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Window && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a9879e90ebeaf90f3ec7477acc1a46749" title="An element would like to close.">gui::EGET_ELEMENT_CLOSED</a> )
|
||
|
{
|
||
|
Game->Device->closeDevice();
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Collision && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a16a1f6de4aeb2d7f34f7b7dbff0a7a0a" title="A checkbox has changed its check state.">gui::EGET_CHECKBOX_CHANGED</a> )
|
||
|
{
|
||
|
<span class="comment">// set fly through active</span>
|
||
|
Game->flyTroughState ^= 1;
|
||
|
Player[0].cam()->setAnimateTarget ( Game->flyTroughState == 0 );
|
||
|
|
||
|
printf ( <span class="stringliteral">"collision %d\n"</span>, Game->flyTroughState == 0 );
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Visible_Map && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a16a1f6de4aeb2d7f34f7b7dbff0a7a0a" title="A checkbox has changed its check state.">gui::EGET_CHECKBOX_CHANGED</a> )
|
||
|
{
|
||
|
<span class="keywordtype">bool</span> v = gui.Visible_Map->isChecked();
|
||
|
|
||
|
<span class="keywordflow">if</span> ( MapParent )
|
||
|
{
|
||
|
printf ( <span class="stringliteral">"static node set visible %d\n"</span>,v );
|
||
|
MapParent->setVisible ( v );
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Visible_Shader && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a16a1f6de4aeb2d7f34f7b7dbff0a7a0a" title="A checkbox has changed its check state.">gui::EGET_CHECKBOX_CHANGED</a> )
|
||
|
{
|
||
|
<span class="keywordtype">bool</span> v = gui.Visible_Shader->isChecked();
|
||
|
|
||
|
<span class="keywordflow">if</span> ( ShaderParent )
|
||
|
{
|
||
|
printf ( <span class="stringliteral">"shader node set visible %d\n"</span>,v );
|
||
|
ShaderParent->setVisible ( v );
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Visible_Skydome && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a16a1f6de4aeb2d7f34f7b7dbff0a7a0a" title="A checkbox has changed its check state.">gui::EGET_CHECKBOX_CHANGED</a> )
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( SkyNode )
|
||
|
{
|
||
|
<span class="keywordtype">bool</span> v = !SkyNode->isVisible();
|
||
|
printf ( <span class="stringliteral">"skynode set visible %d\n"</span>,v );
|
||
|
SkyNode->setVisible ( v );
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> ( eve.GUIEvent.Caller == gui.Respawn && eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" title="A button was clicked.">gui::EGET_BUTTON_CLICKED</a> )
|
||
|
{
|
||
|
Player[0].respawn ();
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||
|
}
|
||
|
|
||
|
<span class="comment">// fire</span>
|
||
|
<span class="keywordflow">if</span> ((eve.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0ca6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">EET_KEY_INPUT_EVENT</a> && eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a52c3b1744ca8ae7b6da19fc00fbb8ee8">KEY_SPACE</a> &&
|
||
|
eve.KeyInput.PressedDown == <span class="keyword">false</span>) ||
|
||
|
(eve.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0caa230b748674e074aa67f661819ad5891" title="A mouse input event.">EET_MOUSE_INPUT_EVENT</a> && eve.MouseInput.Event == <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa26d91b99a8912ff622133f02c60f306a" title="Left mouse button was left up.">EMIE_LMOUSE_LEFT_UP</a>)
|
||
|
)
|
||
|
{
|
||
|
ICameraSceneNode * camera = Game->Device->getSceneManager()->getActiveCamera ();
|
||
|
<span class="keywordflow">if</span> ( camera && camera->isInputReceiverEnabled () )
|
||
|
{
|
||
|
useItem( Player + 0 );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
<span class="comment">// gui active</span>
|
||
|
<span class="keywordflow">if</span> ((eve.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0ca6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">EET_KEY_INPUT_EVENT</a> && eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a5427274e34fd5587155fe8b3b12d96a8">KEY_F1</a> &&
|
||
|
eve.KeyInput.PressedDown == <span class="keyword">false</span>) ||
|
||
|
(eve.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0caa230b748674e074aa67f661819ad5891" title="A mouse input event.">EET_MOUSE_INPUT_EVENT</a> && eve.MouseInput.Event == <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fadb92d5c1011534b2b18065573182d9f4" title="Right mouse button was left up.">EMIE_RMOUSE_LEFT_UP</a>)
|
||
|
)
|
||
|
{
|
||
|
SetGUIActive ( 2 );
|
||
|
}
|
||
|
|
||
|
<span class="comment">// check if user presses the key</span>
|
||
|
<span class="keywordflow">if</span> ( eve.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0ca6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">EET_KEY_INPUT_EVENT</a> && eve.KeyInput.PressedDown == <span class="keyword">false</span>)
|
||
|
{
|
||
|
<span class="comment">// Escape toggles camera Input</span>
|
||
|
<span class="keywordflow">if</span> ( eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3aab32bfc194f119e5d5b9b39527bbcd61">irr::KEY_ESCAPE</a> )
|
||
|
{
|
||
|
SetGUIActive ( 3 );
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3af847cf3df62b0e23942f0bd2d226a9eb">KEY_F11</a>)
|
||
|
{
|
||
|
<span class="comment">// screenshot are taken without gamma!</span>
|
||
|
IImage* image = Game->Device->getVideoDriver()->createScreenShot();
|
||
|
<span class="keywordflow">if</span> (image)
|
||
|
{
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> pos;
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> rot;
|
||
|
ICameraSceneNode * cam = Game->Device->getSceneManager()->getActiveCamera ();
|
||
|
<span class="keywordflow">if</span> ( cam )
|
||
|
{
|
||
|
pos = cam->getPosition ();
|
||
|
rot = cam->getRotation ();
|
||
|
}
|
||
|
|
||
|
<span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *dName[] = { <span class="stringliteral">"null"</span>, <span class="stringliteral">"software"</span>, <span class="stringliteral">"burning"</span>,
|
||
|
<span class="stringliteral">"d3d8"</span>, <span class="stringliteral">"d3d9"</span>, <span class="stringliteral">"opengl"</span> };
|
||
|
|
||
|
snprintf(buf, 256, <span class="stringliteral">"%s_%ls_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f.jpg"</span>,
|
||
|
dName[Game->Device->getVideoDriver()->getDriverType()],
|
||
|
Game->CurrentMapName.c_str(),
|
||
|
pos.X, pos.Y, pos.Z,
|
||
|
rot.X, rot.Y, rot.Z
|
||
|
);
|
||
|
<a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> filename ( buf );
|
||
|
filename.replace ( <span class="charliteral">'/'</span>, <span class="charliteral">'_'</span> );
|
||
|
printf ( <span class="stringliteral">"screenshot : %s\n"</span>, filename.c_str() );
|
||
|
Game->Device->getVideoDriver()->writeImageToFile(image, filename, 100 );
|
||
|
image->drop();
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a5dfbe4e0c7c8d9d810717fc1331fd3c9">KEY_F9</a>)
|
||
|
{
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> value = <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea25111b15f03bee9a99498737286916dc" title="No Debug Data ( Default )">EDS_OFF</a>;
|
||
|
|
||
|
Game->debugState = ( Game->debugState + 1 ) & 3;
|
||
|
|
||
|
<span class="keywordflow">switch</span> ( Game->debugState )
|
||
|
{
|
||
|
<span class="keywordflow">case</span> 1: value = <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea2713e470ee18ec9bfe40fdfb502f8b05" title="Show Vertex Normals.">EDS_NORMALS</a> | <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea349b086537ac770f09935af4e31d3f3e" title="Overlays Mesh Wireframe.">EDS_MESH_WIRE_OVERLAY</a> | <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea80f38e42f1b8cf169e83f44092367bfe" title="EDS_BBOX | EDS_BBOX_BUFFERS.">EDS_BBOX_ALL</a>; <span class="keywordflow">break</span>;
|
||
|
<span class="keywordflow">case</span> 2: value = <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea2713e470ee18ec9bfe40fdfb502f8b05" title="Show Vertex Normals.">EDS_NORMALS</a> | <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea349b086537ac770f09935af4e31d3f3e" title="Overlays Mesh Wireframe.">EDS_MESH_WIRE_OVERLAY</a> | <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbeaa7664e189b8641ac54cf27f70f6d8144" title="Shows Skeleton/Tags.">EDS_SKELETON</a>; <span class="keywordflow">break</span>;
|
||
|
}
|
||
|
</pre></div><p>set debug map data on/off debugState = debugState == EDS_OFF ? EDS_NORMALS | EDS_MESH_WIRE_OVERLAY | EDS_BBOX_ALL: EDS_OFF; </p>
|
||
|
<div class="fragment"><pre class="fragment"> <span class="keywordflow">if</span> ( ItemParent )
|
||
|
{
|
||
|
list<ISceneNode*>::ConstIterator it = ItemParent->getChildren().begin();
|
||
|
<span class="keywordflow">for</span> (; it != ItemParent->getChildren().end(); ++it)
|
||
|
{
|
||
|
(*it)->setDebugDataVisible ( value );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">if</span> ( ShaderParent )
|
||
|
{
|
||
|
list<ISceneNode*>::ConstIterator it = ShaderParent->getChildren().begin();
|
||
|
<span class="keywordflow">for</span> (; it != ShaderParent->getChildren().end(); ++it)
|
||
|
{
|
||
|
(*it)->setDebugDataVisible ( value );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">if</span> ( UnresolvedParent )
|
||
|
{
|
||
|
list<ISceneNode*>::ConstIterator it = UnresolvedParent->getChildren().begin();
|
||
|
<span class="keywordflow">for</span> (; it != UnresolvedParent->getChildren().end(); ++it)
|
||
|
{
|
||
|
(*it)->setDebugDataVisible ( value );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">if</span> ( FogParent )
|
||
|
{
|
||
|
list<ISceneNode*>::ConstIterator it = FogParent->getChildren().begin();
|
||
|
<span class="keywordflow">for</span> (; it != FogParent->getChildren().end(); ++it)
|
||
|
{
|
||
|
(*it)->setDebugDataVisible ( value );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">if</span> ( SkyNode )
|
||
|
{
|
||
|
SkyNode->setDebugDataVisible ( value );
|
||
|
}
|
||
|
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a5111be01fea6429912b3e497b2a85d73">KEY_F8</a>)
|
||
|
{
|
||
|
<span class="comment">// set gravity on/off</span>
|
||
|
Game->gravityState ^= 1;
|
||
|
Player[0].cam()->setGravity ( getGravity ( Game->gravityState ? <span class="stringliteral">"earth"</span> : <span class="stringliteral">"none"</span> ) );
|
||
|
printf ( <span class="stringliteral">"gravity %s\n"</span>, Game->gravityState ? <span class="stringliteral">"earth"</span> : <span class="stringliteral">"none"</span> );
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a7f58cecbda71cea3043c026d3ba00456">KEY_F7</a>)
|
||
|
{
|
||
|
<span class="comment">// set fly through active</span>
|
||
|
Game->flyTroughState ^= 1;
|
||
|
Player[0].cam()->setAnimateTarget ( Game->flyTroughState == 0 );
|
||
|
<span class="keywordflow">if</span> ( gui.Collision )
|
||
|
gui.Collision->setChecked ( Game->flyTroughState == 0 );
|
||
|
|
||
|
printf ( <span class="stringliteral">"collision %d\n"</span>, Game->flyTroughState == 0 );
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a992b194a5b4b4809587db8a43c3e75dd">KEY_F2</a>)
|
||
|
{
|
||
|
Player[0].respawn ();
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a2f017f7a3b6291e5d549ed4a09c03d4e">KEY_F3</a>)
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( MapParent )
|
||
|
{
|
||
|
<span class="keywordtype">bool</span> v = !MapParent->isVisible ();
|
||
|
printf ( <span class="stringliteral">"static node set visible %d\n"</span>,v );
|
||
|
MapParent->setVisible ( v );
|
||
|
<span class="keywordflow">if</span> ( gui.Visible_Map )
|
||
|
gui.Visible_Map->setChecked ( v );
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a8f49f2e6664716985551334f0b2c1b47">KEY_F4</a>)
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( ShaderParent )
|
||
|
{
|
||
|
<span class="keywordtype">bool</span> v = !ShaderParent->isVisible ();
|
||
|
printf ( <span class="stringliteral">"shader node set visible %d\n"</span>,v );
|
||
|
ShaderParent->setVisible ( v );
|
||
|
<span class="keywordflow">if</span> ( gui.Visible_Shader )
|
||
|
gui.Visible_Shader->setChecked ( v );
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a6aecea6261588331b87093b4ab544b1a">KEY_F5</a>)
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( FogParent )
|
||
|
{
|
||
|
<span class="keywordtype">bool</span> v = !FogParent->isVisible ();
|
||
|
printf ( <span class="stringliteral">"fog node set visible %d\n"</span>,v );
|
||
|
FogParent->setVisible ( v );
|
||
|
<span class="keywordflow">if</span> ( gui.Visible_Fog )
|
||
|
gui.Visible_Fog->setChecked ( v );
|
||
|
}
|
||
|
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
<span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a6c0530c3448c3274b137f97df44e2a44">KEY_F6</a>)
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( UnresolvedParent )
|
||
|
{
|
||
|
<span class="keywordtype">bool</span> v = !UnresolvedParent->isVisible ();
|
||
|
printf ( <span class="stringliteral">"unresolved node set visible %d\n"</span>,v );
|
||
|
UnresolvedParent->setVisible ( v );
|
||
|
<span class="keywordflow">if</span> ( gui.Visible_Unresolved )
|
||
|
gui.Visible_Unresolved->setChecked ( v );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
<span class="comment">// check if user presses the key C ( for crouch)</span>
|
||
|
<span class="keywordflow">if</span> ( eve.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0ca6f90390f3147a1693e5e2e3422d6ca09" title="A key input event.">EET_KEY_INPUT_EVENT</a> && eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a85a756fa6a3336312c5f32877a7185e5">KEY_KEY_C</a> )
|
||
|
{
|
||
|
<span class="comment">// crouch</span>
|
||
|
ISceneNodeAnimatorCollisionResponse *anim = Player[0].cam ();
|
||
|
<span class="keywordflow">if</span> ( anim && 0 == Game->flyTroughState )
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( <span class="keyword">false</span> == eve.KeyInput.PressedDown )
|
||
|
{
|
||
|
<span class="comment">// stand up</span>
|
||
|
anim->setEllipsoidRadius ( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(30,45,30) );
|
||
|
anim->setEllipsoidTranslation ( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0,40,0));
|
||
|
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
{
|
||
|
<span class="comment">// on your knees</span>
|
||
|
anim->setEllipsoidRadius ( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(30,20,30) );
|
||
|
anim->setEllipsoidTranslation ( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0,20,0));
|
||
|
}
|
||
|
<span class="keywordflow">return</span> <span class="keyword">true</span>;
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||
|
}
|
||
|
</pre></div><p>useItem </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::useItem( Q3Player * player)
|
||
|
{
|
||
|
ISceneManager* smgr = Game->Device->getSceneManager();
|
||
|
ICameraSceneNode* camera = smgr->getActiveCamera();
|
||
|
|
||
|
<span class="keywordflow">if</span> (!camera)
|
||
|
<span class="keywordflow">return</span>;
|
||
|
|
||
|
SParticleImpact imp;
|
||
|
imp.when = 0;
|
||
|
|
||
|
<span class="comment">// get line of camera</span>
|
||
|
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> start = camera->getPosition();
|
||
|
|
||
|
<span class="keywordflow">if</span> ( player->WeaponNode )
|
||
|
{
|
||
|
start.X += 0.f;
|
||
|
start.Y += 0.f;
|
||
|
start.Z += 0.f;
|
||
|
}
|
||
|
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> end = (camera->getTarget() - start);
|
||
|
end.normalize();
|
||
|
start += end*20.0f;
|
||
|
|
||
|
end = start + (end * camera->getFarValue());
|
||
|
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a1112835405bbec5dadf031dc7934e7d0" title="Typedef for a f32 3d triangle.">triangle3df</a> triangle;
|
||
|
line3d<f32> line(start, end);
|
||
|
|
||
|
<span class="comment">// get intersection point with map</span>
|
||
|
scene::ISceneNode* hitNode;
|
||
|
<span class="keywordflow">if</span> (smgr->getSceneCollisionManager()->getCollisionPoint(
|
||
|
line, Meta, end, triangle,hitNode))
|
||
|
{
|
||
|
<span class="comment">// collides with wall</span>
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> out = triangle.getNormal();
|
||
|
out.setLength(0.03f);
|
||
|
|
||
|
imp.when = 1;
|
||
|
imp.outVector = out;
|
||
|
imp.pos = end;
|
||
|
|
||
|
player->setAnim ( <span class="stringliteral">"pow"</span> );
|
||
|
player->Anim[1].next += player->Anim[1].delta;
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
{
|
||
|
<span class="comment">// doesnt collide with wall</span>
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> start = camera->getPosition();
|
||
|
<span class="keywordflow">if</span> ( player->WeaponNode )
|
||
|
{
|
||
|
<span class="comment">//start.X += 10.f;</span>
|
||
|
<span class="comment">//start.Y += -5.f;</span>
|
||
|
<span class="comment">//start.Z += 1.f;</span>
|
||
|
}
|
||
|
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> end = (camera->getTarget() - start);
|
||
|
end.normalize();
|
||
|
start += end*20.0f;
|
||
|
end = start + (end * camera->getFarValue());
|
||
|
}
|
||
|
|
||
|
<span class="comment">// create fire ball</span>
|
||
|
ISceneNode* node = 0;
|
||
|
node = smgr->addBillboardSceneNode( BulletParent,dimension2d<f32>(10,10), start);
|
||
|
|
||
|
node->setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3acea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">EMF_LIGHTING</a>, <span class="keyword">false</span>);
|
||
|
node->setMaterialTexture(0, Game->Device->getVideoDriver()->getTexture(<span class="stringliteral">"fireball.bmp"</span>));
|
||
|
node->setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a4bc03b7b9dd19e577bf909313ea62510" title="May be written to the zbuffer or is it readonly. Default: true.">video::EMF_ZWRITE_ENABLE</a>, <span class="keyword">false</span>);
|
||
|
node->setMaterialType(<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a1b5a814c4466aca2943ff056003a50d1" title="A transparent material.">EMT_TRANSPARENT_ADD_COLOR</a>);
|
||
|
|
||
|
<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> length = (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>)(end - start).getLength();
|
||
|
<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> speed = 5.8f;
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> time = (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>)(length / speed);
|
||
|
|
||
|
ISceneNodeAnimator* anim = 0;
|
||
|
|
||
|
<span class="comment">// set flight line</span>
|
||
|
|
||
|
anim = smgr->createFlyStraightAnimator(start, end, time);
|
||
|
node->addAnimator(anim);
|
||
|
anim->drop();
|
||
|
|
||
|
snprintf ( buf, 64, <span class="stringliteral">"bullet: %s on %.1f,%1.f,%1.f"</span>,
|
||
|
imp.when ? <span class="stringliteral">"hit"</span> : <span class="stringliteral">"nohit"</span>, end.X, end.Y, end.Z );
|
||
|
node->setName ( buf );
|
||
|
|
||
|
|
||
|
anim = smgr->createDeleteAnimator(time);
|
||
|
node->addAnimator(anim);
|
||
|
anim->drop();
|
||
|
|
||
|
<span class="keywordflow">if</span> (imp.when)
|
||
|
{
|
||
|
<span class="comment">// create impact note</span>
|
||
|
imp.when = Game->Device->getTimer()->getTime() +
|
||
|
(time + (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) ( ( 1.f + Noiser::get() ) * 250.f ));
|
||
|
Impacts.push_back(imp);
|
||
|
}
|
||
|
|
||
|
<span class="comment">// play sound</span>
|
||
|
}
|
||
|
|
||
|
<span class="comment">// rendered when bullets hit something</span>
|
||
|
<span class="keywordtype">void</span> CQuake3EventHandler::createParticleImpacts( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> now )
|
||
|
{
|
||
|
ISceneManager* sm = Game->Device->getSceneManager();
|
||
|
|
||
|
<span class="keyword">struct </span>smokeLayer
|
||
|
{
|
||
|
<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> * texture;
|
||
|
<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> scale;
|
||
|
<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> minparticleSize;
|
||
|
<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> maxparticleSize;
|
||
|
<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> boxSize;
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> minParticle;
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> maxParticle;
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> fadeout;
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> lifetime;
|
||
|
};
|
||
|
|
||
|
smokeLayer smoke[] =
|
||
|
{
|
||
|
{ <span class="stringliteral">"smoke2.jpg"</span>, 0.4f, 1.5f, 18.f, 20.f, 20, 50, 2000, 10000 },
|
||
|
{ <span class="stringliteral">"smoke3.jpg"</span>, 0.2f, 1.2f, 15.f, 20.f, 10, 30, 1000, 12000 }
|
||
|
};
|
||
|
|
||
|
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i;
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> g;
|
||
|
<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> factor = 1;
|
||
|
<span class="keywordflow">for</span> ( g = 0; g != 2; ++g )
|
||
|
{
|
||
|
smoke[g].minParticle *= factor;
|
||
|
smoke[g].maxParticle *= factor;
|
||
|
smoke[g].lifetime *= factor;
|
||
|
smoke[g].boxSize *= Noiser::get() * 0.5f;
|
||
|
}
|
||
|
|
||
|
<span class="keywordflow">for</span> ( i=0; i < Impacts.size(); ++i)
|
||
|
{
|
||
|
<span class="keywordflow">if</span> (now < Impacts[i].when)
|
||
|
<span class="keywordflow">continue</span>;
|
||
|
|
||
|
<span class="comment">// create smoke particle system</span>
|
||
|
IParticleSystemSceneNode* pas = 0;
|
||
|
|
||
|
<span class="keywordflow">for</span> ( g = 0; g != 2; ++g )
|
||
|
{
|
||
|
pas = sm->addParticleSystemSceneNode(<span class="keyword">false</span>, BulletParent, -1, Impacts[i].pos);
|
||
|
|
||
|
snprintf ( buf, 64, <span class="stringliteral">"bullet impact smoke at %.1f,%.1f,%1.f"</span>,
|
||
|
Impacts[i].pos.X,Impacts[i].pos.Y,Impacts[i].pos.Z);
|
||
|
pas->setName ( buf );
|
||
|
|
||
|
<span class="comment">// create a flat smoke</span>
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> direction = Impacts[i].outVector;
|
||
|
direction *= smoke[g].scale;
|
||
|
IParticleEmitter* em = pas->createBoxEmitter(
|
||
|
aabbox3d<f32>(-4.f,0.f,-4.f,20.f,smoke[g].minparticleSize,20.f),
|
||
|
direction,smoke[g].minParticle, smoke[g].maxParticle,
|
||
|
video::SColor(0,0,0,0),video::SColor(0,128,128,128),
|
||
|
250,4000, 60);
|
||
|
|
||
|
em->setMinStartSize (dimension2d<f32>( smoke[g].minparticleSize, smoke[g].minparticleSize));
|
||
|
em->setMaxStartSize (dimension2d<f32>( smoke[g].maxparticleSize, smoke[g].maxparticleSize));
|
||
|
|
||
|
pas->setEmitter(em);
|
||
|
em->drop();
|
||
|
|
||
|
<span class="comment">// particles get invisible</span>
|
||
|
IParticleAffector* paf = pas->createFadeOutParticleAffector(
|
||
|
video::SColor ( 0, 0, 0, 0 ), smoke[g].fadeout);
|
||
|
pas->addAffector(paf);
|
||
|
paf->drop();
|
||
|
|
||
|
<span class="comment">// particle system life time</span>
|
||
|
ISceneNodeAnimator* anim = sm->createDeleteAnimator( smoke[g].lifetime);
|
||
|
pas->addAnimator(anim);
|
||
|
anim->drop();
|
||
|
|
||
|
pas->setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3acea597a2692b8415486a464a7f954d34" title="Will this material be lighted? Default: true.">video::EMF_LIGHTING</a>, <span class="keyword">false</span>);
|
||
|
pas->setMaterialFlag(<a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a4bc03b7b9dd19e577bf909313ea62510" title="May be written to the zbuffer or is it readonly. Default: true.">video::EMF_ZWRITE_ENABLE</a>, <span class="keyword">false</span>);
|
||
|
pas->setMaterialType(<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a1b5a814c4466aca2943ff056003a50d1" title="A transparent material.">video::EMT_TRANSPARENT_ADD_COLOR</a> );
|
||
|
pas->setMaterialTexture(0, Game->Device->getVideoDriver()->getTexture( smoke[g].texture ));
|
||
|
}
|
||
|
|
||
|
|
||
|
<span class="comment">// play impact sound</span>
|
||
|
<span class="preprocessor"> #ifdef USE_IRRKLANG</span>
|
||
|
</pre></div><p>if (irrKlang) { audio::ISound* sound = irrKlang->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->setMinDistance(400); sound->drop(); } } </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="preprocessor"> #endif</span>
|
||
|
<span class="preprocessor"></span>
|
||
|
|
||
|
<span class="comment">// delete entry</span>
|
||
|
Impacts.erase(i);
|
||
|
i--;
|
||
|
}
|
||
|
}
|
||
|
</pre></div><p>render </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::Render()
|
||
|
{
|
||
|
IVideoDriver * driver = Game->Device->getVideoDriver();
|
||
|
<span class="keywordflow">if</span> ( 0 == driver )
|
||
|
<span class="keywordflow">return</span>;
|
||
|
|
||
|
<span class="comment">// TODO: This does not work, yet.</span>
|
||
|
<span class="keyword">const</span> <span class="keywordtype">bool</span> anaglyph=<span class="keyword">false</span>;
|
||
|
<span class="keywordflow">if</span> (anaglyph)
|
||
|
{
|
||
|
scene::ICameraSceneNode* cameraOld = Game->Device->getSceneManager()->getActiveCamera();
|
||
|
driver->beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, SColor(0,0,0,0));
|
||
|
driver->getOverrideMaterial().Material.ColorMask = <a class="code" href="namespaceirr_1_1video.html#aa9f25191ae536c1a4b08ec5334866a21aa5afe366b19c967f884d0bd4ca083df9" title="No color enabled.">ECP_NONE</a>;
|
||
|
driver->getOverrideMaterial().EnableFlags = <a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a72ede4598946d81f12aa407fb680fc40" title="ColorMask bits, for enabling the color planes.">EMF_COLOR_MASK</a>;
|
||
|
driver->getOverrideMaterial().EnablePasses = <a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fac41f4cb4900e84b9e55462089d0e3cb8" title="This is used for sky boxes.">ESNRP_SKY_BOX</a> +
|
||
|
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fad058b020ab42ad745cc03fe379148e1f" title="Solid scene nodes or special scene nodes without materials.">ESNRP_SOLID</a> +
|
||
|
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fad3a1300505d0ab06133e25256b893b2b" title="Transparent scene nodes, drawn after solid nodes. They are sorted from back to front and drawn in tha...">ESNRP_TRANSPARENT</a> +
|
||
|
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fa3d134d3f703e328ab5798e5ff4a5c186" title="Transparent effect scene nodes, drawn after Transparent nodes. They are sorted from back to front and...">ESNRP_TRANSPARENT_EFFECT</a> +
|
||
|
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fadbc7353e3092974abaa4d063faa22421" title="Drawn after the solid nodes, before the transparent nodes, the time for drawing shadow volumes...">ESNRP_SHADOW</a>;
|
||
|
Game->Device->getSceneManager()->drawAll();
|
||
|
driver->clearZBuffer();
|
||
|
|
||
|
<span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> oldPosition = cameraOld->getPosition();
|
||
|
<span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> oldTarget = cameraOld->getTarget();
|
||
|
<span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a73fa92e638c5ca97efd72da307cc9b65" title="Typedef for f32 matrix.">matrix4</a> startMatrix = cameraOld->getAbsoluteTransformation();
|
||
|
<span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> focusPoint = (oldTarget -
|
||
|
cameraOld->getAbsolutePosition()).setLength(10000) +
|
||
|
cameraOld->getAbsolutePosition() ;
|
||
|
|
||
|
scene::ICameraSceneNode* camera = cameraOld;<span class="comment">//Game->Device->getSceneManager()->addCameraSceneNode();</span>
|
||
|
|
||
|
<span class="comment">//Left eye...</span>
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> pos;
|
||
|
<a class="code" href="namespaceirr_1_1core.html#a73fa92e638c5ca97efd72da307cc9b65" title="Typedef for f32 matrix.">matrix4</a> move;
|
||
|
|
||
|
move.setTranslation( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(-1.5f,0.0f,0.0f) );
|
||
|
pos=(startMatrix*move).getTranslation();
|
||
|
|
||
|
driver->getOverrideMaterial().Material.ColorMask = <a class="code" href="namespaceirr_1_1video.html#aa9f25191ae536c1a4b08ec5334866a21a36263a436337ff10be86fc9b5ae2f6d0" title="Red enabled.">ECP_RED</a>;
|
||
|
driver->getOverrideMaterial().EnableFlags = <a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a72ede4598946d81f12aa407fb680fc40" title="ColorMask bits, for enabling the color planes.">EMF_COLOR_MASK</a>;
|
||
|
driver->getOverrideMaterial().EnablePasses =
|
||
|
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fac41f4cb4900e84b9e55462089d0e3cb8" title="This is used for sky boxes.">ESNRP_SKY_BOX</a>|<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fad058b020ab42ad745cc03fe379148e1f" title="Solid scene nodes or special scene nodes without materials.">ESNRP_SOLID</a>|<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fad3a1300505d0ab06133e25256b893b2b" title="Transparent scene nodes, drawn after solid nodes. They are sorted from back to front and drawn in tha...">ESNRP_TRANSPARENT</a>|
|
||
|
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fa3d134d3f703e328ab5798e5ff4a5c186" title="Transparent effect scene nodes, drawn after Transparent nodes. They are sorted from back to front and...">ESNRP_TRANSPARENT_EFFECT</a>|<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fadbc7353e3092974abaa4d063faa22421" title="Drawn after the solid nodes, before the transparent nodes, the time for drawing shadow volumes...">ESNRP_SHADOW</a>;
|
||
|
|
||
|
camera->setPosition(pos);
|
||
|
camera->setTarget(focusPoint);
|
||
|
|
||
|
Game->Device->getSceneManager()->drawAll();
|
||
|
driver->clearZBuffer();
|
||
|
|
||
|
<span class="comment">//Right eye...</span>
|
||
|
move.setTranslation( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(1.5f,0.0f,0.0f) );
|
||
|
pos=(startMatrix*move).getTranslation();
|
||
|
|
||
|
driver->getOverrideMaterial().Material.ColorMask = <a class="code" href="namespaceirr_1_1video.html#aa9f25191ae536c1a4b08ec5334866a21a1e712fd8781a461da6f0a293a3e7180f" title="Green enabled.">ECP_GREEN</a> + <a class="code" href="namespaceirr_1_1video.html#aa9f25191ae536c1a4b08ec5334866a21a31e270dab7c29a6e642ac491b172d16d" title="Blue enabled.">ECP_BLUE</a>;
|
||
|
driver->getOverrideMaterial().EnableFlags = <a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a72ede4598946d81f12aa407fb680fc40" title="ColorMask bits, for enabling the color planes.">EMF_COLOR_MASK</a>;
|
||
|
driver->getOverrideMaterial().EnablePasses =
|
||
|
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fac41f4cb4900e84b9e55462089d0e3cb8" title="This is used for sky boxes.">ESNRP_SKY_BOX</a>|<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fad058b020ab42ad745cc03fe379148e1f" title="Solid scene nodes or special scene nodes without materials.">ESNRP_SOLID</a>|<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fad3a1300505d0ab06133e25256b893b2b" title="Transparent scene nodes, drawn after solid nodes. They are sorted from back to front and drawn in tha...">ESNRP_TRANSPARENT</a>|
|
||
|
<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fa3d134d3f703e328ab5798e5ff4a5c186" title="Transparent effect scene nodes, drawn after Transparent nodes. They are sorted from back to front and...">ESNRP_TRANSPARENT_EFFECT</a>|<a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fadbc7353e3092974abaa4d063faa22421" title="Drawn after the solid nodes, before the transparent nodes, the time for drawing shadow volumes...">ESNRP_SHADOW</a>;
|
||
|
|
||
|
camera->setPosition(pos);
|
||
|
camera->setTarget(focusPoint);
|
||
|
|
||
|
Game->Device->getSceneManager()->drawAll();
|
||
|
|
||
|
driver->getOverrideMaterial().Material.ColorMask=<a class="code" href="namespaceirr_1_1video.html#aa9f25191ae536c1a4b08ec5334866a21a674ec773096b1b504b38ed78213e1e38" title="All planes enabled.">ECP_ALL</a>;
|
||
|
driver->getOverrideMaterial().EnableFlags=0;
|
||
|
driver->getOverrideMaterial().EnablePasses=0;
|
||
|
|
||
|
<span class="keywordflow">if</span> (camera != cameraOld)
|
||
|
{
|
||
|
Game->Device->getSceneManager()->setActiveCamera(cameraOld);
|
||
|
camera->remove();
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
{
|
||
|
camera->setPosition(oldPosition);
|
||
|
camera->setTarget(oldTarget);
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
{
|
||
|
driver->beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, SColor(0,0,0,0));
|
||
|
Game->Device->getSceneManager()->drawAll();
|
||
|
}
|
||
|
Game->Device->getGUIEnvironment()->drawAll();
|
||
|
driver->endScene();
|
||
|
}
|
||
|
</pre></div><p>update the generic scene node </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::Animate()
|
||
|
{
|
||
|
<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> now = Game->Device->getTimer()->getTime();
|
||
|
|
||
|
Q3Player * player = Player + 0;
|
||
|
|
||
|
checkTimeFire ( player->Anim, 4, now );
|
||
|
|
||
|
<span class="comment">// Query Scene Manager attributes</span>
|
||
|
<span class="keywordflow">if</span> ( player->Anim[0].flags & FIRED )
|
||
|
{
|
||
|
ISceneManager *smgr = Game->Device->getSceneManager ();
|
||
|
<span class="keywordtype">wchar_t</span> msg[128];
|
||
|
IVideoDriver * driver = Game->Device->getVideoDriver();
|
||
|
|
||
|
IAttributes * attr = smgr->getParameters();
|
||
|
<span class="preprocessor">#ifdef _IRR_SCENEMANAGER_DEBUG </span>
|
||
|
<span class="preprocessor"></span> swprintf ( msg, 128,
|
||
|
L<span class="stringliteral">"Q3 %s [%ls], FPS:%03d Tri:%.03fm Cull %d/%d nodes (%d,%d,%d)"</span>,
|
||
|
Game->CurrentMapName.c_str(),
|
||
|
driver->getName(),
|
||
|
driver->getFPS (),
|
||
|
(<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>) driver->getPrimitiveCountDrawn( 0 ) * ( 1.f / 1000000.f ),
|
||
|
attr->getAttributeAsInt ( <span class="stringliteral">"culled"</span> ),
|
||
|
attr->getAttributeAsInt ( <span class="stringliteral">"calls"</span> ),
|
||
|
attr->getAttributeAsInt ( <span class="stringliteral">"drawn_solid"</span> ),
|
||
|
attr->getAttributeAsInt ( <span class="stringliteral">"drawn_transparent"</span> ),
|
||
|
attr->getAttributeAsInt ( <span class="stringliteral">"drawn_transparent_effect"</span> )
|
||
|
);
|
||
|
<span class="preprocessor">#else</span>
|
||
|
<span class="preprocessor"></span>swprintf ( msg, 128,
|
||
|
L<span class="stringliteral">"Q3 %s [%ls], FPS:%03d Tri:%.03fm"</span>,
|
||
|
Game->CurrentMapName.c_str(),
|
||
|
driver->getName(),
|
||
|
driver->getFPS (),
|
||
|
(<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>) driver->getPrimitiveCountDrawn( 0 ) * ( 1.f / 1000000.f )
|
||
|
);
|
||
|
<span class="preprocessor">#endif </span>
|
||
|
<span class="preprocessor"></span> Game->Device->setWindowCaption( msg );
|
||
|
|
||
|
swprintf ( msg, 128,
|
||
|
L<span class="stringliteral">"%03d fps, F1 GUI on/off, F2 respawn, F3-F6 toggle Nodes, F7 Collision on/off"</span>
|
||
|
L<span class="stringliteral">", F8 Gravity on/off, Right Mouse Toggle GUI"</span>,
|
||
|
Game->Device->getVideoDriver()->getFPS ()
|
||
|
);
|
||
|
<span class="keywordflow">if</span> ( gui.StatusLine )
|
||
|
gui.StatusLine->setText ( msg );
|
||
|
player->Anim[0].flags &= ~FIRED;
|
||
|
}
|
||
|
|
||
|
<span class="comment">// idle..</span>
|
||
|
<span class="keywordflow">if</span> ( player->Anim[1].flags & FIRED )
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( strcmp ( player->animation, <span class="stringliteral">"idle"</span> ) )
|
||
|
player->setAnim ( <span class="stringliteral">"idle"</span> );
|
||
|
|
||
|
player->Anim[1].flags &= ~FIRED;
|
||
|
}
|
||
|
|
||
|
createParticleImpacts ( now );
|
||
|
|
||
|
}
|
||
|
</pre></div><p> The main game states </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> runGame ( GameData *game )
|
||
|
{
|
||
|
<span class="keywordflow">if</span> ( game->retVal >= 3 )
|
||
|
<span class="keywordflow">return</span>;
|
||
|
|
||
|
game->Device = (*game->createExDevice) ( game->deviceParam );
|
||
|
<span class="keywordflow">if</span> ( 0 == game->Device)
|
||
|
{
|
||
|
<span class="comment">// could not create selected driver.</span>
|
||
|
game->retVal = 0;
|
||
|
<span class="keywordflow">return</span>;
|
||
|
}
|
||
|
|
||
|
<span class="comment">// create an event receiver based on current game data</span>
|
||
|
CQuake3EventHandler *eventHandler = <span class="keyword">new</span> CQuake3EventHandler( game );
|
||
|
|
||
|
<span class="comment">// load stored config</span>
|
||
|
game->load ( <span class="stringliteral">"explorer.cfg"</span> );
|
||
|
|
||
|
<span class="comment">// add our media directory and archive to the file system</span>
|
||
|
<span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i = 0; i < game->CurrentArchiveList.size(); ++i )
|
||
|
{
|
||
|
eventHandler->AddArchive ( game->CurrentArchiveList[i] );
|
||
|
}
|
||
|
|
||
|
<span class="comment">// Load a Map or startup to the GUI</span>
|
||
|
<span class="keywordflow">if</span> ( game->CurrentMapName.size () )
|
||
|
{
|
||
|
eventHandler->LoadMap ( game->CurrentMapName, 1 );
|
||
|
<span class="keywordflow">if</span> ( 0 == game->loadParam.loadSkyShader )
|
||
|
eventHandler->AddSky ( 1, <span class="stringliteral">"skydome2"</span> );
|
||
|
eventHandler->CreatePlayers ();
|
||
|
eventHandler->CreateGUI ();
|
||
|
eventHandler->SetGUIActive ( 0 );
|
||
|
|
||
|
<span class="comment">// set player to last position on restart</span>
|
||
|
<span class="keywordflow">if</span> ( game->retVal == 2 )
|
||
|
{
|
||
|
eventHandler->GetPlayer( 0 )->setpos ( game->PlayerPosition, game->PlayerRotation );
|
||
|
}
|
||
|
}
|
||
|
<span class="keywordflow">else</span>
|
||
|
{
|
||
|
<span class="comment">// start up empty</span>
|
||
|
eventHandler->AddSky ( 1, <span class="stringliteral">"skydome2"</span> );
|
||
|
eventHandler->CreatePlayers ();
|
||
|
eventHandler->CreateGUI ();
|
||
|
eventHandler->SetGUIActive ( 1 );
|
||
|
background_music ( <span class="stringliteral">"IrrlichtTheme.ogg"</span> );
|
||
|
}
|
||
|
|
||
|
|
||
|
game->retVal = 3;
|
||
|
<span class="keywordflow">while</span>( game->Device->run() )
|
||
|
{
|
||
|
eventHandler->Animate ();
|
||
|
eventHandler->Render ();
|
||
|
<span class="comment">//if ( !game->Device->isWindowActive() )</span>
|
||
|
game->Device->yield();
|
||
|
}
|
||
|
|
||
|
game->Device->setGammaRamp ( 1.f, 1.f, 1.f, 0.f, 0.f );
|
||
|
<span class="keyword">delete</span> eventHandler;
|
||
|
}
|
||
|
|
||
|
<span class="preprocessor">#if defined (_IRR_WINDOWS_) && 0</span>
|
||
|
<span class="preprocessor"></span><span class="preprocessor"> #pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")</span>
|
||
|
<span class="preprocessor">#endif</span>
|
||
|
</pre></div><p> The main routine, doing all setup </p>
|
||
|
<div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> <a class="code" href="_irr_compile_config_8h.html#a3f9bf2240c47d3f99b86f83f9123aa9d">IRRCALLCONV</a> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
|
||
|
{
|
||
|
<a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> prgname(argv[0]);
|
||
|
GameData game ( <a class="code" href="namespaceirr_1_1core.html#a9215d20e34c12cb6c1522366389bfcce" title="trim paths">deletePathFromPath</a> ( prgname, 1 ) );
|
||
|
|
||
|
<span class="comment">// dynamically load irrlicht</span>
|
||
|
<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> * dllName = argc > 1 ? argv[1] : <span class="stringliteral">"irrlicht.dll"</span>;
|
||
|
game.createExDevice = load_createDeviceEx ( dllName );
|
||
|
<span class="keywordflow">if</span> ( 0 == game.createExDevice )
|
||
|
{
|
||
|
game.retVal = 3;
|
||
|
printf ( <span class="stringliteral">"Could not load %s.\n"</span>, dllName );
|
||
|
<span class="keywordflow">return</span> game.retVal; <span class="comment">// could not load dll</span>
|
||
|
}
|
||
|
|
||
|
<span class="comment">// start without asking for driver</span>
|
||
|
game.retVal = 1;
|
||
|
<span class="keywordflow">do</span>
|
||
|
{
|
||
|
<span class="comment">// if driver could not created, ask for another driver</span>
|
||
|
<span class="keywordflow">if</span> ( game.retVal == 0 )
|
||
|
{
|
||
|
game.setDefault ();
|
||
|
<span class="comment">// ask user for driver</span>
|
||
|
game.deviceParam.DriverType=driverChoiceConsole();
|
||
|
<span class="keywordflow">if</span> (game.deviceParam.DriverType==<a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0ae685cada50f8c100403134d932d0414c" title="No driver, just for counting the elements.">video::EDT_COUNT</a>)
|
||
|
game.retVal = 3;
|
||
|
}
|
||
|
runGame ( &game );
|
||
|
} <span class="keywordflow">while</span> ( game.retVal < 3 );
|
||
|
|
||
|
<span class="keywordflow">return</span> game.retVal;
|
||
|
}
|
||
|
</pre></div> </div></div>
|
||
|
</div>
|
||
|
<div id="nav-path" class="navpath">
|
||
|
<ul>
|
||
|
<!-- window showing the filter options -->
|
||
|
<div id="MSearchSelectWindow"
|
||
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
||
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
||
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||
|
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark"> </span>Defines</a></div>
|
||
|
|
||
|
<!-- iframe showing the search results (closed by default) -->
|
||
|
<div id="MSearchResultsWindow">
|
||
|
<iframe src="javascript:void(0)" frameborder="0"
|
||
|
name="MSearchResults" id="MSearchResults">
|
||
|
</iframe>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<li class="footer">
|
||
|
<a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht
|
||
|
Engine</a> Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on Sat Jul 9 2016 18:18:27 for Irrlicht 3D Engine by
|
||
|
<a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|