irrlicht/examples/21.Quake3Explorer/tutorial.html

219 lines
149 KiB
HTML
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Tutorial 21: Quake3 Explorer</title>
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- Wanted to avoid copying .css to each folder, so copied default .css from doxyen in here, kicked out most stuff we don't need for examples and modified some a little bit.
Target was having a single html in each example folder which is created from the main.cpp files and needs no files besides some images below media folder.
Feel free to improve :)
-->
<style>
body, table, div, p, dl {
font: 400 14px/22px;
}
body {
background-color: #F0F0F0;
color: black;
margin-left: 5%;
margin-right: 5%;
}
p.reference, p.definition {
font: 400 14px/22px;
}
.title {
font: 400 14px/28px;
font-size: 150%;
font-weight: bold;
margin: 10px 2px;
}
h1, h2, h3, h4, h5, h6 {
-webkit-transition: text-shadow 0.5s linear;
-moz-transition: text-shadow 0.5s linear;
-ms-transition: text-shadow 0.5s linear;
-o-transition: text-shadow 0.5s linear;
transition: text-shadow 0.5s linear;
margin-right: 15px;
}
caption {
font-weight: bold;
}
h3.version {
font-size: 90%;
text-align: center;
}
a {
color: #3D578C;
font-weight: normal;
text-decoration: none;
}
.contents a:visited {
color: #4665A2;
}
a:hover {
text-decoration: underline;
}
a.el {
font-weight: bold;
}
a.code, a.code:visited, a.line, a.line:visited {
color: #4665A2;
}
a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited {
color: #4665A2;
}
pre.fragment {
border: 1px solid #C4CFE5;
background-color: #FBFCFD;
padding: 4px 6px;
margin: 4px 8px 4px 2px;
overflow: auto;
word-wrap: break-word;
font-size: 9pt;
line-height: 125%;
font-family: monospace, fixed;
font-size: 105%;
}
div.fragment {
padding: 0px;
margin: 4px 8px 4px 2px;
background-color: #FBFCFD;
border: 1px solid #C4CFE5;
}
div.line {
font-family: monospace, fixed;
font-size: 13px;
min-height: 13px;
line-height: 1.0;
text-wrap: unrestricted;
white-space: -moz-pre-wrap; /* Moz */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: pre-wrap; /* CSS3 */
word-wrap: break-word; /* IE 5.5+ */
text-indent: -53px;
padding-left: 53px;
padding-bottom: 0px;
margin: 0px;
-webkit-transition-property: background-color, box-shadow;
-webkit-transition-duration: 0.5s;
-moz-transition-property: background-color, box-shadow;
-moz-transition-duration: 0.5s;
-ms-transition-property: background-color, box-shadow;
-ms-transition-duration: 0.5s;
-o-transition-property: background-color, box-shadow;
-o-transition-duration: 0.5s;
transition-property: background-color, box-shadow;
transition-duration: 0.5s;
}
div.contents {
margin-top: 10px;
margin-left: 12px;
margin-right: 8px;
}
div.center {
text-align: center;
margin-top: 0px;
margin-bottom: 0px;
padding: 0px;
}
div.center img {
border: 0px;
}
span.keyword {
color: #008000
}
span.keywordtype {
color: #604020
}
span.keywordflow {
color: #e08000
}
span.comment {
color: #800000
}
span.preprocessor {
color: #806020
}
span.stringliteral {
color: #002080
}
span.charliteral {
color: #008080
}
blockquote {
background-color: #F7F8FB;
border-left: 2px solid #9CAFD4;
margin: 0 24px 0 4px;
padding: 0 12px 0 16px;
}
hr {
height: 0px;
border: none;
border-top: 1px solid #4A6AAA;
}
address {
font-style: normal;
color: #2A3D61;
}
div.header {
background-image:url('nav_h.png');
background-repeat:repeat-x;
background-color: #F9FAFC;
margin: 0px;
border-bottom: 1px solid #C4CFE5;
}
div.headertitle {
padding: 5px 5px 5px 10px;
}
.image {
text-align: center;
}
.caption {
font-weight: bold;
}
div.zoom {
border: 1px solid #90A5CE;
}
tr.heading h2 {
margin-top: 12px;
margin-bottom: 4px;
}
</style>
</head>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<!--END TITLEAREA-->
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">Tutorial 21: Quake3 Explorer </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><div class="image">
<img src="../../media/example_screenshots/021shot.jpg" alt="021shot.jpg"/>
</div>
<p>This tutorial shows how to load different Quake 3 maps.</p>
<p>Features:</p><ul>
<li>Load BSP Archives at Runtime from the menu</li>
<li>Load a Map from the menu. Showing with Screenshot</li>
<li>Set the VideoDriver at runtime from menu</li>
<li>Adjust GammaLevel at runtime</li>
<li>Create SceneNodes for the Shaders</li>
<li>Load EntityList and create Entity SceneNodes</li>
<li>Create Players with Weapons and with Collision Response</li>
<li>Play music</li>
</ul>
<p>You can download the Quake III Arena demo ( copyright id software ) at the following location: <a href="ftp://ftp.idsoftware.com/idstuff/quake3/win32/q3ademo.exe">ftp://ftp.idsoftware.com/idstuff/quake3/win32/q3ademo.exe</a></p>
<p>Copyright 2006-2011 Burningwater, Thomas Alten </p><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;irrlicht.h&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;driverChoice.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;exampleHelper.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;q3factory.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;sound.h&quot;</span></div></div><!-- fragment --><p> Game Data is used to hold Data which is needed to drive the game </p><div class="fragment"><div class="line"><span class="keyword">struct </span>GameData</div><div class="line">{</div><div class="line"> GameData ( <span class="keyword">const</span> path &amp;startupDir) :</div><div class="line"> retVal(0), StartupDir(startupDir), createExDevice(0), Device(0)</div><div class="line"> {</div><div class="line"> setDefault ();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> setDefault ();</div><div class="line"> s32 save ( <span class="keyword">const</span> path &amp;filename );</div><div class="line"> s32 load ( <span class="keyword">const</span> path &amp;filename );</div><div class="line"></div><div class="line"> s32 debugState;</div><div class="line"> s32 gravityState;</div><div class="line"> s32 flyTroughState;</div><div class="line"> s32 wireFrame;</div><div class="line"> s32 guiActive;</div><div class="line"> s32 guiInputActive;</div><div class="line"> f32 GammaValue;</div><div class="line"> s32 retVal;</div><div class="line"> s32 sound;</div><div class="line"></div><div class="line"> path StartupDir;</div><div class="line"> stringw CurrentMapName;</div><div class="line"> array&lt;path&gt; CurrentArchiveList;</div><div class="line"></div><div class="line"> vector3df PlayerPosition;</div><div class="line"> vector3df PlayerRotation;</div><div class="line"></div><div class="line"> tQ3EntityList Variable;</div><div class="line"></div><div class="line"> Q3LevelLoadParameter loadParam;</div><div class="line"> SIrrlichtCreationParameters deviceParam;</div><div class="line"> funcptr_createDeviceEx createExDevice;</div><div class="line"> IrrlichtDevice *Device;</div><div class="line">};</div></div><!-- fragment --><p> set default settings </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> GameData::setDefault ()</div><div class="line">{</div><div class="line"> debugState = EDS_OFF;</div><div class="line"> gravityState = 1;</div><div class="line"> flyTroughState = 0;</div><div class="line"> wireFrame = 0;</div><div class="line"> guiActive = 1;</div><div class="line"> guiInputActive = 0;</div><div class="line"> GammaValue = 1.f;</div><div class="line"></div><div class="line"> <span class="comment">// default deviceParam;</span></div><div class="line"><span class="preprocessor">#if defined ( _IRR_WINDOWS_ )</span></div><div class="line"> deviceParam.DriverType = EDT_DIRECT3D9;</div><div class="line"><span class="preprocessor">#else</span></div><div class="line"> deviceParam.DriverType = EDT_OPENGL;</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"> deviceParam.WindowSize.Width = 800;</div><div class="line"> deviceParam.WindowSize.Height = 600;</div><div class="line"> deviceParam.Fullscreen = <span class="keyword">false</span>;</div><div class="line"> deviceParam.Bits = 24;</div><div class="line"> deviceParam.ZBufferBits = 16;</div><div class="line"> deviceParam.Vsync = <span class="keyword">false</span>;</div><div class="line"> deviceParam.AntiAlias = <span class="keyword">false</span>;</div><div class="line"></div><div class="line"> <span class="comment">// default Quake3 loadParam</span></div><div class="line"> loadParam.defaultLightMapMaterial = EMT_LIGHTMAP;</div><div class="line"> loadParam.defaultModulate =
<p>if (sound) { adjust max value a bit to make to sound of an impact louder sound-&gt;setMinDistance(400); sound-&gt;drop(); } } </p><div class="fragment"><div class="line"><span class="preprocessor"> #endif</span></div><div class="line"></div><div class="line"></div><div class="line"> <span class="comment">// delete entry</span></div><div class="line"> Impacts.erase(i);</div><div class="line"> i--;</div><div class="line"> }</div><div class="line">}</div></div><!-- fragment --><p> render </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> CQuake3EventHandler::Render()</div><div class="line">{</div><div class="line"> IVideoDriver * driver = Game-&gt;Device-&gt;getVideoDriver();</div><div class="line"> <span class="keywordflow">if</span> ( 0 == driver )</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"></div><div class="line"> <span class="comment">// TODO: This does not work, yet.</span></div><div class="line"> <span class="keyword">const</span> <span class="keywordtype">bool</span> anaglyph=<span class="keyword">false</span>;</div><div class="line"> <span class="keywordflow">if</span> (anaglyph)</div><div class="line"> {</div><div class="line"> scene::ICameraSceneNode* cameraOld = Game-&gt;Device-&gt;getSceneManager()-&gt;getActiveCamera();</div><div class="line"> driver-&gt;beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(0,0,0,0));</div><div class="line"> driver-&gt;getOverrideMaterial().Material.ColorMask = ECP_NONE;</div><div class="line"> driver-&gt;getOverrideMaterial().EnableFlags = EMF_COLOR_MASK;</div><div class="line"> driver-&gt;getOverrideMaterial().EnablePasses = ESNRP_SKY_BOX +</div><div class="line"> ESNRP_SOLID +</div><div class="line"> ESNRP_TRANSPARENT +</div><div class="line"> ESNRP_TRANSPARENT_EFFECT +</div><div class="line"> ESNRP_SHADOW;</div><div class="line"> Game-&gt;Device-&gt;getSceneManager()-&gt;drawAll();</div><div class="line"> driver-&gt;clearBuffers(video::ECBF_DEPTH, video::SColor(255,0,0,0));</div><div class="line"></div><div class="line"> <span class="keyword">const</span> vector3df oldPosition = cameraOld-&gt;getPosition();</div><div class="line"> <span class="keyword">const</span> vector3df oldTarget = cameraOld-&gt;getTarget();</div><div class="line"> <span class="keyword">const</span> matrix4 startMatrix = cameraOld-&gt;getAbsoluteTransformation();</div><div class="line"> <span class="keyword">const</span> vector3df focusPoint = (oldTarget -</div><div class="line"> cameraOld-&gt;getAbsolutePosition()).setLength(10000) +</div><div class="line"> cameraOld-&gt;getAbsolutePosition() ;</div><div class="line"></div><div class="line"> scene::ICameraSceneNode* camera = cameraOld;<span class="comment">//Game-&gt;Device-&gt;getSceneManager()-&gt;addCameraSceneNode();</span></div><div class="line"></div><div class="line"> <span class="comment">//Left eye...</span></div><div class="line"> vector3df pos;</div><div class="line"> matrix4 move;</div><div class="line"></div><div class="line"> move.setTranslation( vector3df(-1.5f,0.0f,0.0f) );</div><div class="line"> pos=(startMatrix*move).getTranslation();</div><div class="line"></div><div class="line"> driver-&gt;getOverrideMaterial().Material.ColorMask = ECP_RED;</div><div class="line"> driver-&gt;getOverrideMaterial().EnableFlags = EMF_COLOR_MASK;</div><div class="line"> driver-&gt;getOverrideMaterial().EnablePasses =</div><div class="line"> ESNRP_SKY_BOX|ESNRP_SOLID|ESNRP_TRANSPARENT|</div><div class="line"> ESNRP_TRANSPARENT_EFFECT|ESNRP_SHADOW;</div><div class="line"></div><div class="line"> came
<!-- HTML footer for doxygen 1.8.13-->
<!-- start footer part -->
<p>&nbsp;</p>
</body>
</html>