diff options
author | David Walter Seikel | 2014-01-13 19:47:58 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-01-13 19:47:58 +1000 |
commit | f9158592e1478b2013afc7041d9ed041cf2d2f4a (patch) | |
tree | b16e389d7988700e21b4c9741044cefa536dcbae /libraries/irrlicht-1.8.1/doc/html/example021.html | |
parent | Libraries readme updated with change markers and more of the Irrlicht changes. (diff) | |
download | SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.zip SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.gz SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.bz2 SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.xz |
Update Irrlicht to 1.8.1. Include actual change markers this time. lol
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8.1/doc/html/example021.html | 2190 |
1 files changed, 2190 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8.1/doc/html/example021.html b/libraries/irrlicht-1.8.1/doc/html/example021.html new file mode 100644 index 0000000..8a0f3c4 --- /dev/null +++ b/libraries/irrlicht-1.8.1/doc/html/example021.html | |||
@@ -0,0 +1,2190 @@ | |||
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
2 | <html xmlns="http://www.w3.org/1999/xhtml"> | ||
3 | <head> | ||
4 | <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> | ||
5 | <title>Irrlicht 3D Engine: Tutorial 21: Quake3 Explorer</title> | ||
6 | |||
7 | <link href="tabs.css" rel="stylesheet" type="text/css"/> | ||
8 | <link href="doxygen.css" rel="stylesheet" type="text/css" /> | ||
9 | <link href="navtree.css" rel="stylesheet" type="text/css"/> | ||
10 | <script type="text/javascript" src="jquery.js"></script> | ||
11 | <script type="text/javascript" src="resize.js"></script> | ||
12 | <script type="text/javascript" src="navtree.js"></script> | ||
13 | <script type="text/javascript"> | ||
14 | $(document).ready(initResizable); | ||
15 | </script> | ||
16 | <link href="search/search.css" rel="stylesheet" type="text/css"/> | ||
17 | <script type="text/javascript" src="search/search.js"></script> | ||
18 | <script type="text/javascript"> | ||
19 | $(document).ready(function() { searchBox.OnSelectItem(0); }); | ||
20 | </script> | ||
21 | |||
22 | </head> | ||
23 | <body> | ||
24 | <div id="top"><!-- do not remove this div! --> | ||
25 | |||
26 | |||
27 | <div id="titlearea"> | ||
28 | <table cellspacing="0" cellpadding="0"> | ||
29 | <tbody> | ||
30 | <tr style="height: 56px;"> | ||
31 | |||
32 | <td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td> | ||
33 | |||
34 | |||
35 | <td style="padding-left: 0.5em;"> | ||
36 | <div id="projectname">Irrlicht 3D Engine | ||
37 | |||
38 | </div> | ||
39 | |||
40 | </td> | ||
41 | |||
42 | |||
43 | |||
44 | |||
45 | <td> <div id="MSearchBox" class="MSearchBoxInactive"> | ||
46 | <span class="left"> | ||
47 | <img id="MSearchSelect" src="search/mag_sel.png" | ||
48 | onmouseover="return searchBox.OnSearchSelectShow()" | ||
49 | onmouseout="return searchBox.OnSearchSelectHide()" | ||
50 | alt=""/> | ||
51 | <input type="text" id="MSearchField" value="Search" accesskey="S" | ||
52 | onfocus="searchBox.OnSearchFieldFocus(true)" | ||
53 | onblur="searchBox.OnSearchFieldFocus(false)" | ||
54 | onkeyup="searchBox.OnSearchFieldChange(event)"/> | ||
55 | </span><span class="right"> | ||
56 | <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> | ||
57 | </span> | ||
58 | </div> | ||
59 | </td> | ||
60 | |||
61 | |||
62 | </tr> | ||
63 | </tbody> | ||
64 | </table> | ||
65 | </div> | ||
66 | |||
67 | <!-- Generated by Doxygen 1.7.5.1 --> | ||
68 | <script type="text/javascript"> | ||
69 | var searchBox = new SearchBox("searchBox", "search",false,'Search'); | ||
70 | </script> | ||
71 | <script type="text/javascript" src="dynsections.js"></script> | ||
72 | </div> | ||
73 | <div id="side-nav" class="ui-resizable side-nav-resizable"> | ||
74 | <div id="nav-tree"> | ||
75 | <div id="nav-tree-contents"> | ||
76 | </div> | ||
77 | </div> | ||
78 | <div id="splitbar" style="-moz-user-select:none;" | ||
79 | class="ui-resizable-handle"> | ||
80 | </div> | ||
81 | </div> | ||
82 | <script type="text/javascript"> | ||
83 | initNavTree('example021.html',''); | ||
84 | </script> | ||
85 | <div id="doc-content"> | ||
86 | <div class="header"> | ||
87 | <div class="headertitle"> | ||
88 | <div class="title">Tutorial 21: Quake3 Explorer </div> </div> | ||
89 | </div> | ||
90 | <div class="contents"> | ||
91 | <div class="textblock"><div class="image"> | ||
92 | <img src="021shot.jpg" alt="021shot.jpg"/> | ||
93 | </div> | ||
94 | <p>This Tutorial shows how to load different Quake 3 maps.</p> | ||
95 | <p>Features:</p> | ||
96 | <ul> | ||
97 | <li>Load BSP Archives at Runtime from the menu</li> | ||
98 | <li>Load a Map from the menu. Showing with Screenshot</li> | ||
99 | <li>Set the VideoDriver at runtime from menu</li> | ||
100 | <li>Adjust GammaLevel at runtime</li> | ||
101 | <li>Create SceneNodes for the Shaders</li> | ||
102 | <li>Load EntityList and create Entity SceneNodes</li> | ||
103 | <li>Create Players with Weapons and with Collision Response</li> | ||
104 | <li>Play music</li> | ||
105 | </ul> | ||
106 | <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> | ||
107 | <p>Copyright 2006-2011 Burningwater, Thomas Alten </p> | ||
108 | <div class="fragment"><pre class="fragment"><span class="preprocessor">#include "<a class="code" href="driver_choice_8h.html">driverChoice.h</a>"</span> | ||
109 | <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> | ||
110 | <span class="preprocessor">#include "q3factory.h"</span> | ||
111 | <span class="preprocessor">#include "sound.h"</span> | ||
112 | </pre></div><p>Game Data is used to hold Data which is needed to drive the game </p> | ||
113 | <div class="fragment"><pre class="fragment"><span class="keyword">struct </span>GameData | ||
114 | { | ||
115 | 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) : | ||
116 | retVal(0), StartupDir(startupDir), createExDevice(0), Device(0) | ||
117 | { | ||
118 | setDefault (); | ||
119 | } | ||
120 | |||
121 | <span class="keywordtype">void</span> setDefault (); | ||
122 | <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 ); | ||
123 | <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 ); | ||
124 | |||
125 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> debugState; | ||
126 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> gravityState; | ||
127 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> flyTroughState; | ||
128 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> wireFrame; | ||
129 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> guiActive; | ||
130 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> guiInputActive; | ||
131 | <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> GammaValue; | ||
132 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> retVal; | ||
133 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> sound; | ||
134 | |||
135 | <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> StartupDir; | ||
136 | <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> CurrentMapName; | ||
137 | array<path> CurrentArchiveList; | ||
138 | |||
139 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> PlayerPosition; | ||
140 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> PlayerRotation; | ||
141 | |||
142 | <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a312f35a37540d810fcb14b75fd449c9e">tQ3EntityList</a> Variable; | ||
143 | |||
144 | Q3LevelLoadParameter loadParam; | ||
145 | SIrrlichtCreationParameters deviceParam; | ||
146 | <a class="code" href="namespaceirr.html#a5137701377b2241305607fc37a27e9f8" title="typedef for Function Pointer">funcptr_createDeviceEx</a> createExDevice; | ||
147 | IrrlichtDevice *Device; | ||
148 | }; | ||
149 | </pre></div><p>set default settings </p> | ||
150 | <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> GameData::setDefault () | ||
151 | { | ||
152 | debugState = <a class="code" href="namespaceirr_1_1scene.html#a52b664c4c988113735042b168fc32dbea25111b15f03bee9a99498737286916dc" title="No Debug Data ( Default )">EDS_OFF</a>; | ||
153 | gravityState = 1; | ||
154 | flyTroughState = 0; | ||
155 | wireFrame = 0; | ||
156 | guiActive = 1; | ||
157 | guiInputActive = 0; | ||
158 | GammaValue = 1.f; | ||
159 | |||
160 | <span class="comment">// default deviceParam;</span> | ||
161 | <span class="preprocessor">#if defined ( _IRR_WINDOWS_ )</span> | ||
162 | <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>; | ||
163 | <span class="preprocessor">#else</span> | ||
164 | <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>; | ||
165 | <span class="preprocessor">#endif</span> | ||
166 | <span class="preprocessor"></span> deviceParam.WindowSize.Width = 800; | ||
167 | deviceParam.WindowSize.Height = 600; | ||
168 | deviceParam.Fullscreen = <span class="keyword">false</span>; | ||
169 | deviceParam.Bits = 24; | ||
170 | deviceParam.ZBufferBits = 16; | ||
171 | deviceParam.Vsync = <span class="keyword">false</span>; | ||
172 | deviceParam.AntiAlias = <span class="keyword">false</span>; | ||
173 | |||
174 | <span class="comment">// default Quake3 loadParam</span> | ||
175 | loadParam.defaultLightMapMaterial = <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a5dc90a3b4a8d82f10503ddf834a3143f" title="Material type with standard lightmap technique.">EMT_LIGHTMAP</a>; | ||
176 | loadParam.defaultModulate = <a class="code" href="namespaceirr_1_1video.html#a1402e9045137ae232fafbdf385800843a58cc346f344fb488d403a3783675e5d7">EMFN_MODULATE_1X</a>; | ||
177 | loadParam.defaultFilter = <a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a941c0756b9dc3f987a183a401c6fd4ad" title="Is anisotropic filtering? Default: false.">EMF_ANISOTROPIC_FILTER</a>; | ||
178 | loadParam.verbose = 2; | ||
179 | loadParam.mergeShaderBuffer = 1; <span class="comment">// merge meshbuffers with same material</span> | ||
180 | loadParam.cleanUnResolvedMeshes = 1; <span class="comment">// should unresolved meshes be cleaned. otherwise blue texture</span> | ||
181 | loadParam.loadAllShaders = 1; <span class="comment">// load all scripts in the script directory</span> | ||
182 | loadParam.loadSkyShader = 0; <span class="comment">// load sky Shader</span> | ||
183 | loadParam.alpharef = 1; | ||
184 | |||
185 | sound = 0; | ||
186 | |||
187 | CurrentMapName = <span class="stringliteral">""</span>; | ||
188 | CurrentArchiveList.clear (); | ||
189 | |||
190 | <span class="comment">// Explorer Media directory</span> | ||
191 | CurrentArchiveList.push_back ( StartupDir + <span class="stringliteral">"../../media/"</span> ); | ||
192 | |||
193 | <span class="comment">// Add the original quake3 files before you load your custom map</span> | ||
194 | <span class="comment">// Most mods are using the original shaders, models&items&weapons</span> | ||
195 | CurrentArchiveList.push_back(<span class="stringliteral">"/q/baseq3/"</span>); | ||
196 | |||
197 | CurrentArchiveList.push_back(StartupDir + <span class="stringliteral">"../../media/map-20kdm2.pk3"</span>); | ||
198 | } | ||
199 | </pre></div><p>Load the current game State from a typical quake3 cfg file </p> | ||
200 | <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 ) | ||
201 | { | ||
202 | <span class="keywordflow">if</span> (!Device) | ||
203 | <span class="keywordflow">return</span> 0; | ||
204 | |||
205 | <span class="comment">// the quake3 mesh loader can also handle *.shader and *.cfg file</span> | ||
206 | IQ3LevelMesh* mesh = (IQ3LevelMesh*) Device->getSceneManager()->getMesh ( filename ); | ||
207 | <span class="keywordflow">if</span> (!mesh) | ||
208 | <span class="keywordflow">return</span> 0; | ||
209 | |||
210 | <a class="code" href="namespaceirr_1_1scene_1_1quake3.html#a312f35a37540d810fcb14b75fd449c9e">tQ3EntityList</a> &entityList = mesh->getEntityList (); | ||
211 | |||
212 | <a class="code" href="namespaceirr_1_1core.html#ade1071a878633f2f6d8a75c5d11fec19" title="Typedef for character strings.">stringc</a> s; | ||
213 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> pos; | ||
214 | |||
215 | <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 ) | ||
216 | { | ||
217 | <span class="comment">//dumpShader ( s, &entityList[e], false );</span> | ||
218 | <span class="comment">//printf ( s.c_str () );</span> | ||
219 | |||
220 | <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 ) | ||
221 | { | ||
222 | <span class="keyword">const</span> SVarGroup *group = entityList[e].getGroup ( g ); | ||
223 | |||
224 | <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 ) | ||
225 | { | ||
226 | <span class="keyword">const</span> SVariable &v = group->Variable[index]; | ||
227 | pos = 0; | ||
228 | <span class="keywordflow">if</span> ( v.name == <span class="stringliteral">"playerposition"</span> ) | ||
229 | { | ||
230 | 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 ); | ||
231 | } | ||
232 | <span class="keywordflow">else</span> | ||
233 | <span class="keywordflow">if</span> ( v.name == <span class="stringliteral">"playerrotation"</span> ) | ||
234 | { | ||
235 | 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 ); | ||
236 | } | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | |||
241 | <span class="keywordflow">return</span> 1; | ||
242 | } | ||
243 | </pre></div><p>Store the current game State in a quake3 configuration file </p> | ||
244 | <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 ) | ||
245 | { | ||
246 | <span class="keywordflow">return</span> 0; | ||
247 | <span class="keywordflow">if</span> (!Device) | ||
248 | <span class="keywordflow">return</span> 0; | ||
249 | |||
250 | <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[128]; | ||
251 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i; | ||
252 | |||
253 | <span class="comment">// Store current Archive for restart</span> | ||
254 | CurrentArchiveList.clear(); | ||
255 | IFileSystem *fs = Device->getFileSystem(); | ||
256 | <span class="keywordflow">for</span> ( i = 0; i != fs->getFileArchiveCount(); ++i ) | ||
257 | { | ||
258 | CurrentArchiveList.push_back ( fs->getFileArchive(i)->getFileList()->getPath() ); | ||
259 | } | ||
260 | |||
261 | <span class="comment">// Store Player Position and Rotation</span> | ||
262 | ICameraSceneNode * camera = Device->getSceneManager()->getActiveCamera (); | ||
263 | <span class="keywordflow">if</span> ( camera ) | ||
264 | { | ||
265 | PlayerPosition = camera->getPosition (); | ||
266 | PlayerRotation = camera->getRotation (); | ||
267 | } | ||
268 | |||
269 | IWriteFile *file = fs->createAndWriteFile ( filename ); | ||
270 | <span class="keywordflow">if</span> (!file) | ||
271 | <span class="keywordflow">return</span> 0; | ||
272 | |||
273 | snprintf ( buf, 128, <span class="stringliteral">"playerposition %.f %.f %.f\nplayerrotation %.f %.f %.f\n"</span>, | ||
274 | PlayerPosition.X, PlayerPosition.Z, PlayerPosition.Y, | ||
275 | PlayerRotation.X, PlayerRotation.Z, PlayerRotation.Y); | ||
276 | file->write ( buf, (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) strlen ( buf ) ); | ||
277 | <span class="keywordflow">for</span> ( i = 0; i != fs->getFileArchiveCount(); ++i ) | ||
278 | { | ||
279 | 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 () ); | ||
280 | file->write ( buf, (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) strlen ( buf ) ); | ||
281 | } | ||
282 | |||
283 | file->drop (); | ||
284 | <span class="keywordflow">return</span> 1; | ||
285 | } | ||
286 | </pre></div><p>Representing a player </p> | ||
287 | <div class="fragment"><pre class="fragment"><span class="keyword">struct </span>Q3Player : <span class="keyword">public</span> IAnimationEndCallBack | ||
288 | { | ||
289 | Q3Player () | ||
290 | : Device(0), MapParent(0), Mesh(0), WeaponNode(0), StartPositionCurrent(0) | ||
291 | { | ||
292 | animation[0] = 0; | ||
293 | memset(Anim, 0, <span class="keyword">sizeof</span>(TimeFire)*4); | ||
294 | } | ||
295 | |||
296 | <span class="keyword">virtual</span> <span class="keywordtype">void</span> OnAnimationEnd(IAnimatedMeshSceneNode* node); | ||
297 | |||
298 | <span class="keywordtype">void</span> create ( IrrlichtDevice *device, | ||
299 | IQ3LevelMesh* mesh, | ||
300 | ISceneNode *mapNode, | ||
301 | IMetaTriangleSelector *meta | ||
302 | ); | ||
303 | <span class="keywordtype">void</span> shutdown (); | ||
304 | <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 ); | ||
305 | <span class="keywordtype">void</span> respawn (); | ||
306 | <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 ); | ||
307 | |||
308 | ISceneNodeAnimatorCollisionResponse * cam() { <span class="keywordflow">return</span> camCollisionResponse ( Device ); } | ||
309 | |||
310 | IrrlichtDevice *Device; | ||
311 | ISceneNode* MapParent; | ||
312 | IQ3LevelMesh* Mesh; | ||
313 | IAnimatedMeshSceneNode* WeaponNode; | ||
314 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> StartPositionCurrent; | ||
315 | TimeFire Anim[4]; | ||
316 | <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> animation[64]; | ||
317 | <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[64]; | ||
318 | }; | ||
319 | </pre></div><p> End player </p> | ||
320 | <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::shutdown () | ||
321 | { | ||
322 | setAnim ( 0 ); | ||
323 | |||
324 | dropElement (WeaponNode); | ||
325 | |||
326 | <span class="keywordflow">if</span> ( Device ) | ||
327 | { | ||
328 | ICameraSceneNode* camera = Device->getSceneManager()->getActiveCamera(); | ||
329 | dropElement ( camera ); | ||
330 | Device = 0; | ||
331 | } | ||
332 | |||
333 | MapParent = 0; | ||
334 | Mesh = 0; | ||
335 | } | ||
336 | </pre></div><p> create a new player </p> | ||
337 | <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::create ( IrrlichtDevice *device, IQ3LevelMesh* mesh, ISceneNode *mapNode, IMetaTriangleSelector *meta ) | ||
338 | { | ||
339 | setTimeFire ( Anim + 0, 200, FIRED ); | ||
340 | setTimeFire ( Anim + 1, 5000 ); | ||
341 | |||
342 | <span class="keywordflow">if</span> (!device) | ||
343 | <span class="keywordflow">return</span>; | ||
344 | <span class="comment">// load FPS weapon to Camera</span> | ||
345 | Device = device; | ||
346 | Mesh = mesh; | ||
347 | MapParent = mapNode; | ||
348 | |||
349 | ISceneManager *smgr = device->getSceneManager (); | ||
350 | IVideoDriver * driver = device->getVideoDriver(); | ||
351 | |||
352 | ICameraSceneNode* camera = 0; | ||
353 | |||
354 | SKeyMap keyMap[10]; | ||
355 | keyMap[0].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168af9ff845aa49060787ef81773eeaf1016">EKA_MOVE_FORWARD</a>; | ||
356 | keyMap[0].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae3341f66dcdd3d0cbce80ff741262395">KEY_UP</a>; | ||
357 | keyMap[1].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168af9ff845aa49060787ef81773eeaf1016">EKA_MOVE_FORWARD</a>; | ||
358 | keyMap[1].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae559e3169016a3180c45c2828f391af2">KEY_KEY_W</a>; | ||
359 | |||
360 | keyMap[2].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168af4c724e0a0923e497c7f8a48884e36d9">EKA_MOVE_BACKWARD</a>; | ||
361 | keyMap[2].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3acbab6476bacfd1212c52aba7c1c82886">KEY_DOWN</a>; | ||
362 | keyMap[3].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168af4c724e0a0923e497c7f8a48884e36d9">EKA_MOVE_BACKWARD</a>; | ||
363 | keyMap[3].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae52bafc112fc6c52f6b49cea42fa246e">KEY_KEY_S</a>; | ||
364 | |||
365 | keyMap[4].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a91cad59a86b88c0e6ab5aa75b936d9c7">EKA_STRAFE_LEFT</a>; | ||
366 | keyMap[4].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a71c43cf2c123fd75911fef5501a15241">KEY_LEFT</a>; | ||
367 | keyMap[5].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a91cad59a86b88c0e6ab5aa75b936d9c7">EKA_STRAFE_LEFT</a>; | ||
368 | keyMap[5].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a2fe10b4309013968b9cd14811c3d3c85">KEY_KEY_A</a>; | ||
369 | |||
370 | keyMap[6].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a57c4bd21c235bca312e547c6d1061df2">EKA_STRAFE_RIGHT</a>; | ||
371 | keyMap[6].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ae89f39517a44c78a6602d1b12b478118">KEY_RIGHT</a>; | ||
372 | keyMap[7].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a57c4bd21c235bca312e547c6d1061df2">EKA_STRAFE_RIGHT</a>; | ||
373 | keyMap[7].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3ad20e7e220103e611752b90edeb6cbc9d">KEY_KEY_D</a>; | ||
374 | |||
375 | keyMap[8].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168a574c0935be6337a2e6bc97e8304a7400">EKA_JUMP_UP</a>; | ||
376 | keyMap[8].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a3231acd1573be6e4d121cc6c4ab6ccc4">KEY_KEY_J</a>; | ||
377 | |||
378 | keyMap[9].Action = <a class="code" href="namespaceirr.html#aa9946ac9f3142f9e790ce52d59fd6168aace30d0d2eef7a48f5f863a99dabfb84">EKA_CROUCH</a>; | ||
379 | keyMap[9].KeyCode = <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a85a756fa6a3336312c5f32877a7185e5">KEY_KEY_C</a>; | ||
380 | |||
381 | camera = smgr->addCameraSceneNodeFPS(0, 100.0f, 0.6f, -1, keyMap, 10, <span class="keyword">false</span>, 0.6f); | ||
382 | camera->setName ( <span class="stringliteral">"First Person Camera"</span> ); | ||
383 | <span class="comment">//camera->setFOV ( 100.f * core::DEGTORAD );</span> | ||
384 | camera->setFarValue( 20000.f ); | ||
385 | |||
386 | IAnimatedMeshMD2* weaponMesh = (IAnimatedMeshMD2*) smgr->getMesh(<span class="stringliteral">"gun.md2"</span>); | ||
387 | <span class="keywordflow">if</span> ( 0 == weaponMesh ) | ||
388 | <span class="keywordflow">return</span>; | ||
389 | |||
390 | <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> ) | ||
391 | { | ||
392 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> count = weaponMesh->getAnimationCount(); | ||
393 | <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> i = 0; i != count; ++i ) | ||
394 | { | ||
395 | snprintf ( buf, 64, <span class="stringliteral">"Animation: %s"</span>, weaponMesh->getAnimationName(i) ); | ||
396 | 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>); | ||
397 | } | ||
398 | } | ||
399 | |||
400 | WeaponNode = smgr->addAnimatedMeshSceneNode( | ||
401 | weaponMesh, | ||
402 | smgr->getActiveCamera(), | ||
403 | 10, | ||
404 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>( 0, 0, 0), | ||
405 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(-90,-90,90) | ||
406 | ); | ||
407 | 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>); | ||
408 | WeaponNode->setMaterialTexture(0, driver->getTexture( <span class="stringliteral">"gun.jpg"</span>)); | ||
409 | WeaponNode->setLoopMode ( <span class="keyword">false</span> ); | ||
410 | WeaponNode->setName ( <span class="stringliteral">"tommi the gun man"</span> ); | ||
411 | |||
412 | <span class="comment">//create a collision auto response animator</span> | ||
413 | ISceneNodeAnimator* anim = | ||
414 | smgr->createCollisionResponseAnimator( meta, camera, | ||
415 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(30,45,30), | ||
416 | getGravity ( <span class="stringliteral">"earth"</span> ), | ||
417 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0,40,0), | ||
418 | 0.0005f | ||
419 | ); | ||
420 | |||
421 | camera->addAnimator( anim ); | ||
422 | anim->drop(); | ||
423 | |||
424 | <span class="keywordflow">if</span> ( meta ) | ||
425 | { | ||
426 | meta->drop (); | ||
427 | } | ||
428 | |||
429 | respawn (); | ||
430 | setAnim ( <span class="stringliteral">"idle"</span> ); | ||
431 | } | ||
432 | </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> | ||
433 | <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> Q3Player::respawn () | ||
434 | { | ||
435 | <span class="keywordflow">if</span> (!Device) | ||
436 | <span class="keywordflow">return</span>; | ||
437 | ICameraSceneNode* camera = Device->getSceneManager()->getActiveCamera(); | ||
438 | |||
439 | Device->getLogger()->log( <span class="stringliteral">"respawn"</span> ); | ||
440 | |||
441 | <span class="keywordflow">if</span> ( StartPositionCurrent >= Q3StartPosition ( | ||
442 | Mesh, camera,StartPositionCurrent++, | ||
443 | cam ()->getEllipsoidTranslation() ) | ||
444 | ) | ||
445 | { | ||
446 | StartPositionCurrent = 0; | ||
447 | } | ||
448 | } | ||
449 | </pre></div><p>set Player position from saved coordinates </p> | ||
450 | <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 ) | ||
451 | { | ||
452 | <span class="keywordflow">if</span> (!Device) | ||
453 | <span class="keywordflow">return</span>; | ||
454 | Device->getLogger()->log( <span class="stringliteral">"setpos"</span> ); | ||
455 | |||
456 | ICameraSceneNode* camera = Device->getSceneManager()->getActiveCamera(); | ||
457 | <span class="keywordflow">if</span> ( camera ) | ||
458 | { | ||
459 | camera->setPosition ( pos ); | ||
460 | camera->setRotation ( rotation ); | ||
461 | camera->OnAnimate ( 0 ); | ||
462 | } | ||
463 | } | ||
464 | </pre></div><p> set the Animation of the player and weapon </p> | ||
465 | <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 ) | ||
466 | { | ||
467 | <span class="keywordflow">if</span> ( name ) | ||
468 | { | ||
469 | snprintf ( animation, 64, <span class="stringliteral">"%s"</span>, name ); | ||
470 | <span class="keywordflow">if</span> ( WeaponNode ) | ||
471 | { | ||
472 | WeaponNode->setAnimationEndCallback ( <span class="keyword">this</span> ); | ||
473 | WeaponNode->setMD2Animation ( animation ); | ||
474 | } | ||
475 | } | ||
476 | <span class="keywordflow">else</span> | ||
477 | { | ||
478 | animation[0] = 0; | ||
479 | <span class="keywordflow">if</span> ( WeaponNode ) | ||
480 | { | ||
481 | WeaponNode->setAnimationEndCallback ( 0 ); | ||
482 | } | ||
483 | } | ||
484 | } | ||
485 | |||
486 | |||
487 | <span class="comment">// Callback</span> | ||
488 | <span class="keywordtype">void</span> Q3Player::OnAnimationEnd(IAnimatedMeshSceneNode* node) | ||
489 | { | ||
490 | setAnim ( 0 ); | ||
491 | } | ||
492 | </pre></div><p> GUI Elements </p> | ||
493 | <div class="fragment"><pre class="fragment"><span class="keyword">struct </span>GUI | ||
494 | { | ||
495 | GUI () | ||
496 | { | ||
497 | memset ( <span class="keyword">this</span>, 0, <span class="keyword">sizeof</span> ( *<span class="keyword">this</span> ) ); | ||
498 | } | ||
499 | |||
500 | <span class="keywordtype">void</span> drop() | ||
501 | { | ||
502 | dropElement ( Window ); | ||
503 | dropElement ( Logo ); | ||
504 | } | ||
505 | |||
506 | IGUIComboBox* VideoDriver; | ||
507 | IGUIComboBox* VideoMode; | ||
508 | IGUICheckBox* FullScreen; | ||
509 | IGUICheckBox* Bit32; | ||
510 | IGUIScrollBar* MultiSample; | ||
511 | IGUIButton* SetVideoMode; | ||
512 | |||
513 | IGUIScrollBar* Tesselation; | ||
514 | IGUIScrollBar* Gamma; | ||
515 | IGUICheckBox* Collision; | ||
516 | IGUICheckBox* Visible_Map; | ||
517 | IGUICheckBox* Visible_Shader; | ||
518 | IGUICheckBox* Visible_Fog; | ||
519 | IGUICheckBox* Visible_Unresolved; | ||
520 | IGUICheckBox* Visible_Skydome; | ||
521 | IGUIButton* Respawn; | ||
522 | |||
523 | IGUITable* ArchiveList; | ||
524 | IGUIButton* ArchiveAdd; | ||
525 | IGUIButton* ArchiveRemove; | ||
526 | IGUIFileOpenDialog* ArchiveFileOpen; | ||
527 | IGUIButton* ArchiveUp; | ||
528 | IGUIButton* ArchiveDown; | ||
529 | |||
530 | IGUIListBox* MapList; | ||
531 | IGUITreeView* SceneTree; | ||
532 | IGUIStaticText* StatusLine; | ||
533 | IGUIImage* Logo; | ||
534 | IGUIWindow* Window; | ||
535 | }; | ||
536 | </pre></div><p>CQuake3EventHandler controls the game </p> | ||
537 | <div class="fragment"><pre class="fragment"><span class="keyword">class </span>CQuake3EventHandler : <span class="keyword">public</span> IEventReceiver | ||
538 | { | ||
539 | <span class="keyword">public</span>: | ||
540 | |||
541 | CQuake3EventHandler( GameData *gameData ); | ||
542 | <span class="keyword">virtual</span> ~CQuake3EventHandler (); | ||
543 | |||
544 | <span class="keywordtype">void</span> Animate(); | ||
545 | <span class="keywordtype">void</span> Render(); | ||
546 | |||
547 | <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 ); | ||
548 | <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 ); | ||
549 | <span class="keywordtype">void</span> CreatePlayers(); | ||
550 | <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 ); | ||
551 | Q3Player *GetPlayer ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index ) { <span class="keywordflow">return</span> &Player[index]; } | ||
552 | |||
553 | <span class="keywordtype">void</span> CreateGUI(); | ||
554 | <span class="keywordtype">void</span> SetGUIActive( <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> command); | ||
555 | |||
556 | <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent& eve); | ||
557 | |||
558 | |||
559 | <span class="keyword">private</span>: | ||
560 | |||
561 | GameData *Game; | ||
562 | |||
563 | IQ3LevelMesh* Mesh; | ||
564 | ISceneNode* MapParent; | ||
565 | ISceneNode* ShaderParent; | ||
566 | ISceneNode* ItemParent; | ||
567 | ISceneNode* UnresolvedParent; | ||
568 | ISceneNode* BulletParent; | ||
569 | ISceneNode* FogParent; | ||
570 | ISceneNode * SkyNode; | ||
571 | IMetaTriangleSelector *Meta; | ||
572 | |||
573 | <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> buf[256]; | ||
574 | |||
575 | Q3Player Player[2]; | ||
576 | |||
577 | <span class="keyword">struct </span>SParticleImpact | ||
578 | { | ||
579 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> when; | ||
580 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> pos; | ||
581 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> outVector; | ||
582 | }; | ||
583 | array<SParticleImpact> Impacts; | ||
584 | <span class="keywordtype">void</span> useItem( Q3Player * player); | ||
585 | <span class="keywordtype">void</span> createParticleImpacts( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> now ); | ||
586 | |||
587 | <span class="keywordtype">void</span> createTextures (); | ||
588 | <span class="keywordtype">void</span> addSceneTreeItem( ISceneNode * parent, IGUITreeViewNode* nodeParent); | ||
589 | |||
590 | GUI gui; | ||
591 | <span class="keywordtype">void</span> dropMap (); | ||
592 | }; | ||
593 | </pre></div><p> Constructor </p> | ||
594 | <div class="fragment"><pre class="fragment">CQuake3EventHandler::CQuake3EventHandler( GameData *game ) | ||
595 | : Game(game), Mesh(0), MapParent(0), ShaderParent(0), ItemParent(0), UnresolvedParent(0), | ||
596 | BulletParent(0), FogParent(0), SkyNode(0), Meta(0) | ||
597 | { | ||
598 | buf[0]=0; | ||
599 | <span class="comment">// Also use 16 Bit Textures for 16 Bit RenderDevice</span> | ||
600 | <span class="keywordflow">if</span> ( Game->deviceParam.Bits == 16 ) | ||
601 | { | ||
602 | game->Device->getVideoDriver()->setTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#acaf6f7414534f7d62bff18c5bf11876fa4fe1c1b0f4b44ef4b5da219ce66a0ae8">ETCF_ALWAYS_16_BIT</a>, <span class="keyword">true</span>); | ||
603 | } | ||
604 | |||
605 | <span class="comment">// Quake3 Shader controls Z-Writing</span> | ||
606 | 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>); | ||
607 | |||
608 | <span class="comment">// create internal textures</span> | ||
609 | createTextures (); | ||
610 | |||
611 | sound_init ( game->Device ); | ||
612 | |||
613 | Game->Device->setEventReceiver ( <span class="keyword">this</span> ); | ||
614 | } | ||
615 | |||
616 | |||
617 | <span class="comment">// destructor</span> | ||
618 | CQuake3EventHandler::~CQuake3EventHandler () | ||
619 | { | ||
620 | Player[0].shutdown (); | ||
621 | sound_shutdown (); | ||
622 | |||
623 | Game->save( <span class="stringliteral">"explorer.cfg"</span> ); | ||
624 | |||
625 | Game->Device->drop(); | ||
626 | } | ||
627 | |||
628 | |||
629 | <span class="comment">// create runtime textures smog, fog</span> | ||
630 | <span class="keywordtype">void</span> CQuake3EventHandler::createTextures() | ||
631 | { | ||
632 | IVideoDriver * driver = Game->Device->getVideoDriver(); | ||
633 | |||
634 | <a class="code" href="namespaceirr_1_1core.html#ad2e562e3219072e2f7fc7c2bba0ef0cb" title="Typedef for an unsigned integer dimension.">dimension2du</a> dim(64, 64); | ||
635 | |||
636 | video::IImage* image; | ||
637 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i; | ||
638 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> x; | ||
639 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> y; | ||
640 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> * data; | ||
641 | <span class="keywordflow">for</span> ( i = 0; i != 8; ++i ) | ||
642 | { | ||
643 | 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); | ||
644 | data = (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>*) image->lock (); | ||
645 | <span class="keywordflow">for</span> ( y = 0; y != dim.Height; ++y ) | ||
646 | { | ||
647 | <span class="keywordflow">for</span> ( x = 0; x != dim.Width; ++x ) | ||
648 | { | ||
649 | data [x] = 0xFFFFFFFF; | ||
650 | } | ||
651 | 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() ); | ||
652 | } | ||
653 | image->unlock(); | ||
654 | snprintf ( buf, 64, <span class="stringliteral">"smoke_%02d"</span>, i ); | ||
655 | driver->addTexture( buf, image ); | ||
656 | image->drop (); | ||
657 | } | ||
658 | |||
659 | <span class="comment">// fog</span> | ||
660 | <span class="keywordflow">for</span> ( i = 0; i != 1; ++i ) | ||
661 | { | ||
662 | 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); | ||
663 | data = (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>*) image->lock (); | ||
664 | <span class="keywordflow">for</span> ( y = 0; y != dim.Height; ++y ) | ||
665 | { | ||
666 | <span class="keywordflow">for</span> ( x = 0; x != dim.Width; ++x ) | ||
667 | { | ||
668 | data [x] = 0xFFFFFFFF; | ||
669 | } | ||
670 | 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() ); | ||
671 | } | ||
672 | image->unlock(); | ||
673 | snprintf ( buf, 64, <span class="stringliteral">"fog_%02d"</span>, i ); | ||
674 | driver->addTexture( buf, image ); | ||
675 | image->drop (); | ||
676 | } | ||
677 | } | ||
678 | </pre></div><p>create the GUI </p> | ||
679 | <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::CreateGUI() | ||
680 | { | ||
681 | |||
682 | IGUIEnvironment *env = Game->Device->getGUIEnvironment(); | ||
683 | IVideoDriver * driver = Game->Device->getVideoDriver(); | ||
684 | |||
685 | gui.drop(); | ||
686 | |||
687 | <span class="comment">// set skin font</span> | ||
688 | IGUIFont* font = env->getFont(<span class="stringliteral">"fontlucida.png"</span>); | ||
689 | <span class="keywordflow">if</span> (font) | ||
690 | env->getSkin()->setFont(font); | ||
691 | 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) ); | ||
692 | 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) ); | ||
693 | 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) ); | ||
694 | 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) ); | ||
695 | 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) ); | ||
696 | env->getSkin()->setColor ( <a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aab60eb00de0efde8c5a948ab15d9aa0a7" title="Window background.">EGDC_WINDOW</a>, video::SColor(240,0x66,0x66,0x66) ); | ||
697 | |||
698 | <span class="comment">// minimal gui size 800x600</span> | ||
699 | dimension2d<u32> dim ( 800, 600 ); | ||
700 | dimension2d<u32> vdim ( Game->Device->getVideoDriver()->getScreenSize() ); | ||
701 | |||
702 | <span class="keywordflow">if</span> ( vdim.Height >= dim.Height && vdim.Width >= dim.Width ) | ||
703 | { | ||
704 | <span class="comment">//dim = vdim;</span> | ||
705 | } | ||
706 | <span class="keywordflow">else</span> | ||
707 | { | ||
708 | } | ||
709 | |||
710 | gui.Window = env->addWindow ( rect<s32> ( 0, 0, dim.Width, dim.Height ), <span class="keyword">false</span>, L<span class="stringliteral">"Quake3 Explorer"</span> ); | ||
711 | gui.Window->setToolTipText ( L<span class="stringliteral">"Quake3Explorer. Loads and show various BSP File Format and Shaders."</span> ); | ||
712 | gui.Window->getCloseButton()->setToolTipText ( L<span class="stringliteral">"Quit Quake3 Explorer"</span> ); | ||
713 | |||
714 | <span class="comment">// add a status line help text</span> | ||
715 | gui.StatusLine = env->addStaticText( 0, rect<s32>( 5,dim.Height - 30,dim.Width - 5,dim.Height - 10), | ||
716 | <span class="keyword">false</span>, <span class="keyword">false</span>, gui.Window, -1, <span class="keyword">true</span> | ||
717 | ); | ||
718 | |||
719 | |||
720 | 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> ); | ||
721 | gui.VideoDriver = env->addComboBox(rect<s32>( dim.Width - 300, 24, dim.Width - 10, 40 ),gui.Window); | ||
722 | 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> ); | ||
723 | 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> ); | ||
724 | 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>); | ||
725 | 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>); | ||
726 | 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>); | ||
727 | gui.VideoDriver->setSelected ( gui.VideoDriver->getIndexForItemData ( Game->deviceParam.DriverType ) ); | ||
728 | gui.VideoDriver->setToolTipText ( L<span class="stringliteral">"Use a VideoDriver"</span> ); | ||
729 | |||
730 | 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> ); | ||
731 | gui.VideoMode = env->addComboBox(rect<s32>( dim.Width - 300, 44, dim.Width - 10, 60 ),gui.Window); | ||
732 | gui.VideoMode->setToolTipText ( L<span class="stringliteral">"Supported Screenmodes"</span> ); | ||
733 | IVideoModeList *modeList = Game->Device->getVideoModeList(); | ||
734 | <span class="keywordflow">if</span> ( modeList ) | ||
735 | { | ||
736 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> i; | ||
737 | <span class="keywordflow">for</span> ( i = 0; i != modeList->getVideoModeCount (); ++i ) | ||
738 | { | ||
739 | <a class="code" href="namespaceirr.html#ae9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> d = modeList->getVideoModeDepth ( i ); | ||
740 | <span class="keywordflow">if</span> ( d < 16 ) | ||
741 | <span class="keywordflow">continue</span>; | ||
742 | |||
743 | <a class="code" href="namespaceirr.html#ae9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> w = modeList->getVideoModeResolution ( i ).Width; | ||
744 | <a class="code" href="namespaceirr.html#ae9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> h = modeList->getVideoModeResolution ( i ).Height; | ||
745 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> val = w << 16 | h; | ||
746 | |||
747 | <span class="keywordflow">if</span> ( gui.VideoMode->getIndexForItemData ( val ) >= 0 ) | ||
748 | <span class="keywordflow">continue</span>; | ||
749 | |||
750 | <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; | ||
751 | <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> *a = <span class="stringliteral">""</span>; | ||
752 | <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>; | ||
753 | <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>; | ||
754 | <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>; | ||
755 | <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>; | ||
756 | <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>; | ||
757 | |||
758 | snprintf ( buf, <span class="keyword">sizeof</span> ( buf ), <span class="stringliteral">"%d x %d, %s"</span>,w, h, a ); | ||
759 | gui.VideoMode->addItem ( <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> ( buf ).c_str(), val ); | ||
760 | } | ||
761 | } | ||
762 | gui.VideoMode->setSelected ( gui.VideoMode->getIndexForItemData ( | ||
763 | Game->deviceParam.WindowSize.Width << 16 | | ||
764 | Game->deviceParam.WindowSize.Height ) ); | ||
765 | |||
766 | 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> ); | ||
767 | gui.FullScreen->setToolTipText ( L<span class="stringliteral">"Set Fullscreen or Window Mode"</span> ); | ||
768 | |||
769 | 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> ); | ||
770 | gui.Bit32->setToolTipText ( L<span class="stringliteral">"Use 16 or 32 Bit"</span> ); | ||
771 | |||
772 | 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> ); | ||
773 | gui.MultiSample = env->addScrollBar( <span class="keyword">true</span>, rect<s32>( dim.Width - 150, 64, dim.Width - 70, 80 ), gui.Window,-1 ); | ||
774 | gui.MultiSample->setMin ( 0 ); | ||
775 | gui.MultiSample->setMax ( 8 ); | ||
776 | gui.MultiSample->setSmallStep ( 1 ); | ||
777 | gui.MultiSample->setLargeStep ( 1 ); | ||
778 | gui.MultiSample->setPos ( Game->deviceParam.AntiAlias ); | ||
779 | gui.MultiSample->setToolTipText ( L<span class="stringliteral">"Set the MultiSample (disable, 1x, 2x, 4x, 8x )"</span> ); | ||
780 | |||
781 | gui.SetVideoMode = env->addButton (rect<s32>( dim.Width - 60, 64, dim.Width - 10, 80 ), gui.Window, -1,L<span class="stringliteral">"set"</span> ); | ||
782 | gui.SetVideoMode->setToolTipText ( L<span class="stringliteral">"Set Video Mode with current values"</span> ); | ||
783 | |||
784 | 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> ); | ||
785 | gui.Gamma = env->addScrollBar( <span class="keyword">true</span>, rect<s32>( dim.Width - 300, 104, dim.Width - 10, 120 ), gui.Window,-1 ); | ||
786 | gui.Gamma->setMin ( 50 ); | ||
787 | gui.Gamma->setMax ( 350 ); | ||
788 | gui.Gamma->setSmallStep ( 1 ); | ||
789 | gui.Gamma->setLargeStep ( 10 ); | ||
790 | gui.Gamma->setPos ( <a class="code" href="namespaceirr_1_1core.html#ac230a392b15e3d27c6e2a07a6925a8c4">core::floor32</a> ( Game->GammaValue * 100.f ) ); | ||
791 | gui.Gamma->setToolTipText ( L<span class="stringliteral">"Adjust Gamma Ramp ( 0.5 - 3.5)"</span> ); | ||
792 | Game->Device->setGammaRamp ( Game->GammaValue, Game->GammaValue, Game->GammaValue, 0.f, 0.f ); | ||
793 | |||
794 | |||
795 | 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> ); | ||
796 | gui.Tesselation = env->addScrollBar( <span class="keyword">true</span>, rect<s32>( dim.Width - 300, 124, dim.Width - 10, 140 ), gui.Window,-1 ); | ||
797 | gui.Tesselation->setMin ( 2 ); | ||
798 | gui.Tesselation->setMax ( 12 ); | ||
799 | gui.Tesselation->setSmallStep ( 1 ); | ||
800 | gui.Tesselation->setLargeStep ( 1 ); | ||
801 | gui.Tesselation->setPos ( Game->loadParam.patchTesselation ); | ||
802 | gui.Tesselation->setToolTipText ( L<span class="stringliteral">"How smooth should curved surfaces be rendered"</span> ); | ||
803 | |||
804 | 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> ); | ||
805 | gui.Collision->setToolTipText ( L<span class="stringliteral">"Set collision on or off ( flythrough ). \nPress F7 on your Keyboard"</span> ); | ||
806 | 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> ); | ||
807 | gui.Visible_Map->setToolTipText ( L<span class="stringliteral">"Show or not show the static part the Level. \nPress F3 on your Keyboard"</span> ); | ||
808 | 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> ); | ||
809 | gui.Visible_Shader->setToolTipText ( L<span class="stringliteral">"Show or not show the Shader Nodes. \nPress F4 on your Keyboard"</span> ); | ||
810 | 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> ); | ||
811 | gui.Visible_Fog->setToolTipText ( L<span class="stringliteral">"Show or not show the Fog Nodes. \nPress F5 on your Keyboard"</span> ); | ||
812 | 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> ); | ||
813 | 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> ); | ||
814 | 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> ); | ||
815 | gui.Visible_Skydome->setToolTipText ( L<span class="stringliteral">"Show the or not show the Skydome."</span> ); | ||
816 | |||
817 | <span class="comment">//Respawn = env->addButton ( rect<s32>( dim.Width - 260, 90, dim.Width - 10, 106 ), 0,-1, L"Respawn" );</span> | ||
818 | |||
819 | 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> ); | ||
820 | |||
821 | 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> ); | ||
822 | gui.ArchiveAdd->setToolTipText ( L<span class="stringliteral">"Add an archive, usually packed zip-archives (*.pk3) to the Filesystem"</span> ); | ||
823 | 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> ); | ||
824 | gui.ArchiveRemove->setToolTipText ( L<span class="stringliteral">"Remove the selected archive from the FileSystem."</span> ); | ||
825 | 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> ); | ||
826 | gui.ArchiveUp->setToolTipText ( L<span class="stringliteral">"Arrange Archive Look-up Hirachy. Move the selected Archive up"</span> ); | ||
827 | 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> ); | ||
828 | gui.ArchiveDown->setToolTipText ( L<span class="stringliteral">"Arrange Archive Look-up Hirachy. Move the selected Archive down"</span> ); | ||
829 | |||
830 | |||
831 | gui.ArchiveList = env->addTable ( rect<s32>( 5,dim.Height - 510, dim.Width - 450,dim.Height - 410 ), gui.Window ); | ||
832 | gui.ArchiveList->addColumn ( L<span class="stringliteral">"Type"</span>, 0 ); | ||
833 | gui.ArchiveList->addColumn ( L<span class="stringliteral">"Real File Path"</span>, 1 ); | ||
834 | gui.ArchiveList->setColumnWidth ( 0, 60 ); | ||
835 | gui.ArchiveList->setColumnWidth ( 1, 284 ); | ||
836 | gui.ArchiveList->setToolTipText ( L<span class="stringliteral">"Show the attached Archives"</span> ); | ||
837 | |||
838 | |||
839 | 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> ); | ||
840 | gui.MapList = env->addListBox ( rect<s32>( 5,dim.Height - 380, dim.Width - 450,dim.Height - 40 ), gui.Window, -1, <span class="keyword">true</span> ); | ||
841 | gui.MapList->setToolTipText ( L<span class="stringliteral">"Show the current Maps in all Archives.\n Double-Click the Map to start the level"</span> ); | ||
842 | |||
843 | |||
844 | <span class="comment">// create a visible Scene Tree</span> | ||
845 | 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> ); | ||
846 | gui.SceneTree = env->addTreeView( rect<s32>( dim.Width - 400, dim.Height - 380, dim.Width - 5, dim.Height - 40 ), | ||
847 | gui.Window, -1, <span class="keyword">true</span>, <span class="keyword">true</span>, <span class="keyword">false</span> ); | ||
848 | gui.SceneTree->setToolTipText ( L<span class="stringliteral">"Show the current Scenegraph"</span> ); | ||
849 | gui.SceneTree->getRoot()->clearChildren(); | ||
850 | addSceneTreeItem ( Game->Device->getSceneManager()->getRootSceneNode(), gui.SceneTree->getRoot() ); | ||
851 | |||
852 | |||
853 | IGUIImageList* imageList = env->createImageList( driver->getTexture ( <span class="stringliteral">"iconlist.png"</span> ), | ||
854 | <a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>( 32, 32 ), true ); | ||
855 | |||
856 | <span class="keywordflow">if</span> ( imageList ) | ||
857 | { | ||
858 | gui.SceneTree->setImageList( imageList ); | ||
859 | imageList->drop (); | ||
860 | } | ||
861 | |||
862 | |||
863 | <span class="comment">// load the engine logo</span> | ||
864 | gui.Logo = env->addImage( driver->getTexture(<span class="stringliteral">"irrlichtlogo3.png"</span>), position2d<s32>(5, 16 ), <span class="keyword">true</span>, 0 ); | ||
865 | gui.Logo->setToolTipText ( L<span class="stringliteral">"The great Irrlicht Engine"</span> ); | ||
866 | |||
867 | AddArchive ( <span class="stringliteral">""</span> ); | ||
868 | } | ||
869 | </pre></div><p>Add an Archive to the FileSystems and updates the GUI </p> | ||
870 | <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 ) | ||
871 | { | ||
872 | IFileSystem *fs = Game->Device->getFileSystem(); | ||
873 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i; | ||
874 | |||
875 | <span class="keywordflow">if</span> ( archiveName.size () ) | ||
876 | { | ||
877 | <span class="keywordtype">bool</span> exists = <span class="keyword">false</span>; | ||
878 | <span class="keywordflow">for</span> ( i = 0; i != fs->getFileArchiveCount(); ++i ) | ||
879 | { | ||
880 | <span class="keywordflow">if</span> ( fs->getFileArchive(i)->getFileList()->getPath() == archiveName ) | ||
881 | { | ||
882 | exists = <span class="keyword">true</span>; | ||
883 | <span class="keywordflow">break</span>; | ||
884 | } | ||
885 | } | ||
886 | |||
887 | <span class="keywordflow">if</span> (!exists) | ||
888 | { | ||
889 | fs->addFileArchive(archiveName, <span class="keyword">true</span>, <span class="keyword">false</span>); | ||
890 | } | ||
891 | } | ||
892 | |||
893 | <span class="comment">// store the current archives in game data</span> | ||
894 | <span class="comment">// show the attached Archive in proper order</span> | ||
895 | <span class="keywordflow">if</span> ( gui.ArchiveList ) | ||
896 | { | ||
897 | gui.ArchiveList->clearRows(); | ||
898 | |||
899 | <span class="keywordflow">for</span> ( i = 0; i != fs->getFileArchiveCount(); ++i ) | ||
900 | { | ||
901 | IFileArchive * archive = fs->getFileArchive ( i ); | ||
902 | |||
903 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index = gui.ArchiveList->addRow(i); | ||
904 | |||
905 | <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> typeName; | ||
906 | <span class="keywordflow">switch</span>(archive->getType()) | ||
907 | { | ||
908 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14fa63010a52f2efb42f3c85b91ecf077004" title="A PKZIP archive.">io::EFAT_ZIP</a>: | ||
909 | typeName = <span class="stringliteral">"ZIP"</span>; | ||
910 | <span class="keywordflow">break</span>; | ||
911 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14fa9d37ff1b229bb63f52d29ef65a35b6ce" title="A gzip archive.">io::EFAT_GZIP</a>: | ||
912 | typeName = <span class="stringliteral">"gzip"</span>; | ||
913 | <span class="keywordflow">break</span>; | ||
914 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14fa1d1f159095f087da5647835b47cd85d4" title="A virtual directory.">io::EFAT_FOLDER</a>: | ||
915 | typeName = <span class="stringliteral">"Mount"</span>; | ||
916 | <span class="keywordflow">break</span>; | ||
917 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14faae9e1788acfc49c30a77f80f5ced7cf5" title="An ID Software PAK archive.">io::EFAT_PAK</a>: | ||
918 | typeName = <span class="stringliteral">"PAK"</span>; | ||
919 | <span class="keywordflow">break</span>; | ||
920 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1io.html#adb3e3c445ec8e608ed1f0f93306da14fa0f36ce25d47b45f41a58e32b4c029cb6" title="A Tape ARchive.">io::EFAT_TAR</a>: | ||
921 | typeName = <span class="stringliteral">"TAR"</span>; | ||
922 | <span class="keywordflow">break</span>; | ||
923 | <span class="keywordflow">default</span>: | ||
924 | typeName = <span class="stringliteral">"archive"</span>; | ||
925 | } | ||
926 | |||
927 | gui.ArchiveList->setCellText ( index, 0, typeName ); | ||
928 | gui.ArchiveList->setCellText ( index, 1, archive->getFileList()->getPath() ); | ||
929 | } | ||
930 | } | ||
931 | |||
932 | |||
933 | <span class="comment">// browse the archives for maps</span> | ||
934 | <span class="keywordflow">if</span> ( gui.MapList ) | ||
935 | { | ||
936 | gui.MapList->clear(); | ||
937 | |||
938 | IGUISpriteBank *bank = Game->Device->getGUIEnvironment()->getSpriteBank(<span class="stringliteral">"sprite_q3map"</span>); | ||
939 | <span class="keywordflow">if</span> ( 0 == bank ) | ||
940 | bank = Game->Device->getGUIEnvironment()->addEmptySpriteBank(<span class="stringliteral">"sprite_q3map"</span>); | ||
941 | |||
942 | SGUISprite sprite; | ||
943 | SGUISpriteFrame frame; | ||
944 | core::rect<s32> r; | ||
945 | |||
946 | bank->getSprites().clear(); | ||
947 | bank->getPositions().clear (); | ||
948 | gui.MapList->setSpriteBank ( bank ); | ||
949 | |||
950 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> g = 0; | ||
951 | <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> s; | ||
952 | |||
953 | <span class="comment">// browse the attached file system</span> | ||
954 | fs->setFileListSystem ( <a class="code" href="namespaceirr_1_1io.html#a22364f1caf06442a70f6198025af3fe9a94a9818df56a8fe16b1c7c6f44e8f9f3">FILESYSTEM_VIRTUAL</a> ); | ||
955 | fs->changeWorkingDirectoryTo ( <span class="stringliteral">"/maps/"</span> ); | ||
956 | IFileList *fileList = fs->createFileList (); | ||
957 | fs->setFileListSystem ( <a class="code" href="namespaceirr_1_1io.html#a22364f1caf06442a70f6198025af3fe9acfbc9e5e8773ec885f08eafd6c8d3c6f">FILESYSTEM_NATIVE</a> ); | ||
958 | |||
959 | <span class="keywordflow">for</span> ( i=0; i< fileList->getFileCount(); ++i) | ||
960 | { | ||
961 | s = fileList->getFullFileName(i); | ||
962 | <span class="keywordflow">if</span> ( s.find ( <span class="stringliteral">".bsp"</span> ) >= 0 ) | ||
963 | { | ||
964 | <span class="comment">// get level screenshot. reformat texture to 128x128</span> | ||
965 | <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> c ( s ); | ||
966 | <a class="code" href="namespaceirr_1_1core.html#a905c95bab4a7e8d5360a19b0726383a9" title="delete path from filename">deletePathFromFilename</a> ( c ); | ||
967 | <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 ); | ||
968 | 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; | ||
969 | |||
970 | <a class="code" href="namespaceirr_1_1core.html#ad2e562e3219072e2f7fc7c2bba0ef0cb" title="Typedef for an unsigned integer dimension.">dimension2du</a> dim ( 128, 128 ); | ||
971 | IVideoDriver * driver = Game->Device->getVideoDriver(); | ||
972 | IImage* image = 0; | ||
973 | ITexture *tex = 0; | ||
974 | <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> filename; | ||
975 | |||
976 | filename = c + <span class="stringliteral">".jpg"</span>; | ||
977 | <span class="keywordflow">if</span> ( fs->existFile ( filename ) ) | ||
978 | image = driver->createImageFromFile( filename ); | ||
979 | <span class="keywordflow">if</span> ( 0 == image ) | ||
980 | { | ||
981 | filename = c + <span class="stringliteral">".tga"</span>; | ||
982 | <span class="keywordflow">if</span> ( fs->existFile ( filename ) ) | ||
983 | image = driver->createImageFromFile( filename ); | ||
984 | } | ||
985 | |||
986 | <span class="keywordflow">if</span> ( image ) | ||
987 | { | ||
988 | 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 ); | ||
989 | image->copyToScalingBoxFilter ( filter, 0 ); | ||
990 | image->drop (); | ||
991 | image = filter; | ||
992 | } | ||
993 | |||
994 | <span class="keywordflow">if</span> ( image ) | ||
995 | { | ||
996 | tex = driver->addTexture ( filename, image ); | ||
997 | image->drop (); | ||
998 | } | ||
999 | |||
1000 | |||
1001 | bank->setTexture ( g, tex ); | ||
1002 | |||
1003 | r.LowerRightCorner.X = dim.Width; | ||
1004 | r.LowerRightCorner.Y = dim.Height; | ||
1005 | gui.MapList->setItemHeight ( r.LowerRightCorner.Y + 4 ); | ||
1006 | frame.rectNumber = bank->getPositions().size(); | ||
1007 | frame.textureNumber = g; | ||
1008 | |||
1009 | bank->getPositions().push_back(r); | ||
1010 | |||
1011 | sprite.Frames.set_used ( 0 ); | ||
1012 | sprite.Frames.push_back(frame); | ||
1013 | sprite.frameTime = 0; | ||
1014 | bank->getSprites().push_back(sprite); | ||
1015 | |||
1016 | gui.MapList->addItem ( s.c_str (), g ); | ||
1017 | g += 1; | ||
1018 | } | ||
1019 | } | ||
1020 | fileList->drop (); | ||
1021 | |||
1022 | gui.MapList->setSelected ( -1 ); | ||
1023 | IGUIScrollBar * bar = (IGUIScrollBar*)gui.MapList->getElementFromId( 0 ); | ||
1024 | <span class="keywordflow">if</span> ( bar ) | ||
1025 | bar->setPos ( 0 ); | ||
1026 | |||
1027 | } | ||
1028 | |||
1029 | } | ||
1030 | </pre></div><p>clears the Map in Memory </p> | ||
1031 | <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::dropMap () | ||
1032 | { | ||
1033 | IVideoDriver * driver = Game->Device->getVideoDriver(); | ||
1034 | |||
1035 | driver->removeAllHardwareBuffers (); | ||
1036 | driver->removeAllTextures (); | ||
1037 | |||
1038 | Player[0].shutdown (); | ||
1039 | |||
1040 | |||
1041 | dropElement ( ItemParent ); | ||
1042 | dropElement ( ShaderParent ); | ||
1043 | dropElement ( UnresolvedParent ); | ||
1044 | dropElement ( FogParent ); | ||
1045 | dropElement ( BulletParent ); | ||
1046 | |||
1047 | |||
1048 | Impacts.clear(); | ||
1049 | |||
1050 | <span class="keywordflow">if</span> ( Meta ) | ||
1051 | { | ||
1052 | Meta = 0; | ||
1053 | } | ||
1054 | |||
1055 | dropElement ( MapParent ); | ||
1056 | dropElement ( SkyNode ); | ||
1057 | |||
1058 | <span class="comment">// clean out meshes, because textures are invalid</span> | ||
1059 | <span class="comment">// TODO: better texture handling;-)</span> | ||
1060 | IMeshCache *cache = Game->Device->getSceneManager ()->getMeshCache(); | ||
1061 | cache->clear (); | ||
1062 | Mesh = 0; | ||
1063 | } | ||
1064 | </pre></div><p> Load new map </p> | ||
1065 | <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 ) | ||
1066 | { | ||
1067 | <span class="keywordflow">if</span> ( 0 == mapName.size() ) | ||
1068 | <span class="keywordflow">return</span>; | ||
1069 | |||
1070 | dropMap (); | ||
1071 | |||
1072 | IFileSystem *fs = Game->Device->getFileSystem(); | ||
1073 | ISceneManager *smgr = Game->Device->getSceneManager (); | ||
1074 | |||
1075 | IReadFile* file = fs->createMemoryReadFile(&Game->loadParam, | ||
1076 | <span class="keyword">sizeof</span>(Game->loadParam), L<span class="stringliteral">"levelparameter.cfg"</span>, <span class="keyword">false</span>); | ||
1077 | |||
1078 | <span class="comment">// load cfg file</span> | ||
1079 | smgr->getMesh( file ); | ||
1080 | file->drop (); | ||
1081 | |||
1082 | <span class="comment">// load the actual map</span> | ||
1083 | Mesh = (IQ3LevelMesh*) smgr->getMesh(mapName); | ||
1084 | <span class="keywordflow">if</span> ( 0 == Mesh ) | ||
1085 | <span class="keywordflow">return</span>; | ||
1086 | </pre></div><p>add the geometry mesh to the Scene ( polygon & patches ) The Geometry mesh is optimised for faster drawing </p> | ||
1087 | <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>); | ||
1088 | <span class="keywordflow">if</span> ( 0 == geometry || geometry->getMeshBufferCount() == 0) | ||
1089 | <span class="keywordflow">return</span>; | ||
1090 | |||
1091 | Game->CurrentMapName = mapName; | ||
1092 | |||
1093 | <span class="comment">//create a collision list</span> | ||
1094 | Meta = 0; | ||
1095 | |||
1096 | ITriangleSelector * selector = 0; | ||
1097 | <span class="keywordflow">if</span> (collision) | ||
1098 | Meta = smgr->createMetaTriangleSelector(); | ||
1099 | |||
1100 | <span class="comment">//IMeshBuffer *b0 = geometry->getMeshBuffer(0);</span> | ||
1101 | <span class="comment">//s32 minimalNodes = b0 ? core::s32_max ( 2048, b0->getVertexCount() / 32 ) : 2048;</span> | ||
1102 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> minimalNodes = 2048; | ||
1103 | |||
1104 | MapParent = smgr->addOctreeSceneNode(geometry, 0, -1, minimalNodes); | ||
1105 | MapParent->setName ( mapName ); | ||
1106 | <span class="keywordflow">if</span> ( Meta ) | ||
1107 | { | ||
1108 | selector = smgr->createOctreeTriangleSelector( geometry,MapParent, minimalNodes); | ||
1109 | <span class="comment">//selector = smgr->createTriangleSelector ( geometry, MapParent );</span> | ||
1110 | Meta->addTriangleSelector( selector); | ||
1111 | selector->drop (); | ||
1112 | } | ||
1113 | |||
1114 | <span class="comment">// logical parent for the items</span> | ||
1115 | ItemParent = smgr->addEmptySceneNode(); | ||
1116 | <span class="keywordflow">if</span> ( ItemParent ) | ||
1117 | ItemParent->setName ( <span class="stringliteral">"Item Container"</span> ); | ||
1118 | |||
1119 | ShaderParent = smgr->addEmptySceneNode(); | ||
1120 | <span class="keywordflow">if</span> ( ShaderParent ) | ||
1121 | ShaderParent->setName ( <span class="stringliteral">"Shader Container"</span> ); | ||
1122 | |||
1123 | UnresolvedParent = smgr->addEmptySceneNode(); | ||
1124 | <span class="keywordflow">if</span> ( UnresolvedParent ) | ||
1125 | UnresolvedParent->setName ( <span class="stringliteral">"Unresolved Container"</span> ); | ||
1126 | |||
1127 | FogParent = smgr->addEmptySceneNode(); | ||
1128 | <span class="keywordflow">if</span> ( FogParent ) | ||
1129 | FogParent->setName ( <span class="stringliteral">"Fog Container"</span> ); | ||
1130 | |||
1131 | <span class="comment">// logical parent for the bullets</span> | ||
1132 | BulletParent = smgr->addEmptySceneNode(); | ||
1133 | <span class="keywordflow">if</span> ( BulletParent ) | ||
1134 | BulletParent->setName ( <span class="stringliteral">"Bullet Container"</span> ); | ||
1135 | </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> | ||
1136 | <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> ); | ||
1137 | 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> ); | ||
1138 | 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> ); | ||
1139 | </pre></div><p>Now construct Models from Entity List </p> | ||
1140 | <div class="fragment"><pre class="fragment"> Q3ModelFactory ( Game->loadParam, Game->Device, Mesh, ItemParent, <span class="keyword">false</span> ); | ||
1141 | } | ||
1142 | </pre></div><p>Adds a SceneNode with an icon to the Scene Tree </p> | ||
1143 | <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::addSceneTreeItem( ISceneNode * parent, IGUITreeViewNode* nodeParent) | ||
1144 | { | ||
1145 | IGUITreeViewNode* node; | ||
1146 | <span class="keywordtype">wchar_t</span> msg[128]; | ||
1147 | |||
1148 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> imageIndex; | ||
1149 | list<ISceneNode*>::ConstIterator it = parent->getChildren().begin(); | ||
1150 | <span class="keywordflow">for</span> (; it != parent->getChildren().end(); ++it) | ||
1151 | { | ||
1152 | <span class="keywordflow">switch</span> ( (*it)->getType () ) | ||
1153 | { | ||
1154 | <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>; | ||
1155 | <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>; | ||
1156 | <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>; | ||
1157 | <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>; | ||
1158 | <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>; | ||
1159 | <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>; | ||
1160 | <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>; | ||
1161 | <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>; | ||
1162 | <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>; | ||
1163 | <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>; | ||
1164 | <span class="keywordflow">default</span>:imageIndex = -1; <span class="keywordflow">break</span>; | ||
1165 | } | ||
1166 | |||
1167 | <span class="keywordflow">if</span> ( imageIndex < 0 ) | ||
1168 | { | ||
1169 | swprintf ( msg, 128, L<span class="stringliteral">"%hs,%hs"</span>, | ||
1170 | Game->Device->getSceneManager ()->getSceneNodeTypeName ( (*it)->getType () ), | ||
1171 | (*it)->getName() | ||
1172 | ); | ||
1173 | } | ||
1174 | <span class="keywordflow">else</span> | ||
1175 | { | ||
1176 | swprintf ( msg, 128, L<span class="stringliteral">"%hs"</span>,(*it)->getName() ); | ||
1177 | } | ||
1178 | |||
1179 | node = nodeParent->addChildBack( msg, 0, imageIndex ); | ||
1180 | |||
1181 | <span class="comment">// Add all Animators</span> | ||
1182 | list<ISceneNodeAnimator*>::ConstIterator ait = (*it)->getAnimators().begin(); | ||
1183 | <span class="keywordflow">for</span> (; ait != (*it)->getAnimators().end(); ++ait) | ||
1184 | { | ||
1185 | imageIndex = -1; | ||
1186 | swprintf ( msg, 128, L<span class="stringliteral">"%hs"</span>, | ||
1187 | Game->Device->getSceneManager ()->getAnimatorTypeName ( (*ait)->getType () ) | ||
1188 | ); | ||
1189 | |||
1190 | <span class="keywordflow">switch</span> ( (*ait)->getType () ) | ||
1191 | { | ||
1192 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19add5f15ecd6c0209d4e3d81a287ae9a66" title="Fly circle scene node animator.">ESNAT_FLY_CIRCLE</a>: | ||
1193 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19af71dad2be8d964a88329d2727fb53b74" title="Fly straight scene node animator.">ESNAT_FLY_STRAIGHT</a>: | ||
1194 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19addc7e3bb5180f7087546ccab14dcc4ad" title="Follow spline scene node animator.">ESNAT_FOLLOW_SPLINE</a>: | ||
1195 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19a689aa5051e83b7f61a7abba85eb1be52" title="Rotation scene node animator.">ESNAT_ROTATION</a>: | ||
1196 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19a2f3e75035fbb3227189a0a3d8bcda993" title="Texture scene node animator.">ESNAT_TEXTURE</a>: | ||
1197 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19abbafee6e6a120e26a6e1ed6bd3cbdc86" title="Deletion scene node animator.">ESNAT_DELETION</a>: | ||
1198 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19af5889b6449faa50d3fabd005d4493490" title="Collision respose scene node animator.">ESNAT_COLLISION_RESPONSE</a>: | ||
1199 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19ae40c836272ace5bf243baaca72dba55c" title="FPS camera animator.">ESNAT_CAMERA_FPS</a>: | ||
1200 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1scene.html#a327a1e43872705cf8f3f3342fb307d19a851338028c38a91643f70d2a2e5ff8c4" title="Maya camera animator.">ESNAT_CAMERA_MAYA</a>: | ||
1201 | <span class="keywordflow">default</span>: | ||
1202 | <span class="keywordflow">break</span>; | ||
1203 | } | ||
1204 | node->addChildBack( msg, 0, imageIndex ); | ||
1205 | } | ||
1206 | |||
1207 | addSceneTreeItem ( *it, node ); | ||
1208 | } | ||
1209 | } | ||
1210 | |||
1211 | |||
1212 | <span class="comment">// Adds life!</span> | ||
1213 | <span class="keywordtype">void</span> CQuake3EventHandler::CreatePlayers() | ||
1214 | { | ||
1215 | Player[0].create ( Game->Device, Mesh, MapParent, Meta ); | ||
1216 | } | ||
1217 | |||
1218 | |||
1219 | <span class="comment">// Adds a skydome to the scene</span> | ||
1220 | <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) | ||
1221 | { | ||
1222 | ISceneManager *smgr = Game->Device->getSceneManager (); | ||
1223 | IVideoDriver * driver = Game->Device->getVideoDriver(); | ||
1224 | |||
1225 | <span class="keywordtype">bool</span> oldMipMapState = driver->getTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#acaf6f7414534f7d62bff18c5bf11876fa288b302e9d4faaba80c7796c7bc1682c">video::ETCF_CREATE_MIP_MAPS</a>); | ||
1226 | driver->setTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#acaf6f7414534f7d62bff18c5bf11876fa288b302e9d4faaba80c7796c7bc1682c">video::ETCF_CREATE_MIP_MAPS</a>, <span class="keyword">false</span>); | ||
1227 | |||
1228 | <span class="keywordflow">if</span> ( 0 == dome ) | ||
1229 | { | ||
1230 | <span class="comment">// irrlicht order</span> | ||
1231 | <span class="comment">//static const c8*p[] = { "ft", "lf", "bk", "rt", "up", "dn" };</span> | ||
1232 | <span class="comment">// quake3 order</span> | ||
1233 | <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> }; | ||
1234 | |||
1235 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i = 0; | ||
1236 | snprintf ( buf, 64, <span class="stringliteral">"%s_%s.jpg"</span>, texture, p[i] ); | ||
1237 | SkyNode = smgr->addSkyBoxSceneNode( driver->getTexture ( buf ), 0, 0, 0, 0, 0 ); | ||
1238 | |||
1239 | <span class="keywordflow">if</span> (SkyNode) | ||
1240 | { | ||
1241 | <span class="keywordflow">for</span> ( i = 0; i < 6; ++i ) | ||
1242 | { | ||
1243 | snprintf ( buf, 64, <span class="stringliteral">"%s_%s.jpg"</span>, texture, p[i] ); | ||
1244 | SkyNode->getMaterial(i).setTexture ( 0, driver->getTexture ( buf ) ); | ||
1245 | } | ||
1246 | } | ||
1247 | } | ||
1248 | <span class="keywordflow">else</span> | ||
1249 | <span class="keywordflow">if</span> ( 1 == dome ) | ||
1250 | { | ||
1251 | snprintf ( buf, 64, <span class="stringliteral">"%s.jpg"</span>, texture ); | ||
1252 | SkyNode = smgr->addSkyDomeSceneNode( | ||
1253 | driver->getTexture( buf ), 32,32, | ||
1254 | 1.f, 1.f, 1000.f, 0, 11); | ||
1255 | } | ||
1256 | <span class="keywordflow">else</span> | ||
1257 | <span class="keywordflow">if</span> ( 2 == dome ) | ||
1258 | { | ||
1259 | snprintf ( buf, 64, <span class="stringliteral">"%s.jpg"</span>, texture ); | ||
1260 | SkyNode = smgr->addSkyDomeSceneNode( | ||
1261 | driver->getTexture( buf ), 16,8, | ||
1262 | 0.95f, 2.f, 1000.f, 0, 11); | ||
1263 | } | ||
1264 | |||
1265 | <span class="keywordflow">if</span> (SkyNode) | ||
1266 | SkyNode->setName(<span class="stringliteral">"Skydome"</span>); | ||
1267 | <span class="comment">//SkyNode->getMaterial(0).ZBuffer = video::EMDF_DEPTH_LESS_EQUAL;</span> | ||
1268 | |||
1269 | driver->setTextureCreationFlag(<a class="code" href="namespaceirr_1_1video.html#acaf6f7414534f7d62bff18c5bf11876fa288b302e9d4faaba80c7796c7bc1682c">video::ETCF_CREATE_MIP_MAPS</a>, oldMipMapState); | ||
1270 | } | ||
1271 | |||
1272 | |||
1273 | <span class="comment">// enable GUI elements</span> | ||
1274 | <span class="keywordtype">void</span> CQuake3EventHandler::SetGUIActive( <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> command) | ||
1275 | { | ||
1276 | <span class="keywordtype">bool</span> inputState = <span class="keyword">false</span>; | ||
1277 | |||
1278 | ICameraSceneNode * camera = Game->Device->getSceneManager()->getActiveCamera (); | ||
1279 | |||
1280 | <span class="keywordflow">switch</span> ( command ) | ||
1281 | { | ||
1282 | <span class="keywordflow">case</span> 0: Game->guiActive = 0; inputState = !Game->guiActive; <span class="keywordflow">break</span>; | ||
1283 | <span class="keywordflow">case</span> 1: Game->guiActive = 1; inputState = !Game->guiActive;;<span class="keywordflow">break</span>; | ||
1284 | <span class="keywordflow">case</span> 2: Game->guiActive ^= 1; inputState = !Game->guiActive;<span class="keywordflow">break</span>; | ||
1285 | <span class="keywordflow">case</span> 3: | ||
1286 | <span class="keywordflow">if</span> ( camera ) | ||
1287 | inputState = !camera->isInputReceiverEnabled(); | ||
1288 | <span class="keywordflow">break</span>; | ||
1289 | } | ||
1290 | |||
1291 | <span class="keywordflow">if</span> ( camera ) | ||
1292 | { | ||
1293 | camera->setInputReceiverEnabled ( inputState ); | ||
1294 | Game->Device->getCursorControl()->setVisible( !inputState ); | ||
1295 | } | ||
1296 | |||
1297 | <span class="keywordflow">if</span> ( gui.Window ) | ||
1298 | { | ||
1299 | gui.Window->setVisible ( Game->guiActive != 0 ); | ||
1300 | } | ||
1301 | |||
1302 | <span class="keywordflow">if</span> ( Game->guiActive && | ||
1303 | gui.SceneTree && Game->Device->getGUIEnvironment()->getFocus() != gui.SceneTree | ||
1304 | ) | ||
1305 | { | ||
1306 | gui.SceneTree->getRoot()->clearChildren(); | ||
1307 | addSceneTreeItem ( Game->Device->getSceneManager()->getRootSceneNode(), gui.SceneTree->getRoot() ); | ||
1308 | } | ||
1309 | |||
1310 | Game->Device->getGUIEnvironment()->setFocus ( Game->guiActive ? gui.Window: 0 ); | ||
1311 | } | ||
1312 | </pre></div><p>Handle game input </p> | ||
1313 | <div class="fragment"><pre class="fragment"><span class="keywordtype">bool</span> CQuake3EventHandler::OnEvent(<span class="keyword">const</span> SEvent& eve) | ||
1314 | { | ||
1315 | <span class="keywordflow">if</span> ( eve.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0ca8553b889c8da285c96b90116ae019952" title="A log event.">EET_LOG_TEXT_EVENT</a> ) | ||
1316 | { | ||
1317 | <span class="keywordflow">return</span> <span class="keyword">false</span>; | ||
1318 | } | ||
1319 | |||
1320 | <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> ) | ||
1321 | { | ||
1322 | <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> ) | ||
1323 | { | ||
1324 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selected = gui.MapList->getSelected(); | ||
1325 | <span class="keywordflow">if</span> ( selected >= 0 ) | ||
1326 | { | ||
1327 | <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> loadMap = gui.MapList->getListItem ( selected ); | ||
1328 | <span class="keywordflow">if</span> ( 0 == MapParent || loadMap != Game->CurrentMapName ) | ||
1329 | { | ||
1330 | printf ( <span class="stringliteral">"Loading map %ls\n"</span>, loadMap.c_str() ); | ||
1331 | LoadMap ( loadMap , 1 ); | ||
1332 | <span class="keywordflow">if</span> ( 0 == Game->loadParam.loadSkyShader ) | ||
1333 | { | ||
1334 | AddSky ( 1, <span class="stringliteral">"skydome2"</span> ); | ||
1335 | } | ||
1336 | CreatePlayers (); | ||
1337 | CreateGUI (); | ||
1338 | SetGUIActive ( 0 ); | ||
1339 | <span class="keywordflow">return</span> <span class="keyword">true</span>; | ||
1340 | } | ||
1341 | } | ||
1342 | } | ||
1343 | <span class="keywordflow">else</span> | ||
1344 | <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> ) | ||
1345 | { | ||
1346 | Game->Device->getFileSystem()->removeFileArchive( gui.ArchiveList->getSelected() ); | ||
1347 | Game->CurrentMapName = <span class="stringliteral">""</span>; | ||
1348 | AddArchive ( <span class="stringliteral">""</span> ); | ||
1349 | } | ||
1350 | <span class="keywordflow">else</span> | ||
1351 | <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> ) | ||
1352 | { | ||
1353 | <span class="keywordflow">if</span> ( 0 == gui.ArchiveFileOpen ) | ||
1354 | { | ||
1355 | Game->Device->getFileSystem()->setFileListSystem ( <a class="code" href="namespaceirr_1_1io.html#a22364f1caf06442a70f6198025af3fe9acfbc9e5e8773ec885f08eafd6c8d3c6f">FILESYSTEM_NATIVE</a> ); | ||
1356 | gui.ArchiveFileOpen = Game->Device->getGUIEnvironment()->addFileOpenDialog ( L<span class="stringliteral">"Add Game Archive"</span> , <span class="keyword">false</span>,gui.Window ); | ||
1357 | } | ||
1358 | } | ||
1359 | <span class="keywordflow">else</span> | ||
1360 | <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> ) | ||
1361 | { | ||
1362 | AddArchive ( gui.ArchiveFileOpen->getFileName() ); | ||
1363 | gui.ArchiveFileOpen = 0; | ||
1364 | } | ||
1365 | <span class="keywordflow">else</span> | ||
1366 | <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> ) | ||
1367 | { | ||
1368 | AddArchive ( gui.ArchiveFileOpen->getDirectoryName() ); | ||
1369 | } | ||
1370 | <span class="keywordflow">else</span> | ||
1371 | <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> ) | ||
1372 | { | ||
1373 | gui.ArchiveFileOpen = 0; | ||
1374 | } | ||
1375 | <span class="keywordflow">else</span> | ||
1376 | <span class="keywordflow">if</span> ( ( eve.GUIEvent.Caller == gui.ArchiveUp || eve.GUIEvent.Caller == gui.ArchiveDown ) && | ||
1377 | eve.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" title="A button was clicked.">gui::EGET_BUTTON_CLICKED</a> ) | ||
1378 | { | ||
1379 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> rel = eve.GUIEvent.Caller == gui.ArchiveUp ? -1 : 1; | ||
1380 | <span class="keywordflow">if</span> ( Game->Device->getFileSystem()->moveFileArchive ( gui.ArchiveList->getSelected (), rel ) ) | ||
1381 | { | ||
1382 | <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 ); | ||
1383 | AddArchive ( <span class="stringliteral">""</span> ); | ||
1384 | gui.ArchiveList->setSelected ( newIndex ); | ||
1385 | Game->CurrentMapName = <span class="stringliteral">""</span>; | ||
1386 | } | ||
1387 | } | ||
1388 | <span class="keywordflow">else</span> | ||
1389 | <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> ) | ||
1390 | { | ||
1391 | 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() ); | ||
1392 | } | ||
1393 | <span class="keywordflow">else</span> | ||
1394 | <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> ) | ||
1395 | { | ||
1396 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> val = gui.VideoMode->getItemData ( gui.VideoMode->getSelected() ); | ||
1397 | Game->deviceParam.WindowSize.Width = val >> 16; | ||
1398 | Game->deviceParam.WindowSize.Height = val & 0xFFFF; | ||
1399 | } | ||
1400 | <span class="keywordflow">else</span> | ||
1401 | <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> ) | ||
1402 | { | ||
1403 | Game->deviceParam.Fullscreen = gui.FullScreen->isChecked(); | ||
1404 | } | ||
1405 | <span class="keywordflow">else</span> | ||
1406 | <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> ) | ||
1407 | { | ||
1408 | Game->deviceParam.Bits = gui.Bit32->isChecked() ? 32 : 16; | ||
1409 | } | ||
1410 | <span class="keywordflow">else</span> | ||
1411 | <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> ) | ||
1412 | { | ||
1413 | Game->deviceParam.AntiAlias = gui.MultiSample->getPos(); | ||
1414 | } | ||
1415 | <span class="keywordflow">else</span> | ||
1416 | <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> ) | ||
1417 | { | ||
1418 | Game->loadParam.patchTesselation = gui.Tesselation->getPos (); | ||
1419 | } | ||
1420 | <span class="keywordflow">else</span> | ||
1421 | <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> ) | ||
1422 | { | ||
1423 | Game->GammaValue = gui.Gamma->getPos () * 0.01f; | ||
1424 | Game->Device->setGammaRamp ( Game->GammaValue, Game->GammaValue, Game->GammaValue, 0.f, 0.f ); | ||
1425 | } | ||
1426 | <span class="keywordflow">else</span> | ||
1427 | <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> ) | ||
1428 | { | ||
1429 | Game->retVal = 2; | ||
1430 | Game->Device->closeDevice(); | ||
1431 | } | ||
1432 | <span class="keywordflow">else</span> | ||
1433 | <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> ) | ||
1434 | { | ||
1435 | Game->Device->closeDevice(); | ||
1436 | } | ||
1437 | <span class="keywordflow">else</span> | ||
1438 | <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> ) | ||
1439 | { | ||
1440 | <span class="comment">// set fly through active</span> | ||
1441 | Game->flyTroughState ^= 1; | ||
1442 | Player[0].cam()->setAnimateTarget ( Game->flyTroughState == 0 ); | ||
1443 | |||
1444 | printf ( <span class="stringliteral">"collision %d\n"</span>, Game->flyTroughState == 0 ); | ||
1445 | } | ||
1446 | <span class="keywordflow">else</span> | ||
1447 | <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> ) | ||
1448 | { | ||
1449 | <span class="keywordtype">bool</span> v = gui.Visible_Map->isChecked(); | ||
1450 | |||
1451 | <span class="keywordflow">if</span> ( MapParent ) | ||
1452 | { | ||
1453 | printf ( <span class="stringliteral">"static node set visible %d\n"</span>,v ); | ||
1454 | MapParent->setVisible ( v ); | ||
1455 | } | ||
1456 | } | ||
1457 | <span class="keywordflow">else</span> | ||
1458 | <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> ) | ||
1459 | { | ||
1460 | <span class="keywordtype">bool</span> v = gui.Visible_Shader->isChecked(); | ||
1461 | |||
1462 | <span class="keywordflow">if</span> ( ShaderParent ) | ||
1463 | { | ||
1464 | printf ( <span class="stringliteral">"shader node set visible %d\n"</span>,v ); | ||
1465 | ShaderParent->setVisible ( v ); | ||
1466 | } | ||
1467 | } | ||
1468 | <span class="keywordflow">else</span> | ||
1469 | <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> ) | ||
1470 | { | ||
1471 | <span class="keywordflow">if</span> ( SkyNode ) | ||
1472 | { | ||
1473 | <span class="keywordtype">bool</span> v = !SkyNode->isVisible(); | ||
1474 | printf ( <span class="stringliteral">"skynode set visible %d\n"</span>,v ); | ||
1475 | SkyNode->setVisible ( v ); | ||
1476 | } | ||
1477 | } | ||
1478 | <span class="keywordflow">else</span> | ||
1479 | <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> ) | ||
1480 | { | ||
1481 | Player[0].respawn (); | ||
1482 | } | ||
1483 | |||
1484 | <span class="keywordflow">return</span> <span class="keyword">false</span>; | ||
1485 | } | ||
1486 | |||
1487 | <span class="comment">// fire</span> | ||
1488 | <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> && | ||
1489 | eve.KeyInput.PressedDown == <span class="keyword">false</span>) || | ||
1490 | (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>) | ||
1491 | ) | ||
1492 | { | ||
1493 | ICameraSceneNode * camera = Game->Device->getSceneManager()->getActiveCamera (); | ||
1494 | <span class="keywordflow">if</span> ( camera && camera->isInputReceiverEnabled () ) | ||
1495 | { | ||
1496 | useItem( Player + 0 ); | ||
1497 | } | ||
1498 | } | ||
1499 | |||
1500 | <span class="comment">// gui active</span> | ||
1501 | <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> && | ||
1502 | eve.KeyInput.PressedDown == <span class="keyword">false</span>) || | ||
1503 | (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>) | ||
1504 | ) | ||
1505 | { | ||
1506 | SetGUIActive ( 2 ); | ||
1507 | } | ||
1508 | |||
1509 | <span class="comment">// check if user presses the key</span> | ||
1510 | <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>) | ||
1511 | { | ||
1512 | <span class="comment">// Escape toggles camera Input</span> | ||
1513 | <span class="keywordflow">if</span> ( eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3aab32bfc194f119e5d5b9b39527bbcd61">irr::KEY_ESCAPE</a> ) | ||
1514 | { | ||
1515 | SetGUIActive ( 3 ); | ||
1516 | } | ||
1517 | <span class="keywordflow">else</span> | ||
1518 | <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3af847cf3df62b0e23942f0bd2d226a9eb">KEY_F11</a>) | ||
1519 | { | ||
1520 | <span class="comment">// screenshot are taken without gamma!</span> | ||
1521 | IImage* image = Game->Device->getVideoDriver()->createScreenShot(); | ||
1522 | <span class="keywordflow">if</span> (image) | ||
1523 | { | ||
1524 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> pos; | ||
1525 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a> rot; | ||
1526 | ICameraSceneNode * cam = Game->Device->getSceneManager()->getActiveCamera (); | ||
1527 | <span class="keywordflow">if</span> ( cam ) | ||
1528 | { | ||
1529 | pos = cam->getPosition (); | ||
1530 | rot = cam->getRotation (); | ||
1531 | } | ||
1532 | |||
1533 | <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>, | ||
1534 | <span class="stringliteral">"d3d8"</span>, <span class="stringliteral">"d3d9"</span>, <span class="stringliteral">"opengl"</span> }; | ||
1535 | |||
1536 | snprintf(buf, 256, <span class="stringliteral">"%s_%ls_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f.jpg"</span>, | ||
1537 | dName[Game->Device->getVideoDriver()->getDriverType()], | ||
1538 | Game->CurrentMapName.c_str(), | ||
1539 | pos.X, pos.Y, pos.Z, | ||
1540 | rot.X, rot.Y, rot.Z | ||
1541 | ); | ||
1542 | <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> filename ( buf ); | ||
1543 | filename.replace ( <span class="charliteral">'/'</span>, <span class="charliteral">'_'</span> ); | ||
1544 | printf ( <span class="stringliteral">"screenshot : %s\n"</span>, filename.c_str() ); | ||
1545 | Game->Device->getVideoDriver()->writeImageToFile(image, filename, 100 ); | ||
1546 | image->drop(); | ||
1547 | } | ||
1548 | } | ||
1549 | <span class="keywordflow">else</span> | ||
1550 | <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a5dfbe4e0c7c8d9d810717fc1331fd3c9">KEY_F9</a>) | ||
1551 | { | ||
1552 | <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>; | ||
1553 | |||
1554 | Game->debugState = ( Game->debugState + 1 ) & 3; | ||
1555 | |||
1556 | <span class="keywordflow">switch</span> ( Game->debugState ) | ||
1557 | { | ||
1558 | <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>; | ||
1559 | <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>; | ||
1560 | } | ||
1561 | </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> | ||
1562 | <div class="fragment"><pre class="fragment"> <span class="keywordflow">if</span> ( ItemParent ) | ||
1563 | { | ||
1564 | list<ISceneNode*>::ConstIterator it = ItemParent->getChildren().begin(); | ||
1565 | <span class="keywordflow">for</span> (; it != ItemParent->getChildren().end(); ++it) | ||
1566 | { | ||
1567 | (*it)->setDebugDataVisible ( value ); | ||
1568 | } | ||
1569 | } | ||
1570 | |||
1571 | <span class="keywordflow">if</span> ( ShaderParent ) | ||
1572 | { | ||
1573 | list<ISceneNode*>::ConstIterator it = ShaderParent->getChildren().begin(); | ||
1574 | <span class="keywordflow">for</span> (; it != ShaderParent->getChildren().end(); ++it) | ||
1575 | { | ||
1576 | (*it)->setDebugDataVisible ( value ); | ||
1577 | } | ||
1578 | } | ||
1579 | |||
1580 | <span class="keywordflow">if</span> ( UnresolvedParent ) | ||
1581 | { | ||
1582 | list<ISceneNode*>::ConstIterator it = UnresolvedParent->getChildren().begin(); | ||
1583 | <span class="keywordflow">for</span> (; it != UnresolvedParent->getChildren().end(); ++it) | ||
1584 | { | ||
1585 | (*it)->setDebugDataVisible ( value ); | ||
1586 | } | ||
1587 | } | ||
1588 | |||
1589 | <span class="keywordflow">if</span> ( FogParent ) | ||
1590 | { | ||
1591 | list<ISceneNode*>::ConstIterator it = FogParent->getChildren().begin(); | ||
1592 | <span class="keywordflow">for</span> (; it != FogParent->getChildren().end(); ++it) | ||
1593 | { | ||
1594 | (*it)->setDebugDataVisible ( value ); | ||
1595 | } | ||
1596 | } | ||
1597 | |||
1598 | <span class="keywordflow">if</span> ( SkyNode ) | ||
1599 | { | ||
1600 | SkyNode->setDebugDataVisible ( value ); | ||
1601 | } | ||
1602 | |||
1603 | } | ||
1604 | <span class="keywordflow">else</span> | ||
1605 | <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a5111be01fea6429912b3e497b2a85d73">KEY_F8</a>) | ||
1606 | { | ||
1607 | <span class="comment">// set gravity on/off</span> | ||
1608 | Game->gravityState ^= 1; | ||
1609 | Player[0].cam()->setGravity ( getGravity ( Game->gravityState ? <span class="stringliteral">"earth"</span> : <span class="stringliteral">"none"</span> ) ); | ||
1610 | printf ( <span class="stringliteral">"gravity %s\n"</span>, Game->gravityState ? <span class="stringliteral">"earth"</span> : <span class="stringliteral">"none"</span> ); | ||
1611 | } | ||
1612 | <span class="keywordflow">else</span> | ||
1613 | <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a7f58cecbda71cea3043c026d3ba00456">KEY_F7</a>) | ||
1614 | { | ||
1615 | <span class="comment">// set fly through active</span> | ||
1616 | Game->flyTroughState ^= 1; | ||
1617 | Player[0].cam()->setAnimateTarget ( Game->flyTroughState == 0 ); | ||
1618 | <span class="keywordflow">if</span> ( gui.Collision ) | ||
1619 | gui.Collision->setChecked ( Game->flyTroughState == 0 ); | ||
1620 | |||
1621 | printf ( <span class="stringliteral">"collision %d\n"</span>, Game->flyTroughState == 0 ); | ||
1622 | } | ||
1623 | <span class="keywordflow">else</span> | ||
1624 | <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a992b194a5b4b4809587db8a43c3e75dd">KEY_F2</a>) | ||
1625 | { | ||
1626 | Player[0].respawn (); | ||
1627 | } | ||
1628 | <span class="keywordflow">else</span> | ||
1629 | <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a2f017f7a3b6291e5d549ed4a09c03d4e">KEY_F3</a>) | ||
1630 | { | ||
1631 | <span class="keywordflow">if</span> ( MapParent ) | ||
1632 | { | ||
1633 | <span class="keywordtype">bool</span> v = !MapParent->isVisible (); | ||
1634 | printf ( <span class="stringliteral">"static node set visible %d\n"</span>,v ); | ||
1635 | MapParent->setVisible ( v ); | ||
1636 | <span class="keywordflow">if</span> ( gui.Visible_Map ) | ||
1637 | gui.Visible_Map->setChecked ( v ); | ||
1638 | } | ||
1639 | } | ||
1640 | <span class="keywordflow">else</span> | ||
1641 | <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a8f49f2e6664716985551334f0b2c1b47">KEY_F4</a>) | ||
1642 | { | ||
1643 | <span class="keywordflow">if</span> ( ShaderParent ) | ||
1644 | { | ||
1645 | <span class="keywordtype">bool</span> v = !ShaderParent->isVisible (); | ||
1646 | printf ( <span class="stringliteral">"shader node set visible %d\n"</span>,v ); | ||
1647 | ShaderParent->setVisible ( v ); | ||
1648 | <span class="keywordflow">if</span> ( gui.Visible_Shader ) | ||
1649 | gui.Visible_Shader->setChecked ( v ); | ||
1650 | } | ||
1651 | } | ||
1652 | <span class="keywordflow">else</span> | ||
1653 | <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a6aecea6261588331b87093b4ab544b1a">KEY_F5</a>) | ||
1654 | { | ||
1655 | <span class="keywordflow">if</span> ( FogParent ) | ||
1656 | { | ||
1657 | <span class="keywordtype">bool</span> v = !FogParent->isVisible (); | ||
1658 | printf ( <span class="stringliteral">"fog node set visible %d\n"</span>,v ); | ||
1659 | FogParent->setVisible ( v ); | ||
1660 | <span class="keywordflow">if</span> ( gui.Visible_Fog ) | ||
1661 | gui.Visible_Fog->setChecked ( v ); | ||
1662 | } | ||
1663 | |||
1664 | } | ||
1665 | <span class="keywordflow">else</span> | ||
1666 | <span class="keywordflow">if</span> (eve.KeyInput.Key == <a class="code" href="namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3a6c0530c3448c3274b137f97df44e2a44">KEY_F6</a>) | ||
1667 | { | ||
1668 | <span class="keywordflow">if</span> ( UnresolvedParent ) | ||
1669 | { | ||
1670 | <span class="keywordtype">bool</span> v = !UnresolvedParent->isVisible (); | ||
1671 | printf ( <span class="stringliteral">"unresolved node set visible %d\n"</span>,v ); | ||
1672 | UnresolvedParent->setVisible ( v ); | ||
1673 | <span class="keywordflow">if</span> ( gui.Visible_Unresolved ) | ||
1674 | gui.Visible_Unresolved->setChecked ( v ); | ||
1675 | } | ||
1676 | } | ||
1677 | } | ||
1678 | |||
1679 | <span class="comment">// check if user presses the key C ( for crouch)</span> | ||
1680 | <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> ) | ||
1681 | { | ||
1682 | <span class="comment">// crouch</span> | ||
1683 | ISceneNodeAnimatorCollisionResponse *anim = Player[0].cam (); | ||
1684 | <span class="keywordflow">if</span> ( anim && 0 == Game->flyTroughState ) | ||
1685 | { | ||
1686 | <span class="keywordflow">if</span> ( <span class="keyword">false</span> == eve.KeyInput.PressedDown ) | ||
1687 | { | ||
1688 | <span class="comment">// stand up</span> | ||
1689 | anim->setEllipsoidRadius ( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(30,45,30) ); | ||
1690 | anim->setEllipsoidTranslation ( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0,40,0)); | ||
1691 | |||
1692 | } | ||
1693 | <span class="keywordflow">else</span> | ||
1694 | { | ||
1695 | <span class="comment">// on your knees</span> | ||
1696 | anim->setEllipsoidRadius ( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(30,20,30) ); | ||
1697 | anim->setEllipsoidTranslation ( <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a>(0,20,0)); | ||
1698 | } | ||
1699 | <span class="keywordflow">return</span> <span class="keyword">true</span>; | ||
1700 | } | ||
1701 | } | ||
1702 | <span class="keywordflow">return</span> <span class="keyword">false</span>; | ||
1703 | } | ||
1704 | </pre></div><p>useItem </p> | ||
1705 | <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::useItem( Q3Player * player) | ||
1706 | { | ||
1707 | ISceneManager* smgr = Game->Device->getSceneManager(); | ||
1708 | ICameraSceneNode* camera = smgr->getActiveCamera(); | ||
1709 | |||
1710 | <span class="keywordflow">if</span> (!camera) | ||
1711 | <span class="keywordflow">return</span>; | ||
1712 | |||
1713 | SParticleImpact imp; | ||
1714 | imp.when = 0; | ||
1715 | |||
1716 | <span class="comment">// get line of camera</span> | ||
1717 | |||
1718 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> start = camera->getPosition(); | ||
1719 | |||
1720 | <span class="keywordflow">if</span> ( player->WeaponNode ) | ||
1721 | { | ||
1722 | start.X += 0.f; | ||
1723 | start.Y += 0.f; | ||
1724 | start.Z += 0.f; | ||
1725 | } | ||
1726 | |||
1727 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> end = (camera->getTarget() - start); | ||
1728 | end.normalize(); | ||
1729 | start += end*20.0f; | ||
1730 | |||
1731 | end = start + (end * camera->getFarValue()); | ||
1732 | |||
1733 | <a class="code" href="namespaceirr_1_1core.html#a1112835405bbec5dadf031dc7934e7d0" title="Typedef for a f32 3d triangle.">triangle3df</a> triangle; | ||
1734 | line3d<f32> line(start, end); | ||
1735 | |||
1736 | <span class="comment">// get intersection point with map</span> | ||
1737 | scene::ISceneNode* hitNode; | ||
1738 | <span class="keywordflow">if</span> (smgr->getSceneCollisionManager()->getCollisionPoint( | ||
1739 | line, Meta, end, triangle,hitNode)) | ||
1740 | { | ||
1741 | <span class="comment">// collides with wall</span> | ||
1742 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> out = triangle.getNormal(); | ||
1743 | out.setLength(0.03f); | ||
1744 | |||
1745 | imp.when = 1; | ||
1746 | imp.outVector = out; | ||
1747 | imp.pos = end; | ||
1748 | |||
1749 | player->setAnim ( <span class="stringliteral">"pow"</span> ); | ||
1750 | player->Anim[1].next += player->Anim[1].delta; | ||
1751 | } | ||
1752 | <span class="keywordflow">else</span> | ||
1753 | { | ||
1754 | <span class="comment">// doesnt collide with wall</span> | ||
1755 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> start = camera->getPosition(); | ||
1756 | <span class="keywordflow">if</span> ( player->WeaponNode ) | ||
1757 | { | ||
1758 | <span class="comment">//start.X += 10.f;</span> | ||
1759 | <span class="comment">//start.Y += -5.f;</span> | ||
1760 | <span class="comment">//start.Z += 1.f;</span> | ||
1761 | } | ||
1762 | |||
1763 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> end = (camera->getTarget() - start); | ||
1764 | end.normalize(); | ||
1765 | start += end*20.0f; | ||
1766 | end = start + (end * camera->getFarValue()); | ||
1767 | } | ||
1768 | |||
1769 | <span class="comment">// create fire ball</span> | ||
1770 | ISceneNode* node = 0; | ||
1771 | node = smgr->addBillboardSceneNode( BulletParent,dimension2d<f32>(10,10), start); | ||
1772 | |||
1773 | 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>); | ||
1774 | node->setMaterialTexture(0, Game->Device->getVideoDriver()->getTexture(<span class="stringliteral">"fireball.bmp"</span>)); | ||
1775 | 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>); | ||
1776 | node->setMaterialType(<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a1b5a814c4466aca2943ff056003a50d1" title="A transparent material.">EMT_TRANSPARENT_ADD_COLOR</a>); | ||
1777 | |||
1778 | <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(); | ||
1779 | <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> speed = 5.8f; | ||
1780 | <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); | ||
1781 | |||
1782 | ISceneNodeAnimator* anim = 0; | ||
1783 | |||
1784 | <span class="comment">// set flight line</span> | ||
1785 | |||
1786 | anim = smgr->createFlyStraightAnimator(start, end, time); | ||
1787 | node->addAnimator(anim); | ||
1788 | anim->drop(); | ||
1789 | |||
1790 | snprintf ( buf, 64, <span class="stringliteral">"bullet: %s on %.1f,%1.f,%1.f"</span>, | ||
1791 | imp.when ? <span class="stringliteral">"hit"</span> : <span class="stringliteral">"nohit"</span>, end.X, end.Y, end.Z ); | ||
1792 | node->setName ( buf ); | ||
1793 | |||
1794 | |||
1795 | anim = smgr->createDeleteAnimator(time); | ||
1796 | node->addAnimator(anim); | ||
1797 | anim->drop(); | ||
1798 | |||
1799 | <span class="keywordflow">if</span> (imp.when) | ||
1800 | { | ||
1801 | <span class="comment">// create impact note</span> | ||
1802 | imp.when = Game->Device->getTimer()->getTime() + | ||
1803 | (time + (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) ( ( 1.f + Noiser::get() ) * 250.f )); | ||
1804 | Impacts.push_back(imp); | ||
1805 | } | ||
1806 | |||
1807 | <span class="comment">// play sound</span> | ||
1808 | } | ||
1809 | |||
1810 | <span class="comment">// rendered when bullets hit something</span> | ||
1811 | <span class="keywordtype">void</span> CQuake3EventHandler::createParticleImpacts( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> now ) | ||
1812 | { | ||
1813 | ISceneManager* sm = Game->Device->getSceneManager(); | ||
1814 | |||
1815 | <span class="keyword">struct </span>smokeLayer | ||
1816 | { | ||
1817 | <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> * texture; | ||
1818 | <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> scale; | ||
1819 | <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> minparticleSize; | ||
1820 | <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> maxparticleSize; | ||
1821 | <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> boxSize; | ||
1822 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> minParticle; | ||
1823 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> maxParticle; | ||
1824 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> fadeout; | ||
1825 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> lifetime; | ||
1826 | }; | ||
1827 | |||
1828 | smokeLayer smoke[] = | ||
1829 | { | ||
1830 | { <span class="stringliteral">"smoke2.jpg"</span>, 0.4f, 1.5f, 18.f, 20.f, 20, 50, 2000, 10000 }, | ||
1831 | { <span class="stringliteral">"smoke3.jpg"</span>, 0.2f, 1.2f, 15.f, 20.f, 10, 30, 1000, 12000 } | ||
1832 | }; | ||
1833 | |||
1834 | |||
1835 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i; | ||
1836 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> g; | ||
1837 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> factor = 1; | ||
1838 | <span class="keywordflow">for</span> ( g = 0; g != 2; ++g ) | ||
1839 | { | ||
1840 | smoke[g].minParticle *= factor; | ||
1841 | smoke[g].maxParticle *= factor; | ||
1842 | smoke[g].lifetime *= factor; | ||
1843 | smoke[g].boxSize *= Noiser::get() * 0.5f; | ||
1844 | } | ||
1845 | |||
1846 | <span class="keywordflow">for</span> ( i=0; i < Impacts.size(); ++i) | ||
1847 | { | ||
1848 | <span class="keywordflow">if</span> (now < Impacts[i].when) | ||
1849 | <span class="keywordflow">continue</span>; | ||
1850 | |||
1851 | <span class="comment">// create smoke particle system</span> | ||
1852 | IParticleSystemSceneNode* pas = 0; | ||
1853 | |||
1854 | <span class="keywordflow">for</span> ( g = 0; g != 2; ++g ) | ||
1855 | { | ||
1856 | pas = sm->addParticleSystemSceneNode(<span class="keyword">false</span>, BulletParent, -1, Impacts[i].pos); | ||
1857 | |||
1858 | snprintf ( buf, 64, <span class="stringliteral">"bullet impact smoke at %.1f,%.1f,%1.f"</span>, | ||
1859 | Impacts[i].pos.X,Impacts[i].pos.Y,Impacts[i].pos.Z); | ||
1860 | pas->setName ( buf ); | ||
1861 | |||
1862 | <span class="comment">// create a flat smoke</span> | ||
1863 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> direction = Impacts[i].outVector; | ||
1864 | direction *= smoke[g].scale; | ||
1865 | IParticleEmitter* em = pas->createBoxEmitter( | ||
1866 | aabbox3d<f32>(-4.f,0.f,-4.f,20.f,smoke[g].minparticleSize,20.f), | ||
1867 | direction,smoke[g].minParticle, smoke[g].maxParticle, | ||
1868 | video::SColor(0,0,0,0),video::SColor(0,128,128,128), | ||
1869 | 250,4000, 60); | ||
1870 | |||
1871 | em->setMinStartSize (dimension2d<f32>( smoke[g].minparticleSize, smoke[g].minparticleSize)); | ||
1872 | em->setMaxStartSize (dimension2d<f32>( smoke[g].maxparticleSize, smoke[g].maxparticleSize)); | ||
1873 | |||
1874 | pas->setEmitter(em); | ||
1875 | em->drop(); | ||
1876 | |||
1877 | <span class="comment">// particles get invisible</span> | ||
1878 | IParticleAffector* paf = pas->createFadeOutParticleAffector( | ||
1879 | video::SColor ( 0, 0, 0, 0 ), smoke[g].fadeout); | ||
1880 | pas->addAffector(paf); | ||
1881 | paf->drop(); | ||
1882 | |||
1883 | <span class="comment">// particle system life time</span> | ||
1884 | ISceneNodeAnimator* anim = sm->createDeleteAnimator( smoke[g].lifetime); | ||
1885 | pas->addAnimator(anim); | ||
1886 | anim->drop(); | ||
1887 | |||
1888 | 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>); | ||
1889 | 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>); | ||
1890 | pas->setMaterialType(<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a1b5a814c4466aca2943ff056003a50d1" title="A transparent material.">video::EMT_TRANSPARENT_ADD_COLOR</a> ); | ||
1891 | pas->setMaterialTexture(0, Game->Device->getVideoDriver()->getTexture( smoke[g].texture )); | ||
1892 | } | ||
1893 | |||
1894 | |||
1895 | <span class="comment">// play impact sound</span> | ||
1896 | <span class="preprocessor"> #ifdef USE_IRRKLANG</span> | ||
1897 | </pre></div><p>if (irrKlang) { audio::ISound* sound = irrKlang->play3D(impactSound, Impacts[i].pos, false, false, true);</p> | ||
1898 | <p>if (sound) { adjust max value a bit to make to sound of an impact louder sound->setMinDistance(400); sound->drop(); } } </p> | ||
1899 | <div class="fragment"><pre class="fragment"><span class="preprocessor"> #endif</span> | ||
1900 | <span class="preprocessor"></span> | ||
1901 | |||
1902 | <span class="comment">// delete entry</span> | ||
1903 | Impacts.erase(i); | ||
1904 | i--; | ||
1905 | } | ||
1906 | } | ||
1907 | </pre></div><p>render </p> | ||
1908 | <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::Render() | ||
1909 | { | ||
1910 | IVideoDriver * driver = Game->Device->getVideoDriver(); | ||
1911 | <span class="keywordflow">if</span> ( 0 == driver ) | ||
1912 | <span class="keywordflow">return</span>; | ||
1913 | |||
1914 | <span class="comment">// TODO: This does not work, yet.</span> | ||
1915 | <span class="keyword">const</span> <span class="keywordtype">bool</span> anaglyph=<span class="keyword">false</span>; | ||
1916 | <span class="keywordflow">if</span> (anaglyph) | ||
1917 | { | ||
1918 | scene::ICameraSceneNode* cameraOld = Game->Device->getSceneManager()->getActiveCamera(); | ||
1919 | driver->beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, SColor(0,0,0,0)); | ||
1920 | driver->getOverrideMaterial().Material.ColorMask = <a class="code" href="namespaceirr_1_1video.html#aa9f25191ae536c1a4b08ec5334866a21aa5afe366b19c967f884d0bd4ca083df9" title="No color enabled.">ECP_NONE</a>; | ||
1921 | driver->getOverrideMaterial().EnableFlags = <a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a72ede4598946d81f12aa407fb680fc40" title="ColorMask bits, for enabling the color planes.">EMF_COLOR_MASK</a>; | ||
1922 | driver->getOverrideMaterial().EnablePasses = <a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fac41f4cb4900e84b9e55462089d0e3cb8" title="This is used for sky boxes.">ESNRP_SKY_BOX</a> + | ||
1923 | <a class="code" href="namespaceirr_1_1scene.html#a7862269bd1abc123929d4dbb8200d67fad058b020ab42ad745cc03fe379148e1f" title="Solid scene nodes or special scene nodes without materials.">ESNRP_SOLID</a> + | ||
1924 | <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> + | ||
1925 | <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> + | ||
1926 | <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>; | ||
1927 | Game->Device->getSceneManager()->drawAll(); | ||
1928 | driver->clearZBuffer(); | ||
1929 | |||
1930 | <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(); | ||
1931 | <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(); | ||
1932 | <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#a73fa92e638c5ca97efd72da307cc9b65" title="Typedef for f32 matrix.">matrix4</a> startMatrix = cameraOld->getAbsoluteTransformation(); | ||
1933 | <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 - | ||
1934 | cameraOld->getAbsolutePosition()).setLength(10000) + | ||
1935 | cameraOld->getAbsolutePosition() ; | ||
1936 | |||
1937 | scene::ICameraSceneNode* camera = cameraOld;<span class="comment">//Game->Device->getSceneManager()->addCameraSceneNode();</span> | ||
1938 | |||
1939 | <span class="comment">//Left eye...</span> | ||
1940 | <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">vector3df</a> pos; | ||
1941 | <a class="code" href="namespaceirr_1_1core.html#a73fa92e638c5ca97efd72da307cc9b65" title="Typedef for f32 matrix.">matrix4</a> move; | ||
1942 | |||
1943 | 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) ); | ||
1944 | pos=(startMatrix*move).getTranslation(); | ||
1945 | |||
1946 | driver->getOverrideMaterial().Material.ColorMask = <a class="code" href="namespaceirr_1_1video.html#aa9f25191ae536c1a4b08ec5334866a21a36263a436337ff10be86fc9b5ae2f6d0" title="Red enabled.">ECP_RED</a>; | ||
1947 | driver->getOverrideMaterial().EnableFlags = <a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a72ede4598946d81f12aa407fb680fc40" title="ColorMask bits, for enabling the color planes.">EMF_COLOR_MASK</a>; | ||
1948 | driver->getOverrideMaterial().EnablePasses = | ||
1949 | <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>| | ||
1950 | <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>; | ||
1951 | |||
1952 | camera->setPosition(pos); | ||
1953 | camera->setTarget(focusPoint); | ||
1954 | |||
1955 | Game->Device->getSceneManager()->drawAll(); | ||
1956 | driver->clearZBuffer(); | ||
1957 | |||
1958 | <span class="comment">//Right eye...</span> | ||
1959 | 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) ); | ||
1960 | pos=(startMatrix*move).getTranslation(); | ||
1961 | |||
1962 | 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>; | ||
1963 | driver->getOverrideMaterial().EnableFlags = <a class="code" href="namespaceirr_1_1video.html#a8a3bc00ae8137535b9fbc5f40add70d3a72ede4598946d81f12aa407fb680fc40" title="ColorMask bits, for enabling the color planes.">EMF_COLOR_MASK</a>; | ||
1964 | driver->getOverrideMaterial().EnablePasses = | ||
1965 | <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>| | ||
1966 | <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>; | ||
1967 | |||
1968 | camera->setPosition(pos); | ||
1969 | camera->setTarget(focusPoint); | ||
1970 | |||
1971 | Game->Device->getSceneManager()->drawAll(); | ||
1972 | |||
1973 | driver->getOverrideMaterial().Material.ColorMask=<a class="code" href="namespaceirr_1_1video.html#aa9f25191ae536c1a4b08ec5334866a21a674ec773096b1b504b38ed78213e1e38" title="All planes enabled.">ECP_ALL</a>; | ||
1974 | driver->getOverrideMaterial().EnableFlags=0; | ||
1975 | driver->getOverrideMaterial().EnablePasses=0; | ||
1976 | |||
1977 | <span class="keywordflow">if</span> (camera != cameraOld) | ||
1978 | { | ||
1979 | Game->Device->getSceneManager()->setActiveCamera(cameraOld); | ||
1980 | camera->remove(); | ||
1981 | } | ||
1982 | <span class="keywordflow">else</span> | ||
1983 | { | ||
1984 | camera->setPosition(oldPosition); | ||
1985 | camera->setTarget(oldTarget); | ||
1986 | } | ||
1987 | } | ||
1988 | <span class="keywordflow">else</span> | ||
1989 | { | ||
1990 | driver->beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, SColor(0,0,0,0)); | ||
1991 | Game->Device->getSceneManager()->drawAll(); | ||
1992 | } | ||
1993 | Game->Device->getGUIEnvironment()->drawAll(); | ||
1994 | driver->endScene(); | ||
1995 | } | ||
1996 | </pre></div><p>update the generic scene node </p> | ||
1997 | <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> CQuake3EventHandler::Animate() | ||
1998 | { | ||
1999 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> now = Game->Device->getTimer()->getTime(); | ||
2000 | |||
2001 | Q3Player * player = Player + 0; | ||
2002 | |||
2003 | checkTimeFire ( player->Anim, 4, now ); | ||
2004 | |||
2005 | <span class="comment">// Query Scene Manager attributes</span> | ||
2006 | <span class="keywordflow">if</span> ( player->Anim[0].flags & FIRED ) | ||
2007 | { | ||
2008 | ISceneManager *smgr = Game->Device->getSceneManager (); | ||
2009 | <span class="keywordtype">wchar_t</span> msg[128]; | ||
2010 | IVideoDriver * driver = Game->Device->getVideoDriver(); | ||
2011 | |||
2012 | IAttributes * attr = smgr->getParameters(); | ||
2013 | <span class="preprocessor">#ifdef _IRR_SCENEMANAGER_DEBUG </span> | ||
2014 | <span class="preprocessor"></span> swprintf ( msg, 128, | ||
2015 | L<span class="stringliteral">"Q3 %s [%ls], FPS:%03d Tri:%.03fm Cull %d/%d nodes (%d,%d,%d)"</span>, | ||
2016 | Game->CurrentMapName.c_str(), | ||
2017 | driver->getName(), | ||
2018 | driver->getFPS (), | ||
2019 | (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>) driver->getPrimitiveCountDrawn( 0 ) * ( 1.f / 1000000.f ), | ||
2020 | attr->getAttributeAsInt ( <span class="stringliteral">"culled"</span> ), | ||
2021 | attr->getAttributeAsInt ( <span class="stringliteral">"calls"</span> ), | ||
2022 | attr->getAttributeAsInt ( <span class="stringliteral">"drawn_solid"</span> ), | ||
2023 | attr->getAttributeAsInt ( <span class="stringliteral">"drawn_transparent"</span> ), | ||
2024 | attr->getAttributeAsInt ( <span class="stringliteral">"drawn_transparent_effect"</span> ) | ||
2025 | ); | ||
2026 | <span class="preprocessor">#else</span> | ||
2027 | <span class="preprocessor"></span>swprintf ( msg, 128, | ||
2028 | L<span class="stringliteral">"Q3 %s [%ls], FPS:%03d Tri:%.03fm"</span>, | ||
2029 | Game->CurrentMapName.c_str(), | ||
2030 | driver->getName(), | ||
2031 | driver->getFPS (), | ||
2032 | (<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a>) driver->getPrimitiveCountDrawn( 0 ) * ( 1.f / 1000000.f ) | ||
2033 | ); | ||
2034 | <span class="preprocessor">#endif </span> | ||
2035 | <span class="preprocessor"></span> Game->Device->setWindowCaption( msg ); | ||
2036 | |||
2037 | swprintf ( msg, 128, | ||
2038 | L<span class="stringliteral">"%03d fps, F1 GUI on/off, F2 respawn, F3-F6 toggle Nodes, F7 Collision on/off"</span> | ||
2039 | L<span class="stringliteral">", F8 Gravity on/off, Right Mouse Toggle GUI"</span>, | ||
2040 | Game->Device->getVideoDriver()->getFPS () | ||
2041 | ); | ||
2042 | <span class="keywordflow">if</span> ( gui.StatusLine ) | ||
2043 | gui.StatusLine->setText ( msg ); | ||
2044 | player->Anim[0].flags &= ~FIRED; | ||
2045 | } | ||
2046 | |||
2047 | <span class="comment">// idle..</span> | ||
2048 | <span class="keywordflow">if</span> ( player->Anim[1].flags & FIRED ) | ||
2049 | { | ||
2050 | <span class="keywordflow">if</span> ( strcmp ( player->animation, <span class="stringliteral">"idle"</span> ) ) | ||
2051 | player->setAnim ( <span class="stringliteral">"idle"</span> ); | ||
2052 | |||
2053 | player->Anim[1].flags &= ~FIRED; | ||
2054 | } | ||
2055 | |||
2056 | createParticleImpacts ( now ); | ||
2057 | |||
2058 | } | ||
2059 | </pre></div><p> The main game states </p> | ||
2060 | <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> runGame ( GameData *game ) | ||
2061 | { | ||
2062 | <span class="keywordflow">if</span> ( game->retVal >= 3 ) | ||
2063 | <span class="keywordflow">return</span>; | ||
2064 | |||
2065 | game->Device = (*game->createExDevice) ( game->deviceParam ); | ||
2066 | <span class="keywordflow">if</span> ( 0 == game->Device) | ||
2067 | { | ||
2068 | <span class="comment">// could not create selected driver.</span> | ||
2069 | game->retVal = 0; | ||
2070 | <span class="keywordflow">return</span>; | ||
2071 | } | ||
2072 | |||
2073 | <span class="comment">// create an event receiver based on current game data</span> | ||
2074 | CQuake3EventHandler *eventHandler = <span class="keyword">new</span> CQuake3EventHandler( game ); | ||
2075 | |||
2076 | <span class="comment">// load stored config</span> | ||
2077 | game->load ( <span class="stringliteral">"explorer.cfg"</span> ); | ||
2078 | |||
2079 | <span class="comment">// add our media directory and archive to the file system</span> | ||
2080 | <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 ) | ||
2081 | { | ||
2082 | eventHandler->AddArchive ( game->CurrentArchiveList[i] ); | ||
2083 | } | ||
2084 | |||
2085 | <span class="comment">// Load a Map or startup to the GUI</span> | ||
2086 | <span class="keywordflow">if</span> ( game->CurrentMapName.size () ) | ||
2087 | { | ||
2088 | eventHandler->LoadMap ( game->CurrentMapName, 1 ); | ||
2089 | <span class="keywordflow">if</span> ( 0 == game->loadParam.loadSkyShader ) | ||
2090 | eventHandler->AddSky ( 1, <span class="stringliteral">"skydome2"</span> ); | ||
2091 | eventHandler->CreatePlayers (); | ||
2092 | eventHandler->CreateGUI (); | ||
2093 | eventHandler->SetGUIActive ( 0 ); | ||
2094 | |||
2095 | <span class="comment">// set player to last position on restart</span> | ||
2096 | <span class="keywordflow">if</span> ( game->retVal == 2 ) | ||
2097 | { | ||
2098 | eventHandler->GetPlayer( 0 )->setpos ( game->PlayerPosition, game->PlayerRotation ); | ||
2099 | } | ||
2100 | } | ||
2101 | <span class="keywordflow">else</span> | ||
2102 | { | ||
2103 | <span class="comment">// start up empty</span> | ||
2104 | eventHandler->AddSky ( 1, <span class="stringliteral">"skydome2"</span> ); | ||
2105 | eventHandler->CreatePlayers (); | ||
2106 | eventHandler->CreateGUI (); | ||
2107 | eventHandler->SetGUIActive ( 1 ); | ||
2108 | background_music ( <span class="stringliteral">"IrrlichtTheme.ogg"</span> ); | ||
2109 | } | ||
2110 | |||
2111 | |||
2112 | game->retVal = 3; | ||
2113 | <span class="keywordflow">while</span>( game->Device->run() ) | ||
2114 | { | ||
2115 | eventHandler->Animate (); | ||
2116 | eventHandler->Render (); | ||
2117 | <span class="comment">//if ( !game->Device->isWindowActive() )</span> | ||
2118 | game->Device->yield(); | ||
2119 | } | ||
2120 | |||
2121 | game->Device->setGammaRamp ( 1.f, 1.f, 1.f, 0.f, 0.f ); | ||
2122 | <span class="keyword">delete</span> eventHandler; | ||
2123 | } | ||
2124 | |||
2125 | <span class="preprocessor">#if defined (_IRR_WINDOWS_) && 0</span> | ||
2126 | <span class="preprocessor"></span><span class="preprocessor"> #pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")</span> | ||
2127 | <span class="preprocessor">#endif</span> | ||
2128 | </pre></div><p> The main routine, doing all setup </p> | ||
2129 | <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[]) | ||
2130 | { | ||
2131 | <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">path</a> prgname(argv[0]); | ||
2132 | GameData game ( <a class="code" href="namespaceirr_1_1core.html#a9215d20e34c12cb6c1522366389bfcce" title="trim paths">deletePathFromPath</a> ( prgname, 1 ) ); | ||
2133 | |||
2134 | <span class="comment">// dynamically load irrlicht</span> | ||
2135 | <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>; | ||
2136 | game.createExDevice = load_createDeviceEx ( dllName ); | ||
2137 | <span class="keywordflow">if</span> ( 0 == game.createExDevice ) | ||
2138 | { | ||
2139 | game.retVal = 3; | ||
2140 | printf ( <span class="stringliteral">"Could not load %s.\n"</span>, dllName ); | ||
2141 | <span class="keywordflow">return</span> game.retVal; <span class="comment">// could not load dll</span> | ||
2142 | } | ||
2143 | |||
2144 | <span class="comment">// start without asking for driver</span> | ||
2145 | game.retVal = 1; | ||
2146 | <span class="keywordflow">do</span> | ||
2147 | { | ||
2148 | <span class="comment">// if driver could not created, ask for another driver</span> | ||
2149 | <span class="keywordflow">if</span> ( game.retVal == 0 ) | ||
2150 | { | ||
2151 | game.setDefault (); | ||
2152 | <span class="comment">// ask user for driver</span> | ||
2153 | game.deviceParam.DriverType=driverChoiceConsole(); | ||
2154 | <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>) | ||
2155 | game.retVal = 3; | ||
2156 | } | ||
2157 | runGame ( &game ); | ||
2158 | } <span class="keywordflow">while</span> ( game.retVal < 3 ); | ||
2159 | |||
2160 | <span class="keywordflow">return</span> game.retVal; | ||
2161 | } | ||
2162 | </pre></div> </div></div> | ||
2163 | </div> | ||
2164 | <div id="nav-path" class="navpath"> | ||
2165 | <ul> | ||
2166 | <!-- window showing the filter options --> | ||
2167 | <div id="MSearchSelectWindow" | ||
2168 | onmouseover="return searchBox.OnSearchSelectShow()" | ||
2169 | onmouseout="return searchBox.OnSearchSelectHide()" | ||
2170 | onkeydown="return searchBox.OnSearchSelectKey(event)"> | ||
2171 | <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> | ||
2172 | |||
2173 | <!-- iframe showing the search results (closed by default) --> | ||
2174 | <div id="MSearchResultsWindow"> | ||
2175 | <iframe src="javascript:void(0)" frameborder="0" | ||
2176 | name="MSearchResults" id="MSearchResults"> | ||
2177 | </iframe> | ||
2178 | </div> | ||
2179 | |||
2180 | |||
2181 | <li class="footer"> | ||
2182 | <a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht | ||
2183 | Engine</a> Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on Sun Nov 17 2013 20:18:41 for Irrlicht 3D Engine by | ||
2184 | <a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li> | ||
2185 | </ul> | ||
2186 | </div> | ||
2187 | |||
2188 | |||
2189 | </body> | ||
2190 | </html> | ||