irrlicht/examples/22.MaterialViewer/tutorial.html
cutealien 3fa6370cea Merging r6172 through r6199 from branch releases/1.8 to trunk
Changes are all related to automatic creation of documentation.
Note: It's not yet fully working in trunk due to changes since 1.8


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6200 dfc29bdd-3216-0410-991c-e03cc46cb475
2021-03-18 20:33:59 +00:00

207 lines
80 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Tutorial 22: Material Viewer</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 22: Material Viewer </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><div class="image">
<img src="../../media/022shot.jpg" alt="022shot.jpg"/>
</div>
<p>This example can be used to play around with material settings and watch the results. Only the default non-shader materials are used in here.</p>
<p>You have two nodes to make it easier to see which difference your settings will make. Additionally you have one lightscenenode and you can set the global ambient values. </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"></div><div class="line"><span class="keyword">using namespace </span>irr;</div><div class="line"></div><div class="line"><span class="preprocessor">#ifdef _MSC_VER</span></div><div class="line"><span class="preprocessor">#pragma comment(lib, &quot;Irrlicht.lib&quot;)</span></div><div class="line"><span class="preprocessor">#endif</span></div></div><!-- fragment --><p> Variables within the empty namespace are globals which are restricted to this file. </p><div class="fragment"><div class="line"><span class="keyword">namespace</span></div><div class="line">{</div><div class="line"> <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* <span class="keyword">const</span> DriverTypeNames[] =</div><div class="line"> {</div><div class="line"> L<span class="stringliteral">&quot;NULL&quot;</span>,</div><div class="line"> L<span class="stringliteral">&quot;SOFTWARE&quot;</span>,</div><div class="line"> L<span class="stringliteral">&quot;BURNINGSVIDEO&quot;</span>,</div><div class="line"> L<span class="stringliteral">&quot;DIRECT3D8&quot;</span>,</div><div class="line"> L<span class="stringliteral">&quot;DIRECT3D9&quot;</span>,</div><div class="line"> L<span class="stringliteral">&quot;OPENGL&quot;</span>,</div><div class="line"> 0,</div><div class="line"> };</div><div class="line"></div><div class="line"> <span class="comment">// For the gui id&#39;s</span></div><div class="line"> <span class="keyword">enum</span> EGUI_IDS</div><div class="line"> {</div><div class="line"> GUI_ID_OPEN_TEXTURE = 1,</div><div class="line"> GUI_ID_QUIT,</div><div class="line"> GUI_ID_MAX</div><div class="line"> };</div><div class="line"></div><div class="line"> <span class="comment">// Name used in texture selection to clear the textures on the node</span></div><div class="line"> <span class="keyword">const</span> core::stringw CLEAR_TEXTURE = L<span class="stringliteral">&quot;CLEAR texture&quot;</span>;</div><div class="line"></div><div class="line"> <span class="comment">// some useful color constants</span></div><div class="line"> <span class="keyword">const</span> video::SColor SCOL_BLACK = video::SColor(255, 0, 0, 0);</div><div class="line"> <span class="keyword">const</span> video::SColor SCOL_BLUE = video::SColor(255, 0, 0, 255);</div><div class="line"> <span class="keyword">const</span> video::SColor SCOL_CYAN = video::SColor(255, 0, 255, 255);</div><div class="line"> <span class="keyword">const</span> video::SColor SCOL_GRAY = video::SColor(255, 128,128, 128);</div><div class="line"> <span class="keyword">const</span> video::SColor SCOL_GREEN = video::SColor(255, 0, 255, 0);</div><div class="line"> <span class="keyword">const</span> video::SColor SCOL_MAGENTA = video::SColor(255, 255, 0, 255);</div><div class="line"> <span class="keyword">const</span> video::SColor SCOL_RED = video::SColor(255, 255, 0, 0);</div><div class="line"> <span class="keyword">const</span> video::SColor SCOL_YELLOW = video::SColor(255, 255, 255, 0);</div><div class="line"> <span class="keyword">const</span> video::SColor SCOL_WHITE = video::SColor(255, 255, 255, 255);</div><div class="line">}; <span class="comment">// namespace</span></div></div><!-- fragment --><p> Returns a new unique number on each call. </p><div class="fragment"><div class="line">s32 makeUniqueId()</div><div class="line">{</div><div class="line"> <span class="keyword">static</span> <span class="keywordtype">int</span> unique = GUI_ID_MAX;</div><div class="line"> ++unique;</div><div class="line"> <span class="keywordflow">return</span> unique;</div><div class="line">}</div></div><!-- fragment --><p> Find out which vertex-type is needed for the given material type. </p><div class="fragment"><div class="line">video::E_VERTEX_TYPE getVertexTypeForMaterialType(video::E_MATERIAL_TYPE materialType)</div><div class="line">{</div><div class="line"> <span class="keyword">using namespace </span>video;</div><div class="line"></div><div class="line"> <span class="keywordflow">switch</span> ( materialType )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">case</span> EMT_SOLID:</div><div class="line"> <span class="keywordflow">return</span> EVT_STANDARD;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> EMT_SOLID_2_LAYER:</div><div class="line"> <span class="keywordflow">return</span> EVT_STANDARD;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> EMT_LIGHTMAP:</div><div class="line"> <span class="keywordflow">case</span> EMT_LIGHTMAP_ADD:</div><div class="line"> <span class="keywordflow">case</span> EMT_LIGHTMAP_M2:</div><div class="line"> <span class="keywordflow">case</span> EMT_LIGHTMAP_M4:</div><div class="line"> <span class="keywordflow">case</span> EMT_LIGHTMAP_LIGHTING:</div><div class="line"> <span class="keywordflow">case</span> EMT_LIGHTMAP_LIGHTING_M2:</div><div class="line"> <span class="keywordflow">case</span> EMT_LIGHTMAP_LIGHTING_M4:</div><div class="line"> <span class="keywordflow">return</span> EVT_2TCOORDS;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> EMT_DETAIL_MAP:</div><div class="line"> <span class="keywordflow">return</span> EVT_2TCOORDS;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> EMT_SPHERE_MAP:</div><div class="line"> <span class="keywordflow">return</span> EVT_STANDARD;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> EMT_REFLECTION_2_LAYER:</div><div class="line"> <span class="keywordflow">return</span> EVT_2TCOORDS;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> EMT_TRANSPARENT_ADD_COLOR:</div><div class="line"> <span class="keywordflow">return</span> EVT_STANDARD;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> EMT_TRANSPARENT_ALPHA_CHANNEL:</div><div class="line"> <span class="keywordflow">return</span> EVT_STANDARD;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> EMT_TRANSPARENT_ALPHA_CHANNEL_REF:</div><div class="line"> <span class="keywordflow">return</span> EVT_STANDARD;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> EMT_TRANSPARENT_VERTEX_ALPHA:</div><div class="line"> <span class="keywordflow">return</span> EVT_STANDARD;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> EMT_TRANSPARENT_REFLECTION_2_LAYER:</div><div class="line"> <span class="keywordflow">return</span> EVT_2TCOORDS;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> EMT_NORMAL_MAP_SOLID:</div><div class="line"> <span class="keywordflow">case</span> EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR:</div><div class="line"> <span class="keywordflow">case</span> EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA:</div><div class="line"> <span class="keywordflow">case</span> EMT_PARALLAX_MAP_SOLID:</div><div class="line"> <span class="keywordflow">case</span> EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR:</div><div class="line"> <span class="keywordflow">case</span> EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA:</div><div class="line"> <span class="keywordflow">return</span> EVT_TANGENTS;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> EMT_ONETEXTURE_BLEND:</div><div class="line"> <span class="keywordflow">return</span> EVT_STANDARD;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> EMT_FORCE_32BIT:</div><div class="line"> <span class="keywordflow">return</span> EVT_STANDARD;</div><div class="line"> }</div><div class="line"> <span class="keywordflow">return</span> EVT_STANDARD;</div><div class="line">}</div></div><!-- fragment --><p> Custom GUI-control to edit colorvalues. </p><div class="fragment"><div class="line"><span class="keyword">class </span>CColorControl : <span class="keyword">public</span> gui::IGUIElement</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line"> <span class="comment">// Constructor</span></div><div class="line"> CColorControl(gui::IGUIEnvironment* guiEnv, <span class="keyword">const</span> core::position2d&lt;s32&gt; &amp; pos, <span class="keyword">const</span> <span class="keywordtype">wchar_t</span> *text, IGUIElement* parent, s32 <span class="keywordtype">id</span>=-1 )</div><div class="line"> : gui::IGUIElement(gui::EGUIET_ELEMENT, guiEnv, parent,id, core::rect&lt; s32 &gt;(pos, pos+core::dimension2d&lt;s32&gt;(80, 75)))</div><div class="line"> , DirtyFlag(true)</div><div class="line"> , ColorStatic(0)</div><div class="line"> , EditAlpha(0)</div><div class="line"> , EditRed(0)</div><div class="line"> , EditGreen(0)</div><div class="line"> , EditBlue(0)</div><div class="line"> {</div><div class="line"> <span class="keyword">using namespace </span>gui;</div><div class="line"> ButtonSetId = makeUniqueId();</div><div class="line"></div><div class="line"> <span class="keyword">const</span> core::rect&lt; s32 &gt; rectControls(0,0,AbsoluteRect.getWidth(),AbsoluteRect.getHeight() );</div><div class="line"> IGUIStaticText * groupElement = guiEnv-&gt;addStaticText (L<span class="stringliteral">&quot;&quot;</span>, rectControls, <span class="keyword">true</span>, <span class="keyword">false</span>, <span class="keyword">this</span>, -1, <span class="keyword">false</span>);</div><div class="line"> groupElement-&gt;setNotClipped(<span class="keyword">true</span>);</div><div class="line"></div><div class="line"> guiEnv-&gt;addStaticText (text, core::rect&lt;s32&gt;(0,0,80,15), <span class="keyword">false</span>, <span class="keyword">false</span>, groupElement, -1, <span class="keyword">false</span>);</div><div class="line"></div><div class="line"> EditAlpha = addEditForNumbers(guiEnv, core::position2d&lt;s32&gt;(0,15), L<span class="stringliteral">&quot;a&quot;</span>, -1, groupElement );</div><div class="line"> EditRed = addEditForNumbers(guiEnv, core::position2d&lt;s32&gt;(0,30), L<span class="stringliteral">&quot;r&quot;</span>, -1, groupElement );</div><div class="line"> EditGreen = addEditForNumbers(guiEnv, core::position2d&lt;s32&gt;(0,45), L<span class="stringliteral">&quot;g&quot;</span>, -1, groupElement );</div><div class="line"> EditBlue = addEditForNumbers(guiEnv, core::position2d&lt;s32&gt;(0,60), L<span class="stringliteral">&quot;b&quot;</span>, -1, groupElement );</div><div class="line"></div><div class="line"> ColorStatic = guiEnv-&gt;addStaticText (L<span class="stringliteral">&quot;&quot;</span>, core::rect&lt;s32&gt;(60,15,80,75), <span class="keyword">true</span>, <span class="keyword">false</span>, groupElement, -1, <span class="keyword">true</span>);</div><div class="line"></div><div class="line"> guiEnv-&gt;addButton (core::rect&lt;s32&gt;(60,35,80,50), groupElement, ButtonSetId, L<span class="stringliteral">&quot;set&quot;</span>);</div><div class="line"> SetEditsFromColor(Color);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// event receiver</span></div><div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent &amp;event)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( event.EventType != EET_GUI_EVENT )</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( event.GUIEvent.Caller-&gt;getID() == ButtonSetId &amp;&amp; <span class="keyword">event</span>.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED )</div><div class="line"> {</div><div class="line"> Color = GetColorFromEdits();</div><div class="line"> SetEditsFromColor(Color);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// set the color values</span></div><div class="line"> <span class="keywordtype">void</span> setColor(<span class="keyword">const</span> video::SColor&amp; col)</div><div class="line"> {</div><div class="line"> DirtyFlag = <span class="keyword">true</span>;</div><div class="line"> Color = col;</div><div class="line"> SetEditsFromColor(Color);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// get the color values</span></div><div class="line"> <span class="keyword">const</span> video::SColor&amp; getColor()<span class="keyword"> const</span></div><div class="line"><span class="keyword"> </span>{</div><div class="line"> <span class="keywordflow">return</span> Color;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// To reset the dirty flag</span></div><div class="line"> <span class="keywordtype">void</span> resetDirty()</div><div class="line"> {</div><div class="line"> DirtyFlag = <span class="keyword">false</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// when the color was changed the dirty flag is set</span></div><div class="line"> <span class="keywordtype">bool</span> isDirty()<span class="keyword"> const</span></div><div class="line"><span class="keyword"> </span>{</div><div class="line"> <span class="keywordflow">return</span> DirtyFlag;</div><div class="line"> };</div><div class="line"></div><div class="line"><span class="keyword">protected</span>:</div><div class="line"></div><div class="line"> <span class="comment">// Add a staticbox for a description + an editbox so users can enter numbers</span></div><div class="line"> gui::IGUIEditBox* addEditForNumbers(gui::IGUIEnvironment* guiEnv, <span class="keyword">const</span> core::position2d&lt;s32&gt; &amp; pos, <span class="keyword">const</span> <span class="keywordtype">wchar_t</span> *text, s32 <span class="keywordtype">id</span>, gui::IGUIElement * parent)</div><div class="line"> {</div><div class="line"> <span class="keyword">using namespace </span>gui;</div><div class="line"></div><div class="line"> core::rect&lt; s32 &gt; rect(pos, pos+core::dimension2d&lt;s32&gt;(10, 15));</div><div class="line"> guiEnv-&gt;addStaticText (text, rect, <span class="keyword">false</span>, <span class="keyword">false</span>, parent, -1, <span class="keyword">false</span>);</div><div class="line"> rect += core::position2d&lt;s32&gt;( 20, 0 );</div><div class="line"> rect.LowerRightCorner.X += 20;</div><div class="line"> gui::IGUIEditBox* edit = guiEnv-&gt;addEditBox(L<span class="stringliteral">&quot;0&quot;</span>, rect, <span class="keyword">true</span>, parent, <span class="keywordtype">id</span>);</div><div class="line"> <span class="keywordflow">return</span> edit;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Get the color value from the editfields</span></div><div class="line"> video::SColor GetColorFromEdits()</div><div class="line"> {</div><div class="line"> video::SColor col;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (EditAlpha)</div><div class="line"> {</div><div class="line"> u32 alpha = core::strtoul10(core::stringc(EditAlpha-&gt;getText()).c_str());</div><div class="line"> <span class="keywordflow">if</span> (alpha &gt; 255)</div><div class="line"> alpha = 255;</div><div class="line"> col.setAlpha(alpha);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (EditRed)</div><div class="line"> {</div><div class="line"> u32 red = core::strtoul10(core::stringc(EditRed-&gt;getText()).c_str());</div><div class="line"> <span class="keywordflow">if</span> (red &gt; 255)</div><div class="line"> red = 255;</div><div class="line"> col.setRed(red);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (EditGreen)</div><div class="line"> {</div><div class="line"> u32 green = core::strtoul10(core::stringc(EditGreen-&gt;getText()).c_str());</div><div class="line"> <span class="keywordflow">if</span> (green &gt; 255)</div><div class="line"> green = 255;</div><div class="line"> col.setGreen(green);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (EditBlue)</div><div class="line"> {</div><div class="line"> u32 blue = core::strtoul10(core::stringc(EditBlue-&gt;getText()).c_str());</div><div class="line"> <span class="keywordflow">if</span> (blue &gt; 255)</div><div class="line"> blue = 255;</div><div class="line"> col.setBlue(blue);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> col;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Fill the editfields with the value for the given color</span></div><div class="line"> <span class="keywordtype">void</span> SetEditsFromColor(video::SColor col)</div><div class="line"> {</div><div class="line"> DirtyFlag = <span class="keyword">true</span>;</div><div class="line"> <span class="keywordflow">if</span> ( EditAlpha )</div><div class="line"> EditAlpha-&gt;setText( core::stringw(col.getAlpha()).c_str() );</div><div class="line"> <span class="keywordflow">if</span> ( EditRed )</div><div class="line"> EditRed-&gt;setText( core::stringw(col.getRed()).c_str() );</div><div class="line"> <span class="keywordflow">if</span> ( EditGreen )</div><div class="line"> EditGreen-&gt;setText( core::stringw(col.getGreen()).c_str() );</div><div class="line"> <span class="keywordflow">if</span> ( EditBlue )</div><div class="line"> EditBlue-&gt;setText( core::stringw(col.getBlue()).c_str() );</div><div class="line"> <span class="keywordflow">if</span> ( ColorStatic )</div><div class="line"> ColorStatic-&gt;setBackgroundColor(col);</div><div class="line"> }</div><div class="line"></div><div class="line"><span class="keyword">private</span>:</div><div class="line"></div><div class="line"> <span class="keywordtype">bool</span> DirtyFlag;</div><div class="line"> video::SColor Color;</div><div class="line"> s32 ButtonSetId;</div><div class="line"> gui::IGUIStaticText * ColorStatic;</div><div class="line"> gui::IGUIEditBox * EditAlpha;</div><div class="line"> gui::IGUIEditBox * EditRed;</div><div class="line"> gui::IGUIEditBox * EditGreen;</div><div class="line"> gui::IGUIEditBox * EditBlue;</div><div class="line">};</div></div><!-- fragment --><p> Custom GUI-control for to edit all colors typically used in materials and lights </p><div class="fragment"><div class="line"><span class="keyword">class </span>CAllColorsControl : <span class="keyword">public</span> gui::IGUIElement</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line"> <span class="comment">// Constructor</span></div><div class="line"> CAllColorsControl(gui::IGUIEnvironment* guiEnv, <span class="keyword">const</span> core::position2d&lt;s32&gt; &amp; pos, <span class="keyword">const</span> <span class="keywordtype">wchar_t</span> * description, <span class="keywordtype">bool</span> hasEmissive, IGUIElement* parent, s32 <span class="keywordtype">id</span>=-1)</div><div class="line"> : gui::IGUIElement(gui::EGUIET_ELEMENT, guiEnv, parent,id, core::rect&lt;s32&gt;(pos,pos+core::dimension2d&lt;s32&gt;(60,250)))</div><div class="line"> , ControlAmbientColor(0), ControlDiffuseColor(0), ControlSpecularColor(0), ControlEmissiveColor(0)</div><div class="line"> {</div><div class="line"> core::rect&lt;s32&gt; rect(0, 0, 60, 15);</div><div class="line"> guiEnv-&gt;addStaticText (description, rect, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">this</span>, -1, <span class="keyword">false</span>);</div><div class="line"> createColorControls(guiEnv, core::position2d&lt;s32&gt;(0, 15), hasEmissive);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Destructor</span></div><div class="line"> <span class="keyword">virtual</span> ~CAllColorsControl()</div><div class="line"> {</div><div class="line"> ControlAmbientColor-&gt;drop();</div><div class="line"> ControlDiffuseColor-&gt;drop();</div><div class="line"> <span class="keywordflow">if</span> ( ControlEmissiveColor )</div><div class="line"> ControlEmissiveColor-&gt;drop();</div><div class="line"> ControlSpecularColor-&gt;drop();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Set the color values to those within the material</span></div><div class="line"> <span class="keywordtype">void</span> setColorsToMaterialColors(<span class="keyword">const</span> video::SMaterial &amp; material)</div><div class="line"> {</div><div class="line"> ControlAmbientColor-&gt;setColor(material.AmbientColor);</div><div class="line"> ControlDiffuseColor-&gt;setColor(material.DiffuseColor);</div><div class="line"> ControlEmissiveColor-&gt;setColor(material.EmissiveColor);</div><div class="line"> ControlSpecularColor-&gt;setColor(material.SpecularColor);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Update all changed colors in the material</span></div><div class="line"> <span class="keywordtype">void</span> updateMaterialColors(video::SMaterial &amp; material)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( ControlAmbientColor-&gt;isDirty() )</div><div class="line"> material.AmbientColor = ControlAmbientColor-&gt;getColor();</div><div class="line"> <span class="keywordflow">if</span> ( ControlDiffuseColor-&gt;isDirty() )</div><div class="line"> material.DiffuseColor = ControlDiffuseColor-&gt;getColor();</div><div class="line"> <span class="keywordflow">if</span> ( ControlEmissiveColor-&gt;isDirty() )</div><div class="line"> material.EmissiveColor = ControlEmissiveColor-&gt;getColor();</div><div class="line"> <span class="keywordflow">if</span> ( ControlSpecularColor-&gt;isDirty() )</div><div class="line"> material.SpecularColor = ControlSpecularColor-&gt;getColor();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Set the color values to those from the light data</span></div><div class="line"> <span class="keywordtype">void</span> setColorsToLightDataColors(<span class="keyword">const</span> video::SLight &amp; lightData)</div><div class="line"> {</div><div class="line"> ControlAmbientColor-&gt;setColor(lightData.AmbientColor.toSColor());</div><div class="line"> ControlAmbientColor-&gt;setColor(lightData.DiffuseColor.toSColor());</div><div class="line"> ControlAmbientColor-&gt;setColor(lightData.SpecularColor.toSColor());</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Update all changed colors in the light data</span></div><div class="line"> <span class="keywordtype">void</span> updateLightColors(video::SLight &amp; lightData)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( ControlAmbientColor-&gt;isDirty() )</div><div class="line"> lightData.AmbientColor = video::SColorf( ControlAmbientColor-&gt;getColor() );</div><div class="line"> <span class="keywordflow">if</span> ( ControlDiffuseColor-&gt;isDirty() )</div><div class="line"> lightData.DiffuseColor = video::SColorf( ControlDiffuseColor-&gt;getColor() );</div><div class="line"> <span class="keywordflow">if</span> ( ControlSpecularColor-&gt;isDirty() )</div><div class="line"> lightData.SpecularColor = video::SColorf(ControlSpecularColor-&gt;getColor() );</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// To reset the dirty flags</span></div><div class="line"> <span class="keywordtype">void</span> resetDirty()</div><div class="line"> {</div><div class="line"> ControlAmbientColor-&gt;resetDirty();</div><div class="line"> ControlDiffuseColor-&gt;resetDirty();</div><div class="line"> ControlSpecularColor-&gt;resetDirty();</div><div class="line"> <span class="keywordflow">if</span> ( ControlEmissiveColor )</div><div class="line"> ControlEmissiveColor-&gt;resetDirty();</div><div class="line"> }</div><div class="line"></div><div class="line"><span class="keyword">protected</span>:</div><div class="line"> <span class="keywordtype">void</span> createColorControls(gui::IGUIEnvironment* guiEnv, <span class="keyword">const</span> core::position2d&lt;s32&gt; &amp; pos, <span class="keywordtype">bool</span> hasEmissive)</div><div class="line"> {</div><div class="line"> ControlAmbientColor = <span class="keyword">new</span> CColorControl( guiEnv, pos, L<span class="stringliteral">&quot;ambient&quot;</span>, <span class="keyword">this</span>);</div><div class="line"> ControlDiffuseColor = <span class="keyword">new</span> CColorControl( guiEnv, pos + core::position2d&lt;s32&gt;(0, 75), L<span class="stringliteral">&quot;diffuse&quot;</span>, <span class="keyword">this</span> );</div><div class="line"> ControlSpecularColor = <span class="keyword">new</span> CColorControl( guiEnv, pos + core::position2d&lt;s32&gt;(0, 150), L<span class="stringliteral">&quot;specular&quot;</span>, <span class="keyword">this</span> );</div><div class="line"> <span class="keywordflow">if</span> ( hasEmissive )</div><div class="line"> {</div><div class="line"> ControlEmissiveColor = <span class="keyword">new</span> CColorControl( guiEnv, pos + core::position2d&lt;s32&gt;(0, 225), L<span class="stringliteral">&quot;emissive&quot;</span>, <span class="keyword">this</span> );</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"><span class="keyword">private</span>:</div><div class="line"> CColorControl* ControlAmbientColor;</div><div class="line"> CColorControl* ControlDiffuseColor;</div><div class="line"> CColorControl* ControlSpecularColor;</div><div class="line"> CColorControl* ControlEmissiveColor;</div><div class="line">};</div></div><!-- fragment --><p> GUI-Control to offer a selection of available textures. </p><div class="fragment"><div class="line"><span class="keyword">class </span>CTextureControl : <span class="keyword">public</span> gui::IGUIElement</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line"> CTextureControl(gui::IGUIEnvironment* guiEnv, video::IVideoDriver * driver, <span class="keyword">const</span> core::position2d&lt;s32&gt; &amp; pos, IGUIElement* parent, s32 <span class="keywordtype">id</span>=-1)</div><div class="line"> : gui::IGUIElement(gui::EGUIET_ELEMENT, guiEnv, parent,id, core::rect&lt;s32&gt;(pos,pos+core::dimension2d&lt;s32&gt;(100,15)))</div><div class="line"> , DirtyFlag(true), ComboTexture(0)</div><div class="line"> {</div><div class="line"> core::rect&lt;s32&gt; rectCombo(0, 0, AbsoluteRect.getWidth(),AbsoluteRect.getHeight());</div><div class="line"> ComboTexture = guiEnv-&gt;addComboBox (rectCombo, <span class="keyword">this</span>);</div><div class="line"> updateTextures(driver);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent &amp;event)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( event.EventType != EET_GUI_EVENT )</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == ComboTexture &amp;&amp; event.GUIEvent.EventType == gui::EGET_COMBO_BOX_CHANGED )</div><div class="line"> {</div><div class="line"> DirtyFlag = <span class="keyword">true</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Workaround for a problem with comboboxes.</span></div><div class="line"> <span class="comment">// We have to get in front when the combobox wants to get in front or combobox-list might be drawn below other elements.</span></div><div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> bringToFront(IGUIElement* element)</div><div class="line"> {</div><div class="line"> <span class="keywordtype">bool</span> result = gui::IGUIElement::bringToFront(element);</div><div class="line"> <span class="keywordflow">if</span> ( Parent &amp;&amp; element == ComboTexture )</div><div class="line"> result &amp;= Parent-&gt;bringToFront(<span class="keyword">this</span>);</div><div class="line"> <span class="keywordflow">return</span> result;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// return selected texturename (if any, otherwise 0)</span></div><div class="line"> <span class="keyword">const</span> <span class="keywordtype">wchar_t</span> * getSelectedTextureName()<span class="keyword"> const</span></div><div class="line"><span class="keyword"> </span>{</div><div class="line"> s32 selected = ComboTexture-&gt;getSelected();</div><div class="line"> <span class="keywordflow">if</span> ( selected &lt; 0 )</div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line"> <span class="keywordflow">return</span> ComboTexture-&gt;getItem(selected);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// reset the dirty flag</span></div><div class="line"> <span class="keywordtype">void</span> resetDirty()</div><div class="line"> {</div><div class="line"> DirtyFlag = <span class="keyword">false</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// when the texture was changed the dirty flag is set</span></div><div class="line"> <span class="keywordtype">bool</span> isDirty()<span class="keyword"> const</span></div><div class="line"><span class="keyword"> </span>{</div><div class="line"> <span class="keywordflow">return</span> DirtyFlag;</div><div class="line"> };</div><div class="line"></div><div class="line"> <span class="comment">// Put the names of all currently loaded textures in a combobox</span></div><div class="line"> <span class="keywordtype">void</span> updateTextures(video::IVideoDriver * driver)</div><div class="line"> {</div><div class="line"> s32 oldSelected = ComboTexture-&gt;getSelected();</div><div class="line"> s32 selectNew = -1;</div><div class="line"> core::stringw oldTextureName;</div><div class="line"> <span class="keywordflow">if</span> ( oldSelected &gt;= 0 )</div><div class="line"> {</div><div class="line"> oldTextureName = ComboTexture-&gt;getItem(oldSelected);</div><div class="line"> }</div><div class="line"> ComboTexture-&gt;clear();</div><div class="line"> <span class="keywordflow">for</span> ( u32 i=0; i &lt; driver-&gt;getTextureCount(); ++i )</div><div class="line"> {</div><div class="line"> video::ITexture * texture = driver-&gt;getTextureByIndex(i);</div><div class="line"> core::stringw name( texture-&gt;getName() );</div><div class="line"> ComboTexture-&gt;addItem( name.c_str() );</div><div class="line"> <span class="keywordflow">if</span> ( !oldTextureName.empty() &amp;&amp; selectNew &lt; 0 &amp;&amp; name == oldTextureName )</div><div class="line"> selectNew = i;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// add another name which can be used to clear the texture</span></div><div class="line"> ComboTexture-&gt;addItem( CLEAR_TEXTURE.c_str() );</div><div class="line"> <span class="keywordflow">if</span> ( CLEAR_TEXTURE == oldTextureName )</div><div class="line"> selectNew = ComboTexture-&gt;getItemCount()-1;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( selectNew &gt;= 0 )</div><div class="line"> ComboTexture-&gt;setSelected(selectNew);</div><div class="line"></div><div class="line"> DirtyFlag = <span class="keyword">true</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"><span class="keyword">private</span>:</div><div class="line"> <span class="keywordtype">bool</span> DirtyFlag;</div><div class="line"> gui::IGUIComboBox * ComboTexture;</div><div class="line">};</div></div><!-- fragment --><p> Control which allows setting some of the material values for a meshscenenode </p><div class="fragment"><div class="line"><span class="keyword">struct </span>SMeshNodeControl</div><div class="line">{</div><div class="line"> <span class="comment">// constructor</span></div><div class="line"> SMeshNodeControl()</div><div class="line"> : Initialized(false), Driver(0), MeshManipulator(0), SceneNode(0), SceneNode2T(0), SceneNodeTangents(0)</div><div class="line"> , AllColorsControl(0), ButtonLighting(0), InfoLighting(0), ComboMaterial(0), TextureControl1(0), TextureControl2(0), ControlVertexColors(0)</div><div class="line"> {</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Destructor</span></div><div class="line"> <span class="keyword">virtual</span> ~SMeshNodeControl()</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( TextureControl1 )</div><div class="line"> TextureControl1-&gt;drop();</div><div class="line"> <span class="keywordflow">if</span> ( TextureControl2 )</div><div class="line"> TextureControl2-&gt;drop();</div><div class="line"> <span class="keywordflow">if</span> ( ControlVertexColors )</div><div class="line"> ControlVertexColors-&gt;drop();</div><div class="line"> <span class="keywordflow">if</span> ( AllColorsControl )</div><div class="line"> AllColorsControl-&gt;drop();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> init(scene::IMeshSceneNode* node, IrrlichtDevice * device, <span class="keyword">const</span> core::position2d&lt;s32&gt; &amp; pos, <span class="keyword">const</span> <span class="keywordtype">wchar_t</span> * description)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( Initialized || !node || !device) <span class="comment">// initializing twice or with invalid data not allowed</span></div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"></div><div class="line"> Driver = device-&gt;getVideoDriver ();</div><div class="line"> gui::IGUIEnvironment* guiEnv = device-&gt;getGUIEnvironment();</div><div class="line"> scene::ISceneManager* smgr = device-&gt;getSceneManager();</div><div class="line"> MeshManipulator = smgr-&gt;getMeshManipulator();</div><div class="line"></div><div class="line"> SceneNode = node;</div><div class="line"> scene::IMeshManipulator * meshManip = smgr-&gt;getMeshManipulator();</div><div class="line"></div><div class="line"> scene::IMesh * mesh2T = meshManip-&gt;createMeshWith2TCoords(node-&gt;getMesh());</div><div class="line"> SceneNode2T = smgr-&gt;addMeshSceneNode(mesh2T, 0, -1, SceneNode-&gt;getPosition(), SceneNode-&gt;getRotation(), SceneNode-&gt;getScale() );</div><div class="line"> mesh2T-&gt;drop();</div><div class="line"></div><div class="line"> scene::IMesh * meshTangents = meshManip-&gt;createMeshWithTangents(node-&gt;getMesh(), <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>);</div><div class="line"> SceneNodeTangents = smgr-&gt;addMeshSceneNode(meshTangents, 0, -1</div><div class="line"> , SceneNode-&gt;getPosition(), SceneNode-&gt;getRotation(), SceneNode-&gt;getScale() );</div><div class="line"> meshTangents-&gt;drop();</div><div class="line"></div><div class="line"> video::SMaterial &amp; material = SceneNode-&gt;getMaterial(0);</div><div class="line"> material.Lighting = <span class="keyword">true</span>;</div><div class="line"> AllColorsControl = <span class="keyword">new</span> CAllColorsControl(guiEnv, pos, description, <span class="keyword">true</span>, guiEnv-&gt;getRootGUIElement());</div><div class="line"> AllColorsControl-&gt;setColorsToMaterialColors(material);</div><div class="line"></div><div class="line"> core::rect&lt;s32&gt; rectBtn(pos + core::position2d&lt;s32&gt;(0, 320), core::dimension2d&lt;s32&gt;(60, 15));</div><div class="line"> ButtonLighting = guiEnv-&gt;addButton (rectBtn, 0, -1, L<span class="stringliteral">&quot;Lighting&quot;</span>);</div><div class="line"> ButtonLighting-&gt;setIsPushButton(<span class="keyword">true</span>);</div><div class="line"> ButtonLighting-&gt;setPressed(material.Lighting);</div><div class="line"> core::rect&lt;s32&gt; rectInfo( rectBtn.LowerRightCorner.X, rectBtn.UpperLeftCorner.Y, rectBtn.LowerRightCorner.X+40, rectBtn.UpperLeftCorner.Y+15 );</div><div class="line"> InfoLighting = guiEnv-&gt;addStaticText(L<span class="stringliteral">&quot;&quot;</span>, rectInfo, <span class="keyword">true</span>, <span class="keyword">false</span> );</div><div class="line"> InfoLighting-&gt;setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_CENTER );</div><div class="line"></div><div class="line"> core::rect&lt;s32&gt; rectCombo(pos.X, rectBtn.LowerRightCorner.Y, pos.X+100, rectBtn.LowerRightCorner.Y+15);</div><div class="line"> ComboMaterial = guiEnv-&gt;addComboBox (rectCombo);</div><div class="line"> <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i &lt;= (int)video::EMT_ONETEXTURE_BLEND; ++i )</div><div class="line"> {</div><div class="line"> ComboMaterial-&gt;addItem( core::stringw(video::sBuiltInMaterialTypeNames[i]).c_str() );</div><div class="line"> }</div><div class="line"> ComboMaterial-&gt;setSelected( (s32)material.MaterialType );</div><div class="line"></div><div class="line"> core::position2d&lt;s32&gt; posTex(rectCombo.UpperLeftCorner.X,rectCombo.LowerRightCorner.Y);</div><div class="line"> TextureControl1 = <span class="keyword">new</span> CTextureControl(guiEnv, Driver, posTex, guiEnv-&gt;getRootGUIElement());</div><div class="line"> posTex.Y += 15;</div><div class="line"> TextureControl2 = <span class="keyword">new</span> CTextureControl(guiEnv, Driver, posTex, guiEnv-&gt;getRootGUIElement());</div><div class="line"></div><div class="line"> core::position2d&lt;s32&gt; posVertexColors( posTex.X, posTex.Y + 15);</div><div class="line"> ControlVertexColors = <span class="keyword">new</span> CColorControl( guiEnv, posVertexColors, L<span class="stringliteral">&quot;Vertex colors&quot;</span>, guiEnv-&gt;getRootGUIElement());</div><div class="line"></div><div class="line"> video::S3DVertex * vertices = (video::S3DVertex *)node-&gt;getMesh()-&gt;getMeshBuffer(0)-&gt;getVertices();</div><div class="line"> <span class="keywordflow">if</span> ( vertices )</div><div class="line"> {</div><div class="line"> ControlVertexColors-&gt;setColor(vertices[0].Color);</div><div class="line"> }</div><div class="line"></div><div class="line"> Initialized = <span class="keyword">true</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> update()</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( !Initialized )</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"></div><div class="line"> video::SMaterial &amp; material = SceneNode-&gt;getMaterial(0);</div><div class="line"> video::SMaterial &amp; material2T = SceneNode2T-&gt;getMaterial(0);</div><div class="line"> video::SMaterial &amp; materialTangents = SceneNodeTangents-&gt;getMaterial(0);</div><div class="line"></div><div class="line"> s32 selectedMaterial = ComboMaterial-&gt;getSelected();</div><div class="line"> <span class="keywordflow">if</span> ( selectedMaterial &gt;= (s32)video::EMT_SOLID &amp;&amp; selectedMaterial &lt;= (s32)video::EMT_ONETEXTURE_BLEND)</div><div class="line"> {</div><div class="line"> video::E_VERTEX_TYPE vertexType = getVertexTypeForMaterialType((video::E_MATERIAL_TYPE)selectedMaterial);</div><div class="line"> <span class="keywordflow">switch</span> ( vertexType )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">case</span> video::EVT_STANDARD:</div><div class="line"> material.MaterialType = (video::E_MATERIAL_TYPE)selectedMaterial;</div><div class="line"> SceneNode-&gt;setVisible(<span class="keyword">true</span>);</div><div class="line"> SceneNode2T-&gt;setVisible(<span class="keyword">false</span>);</div><div class="line"> SceneNodeTangents-&gt;setVisible(<span class="keyword">false</span>);</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> video::EVT_2TCOORDS:</div><div class="line"> material2T.MaterialType = (video::E_MATERIAL_TYPE)selectedMaterial;</div><div class="line"> SceneNode-&gt;setVisible(<span class="keyword">false</span>);</div><div class="line"> SceneNode2T-&gt;setVisible(<span class="keyword">true</span>);</div><div class="line"> SceneNodeTangents-&gt;setVisible(<span class="keyword">false</span>);</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> video::EVT_TANGENTS:</div><div class="line"> materialTangents.MaterialType = (video::E_MATERIAL_TYPE)selectedMaterial;</div><div class="line"> SceneNode-&gt;setVisible(<span class="keyword">false</span>);</div><div class="line"> SceneNode2T-&gt;setVisible(<span class="keyword">false</span>);</div><div class="line"> SceneNodeTangents-&gt;setVisible(<span class="keyword">true</span>);</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> updateMaterial(material);</div><div class="line"> updateMaterial(material2T);</div><div class="line"> updateMaterial(materialTangents);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( ButtonLighting-&gt;isPressed() )</div><div class="line"> InfoLighting-&gt;setText(L<span class="stringliteral">&quot;on&quot;</span>);</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> InfoLighting-&gt;setText(L<span class="stringliteral">&quot;off&quot;</span>);</div><div class="line"></div><div class="line"> AllColorsControl-&gt;resetDirty();</div><div class="line"> TextureControl1-&gt;resetDirty();</div><div class="line"> TextureControl2-&gt;resetDirty();</div><div class="line"> ControlVertexColors-&gt;resetDirty();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> updateTextures()</div><div class="line"> {</div><div class="line"> TextureControl1-&gt;updateTextures(Driver);</div><div class="line"> TextureControl2-&gt;updateTextures(Driver);</div><div class="line"> }</div><div class="line"></div><div class="line"><span class="keyword">protected</span>:</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> updateMaterial(video::SMaterial &amp; material)</div><div class="line"> {</div><div class="line"> AllColorsControl-&gt;updateMaterialColors(material);</div><div class="line"> material.Lighting = ButtonLighting-&gt;isPressed();</div><div class="line"> <span class="keywordflow">if</span> ( TextureControl1-&gt;isDirty() )</div><div class="line"> {</div><div class="line"> material.TextureLayer[0].Texture = Driver-&gt;getTexture( io::path(TextureControl1-&gt;getSelectedTextureName()) );</div><div class="line"> }</div><div class="line"> <span class="keywordflow">if</span> ( TextureControl2-&gt;isDirty() )</div><div class="line"> {</div><div class="line"> material.TextureLayer[1].Texture = Driver-&gt;getTexture( io::path(TextureControl2-&gt;getSelectedTextureName()) );</div><div class="line"> }</div><div class="line"> <span class="keywordflow">if</span> ( ControlVertexColors-&gt;isDirty() )</div><div class="line"> {</div><div class="line"> MeshManipulator-&gt;setVertexColors (SceneNode-&gt;getMesh(), ControlVertexColors-&gt;getColor());</div><div class="line"> MeshManipulator-&gt;setVertexColors (SceneNode2T-&gt;getMesh(), ControlVertexColors-&gt;getColor());</div><div class="line"> MeshManipulator-&gt;setVertexColors (SceneNodeTangents-&gt;getMesh(), ControlVertexColors-&gt;getColor());</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">bool</span> Initialized;</div><div class="line"> video::IVideoDriver * Driver;</div><div class="line"> scene::IMeshManipulator* MeshManipulator;</div><div class="line"> scene::IMeshSceneNode* SceneNode;</div><div class="line"> scene::IMeshSceneNode* SceneNode2T;</div><div class="line"> scene::IMeshSceneNode* SceneNodeTangents;</div><div class="line"> CAllColorsControl* AllColorsControl;</div><div class="line"> gui::IGUIButton * ButtonLighting;</div><div class="line"> gui::IGUIStaticText* InfoLighting;</div><div class="line"> gui::IGUIComboBox * ComboMaterial;</div><div class="line"> CTextureControl* TextureControl1;</div><div class="line"> CTextureControl* TextureControl2;</div><div class="line"> CColorControl* ControlVertexColors;</div><div class="line">};</div></div><!-- fragment --><p> Control to allow setting the color values of a lightscenenode. </p><div class="fragment"><div class="line"><span class="keyword">struct </span>SLightNodeControl</div><div class="line">{</div><div class="line"> <span class="comment">// constructor</span></div><div class="line"> SLightNodeControl() : Initialized(false), SceneNode(0), AllColorsControl(0)</div><div class="line"> {</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keyword">virtual</span> ~SLightNodeControl()</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( AllColorsControl )</div><div class="line"> AllColorsControl-&gt;drop();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> init(scene::ILightSceneNode* node, gui::IGUIEnvironment* guiEnv, <span class="keyword">const</span> core::position2d&lt;s32&gt; &amp; pos, <span class="keyword">const</span> <span class="keywordtype">wchar_t</span> * description)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( Initialized || !node || !guiEnv) <span class="comment">// initializing twice or with invalid data not allowed</span></div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"> SceneNode = node;</div><div class="line"> AllColorsControl = <span class="keyword">new</span> CAllColorsControl(guiEnv, pos, description, <span class="keyword">false</span>, guiEnv-&gt;getRootGUIElement());</div><div class="line"> <span class="keyword">const</span> video::SLight &amp; lightData = SceneNode-&gt;getLightData();</div><div class="line"> AllColorsControl-&gt;setColorsToLightDataColors(lightData);</div><div class="line"> Initialized = <span class="keyword">true</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> update()</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( !Initialized )</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"></div><div class="line"> video::SLight &amp; lightData = SceneNode-&gt;getLightData();</div><div class="line"> AllColorsControl-&gt;updateLightColors(lightData);</div><div class="line"> }</div><div class="line"></div><div class="line"><span class="keyword">protected</span>:</div><div class="line"> <span class="keywordtype">bool</span> Initialized;</div><div class="line"> scene::ILightSceneNode* SceneNode;</div><div class="line"> CAllColorsControl* AllColorsControl;</div><div class="line">};</div></div><!-- fragment --><p> Application configuration </p><div class="fragment"><div class="line"><span class="keyword">struct </span>SConfig</div><div class="line">{</div><div class="line"> SConfig()</div><div class="line"> : RenderInBackground(true)</div><div class="line"> , DriverType(video::EDT_BURNINGSVIDEO)</div><div class="line"> , ScreenSize(640, 480)</div><div class="line"> {</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">bool</span> RenderInBackground;</div><div class="line"> video::E_DRIVER_TYPE DriverType;</div><div class="line"> core::dimension2d&lt;u32&gt; ScreenSize;</div><div class="line">};</div></div><!-- fragment --><p> Main application class </p><div class="fragment"><div class="line"><span class="keyword">class </span>CApp : <span class="keyword">public</span> IEventReceiver</div><div class="line">{</div><div class="line"> <span class="keyword">friend</span> <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]);</div><div class="line"></div><div class="line"><span class="keyword">public</span>:</div><div class="line"> <span class="comment">// constructor</span></div><div class="line"> CApp()</div><div class="line"> : IsRunning(false)</div><div class="line"> , Device(0)</div><div class="line"> , Camera(0)</div><div class="line"> , GlobalAmbient(0)</div><div class="line"> {</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// destructor</span></div><div class="line"> ~CApp()</div><div class="line"> {</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// stop running - will quit at end of mainloop</span></div><div class="line"> <span class="keywordtype">void</span> stopApp()</div><div class="line"> {</div><div class="line"> IsRunning = <span class="keyword">false</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Event handler</span></div><div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent &amp;event)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> (event.EventType == EET_GUI_EVENT)</div><div class="line"> {</div><div class="line"> gui::IGUIEnvironment* env = Device-&gt;getGUIEnvironment();</div><div class="line"></div><div class="line"> <span class="keywordflow">switch</span>(event.GUIEvent.EventType)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">case</span> gui::EGET_MENU_ITEM_SELECTED:</div><div class="line"> {</div><div class="line"> gui::IGUIContextMenu* menu = (gui::IGUIContextMenu*)event.GUIEvent.Caller;</div><div class="line"> s32 <span class="keywordtype">id</span> = menu-&gt;getItemCommandId(menu-&gt;getSelectedItem());</div><div class="line"></div><div class="line"> <span class="keywordflow">switch</span>(<span class="keywordtype">id</span>)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">case</span> GUI_ID_OPEN_TEXTURE: <span class="comment">// File -&gt; Open Texture</span></div><div class="line"> env-&gt;addFileOpenDialog(L<span class="stringliteral">&quot;Please select a texture file to open&quot;</span>);</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> <span class="keywordflow">case</span> GUI_ID_QUIT: <span class="comment">// File -&gt; Quit</span></div><div class="line"> stopApp();</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> }</div><div class="line"> }</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line"> <span class="keywordflow">case</span> gui::EGET_FILE_SELECTED:</div><div class="line"> {</div><div class="line"> <span class="comment">// load the model file, selected in the file open dialog</span></div><div class="line"> gui::IGUIFileOpenDialog* dialog =</div><div class="line"> (gui::IGUIFileOpenDialog*)event.GUIEvent.Caller;</div><div class="line"> loadTexture(io::path(dialog-&gt;getFileName()).c_str());</div><div class="line"> }</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line"> <span class="keywordflow">default</span>:</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"><span class="keyword">protected</span>:</div><div class="line"></div><div class="line"> <span class="comment">// Application initialization</span></div><div class="line"> <span class="comment">// returns true when it was successful initialized, otherwise false.</span></div><div class="line"> <span class="keywordtype">bool</span> init(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div><div class="line"> {</div><div class="line"> <span class="comment">// ask user for driver</span></div><div class="line"> Config.DriverType=driverChoiceConsole();</div><div class="line"> <span class="keywordflow">if</span> (Config.DriverType==video::EDT_COUNT)</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"></div><div class="line"> <span class="comment">// create the device with the settings from our config</span></div><div class="line"> Device = createDevice(Config.DriverType, Config.ScreenSize);</div><div class="line"> <span class="keywordflow">if</span> (!Device)</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"> Device-&gt;setWindowCaption( DriverTypeNames[Config.DriverType] );</div><div class="line"> Device-&gt;setEventReceiver(<span class="keyword">this</span>);</div><div class="line"></div><div class="line"> scene::ISceneManager* smgr = Device-&gt;getSceneManager();</div><div class="line"> video::IVideoDriver * driver = Device-&gt;getVideoDriver ();</div><div class="line"> gui::IGUIEnvironment* guiEnv = Device-&gt;getGUIEnvironment();</div><div class="line"></div><div class="line"> <span class="comment">// set a nicer font</span></div><div class="line"> gui::IGUISkin* skin = guiEnv-&gt;getSkin();</div><div class="line"> gui::IGUIFont* font = guiEnv-&gt;getFont(<span class="stringliteral">&quot;../../media/fonthaettenschweiler.bmp&quot;</span>);</div><div class="line"> <span class="keywordflow">if</span> (font)</div><div class="line"> skin-&gt;setFont(font);</div><div class="line"></div><div class="line"> <span class="comment">// remove some alpha value because it makes those menus harder to read otherwise</span></div><div class="line"> video::SColor col3dHighLight( skin-&gt;getColor(gui::EGDC_APP_WORKSPACE) );</div><div class="line"> col3dHighLight.setAlpha(255);</div><div class="line"> video::SColor colHighLight( col3dHighLight );</div><div class="line"> skin-&gt;setColor(gui::EGDC_HIGH_LIGHT, colHighLight );</div><div class="line"> skin-&gt;setColor(gui::EGDC_3D_HIGH_LIGHT, col3dHighLight );</div><div class="line"></div><div class="line"> <span class="comment">// Add some textures which are useful to test material settings</span></div><div class="line"> createDefaultTextures(driver);</div><div class="line"></div><div class="line"> <span class="comment">// create a menu</span></div><div class="line"> gui::IGUIContextMenu * menuBar = guiEnv-&gt;addMenu();</div><div class="line"> menuBar-&gt;addItem(L<span class="stringliteral">&quot;File&quot;</span>, -1, <span class="keyword">true</span>, <span class="keyword">true</span>);</div><div class="line"></div><div class="line"> gui::IGUIContextMenu* subMenuFile = menuBar-&gt;getSubMenu(0);</div><div class="line"> subMenuFile-&gt;addItem(L<span class="stringliteral">&quot;Open texture ...&quot;</span>, GUI_ID_OPEN_TEXTURE);</div><div class="line"> subMenuFile-&gt;addSeparator();</div><div class="line"> subMenuFile-&gt;addItem(L<span class="stringliteral">&quot;Quit&quot;</span>, GUI_ID_QUIT);</div><div class="line"></div><div class="line"> <span class="comment">// a static camera</span></div><div class="line"> Camera = smgr-&gt;addCameraSceneNode (0, core::vector3df(0, 0, 0),</div><div class="line"> core::vector3df(0, 0, 100),</div><div class="line"> -1);</div><div class="line"></div><div class="line"> <span class="comment">// add the nodes which are used to show the materials</span></div><div class="line"> scene::IMeshSceneNode* nodeL = smgr-&gt;addCubeSceneNode (30.0f, 0, -1,</div><div class="line"> core::vector3df(-35, 0, 100),</div><div class="line"> core::vector3df(0, 0, 0),</div><div class="line"> core::vector3df(1.0f, 1.0f, 1.0f));</div><div class="line"> NodeLeft.init( nodeL, Device, core::position2d&lt;s32&gt;(10,20), L<span class="stringliteral">&quot;left node&quot;</span> );</div><div class="line"></div><div class="line"> scene::IMeshSceneNode* nodeR = smgr-&gt;addCubeSceneNode (30.0f, 0, -1,</div><div class="line"> core::vector3df(35, 0, 100),</div><div class="line"> core::vector3df(0, 0, 0),</div><div class="line"> core::vector3df(1.0f, 1.0f, 1.0f));</div><div class="line"> NodeRight.init( nodeR, Device, core::position2d&lt;s32&gt;(530,20), L<span class="stringliteral">&quot;right node&quot;</span> );</div><div class="line"></div><div class="line"> <span class="comment">// add one light</span></div><div class="line"> scene::ILightSceneNode* nodeLight = smgr-&gt;addLightSceneNode(0, core::vector3df(0, 0, 0),</div><div class="line"> video::SColorf(1.0f, 1.0f, 1.0f),</div><div class="line"> 100.0f);</div><div class="line"> LightControl.init(nodeLight, guiEnv, core::position2d&lt;s32&gt;(270,20), L<span class="stringliteral">&quot;light&quot;</span> );</div><div class="line"></div><div class="line"> <span class="comment">// one large cube around everything. That&#39;s mainly to make the light more obvious.</span></div><div class="line"> scene::IMeshSceneNode* backgroundCube = smgr-&gt;addCubeSceneNode (200.0f, 0, -1, core::vector3df(0, 0, 0),</div><div class="line"> core::vector3df(45, 0, 0),</div><div class="line"> core::vector3df(1.0f, 1.0f, 1.0f));</div><div class="line"> backgroundCube-&gt;getMaterial(0).BackfaceCulling = <span class="keyword">false</span>; <span class="comment">// we are within the cube, so we have to disable backface culling to see it</span></div><div class="line"> backgroundCube-&gt;getMaterial(0).EmissiveColor.set(255,50,50,50); <span class="comment">// we keep some self lighting to keep texts visible</span></div><div class="line"></div><div class="line"> <span class="comment">// set the ambient light value</span></div><div class="line"> GlobalAmbient = <span class="keyword">new</span> CColorControl( guiEnv, core::position2d&lt;s32&gt;(270, 300), L<span class="stringliteral">&quot;global ambient&quot;</span>, guiEnv-&gt;getRootGUIElement());</div><div class="line"> GlobalAmbient-&gt;setColor( smgr-&gt;getAmbientLight().toSColor() );</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Update one frame</span></div><div class="line"> <span class="keywordtype">bool</span> update()</div><div class="line"> {</div><div class="line"> <span class="keyword">using namespace </span>irr;</div><div class="line"></div><div class="line"> video::IVideoDriver* videoDriver = Device-&gt;getVideoDriver();</div><div class="line"> <span class="keywordflow">if</span> ( !Device-&gt;run() )</div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( Device-&gt;isWindowActive() || Config.RenderInBackground )</div><div class="line"> {</div><div class="line"> gui::IGUIEnvironment* guiEnv = Device-&gt;getGUIEnvironment();</div><div class="line"> scene::ISceneManager* smgr = Device-&gt;getSceneManager();</div><div class="line"> gui::IGUISkin * skin = guiEnv-&gt;getSkin();</div><div class="line"></div><div class="line"> <span class="comment">// update our controls</span></div><div class="line"> NodeLeft.update();</div><div class="line"> NodeRight.update();</div><div class="line"> LightControl.update();</div><div class="line"></div><div class="line"> <span class="comment">// update ambient light settings</span></div><div class="line"> <span class="keywordflow">if</span> ( GlobalAmbient-&gt;isDirty() )</div><div class="line"> {</div><div class="line"> smgr-&gt;setAmbientLight( GlobalAmbient-&gt;getColor() );</div><div class="line"> GlobalAmbient-&gt;resetDirty();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// draw everything</span></div><div class="line"> video::SColor bkColor( skin-&gt;getColor(gui::EGDC_APP_WORKSPACE) );</div><div class="line"> videoDriver-&gt;beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, bkColor);</div><div class="line"></div><div class="line"> smgr-&gt;drawAll();</div><div class="line"> guiEnv-&gt;drawAll();</div><div class="line"></div><div class="line"> videoDriver-&gt;endScene();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Run the application. Our main loop.</span></div><div class="line"> <span class="keywordtype">void</span> run()</div><div class="line"> {</div><div class="line"> IsRunning = <span class="keyword">true</span>;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( !Device )</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"></div><div class="line"> <span class="comment">// main application loop</span></div><div class="line"> <span class="keywordflow">while</span>(IsRunning)</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( !update() )</div><div class="line"> <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line"> Device-&gt;sleep( 5 );</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Close down the application</span></div><div class="line"> <span class="keywordtype">void</span> quit()</div><div class="line"> {</div><div class="line"> IsRunning = <span class="keyword">false</span>;</div><div class="line"> GlobalAmbient-&gt;drop();</div><div class="line"> GlobalAmbient = NULL;</div><div class="line"> <span class="keywordflow">if</span> ( Device )</div><div class="line"> {</div><div class="line"> Device-&gt;closeDevice();</div><div class="line"> Device-&gt;drop();</div><div class="line"> Device = NULL;</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Create some useful textures.</span></div><div class="line"> <span class="comment">// Note that the function put readability over speed, you shouldn&#39;t use setPixel at runtime but for initialization it&#39;s nice.</span></div><div class="line"> <span class="keywordtype">void</span> createDefaultTextures(video::IVideoDriver * driver)</div><div class="line"> {</div><div class="line"> <span class="keyword">const</span> u32 width = 256;</div><div class="line"> <span class="keyword">const</span> u32 height = 256;</div><div class="line"> video::IImage * imageA8R8G8B8 = driver-&gt;createImage (video::ECF_A8R8G8B8, core::dimension2d&lt;u32&gt;(width, height));</div><div class="line"> <span class="keywordflow">if</span> ( !imageA8R8G8B8 )</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"> <span class="keyword">const</span> u32 pitch = imageA8R8G8B8-&gt;getPitch();</div><div class="line"></div><div class="line"> <span class="comment">// some nice square-pattern with 9 typical colors</span></div><div class="line"> <span class="keywordflow">for</span> ( u32 y = 0; y &lt; height; ++ y )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">for</span> ( u32 x = 0; x &lt; pitch; ++x )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( y &lt; height/3 )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( x &lt; width/3 )</div><div class="line"> imageA8R8G8B8-&gt;setPixel (x, y, SCOL_BLACK);</div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( x &lt; 2*width/3 )</div><div class="line"> imageA8R8G8B8-&gt;setPixel (x, y, SCOL_BLUE);</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> imageA8R8G8B8-&gt;setPixel (x, y, SCOL_CYAN);</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( y &lt; 2*height/3 )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( x &lt; width/3 )</div><div class="line"> imageA8R8G8B8-&gt;setPixel (x, y, SCOL_GRAY);</div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( x &lt; 2*width/3 )</div><div class="line"> imageA8R8G8B8-&gt;setPixel (x, y, SCOL_GREEN);</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> imageA8R8G8B8-&gt;setPixel (x, y, SCOL_MAGENTA);</div><div class="line"> }</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> {</div><div class="line"> <span class="keywordflow">if</span> ( x &lt; width/3 )</div><div class="line"> imageA8R8G8B8-&gt;setPixel (x, y, SCOL_RED);</div><div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( x &lt; 2*width/3 )</div><div class="line"> imageA8R8G8B8-&gt;setPixel (x, y, SCOL_YELLOW);</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> imageA8R8G8B8-&gt;setPixel (x, y, SCOL_WHITE);</div><div class="line"> }</div><div class="line"> }</div><div class="line"> }</div><div class="line"> driver-&gt;addTexture (io::path(<span class="stringliteral">&quot;CARO_A8R8G8B8&quot;</span>), imageA8R8G8B8);</div><div class="line"></div><div class="line"> <span class="comment">// all white</span></div><div class="line"> imageA8R8G8B8-&gt;fill(SCOL_WHITE);</div><div class="line"> driver-&gt;addTexture (io::path(<span class="stringliteral">&quot;WHITE_A8R8G8B8&quot;</span>), imageA8R8G8B8);</div><div class="line"></div><div class="line"> <span class="comment">// all black</span></div><div class="line"> imageA8R8G8B8-&gt;fill(SCOL_BLACK);</div><div class="line"> driver-&gt;addTexture (io::path(<span class="stringliteral">&quot;BLACK_A8R8G8B8&quot;</span>), imageA8R8G8B8);</div><div class="line"></div><div class="line"> <span class="comment">// gray-scale</span></div><div class="line"> <span class="keywordflow">for</span> ( u32 y = 0; y &lt; height; ++ y )</div><div class="line"> {</div><div class="line"> <span class="keywordflow">for</span> ( u32 x = 0; x &lt; pitch; ++x )</div><div class="line"> {</div><div class="line"> imageA8R8G8B8-&gt;setPixel (x, y, video::SColor(y, x,x,x) );</div><div class="line"> }</div><div class="line"> }</div><div class="line"> driver-&gt;addTexture (io::path(<span class="stringliteral">&quot;GRAYSCALE_A8R8G8B8&quot;</span>), imageA8R8G8B8);</div><div class="line"></div><div class="line"> imageA8R8G8B8-&gt;drop();</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Load a texture and make sure nodes know it when more textures are available.</span></div><div class="line"> <span class="keywordtype">void</span> loadTexture(<span class="keyword">const</span> io::path &amp;name)</div><div class="line"> {</div><div class="line"> Device-&gt;getVideoDriver()-&gt;getTexture(name);</div><div class="line"> NodeLeft.updateTextures();</div><div class="line"> NodeRight.updateTextures();</div><div class="line"> }</div><div class="line"></div><div class="line"><span class="keyword">private</span>:</div><div class="line"> SConfig Config;</div><div class="line"> <span class="keyword">volatile</span> <span class="keywordtype">bool</span> IsRunning;</div><div class="line"> IrrlichtDevice * Device;</div><div class="line"> scene::ICameraSceneNode * Camera;</div><div class="line"> SMeshNodeControl NodeLeft;</div><div class="line"> SMeshNodeControl NodeRight;</div><div class="line"> SLightNodeControl LightControl;</div><div class="line"> CColorControl * GlobalAmbient;</div><div class="line">};</div></div><!-- fragment --><p> A very short main as we do everything else in classes. </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div><div class="line">{</div><div class="line"> CApp APP;</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> ( !APP.init(argc, argv) )</div><div class="line"> {</div><div class="line"> printf(<span class="stringliteral">&quot;init failed\n&quot;</span>);</div><div class="line"> <span class="keywordflow">return</span> 1;</div><div class="line"> }</div><div class="line"></div><div class="line"> APP.run();</div><div class="line"> APP.quit();</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --> </div></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.13-->
<!-- start footer part -->
<p>&nbsp;</p>
</body>
</html>