aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/doc/html/example022.html
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/doc/html/example022.html')
-rw-r--r--src/others/irrlicht-1.8.1/doc/html/example022.html1136
1 files changed, 1136 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/doc/html/example022.html b/src/others/irrlicht-1.8.1/doc/html/example022.html
new file mode 100644
index 0000000..bd1d46d
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/doc/html/example022.html
@@ -0,0 +1,1136 @@
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 22: Material Viewer</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">
69var 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('example022.html','');
84</script>
85<div id="doc-content">
86<div class="header">
87 <div class="headertitle">
88<div class="title">Tutorial 22: Material Viewer </div> </div>
89</div>
90<div class="contents">
91<div class="textblock"><div class="image">
92<img src="022shot.jpg" alt="022shot.jpg"/>
93</div>
94 <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>
95<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>
96<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;<a class="code" href="irrlicht_8h.html" title="Main header file of the irrlicht, the only file needed to include.">irrlicht.h</a>&gt;</span>
97<span class="preprocessor">#include &quot;<a class="code" href="driver_choice_8h.html">driverChoice.h</a>&quot;</span>
98
99<span class="keyword">using namespace </span>irr;
100
101<span class="preprocessor">#ifdef _MSC_VER</span>
102<span class="preprocessor"></span><span class="preprocessor">#pragma comment(lib, &quot;Irrlicht.lib&quot;)</span>
103<span class="preprocessor">#endif</span>
104</pre></div><p>Variables within the empty namespace are globals which are restricted to this file. </p>
105<div class="fragment"><pre class="fragment"><span class="keyword">namespace</span>
106{
107 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* <span class="keyword">const</span> DriverTypeNames[] =
108 {
109 L<span class="stringliteral">&quot;NULL&quot;</span>,
110 L<span class="stringliteral">&quot;SOFTWARE&quot;</span>,
111 L<span class="stringliteral">&quot;BURNINGSVIDEO&quot;</span>,
112 L<span class="stringliteral">&quot;DIRECT3D8&quot;</span>,
113 L<span class="stringliteral">&quot;DIRECT3D9&quot;</span>,
114 L<span class="stringliteral">&quot;OPENGL&quot;</span>,
115 0,
116 };
117
118 <span class="comment">// For the gui id&#39;s</span>
119 <span class="keyword">enum</span> EGUI_IDS
120 {
121 GUI_ID_OPEN_TEXTURE = 1,
122 GUI_ID_QUIT,
123 GUI_ID_MAX
124 };
125
126 <span class="comment">// Name used in texture selection to clear the textures on the node</span>
127 <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> CLEAR_TEXTURE = L<span class="stringliteral">&quot;CLEAR texture&quot;</span>;
128
129 <span class="comment">// some useful color constants</span>
130 <span class="keyword">const</span> video::SColor SCOL_BLACK = video::SColor(255, 0, 0, 0);
131 <span class="keyword">const</span> video::SColor SCOL_BLUE = video::SColor(255, 0, 0, 255);
132 <span class="keyword">const</span> video::SColor SCOL_CYAN = video::SColor(255, 0, 255, 255);
133 <span class="keyword">const</span> video::SColor SCOL_GRAY = video::SColor(255, 128,128, 128);
134 <span class="keyword">const</span> video::SColor SCOL_GREEN = video::SColor(255, 0, 255, 0);
135 <span class="keyword">const</span> video::SColor SCOL_MAGENTA = video::SColor(255, 255, 0, 255);
136 <span class="keyword">const</span> video::SColor SCOL_RED = video::SColor(255, 255, 0, 0);
137 <span class="keyword">const</span> video::SColor SCOL_YELLOW = video::SColor(255, 255, 255, 0);
138 <span class="keyword">const</span> video::SColor SCOL_WHITE = video::SColor(255, 255, 255, 255);
139}; <span class="comment">// namespace</span>
140</pre></div><p>Returns a new unique number on each call. </p>
141<div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> makeUniqueId()
142{
143 <span class="keyword">static</span> <span class="keywordtype">int</span> unique = GUI_ID_MAX;
144 ++unique;
145 <span class="keywordflow">return</span> unique;
146}
147</pre></div><p>Find out which vertex-type is needed for the given material type. </p>
148<div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deac" title="Enumeration for all vertex types there are.">video::E_VERTEX_TYPE</a> getVertexTypeForMaterialType(<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1" title="Abstracted and easy to use fixed function/programmable pipeline material modes.">video::E_MATERIAL_TYPE</a> materialType)
149{
150 <span class="keyword">using namespace </span>video;
151
152 <span class="keywordflow">switch</span> ( materialType )
153 {
154 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a9bc471b9c18c9e2d20496004d2a2e803" title="Standard solid material.">EMT_SOLID</a>:
155 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca98c8b791280bbf9252c4f4a37e91a416" title="Standard vertex type used by the Irrlicht engine, video::S3DVertex.">EVT_STANDARD</a>;
156
157 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a3246cbdb780b42b819eb8a24c2ef40d9" title="Solid material with 2 texture layers.">EMT_SOLID_2_LAYER</a>:
158 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca98c8b791280bbf9252c4f4a37e91a416" title="Standard vertex type used by the Irrlicht engine, video::S3DVertex.">EVT_STANDARD</a>;
159
160 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a5dc90a3b4a8d82f10503ddf834a3143f" title="Material type with standard lightmap technique.">EMT_LIGHTMAP</a>:
161 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a7aa628bfc8b6ac56c30e93549b799855" title="Material type with lightmap technique like EMT_LIGHTMAP.">EMT_LIGHTMAP_ADD</a>:
162 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1abd740658d7ca152bab745c63107d7edb" title="Material type with standard lightmap technique.">EMT_LIGHTMAP_M2</a>:
163 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1ad61a64f074256bb1cc1b6c130e18ebdc" title="Material type with standard lightmap technique.">EMT_LIGHTMAP_M4</a>:
164 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1add532294454c4842964c79a14ac4af34" title="Like EMT_LIGHTMAP, but also supports dynamic lighting.">EMT_LIGHTMAP_LIGHTING</a>:
165 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a9cd386cb5151eabccbdded029529dec0" title="Like EMT_LIGHTMAP_M2, but also supports dynamic lighting.">EMT_LIGHTMAP_LIGHTING_M2</a>:
166 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a6b7a3c28cfc214c63df8674565e28f17" title="Like EMT_LIGHTMAP_4, but also supports dynamic lighting.">EMT_LIGHTMAP_LIGHTING_M4</a>:
167 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca7b5127a706ee33eb4385d702da007016" title="Vertex with two texture coordinates, video::S3DVertex2TCoords.">EVT_2TCOORDS</a>;
168
169 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a065af4f8daeb15f81bfe0417a3f231b1" title="Detail mapped material.">EMT_DETAIL_MAP</a>:
170 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca7b5127a706ee33eb4385d702da007016" title="Vertex with two texture coordinates, video::S3DVertex2TCoords.">EVT_2TCOORDS</a>;
171
172 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a42a8b6f5c933864ca104b3d46692c43b" title="Look like a reflection of the environment around it.">EMT_SPHERE_MAP</a>:
173 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca98c8b791280bbf9252c4f4a37e91a416" title="Standard vertex type used by the Irrlicht engine, video::S3DVertex.">EVT_STANDARD</a>;
174
175 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1ad8574343353ed8ade6e78bc04d64b6ae" title="A reflecting material with an optional non reflecting texture layer.">EMT_REFLECTION_2_LAYER</a>:
176 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca7b5127a706ee33eb4385d702da007016" title="Vertex with two texture coordinates, video::S3DVertex2TCoords.">EVT_2TCOORDS</a>;
177
178 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a1b5a814c4466aca2943ff056003a50d1" title="A transparent material.">EMT_TRANSPARENT_ADD_COLOR</a>:
179 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca98c8b791280bbf9252c4f4a37e91a416" title="Standard vertex type used by the Irrlicht engine, video::S3DVertex.">EVT_STANDARD</a>;
180
181 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1ac08aa3715ad41281472202107a81f736" title="Makes the material transparent based on the texture alpha channel.">EMT_TRANSPARENT_ALPHA_CHANNEL</a>:
182 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca98c8b791280bbf9252c4f4a37e91a416" title="Standard vertex type used by the Irrlicht engine, video::S3DVertex.">EVT_STANDARD</a>;
183
184 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a167b3eb9c4c09ee1f145d914f4ddb619" title="Makes the material transparent based on the texture alpha channel.">EMT_TRANSPARENT_ALPHA_CHANNEL_REF</a>:
185 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca98c8b791280bbf9252c4f4a37e91a416" title="Standard vertex type used by the Irrlicht engine, video::S3DVertex.">EVT_STANDARD</a>;
186
187 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a26529b1cf18ec4d8073809f6bd15ebbb" title="Makes the material transparent based on the vertex alpha value.">EMT_TRANSPARENT_VERTEX_ALPHA</a>:
188 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca98c8b791280bbf9252c4f4a37e91a416" title="Standard vertex type used by the Irrlicht engine, video::S3DVertex.">EVT_STANDARD</a>;
189
190 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a8b074c837c82178daa178a3a7321a32d" title="A transparent reflecting material with an optional additional non reflecting texture layer...">EMT_TRANSPARENT_REFLECTION_2_LAYER</a>:
191 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca7b5127a706ee33eb4385d702da007016" title="Vertex with two texture coordinates, video::S3DVertex2TCoords.">EVT_2TCOORDS</a>;
192
193 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a89220ece17ea7d54a530de9756734c70" title="A solid normal map renderer.">EMT_NORMAL_MAP_SOLID</a>:
194 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a12323a7408cc28c4e57c4ae52758086c" title="A transparent normal map renderer.">EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR</a>:
195 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a0d6f6973795d52d137955699537565db" title="A transparent (based on the vertex alpha value) normal map renderer.">EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA</a>:
196 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a833aaad409476c3c4baf59e2d1096f4a" title="Just like EMT_NORMAL_MAP_SOLID, but uses parallax mapping.">EMT_PARALLAX_MAP_SOLID</a>:
197 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a84787f1dfcbdc1578ecd84f6de4a22a1" title="A material like EMT_PARALLAX_MAP_SOLID, but transparent.">EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR</a>:
198 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a4c3e6b604a6d0fc5dffec661f470c11a" title="A material like EMT_PARALLAX_MAP_SOLID, but transparent.">EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA</a>:
199 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca8c50b5b2c88f08709d640fecc83dfb9b" title="Vertex with a tangent and binormal vector, video::S3DVertexTangents.">EVT_TANGENTS</a>;
200
201 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a09498eaf291e1f7abdc04db808cc15d9" title="BlendFunc = source * sourceFactor + dest * destFactor ( E_BLEND_FUNC )">EMT_ONETEXTURE_BLEND</a>:
202 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca98c8b791280bbf9252c4f4a37e91a416" title="Standard vertex type used by the Irrlicht engine, video::S3DVertex.">EVT_STANDARD</a>;
203
204 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a85962cdf5aab2ddd245cada9b1859e30" title="This value is not used. It only forces this enumeration to compile to 32 bit.">EMT_FORCE_32BIT</a>:
205 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca98c8b791280bbf9252c4f4a37e91a416" title="Standard vertex type used by the Irrlicht engine, video::S3DVertex.">EVT_STANDARD</a>;
206 }
207 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca98c8b791280bbf9252c4f4a37e91a416" title="Standard vertex type used by the Irrlicht engine, video::S3DVertex.">EVT_STANDARD</a>;
208}
209</pre></div><p>Custom GUI-control to edit colorvalues. </p>
210<div class="fragment"><pre class="fragment"><span class="keyword">class </span>CColorControl : <span class="keyword">public</span> gui::IGUIElement
211{
212<span class="keyword">public</span>:
213 <span class="comment">// Constructor</span>
214 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, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <span class="keywordtype">id</span>=-1 )
215 : gui::IGUIElement(gui::<a class="code" href="namespaceirr_1_1gui.html#ae4d66df0ecf4117cdbcf9f22404bd254afab12396466cf3add0f9e7408a053932" title="Unknown type.">EGUIET_ELEMENT</a>, guiEnv, parent,id, core::rect&lt; <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> &gt;(pos, pos+core::dimension2d&lt;<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>&gt;(80, 75)))
216 , DirtyFlag(true)
217 , ColorStatic(0)
218 , EditAlpha(0)
219 , EditRed(0)
220 , EditGreen(0)
221 , EditBlue(0)
222 {
223 <span class="keyword">using namespace </span>gui;
224 ButtonSetId = makeUniqueId();
225
226 <span class="keyword">const</span> core::rect&lt; s32 &gt; rectControls(0,0,AbsoluteRect.getWidth(),AbsoluteRect.getHeight() );
227 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>);
228 groupElement-&gt;setNotClipped(<span class="keyword">true</span>);
229
230 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>);
231
232 EditAlpha = addEditForNumbers(guiEnv, core::position2d&lt;s32&gt;(0,15), L<span class="stringliteral">&quot;a&quot;</span>, -1, groupElement );
233 EditRed = addEditForNumbers(guiEnv, core::position2d&lt;s32&gt;(0,30), L<span class="stringliteral">&quot;r&quot;</span>, -1, groupElement );
234 EditGreen = addEditForNumbers(guiEnv, core::position2d&lt;s32&gt;(0,45), L<span class="stringliteral">&quot;g&quot;</span>, -1, groupElement );
235 EditBlue = addEditForNumbers(guiEnv, core::position2d&lt;s32&gt;(0,60), L<span class="stringliteral">&quot;b&quot;</span>, -1, groupElement );
236
237 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>);
238
239 guiEnv-&gt;addButton (core::rect&lt;s32&gt;(60,35,80,50), groupElement, ButtonSetId, L<span class="stringliteral">&quot;set&quot;</span>);
240 SetEditsFromColor(Color);
241 }
242
243 <span class="comment">// event receiver</span>
244 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent &amp;event)
245 {
246 <span class="keywordflow">if</span> ( event.EventType != <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0cae85bb44dd09a29c879d64a05047fc1d2" title="An event of the graphical user interface.">EET_GUI_EVENT</a> )
247 <span class="keywordflow">return</span> <span class="keyword">false</span>;
248
249 <span class="keywordflow">if</span> ( event.GUIEvent.Caller-&gt;getID() == ButtonSetId &amp;&amp; <span class="keyword">event</span>.GUIEvent.EventType == <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" title="A button was clicked.">gui::EGET_BUTTON_CLICKED</a> )
250 {
251 Color = GetColorFromEdits();
252 SetEditsFromColor(Color);
253 }
254
255 <span class="keywordflow">return</span> <span class="keyword">false</span>;
256 }
257
258 <span class="comment">// set the color values</span>
259 <span class="keywordtype">void</span> setColor(<span class="keyword">const</span> video::SColor&amp; col)
260 {
261 DirtyFlag = <span class="keyword">true</span>;
262 Color = col;
263 SetEditsFromColor(Color);
264 }
265
266 <span class="comment">// get the color values</span>
267 <span class="keyword">const</span> video::SColor&amp; getColor()<span class="keyword"> const</span>
268<span class="keyword"> </span>{
269 <span class="keywordflow">return</span> Color;
270 }
271
272 <span class="comment">// To reset the dirty flag</span>
273 <span class="keywordtype">void</span> resetDirty()
274 {
275 DirtyFlag = <span class="keyword">false</span>;
276 }
277
278 <span class="comment">// when the color was changed the dirty flag is set</span>
279 <span class="keywordtype">bool</span> isDirty()<span class="keyword"> const</span>
280<span class="keyword"> </span>{
281 <span class="keywordflow">return</span> DirtyFlag;
282 };
283
284<span class="keyword">protected</span>:
285
286 <span class="comment">// Add a staticbox for a description + an editbox so users can enter numbers</span>
287 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, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <span class="keywordtype">id</span>, gui::IGUIElement * parent)
288 {
289 <span class="keyword">using namespace </span>gui;
290
291 core::rect&lt; s32 &gt; rect(pos, pos+core::dimension2d&lt;s32&gt;(10, 15));
292 guiEnv-&gt;addStaticText (text, rect, <span class="keyword">false</span>, <span class="keyword">false</span>, parent, -1, <span class="keyword">false</span>);
293 rect += core::position2d&lt;s32&gt;( 20, 0 );
294 rect.LowerRightCorner.X += 20;
295 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>);
296 <span class="keywordflow">return</span> edit;
297 }
298
299 <span class="comment">// Get the color value from the editfields</span>
300 video::SColor GetColorFromEdits()
301 {
302 video::SColor col;
303
304 <span class="keywordflow">if</span> (EditAlpha)
305 {
306 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> alpha = <a class="code" href="namespaceirr_1_1core.html#ae7f759b603f4caaa8471cb9bc2e23648" title="Convert a simple string of base 10 digits into an unsigned 32 bit integer.">core::strtoul10</a>(<a class="code" href="namespaceirr_1_1core.html#ade1071a878633f2f6d8a75c5d11fec19" title="Typedef for character strings.">core::stringc</a>(EditAlpha-&gt;getText()).c_str());
307 <span class="keywordflow">if</span> (alpha &gt; 255)
308 alpha = 255;
309 col.setAlpha(alpha);
310 }
311
312 <span class="keywordflow">if</span> (EditRed)
313 {
314 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> red = <a class="code" href="namespaceirr_1_1core.html#ae7f759b603f4caaa8471cb9bc2e23648" title="Convert a simple string of base 10 digits into an unsigned 32 bit integer.">core::strtoul10</a>(<a class="code" href="namespaceirr_1_1core.html#ade1071a878633f2f6d8a75c5d11fec19" title="Typedef for character strings.">core::stringc</a>(EditRed-&gt;getText()).c_str());
315 <span class="keywordflow">if</span> (red &gt; 255)
316 red = 255;
317 col.setRed(red);
318 }
319
320 <span class="keywordflow">if</span> (EditGreen)
321 {
322 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> green = <a class="code" href="namespaceirr_1_1core.html#ae7f759b603f4caaa8471cb9bc2e23648" title="Convert a simple string of base 10 digits into an unsigned 32 bit integer.">core::strtoul10</a>(<a class="code" href="namespaceirr_1_1core.html#ade1071a878633f2f6d8a75c5d11fec19" title="Typedef for character strings.">core::stringc</a>(EditGreen-&gt;getText()).c_str());
323 <span class="keywordflow">if</span> (green &gt; 255)
324 green = 255;
325 col.setGreen(green);
326 }
327
328 <span class="keywordflow">if</span> (EditBlue)
329 {
330 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> blue = <a class="code" href="namespaceirr_1_1core.html#ae7f759b603f4caaa8471cb9bc2e23648" title="Convert a simple string of base 10 digits into an unsigned 32 bit integer.">core::strtoul10</a>(<a class="code" href="namespaceirr_1_1core.html#ade1071a878633f2f6d8a75c5d11fec19" title="Typedef for character strings.">core::stringc</a>(EditBlue-&gt;getText()).c_str());
331 <span class="keywordflow">if</span> (blue &gt; 255)
332 blue = 255;
333 col.setBlue(blue);
334 }
335
336 <span class="keywordflow">return</span> col;
337 }
338
339 <span class="comment">// Fill the editfields with the value for the given color</span>
340 <span class="keywordtype">void</span> SetEditsFromColor(video::SColor col)
341 {
342 DirtyFlag = <span class="keyword">true</span>;
343 <span class="keywordflow">if</span> ( EditAlpha )
344 EditAlpha-&gt;setText( <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a>(col.getAlpha()).c_str() );
345 <span class="keywordflow">if</span> ( EditRed )
346 EditRed-&gt;setText( <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a>(col.getRed()).c_str() );
347 <span class="keywordflow">if</span> ( EditGreen )
348 EditGreen-&gt;setText( <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a>(col.getGreen()).c_str() );
349 <span class="keywordflow">if</span> ( EditBlue )
350 EditBlue-&gt;setText( <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a>(col.getBlue()).c_str() );
351 <span class="keywordflow">if</span> ( ColorStatic )
352 ColorStatic-&gt;setBackgroundColor(col);
353 }
354
355<span class="keyword">private</span>:
356
357 <span class="keywordtype">bool</span> DirtyFlag;
358 video::SColor Color;
359 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> ButtonSetId;
360 gui::IGUIStaticText * ColorStatic;
361 gui::IGUIEditBox * EditAlpha;
362 gui::IGUIEditBox * EditRed;
363 gui::IGUIEditBox * EditGreen;
364 gui::IGUIEditBox * EditBlue;
365};
366</pre></div><p>Custom GUI-control for to edit all colors typically used in materials and lights </p>
367<div class="fragment"><pre class="fragment"><span class="keyword">class </span>CAllColorsControl : <span class="keyword">public</span> gui::IGUIElement
368{
369<span class="keyword">public</span>:
370 <span class="comment">// Constructor</span>
371 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, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <span class="keywordtype">id</span>=-1)
372 : gui::IGUIElement(gui::<a class="code" href="namespaceirr_1_1gui.html#ae4d66df0ecf4117cdbcf9f22404bd254afab12396466cf3add0f9e7408a053932" title="Unknown type.">EGUIET_ELEMENT</a>, guiEnv, parent,id, core::rect&lt;<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>&gt;(pos,pos+core::dimension2d&lt;<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>&gt;(60,250)))
373 , ControlAmbientColor(0), ControlDiffuseColor(0), ControlSpecularColor(0), ControlEmissiveColor(0)
374 {
375 core::rect&lt;s32&gt; rect(0, 0, 60, 15);
376 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>);
377 createColorControls(guiEnv, core::position2d&lt;s32&gt;(0, 15), hasEmissive);
378 }
379
380 <span class="comment">// Destructor</span>
381 <span class="keyword">virtual</span> ~CAllColorsControl()
382 {
383 ControlAmbientColor-&gt;drop();
384 ControlDiffuseColor-&gt;drop();
385 <span class="keywordflow">if</span> ( ControlEmissiveColor )
386 ControlEmissiveColor-&gt;drop();
387 ControlSpecularColor-&gt;drop();
388 }
389
390 <span class="comment">// Set the color values to those within the material</span>
391 <span class="keywordtype">void</span> setColorsToMaterialColors(<span class="keyword">const</span> video::SMaterial &amp; material)
392 {
393 ControlAmbientColor-&gt;setColor(material.AmbientColor);
394 ControlDiffuseColor-&gt;setColor(material.DiffuseColor);
395 ControlEmissiveColor-&gt;setColor(material.EmissiveColor);
396 ControlSpecularColor-&gt;setColor(material.SpecularColor);
397 }
398
399 <span class="comment">// Update all changed colors in the material</span>
400 <span class="keywordtype">void</span> updateMaterialColors(video::SMaterial &amp; material)
401 {
402 <span class="keywordflow">if</span> ( ControlAmbientColor-&gt;isDirty() )
403 material.AmbientColor = ControlAmbientColor-&gt;getColor();
404 <span class="keywordflow">if</span> ( ControlDiffuseColor-&gt;isDirty() )
405 material.DiffuseColor = ControlDiffuseColor-&gt;getColor();
406 <span class="keywordflow">if</span> ( ControlEmissiveColor-&gt;isDirty() )
407 material.EmissiveColor = ControlEmissiveColor-&gt;getColor();
408 <span class="keywordflow">if</span> ( ControlSpecularColor-&gt;isDirty() )
409 material.SpecularColor = ControlSpecularColor-&gt;getColor();
410 }
411
412 <span class="comment">// Set the color values to those from the light data</span>
413 <span class="keywordtype">void</span> setColorsToLightDataColors(<span class="keyword">const</span> video::SLight &amp; lightData)
414 {
415 ControlAmbientColor-&gt;setColor(lightData.AmbientColor.toSColor());
416 ControlAmbientColor-&gt;setColor(lightData.DiffuseColor.toSColor());
417 ControlAmbientColor-&gt;setColor(lightData.SpecularColor.toSColor());
418 }
419
420 <span class="comment">// Update all changed colors in the light data</span>
421 <span class="keywordtype">void</span> updateLightColors(video::SLight &amp; lightData)
422 {
423 <span class="keywordflow">if</span> ( ControlAmbientColor-&gt;isDirty() )
424 lightData.AmbientColor = video::SColorf( ControlAmbientColor-&gt;getColor() );
425 <span class="keywordflow">if</span> ( ControlDiffuseColor-&gt;isDirty() )
426 lightData.DiffuseColor = video::SColorf( ControlDiffuseColor-&gt;getColor() );
427 <span class="keywordflow">if</span> ( ControlSpecularColor-&gt;isDirty() )
428 lightData.SpecularColor = video::SColorf(ControlSpecularColor-&gt;getColor() );
429 }
430
431 <span class="comment">// To reset the dirty flags</span>
432 <span class="keywordtype">void</span> resetDirty()
433 {
434 ControlAmbientColor-&gt;resetDirty();
435 ControlDiffuseColor-&gt;resetDirty();
436 ControlSpecularColor-&gt;resetDirty();
437 <span class="keywordflow">if</span> ( ControlEmissiveColor )
438 ControlEmissiveColor-&gt;resetDirty();
439 }
440
441<span class="keyword">protected</span>:
442 <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)
443 {
444 ControlAmbientColor = <span class="keyword">new</span> CColorControl( guiEnv, pos, L<span class="stringliteral">&quot;ambient&quot;</span>, <span class="keyword">this</span>);
445 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> );
446 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> );
447 <span class="keywordflow">if</span> ( hasEmissive )
448 {
449 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> );
450 }
451 }
452
453<span class="keyword">private</span>:
454 CColorControl* ControlAmbientColor;
455 CColorControl* ControlDiffuseColor;
456 CColorControl* ControlSpecularColor;
457 CColorControl* ControlEmissiveColor;
458};
459</pre></div><p>GUI-Control to offer a selection of available textures. </p>
460<div class="fragment"><pre class="fragment"><span class="keyword">class </span>CTextureControl : <span class="keyword">public</span> gui::IGUIElement
461{
462<span class="keyword">public</span>:
463 CTextureControl(gui::IGUIEnvironment* guiEnv, video::IVideoDriver * driver, <span class="keyword">const</span> core::position2d&lt;s32&gt; &amp; pos, IGUIElement* parent, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <span class="keywordtype">id</span>=-1)
464 : gui::IGUIElement(gui::<a class="code" href="namespaceirr_1_1gui.html#ae4d66df0ecf4117cdbcf9f22404bd254afab12396466cf3add0f9e7408a053932" title="Unknown type.">EGUIET_ELEMENT</a>, guiEnv, parent,id, core::rect&lt;<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>&gt;(pos,pos+core::dimension2d&lt;<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>&gt;(100,15)))
465 , DirtyFlag(true), ComboTexture(0)
466 {
467 core::rect&lt;s32&gt; rectCombo(0, 0, AbsoluteRect.getWidth(),AbsoluteRect.getHeight());
468 ComboTexture = guiEnv-&gt;addComboBox (rectCombo, <span class="keyword">this</span>);
469 updateTextures(driver);
470 }
471
472 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent &amp;event)
473 {
474 <span class="keywordflow">if</span> ( event.EventType != <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0cae85bb44dd09a29c879d64a05047fc1d2" title="An event of the graphical user interface.">EET_GUI_EVENT</a> )
475 <span class="keywordflow">return</span> <span class="keyword">false</span>;
476
477 <span class="keywordflow">if</span> ( event.GUIEvent.Caller == ComboTexture &amp;&amp; event.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> )
478 {
479 DirtyFlag = <span class="keyword">true</span>;
480 }
481
482 <span class="keywordflow">return</span> <span class="keyword">false</span>;
483 }
484
485 <span class="comment">// Workaround for a problem with comboboxes.</span>
486 <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>
487 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> bringToFront(IGUIElement* element)
488 {
489 <span class="keywordtype">bool</span> result = gui::IGUIElement::bringToFront(element);
490 <span class="keywordflow">if</span> ( Parent &amp;&amp; element == ComboTexture )
491 result &amp;= Parent-&gt;bringToFront(<span class="keyword">this</span>);
492 <span class="keywordflow">return</span> result;
493 }
494
495 <span class="comment">// return selected texturename (if any, otherwise 0)</span>
496 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span> * getSelectedTextureName()<span class="keyword"> const</span>
497<span class="keyword"> </span>{
498 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selected = ComboTexture-&gt;getSelected();
499 <span class="keywordflow">if</span> ( selected &lt; 0 )
500 <span class="keywordflow">return</span> 0;
501 <span class="keywordflow">return</span> ComboTexture-&gt;getItem(selected);
502 }
503
504 <span class="comment">// reset the dirty flag</span>
505 <span class="keywordtype">void</span> resetDirty()
506 {
507 DirtyFlag = <span class="keyword">false</span>;
508 }
509
510 <span class="comment">// when the texture was changed the dirty flag is set</span>
511 <span class="keywordtype">bool</span> isDirty()<span class="keyword"> const</span>
512<span class="keyword"> </span>{
513 <span class="keywordflow">return</span> DirtyFlag;
514 };
515
516 <span class="comment">// Put the names of all currently loaded textures in a combobox</span>
517 <span class="keywordtype">void</span> updateTextures(video::IVideoDriver * driver)
518 {
519 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> oldSelected = ComboTexture-&gt;getSelected();
520 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selectNew = -1;
521 <span class="keyword">const</span> <span class="keywordtype">wchar_t</span> * oldTextureName = 0;
522 <span class="keywordflow">if</span> ( oldSelected &gt;= 0 )
523 {
524 oldTextureName = ComboTexture-&gt;getItem(oldSelected);
525 }
526 ComboTexture-&gt;clear();
527 <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i=0; i &lt; driver-&gt;getTextureCount(); ++i )
528 {
529 video::ITexture * texture = driver-&gt;getTextureByIndex(i);
530 <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a> name( texture-&gt;getName() );
531 ComboTexture-&gt;addItem( name.c_str() );
532 <span class="keywordflow">if</span> ( oldTextureName &amp;&amp; selectNew &lt; 0 &amp;&amp; name == oldTextureName )
533 selectNew = i;
534 }
535
536 <span class="comment">// add another name which can be used to clear the texture</span>
537 ComboTexture-&gt;addItem( CLEAR_TEXTURE.c_str() );
538 <span class="keywordflow">if</span> ( CLEAR_TEXTURE == oldTextureName )
539 selectNew = ComboTexture-&gt;getItemCount()-1;
540
541 <span class="keywordflow">if</span> ( selectNew &gt;= 0 )
542 ComboTexture-&gt;setSelected(selectNew);
543
544 DirtyFlag = <span class="keyword">true</span>;
545 }
546
547<span class="keyword">private</span>:
548 <span class="keywordtype">bool</span> DirtyFlag;
549 gui::IGUIComboBox * ComboTexture;
550};
551</pre></div><p>Control which allows setting some of the material values for a meshscenenode </p>
552<div class="fragment"><pre class="fragment"><span class="keyword">struct </span>SMeshNodeControl
553{
554 <span class="comment">// constructor</span>
555 SMeshNodeControl()
556 : Initialized(false), Driver(0), MeshManipulator(0), SceneNode(0), SceneNode2T(0), SceneNodeTangents(0)
557 , AllColorsControl(0), ButtonLighting(0), InfoLighting(0), ComboMaterial(0), TextureControl1(0), TextureControl2(0), ControlVertexColors(0)
558 {
559 }
560
561 <span class="comment">// Destructor</span>
562 <span class="keyword">virtual</span> ~SMeshNodeControl()
563 {
564 <span class="keywordflow">if</span> ( TextureControl1 )
565 TextureControl1-&gt;drop();
566 <span class="keywordflow">if</span> ( TextureControl2 )
567 TextureControl2-&gt;drop();
568 <span class="keywordflow">if</span> ( ControlVertexColors )
569 ControlVertexColors-&gt;drop();
570 <span class="keywordflow">if</span> ( AllColorsControl )
571 AllColorsControl-&gt;drop();
572 }
573
574 <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)
575 {
576 <span class="keywordflow">if</span> ( Initialized || !node || !device) <span class="comment">// initializing twice or with invalid data not allowed</span>
577 <span class="keywordflow">return</span>;
578
579 Driver = device-&gt;getVideoDriver ();
580 gui::IGUIEnvironment* guiEnv = device-&gt;getGUIEnvironment();
581 scene::ISceneManager* smgr = device-&gt;getSceneManager();
582 MeshManipulator = smgr-&gt;getMeshManipulator();
583
584 SceneNode = node;
585 scene::IMeshManipulator * meshManip = smgr-&gt;getMeshManipulator();
586
587 scene::IMesh * mesh2T = meshManip-&gt;createMeshWith2TCoords(node-&gt;getMesh());
588 SceneNode2T = smgr-&gt;addMeshSceneNode(mesh2T, 0, -1, SceneNode-&gt;getPosition(), SceneNode-&gt;getRotation(), SceneNode-&gt;getScale() );
589 mesh2T-&gt;drop();
590
591 scene::IMesh * meshTangents = meshManip-&gt;createMeshWithTangents(node-&gt;getMesh(), <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>);
592 SceneNodeTangents = smgr-&gt;addMeshSceneNode(meshTangents, 0, -1
593 , SceneNode-&gt;getPosition(), SceneNode-&gt;getRotation(), SceneNode-&gt;getScale() );
594 meshTangents-&gt;drop();
595
596 video::SMaterial &amp; material = SceneNode-&gt;getMaterial(0);
597 material.Lighting = <span class="keyword">true</span>;
598 AllColorsControl = <span class="keyword">new</span> CAllColorsControl(guiEnv, pos, description, <span class="keyword">true</span>, guiEnv-&gt;getRootGUIElement());
599 AllColorsControl-&gt;setColorsToMaterialColors(material);
600
601 core::rect&lt;s32&gt; rectBtn(pos + core::position2d&lt;s32&gt;(0, 320), core::dimension2d&lt;s32&gt;(60, 15));
602 ButtonLighting = guiEnv-&gt;addButton (rectBtn, 0, -1, L<span class="stringliteral">&quot;Lighting&quot;</span>);
603 ButtonLighting-&gt;setIsPushButton(<span class="keyword">true</span>);
604 ButtonLighting-&gt;setPressed(material.Lighting);
605 core::rect&lt;s32&gt; rectInfo( rectBtn.LowerRightCorner.X, rectBtn.UpperLeftCorner.Y, rectBtn.LowerRightCorner.X+40, rectBtn.UpperLeftCorner.Y+15 );
606 InfoLighting = guiEnv-&gt;addStaticText(L<span class="stringliteral">&quot;&quot;</span>, rectInfo, <span class="keyword">true</span>, <span class="keyword">false</span> );
607 InfoLighting-&gt;setTextAlignment(<a class="code" href="namespaceirr_1_1gui.html#a19eb5fb40e67f108cb16aba922ddaa2da9da0fb4bcb85d509bdfe018b720e4606" title="Aligned to the center of parent.">gui::EGUIA_CENTER</a>, <a class="code" href="namespaceirr_1_1gui.html#a19eb5fb40e67f108cb16aba922ddaa2da9da0fb4bcb85d509bdfe018b720e4606" title="Aligned to the center of parent.">gui::EGUIA_CENTER</a> );
608
609 core::rect&lt;s32&gt; rectCombo(pos.X, rectBtn.LowerRightCorner.Y, pos.X+100, rectBtn.LowerRightCorner.Y+15);
610 ComboMaterial = guiEnv-&gt;addComboBox (rectCombo);
611 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i &lt;= (int)<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a09498eaf291e1f7abdc04db808cc15d9" title="BlendFunc = source * sourceFactor + dest * destFactor ( E_BLEND_FUNC )">video::EMT_ONETEXTURE_BLEND</a>; ++i )
612 {
613 ComboMaterial-&gt;addItem( <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">core::stringw</a>(<a class="code" href="namespaceirr_1_1video.html#a833460ba01098710b6df3ec5c281c873" title="Array holding the built in material type names.">video::sBuiltInMaterialTypeNames</a>[i]).c_str() );
614 }
615 ComboMaterial-&gt;setSelected( (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>)material.MaterialType );
616
617 core::position2d&lt;s32&gt; posTex(rectCombo.UpperLeftCorner.X,rectCombo.LowerRightCorner.Y);
618 TextureControl1 = <span class="keyword">new</span> CTextureControl(guiEnv, Driver, posTex, guiEnv-&gt;getRootGUIElement());
619 posTex.Y += 15;
620 TextureControl2 = <span class="keyword">new</span> CTextureControl(guiEnv, Driver, posTex, guiEnv-&gt;getRootGUIElement());
621
622 core::position2d&lt;s32&gt; posVertexColors( posTex.X, posTex.Y + 15);
623 ControlVertexColors = <span class="keyword">new</span> CColorControl( guiEnv, posVertexColors, L<span class="stringliteral">&quot;Vertex colors&quot;</span>, guiEnv-&gt;getRootGUIElement());
624
625 video::S3DVertex * vertices = (video::S3DVertex *)node-&gt;getMesh()-&gt;getMeshBuffer(0)-&gt;getVertices();
626 <span class="keywordflow">if</span> ( vertices )
627 {
628 ControlVertexColors-&gt;setColor(vertices[0].Color);
629 }
630
631 Initialized = <span class="keyword">true</span>;
632 }
633
634 <span class="keywordtype">void</span> update()
635 {
636 <span class="keywordflow">if</span> ( !Initialized )
637 <span class="keywordflow">return</span>;
638
639 video::SMaterial &amp; material = SceneNode-&gt;getMaterial(0);
640 video::SMaterial &amp; material2T = SceneNode2T-&gt;getMaterial(0);
641 video::SMaterial &amp; materialTangents = SceneNodeTangents-&gt;getMaterial(0);
642
643 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selectedMaterial = ComboMaterial-&gt;getSelected();
644 <span class="keywordflow">if</span> ( selectedMaterial &gt;= (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>)<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a9bc471b9c18c9e2d20496004d2a2e803" title="Standard solid material.">video::EMT_SOLID</a> &amp;&amp; selectedMaterial &lt;= (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>)<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1a09498eaf291e1f7abdc04db808cc15d9" title="BlendFunc = source * sourceFactor + dest * destFactor ( E_BLEND_FUNC )">video::EMT_ONETEXTURE_BLEND</a>)
645 {
646 <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deac" title="Enumeration for all vertex types there are.">video::E_VERTEX_TYPE</a> vertexType = getVertexTypeForMaterialType((<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1" title="Abstracted and easy to use fixed function/programmable pipeline material modes.">video::E_MATERIAL_TYPE</a>)selectedMaterial);
647 <span class="keywordflow">switch</span> ( vertexType )
648 {
649 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca98c8b791280bbf9252c4f4a37e91a416" title="Standard vertex type used by the Irrlicht engine, video::S3DVertex.">video::EVT_STANDARD</a>:
650 material.MaterialType = (<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1" title="Abstracted and easy to use fixed function/programmable pipeline material modes.">video::E_MATERIAL_TYPE</a>)selectedMaterial;
651 SceneNode-&gt;setVisible(<span class="keyword">true</span>);
652 SceneNode2T-&gt;setVisible(<span class="keyword">false</span>);
653 SceneNodeTangents-&gt;setVisible(<span class="keyword">false</span>);
654 <span class="keywordflow">break</span>;
655 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca7b5127a706ee33eb4385d702da007016" title="Vertex with two texture coordinates, video::S3DVertex2TCoords.">video::EVT_2TCOORDS</a>:
656 material2T.MaterialType = (<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1" title="Abstracted and easy to use fixed function/programmable pipeline material modes.">video::E_MATERIAL_TYPE</a>)selectedMaterial;
657 SceneNode-&gt;setVisible(<span class="keyword">false</span>);
658 SceneNode2T-&gt;setVisible(<span class="keyword">true</span>);
659 SceneNodeTangents-&gt;setVisible(<span class="keyword">false</span>);
660 <span class="keywordflow">break</span>;
661 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1video.html#a0e3b59e025e0d0db0ed2ee0ce904deaca8c50b5b2c88f08709d640fecc83dfb9b" title="Vertex with a tangent and binormal vector, video::S3DVertexTangents.">video::EVT_TANGENTS</a>:
662 materialTangents.MaterialType = (<a class="code" href="namespaceirr_1_1video.html#ac8e9b6c66f7cebabd1a6d30cbc5430f1" title="Abstracted and easy to use fixed function/programmable pipeline material modes.">video::E_MATERIAL_TYPE</a>)selectedMaterial;
663 SceneNode-&gt;setVisible(<span class="keyword">false</span>);
664 SceneNode2T-&gt;setVisible(<span class="keyword">false</span>);
665 SceneNodeTangents-&gt;setVisible(<span class="keyword">true</span>);
666 <span class="keywordflow">break</span>;
667 }
668 }
669
670 updateMaterial(material);
671 updateMaterial(material2T);
672 updateMaterial(materialTangents);
673
674 <span class="keywordflow">if</span> ( ButtonLighting-&gt;isPressed() )
675 InfoLighting-&gt;setText(L<span class="stringliteral">&quot;on&quot;</span>);
676 <span class="keywordflow">else</span>
677 InfoLighting-&gt;setText(L<span class="stringliteral">&quot;off&quot;</span>);
678
679 AllColorsControl-&gt;resetDirty();
680 TextureControl1-&gt;resetDirty();
681 TextureControl2-&gt;resetDirty();
682 ControlVertexColors-&gt;resetDirty();
683 }
684
685 <span class="keywordtype">void</span> updateTextures()
686 {
687 TextureControl1-&gt;updateTextures(Driver);
688 TextureControl2-&gt;updateTextures(Driver);
689 }
690
691<span class="keyword">protected</span>:
692
693 <span class="keywordtype">void</span> updateMaterial(video::SMaterial &amp; material)
694 {
695 AllColorsControl-&gt;updateMaterialColors(material);
696 material.Lighting = ButtonLighting-&gt;isPressed();
697 <span class="keywordflow">if</span> ( TextureControl1-&gt;isDirty() )
698 {
699 material.TextureLayer[0].Texture = Driver-&gt;getTexture( <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(TextureControl1-&gt;getSelectedTextureName()) );
700 }
701 <span class="keywordflow">if</span> ( TextureControl2-&gt;isDirty() )
702 {
703 material.TextureLayer[1].Texture = Driver-&gt;getTexture( <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(TextureControl2-&gt;getSelectedTextureName()) );
704 }
705 <span class="keywordflow">if</span> ( ControlVertexColors-&gt;isDirty() )
706 {
707 MeshManipulator-&gt;setVertexColors (SceneNode-&gt;getMesh(), ControlVertexColors-&gt;getColor());
708 MeshManipulator-&gt;setVertexColors (SceneNode2T-&gt;getMesh(), ControlVertexColors-&gt;getColor());
709 MeshManipulator-&gt;setVertexColors (SceneNodeTangents-&gt;getMesh(), ControlVertexColors-&gt;getColor());
710 }
711 }
712
713 <span class="keywordtype">bool</span> Initialized;
714 video::IVideoDriver * Driver;
715 scene::IMeshManipulator* MeshManipulator;
716 scene::IMeshSceneNode* SceneNode;
717 scene::IMeshSceneNode* SceneNode2T;
718 scene::IMeshSceneNode* SceneNodeTangents;
719 CAllColorsControl* AllColorsControl;
720 gui::IGUIButton * ButtonLighting;
721 gui::IGUIStaticText* InfoLighting;
722 gui::IGUIComboBox * ComboMaterial;
723 CTextureControl* TextureControl1;
724 CTextureControl* TextureControl2;
725 CColorControl* ControlVertexColors;
726};
727</pre></div><p>Control to allow setting the color values of a lightscenenode. </p>
728<div class="fragment"><pre class="fragment"><span class="keyword">struct </span>SLightNodeControl
729{
730 <span class="comment">// constructor</span>
731 SLightNodeControl() : Initialized(false), SceneNode(0), AllColorsControl(0)
732 {
733 }
734
735 <span class="keyword">virtual</span> ~SLightNodeControl()
736 {
737 <span class="keywordflow">if</span> ( AllColorsControl )
738 AllColorsControl-&gt;drop();
739 }
740
741 <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)
742 {
743 <span class="keywordflow">if</span> ( Initialized || !node || !guiEnv) <span class="comment">// initializing twice or with invalid data not allowed</span>
744 <span class="keywordflow">return</span>;
745 SceneNode = node;
746 AllColorsControl = <span class="keyword">new</span> CAllColorsControl(guiEnv, pos, description, <span class="keyword">false</span>, guiEnv-&gt;getRootGUIElement());
747 <span class="keyword">const</span> video::SLight &amp; lightData = SceneNode-&gt;getLightData();
748 AllColorsControl-&gt;setColorsToLightDataColors(lightData);
749 Initialized = <span class="keyword">true</span>;
750 }
751
752 <span class="keywordtype">void</span> update()
753 {
754 <span class="keywordflow">if</span> ( !Initialized )
755 <span class="keywordflow">return</span>;
756
757 video::SLight &amp; lightData = SceneNode-&gt;getLightData();
758 AllColorsControl-&gt;updateLightColors(lightData);
759 }
760
761<span class="keyword">protected</span>:
762 <span class="keywordtype">bool</span> Initialized;
763 scene::ILightSceneNode* SceneNode;
764 CAllColorsControl* AllColorsControl;
765};
766</pre></div><p>Application configuration </p>
767<div class="fragment"><pre class="fragment"><span class="keyword">struct </span>SConfig
768{
769 SConfig()
770 : RenderInBackground(true)
771 , DriverType(video::<a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0ae85481da26159b967191ccc6de1e4a05" title="The Burning&#39;s Software Renderer, an alternative software renderer.">EDT_BURNINGSVIDEO</a>)
772 , ScreenSize(640, 480)
773 {
774 }
775
776 <span class="keywordtype">bool</span> RenderInBackground;
777 <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0" title="An enum for all types of drivers the Irrlicht Engine supports.">video::E_DRIVER_TYPE</a> DriverType;
778 core::dimension2d&lt;u32&gt; ScreenSize;
779};
780</pre></div><p>Main application class </p>
781<div class="fragment"><pre class="fragment"><span class="keyword">class </span>CApp : <span class="keyword">public</span> IEventReceiver
782{
783 <span class="keyword">friend</span> <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]);
784
785<span class="keyword">public</span>:
786 <span class="comment">// constructor</span>
787 CApp()
788 : IsRunning(false)
789 , Device(0)
790 , Camera(0)
791 , GlobalAmbient(0)
792 {
793 }
794
795 <span class="comment">// destructor</span>
796 ~CApp()
797 {
798 }
799
800 <span class="comment">// stop running - will quit at end of mainloop</span>
801 <span class="keywordtype">void</span> stopApp()
802 {
803 IsRunning = <span class="keyword">false</span>;
804 }
805
806 <span class="comment">// Event handler</span>
807 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent &amp;event)
808 {
809 <span class="keywordflow">if</span> (event.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0cae85bb44dd09a29c879d64a05047fc1d2" title="An event of the graphical user interface.">EET_GUI_EVENT</a>)
810 {
811 gui::IGUIEnvironment* env = Device-&gt;getGUIEnvironment();
812
813 <span class="keywordflow">switch</span>(event.GUIEvent.EventType)
814 {
815 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a90e8bebdd49f2a2e451b1105a87ee7ef" title="A menu item was selected in a (context) menu.">gui::EGET_MENU_ITEM_SELECTED</a>:
816 {
817 gui::IGUIContextMenu* menu = (gui::IGUIContextMenu*)event.GUIEvent.Caller;
818 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <span class="keywordtype">id</span> = menu-&gt;getItemCommandId(menu-&gt;getSelectedItem());
819
820 <span class="keywordflow">switch</span>(<span class="keywordtype">id</span>)
821 {
822 <span class="keywordflow">case</span> GUI_ID_OPEN_TEXTURE: <span class="comment">// File -&gt; Open Texture</span>
823 env-&gt;addFileOpenDialog(L<span class="stringliteral">&quot;Please select a texture file to open&quot;</span>);
824 <span class="keywordflow">break</span>;
825 <span class="keywordflow">case</span> GUI_ID_QUIT: <span class="comment">// File -&gt; Quit</span>
826 stopApp();
827 <span class="keywordflow">break</span>;
828 }
829 }
830 <span class="keywordflow">break</span>;
831
832 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a5b6504cf6b541d5ad95407c384632873" title="A file has been selected in the file dialog.">gui::EGET_FILE_SELECTED</a>:
833 {
834 <span class="comment">// load the model file, selected in the file open dialog</span>
835 gui::IGUIFileOpenDialog* dialog =
836 (gui::IGUIFileOpenDialog*)event.GUIEvent.Caller;
837 loadTexture(<a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(dialog-&gt;getFileName()).c_str());
838 }
839 <span class="keywordflow">break</span>;
840
841 <span class="keywordflow">default</span>:
842 <span class="keywordflow">break</span>;
843 }
844 }
845
846 <span class="keywordflow">return</span> <span class="keyword">false</span>;
847 }
848
849<span class="keyword">protected</span>:
850
851 <span class="comment">// Application initialization</span>
852 <span class="comment">// returns true when it was successful initialized, otherwise false.</span>
853 <span class="keywordtype">bool</span> init(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
854 {
855 <span class="comment">// ask user for driver</span>
856 Config.DriverType=driverChoiceConsole();
857 <span class="keywordflow">if</span> (Config.DriverType==<a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0ae685cada50f8c100403134d932d0414c" title="No driver, just for counting the elements.">video::EDT_COUNT</a>)
858 <span class="keywordflow">return</span> <span class="keyword">false</span>;
859
860 <span class="comment">// create the device with the settings from our config</span>
861 Device = <a class="code" href="namespaceirr.html#abaf4d8719cc26b0d30813abf85e47c76" title="Creates an Irrlicht device. The Irrlicht device is the root object for using the engine.">createDevice</a>(Config.DriverType, Config.ScreenSize);
862 <span class="keywordflow">if</span> (!Device)
863 <span class="keywordflow">return</span> <span class="keyword">false</span>;
864 Device-&gt;setWindowCaption( DriverTypeNames[Config.DriverType] );
865 Device-&gt;setEventReceiver(<span class="keyword">this</span>);
866
867 scene::ISceneManager* smgr = Device-&gt;getSceneManager();
868 video::IVideoDriver * driver = Device-&gt;getVideoDriver ();
869 gui::IGUIEnvironment* guiEnv = Device-&gt;getGUIEnvironment();
870
871 <span class="comment">// set a nicer font</span>
872 gui::IGUISkin* skin = guiEnv-&gt;getSkin();
873 gui::IGUIFont* font = guiEnv-&gt;getFont(<span class="stringliteral">&quot;../../media/fonthaettenschweiler.bmp&quot;</span>);
874 <span class="keywordflow">if</span> (font)
875 skin-&gt;setFont(font);
876
877 <span class="comment">// remove some alpha value because it makes those menus harder to read otherwise</span>
878 video::SColor col3dHighLight( skin-&gt;getColor(<a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aa130f7af380737d820220cc59a716b04d" title="Background color of multiple document interface (MDI) applications.">gui::EGDC_APP_WORKSPACE</a>) );
879 col3dHighLight.setAlpha(255);
880 video::SColor colHighLight( col3dHighLight );
881 skin-&gt;setColor(<a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aa1a7a2f4f13165eee4772e76f11866cbd" title="Item(s) selected in a control.">gui::EGDC_HIGH_LIGHT</a>, colHighLight );
882 skin-&gt;setColor(<a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aa1227b2c3a809d139e1ead87aa29fa101" title="Highlight color for three-dimensional display elements (for edges facing the light source...">gui::EGDC_3D_HIGH_LIGHT</a>, col3dHighLight );
883
884 <span class="comment">// Add some textures which are useful to test material settings</span>
885 createDefaultTextures(driver);
886
887 <span class="comment">// create a menu</span>
888 gui::IGUIContextMenu * menuBar = guiEnv-&gt;addMenu();
889 menuBar-&gt;addItem(L<span class="stringliteral">&quot;File&quot;</span>, -1, <span class="keyword">true</span>, <span class="keyword">true</span>);
890
891 gui::IGUIContextMenu* subMenuFile = menuBar-&gt;getSubMenu(0);
892 subMenuFile-&gt;addItem(L<span class="stringliteral">&quot;Open texture ...&quot;</span>, GUI_ID_OPEN_TEXTURE);
893 subMenuFile-&gt;addSeparator();
894 subMenuFile-&gt;addItem(L<span class="stringliteral">&quot;Quit&quot;</span>, GUI_ID_QUIT);
895
896 <span class="comment">// a static camera</span>
897 Camera = smgr-&gt;addCameraSceneNode (0, <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0, 0, 0),
898 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0, 0, 100),
899 -1);
900
901 <span class="comment">// add the nodes which are used to show the materials</span>
902 scene::IMeshSceneNode* nodeL = smgr-&gt;addCubeSceneNode (30.0f, 0, -1,
903 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(-35, 0, 100),
904 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0, 0, 0),
905 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(1.0f, 1.0f, 1.0f));
906 NodeLeft.init( nodeL, Device, core::position2d&lt;s32&gt;(10,20), L<span class="stringliteral">&quot;left node&quot;</span> );
907
908 scene::IMeshSceneNode* nodeR = smgr-&gt;addCubeSceneNode (30.0f, 0, -1,
909 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(35, 0, 100),
910 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0, 0, 0),
911 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(1.0f, 1.0f, 1.0f));
912 NodeRight.init( nodeR, Device, core::position2d&lt;s32&gt;(530,20), L<span class="stringliteral">&quot;right node&quot;</span> );
913
914 <span class="comment">// add one light</span>
915 scene::ILightSceneNode* nodeLight = smgr-&gt;addLightSceneNode(0, <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0, 0, 0),
916 video::SColorf(1.0f, 1.0f, 1.0f),
917 100.0f);
918 LightControl.init(nodeLight, guiEnv, core::position2d&lt;s32&gt;(270,20), L<span class="stringliteral">&quot;light&quot;</span> );
919
920 <span class="comment">// one large cube around everything. That&#39;s mainly to make the light more obvious.</span>
921 scene::IMeshSceneNode* backgroundCube = smgr-&gt;addCubeSceneNode (200.0f, 0, -1, <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(0, 0, 0),
922 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(45, 0, 0),
923 <a class="code" href="namespaceirr_1_1core.html#a06f169d08b5c429f5575acb7edbad811" title="Typedef for a f32 3d vector.">core::vector3df</a>(1.0f, 1.0f, 1.0f));
924 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>
925 backgroundCube-&gt;getMaterial(0).EmissiveColor.set(255,50,50,50); <span class="comment">// we keep some self lighting to keep texts visible</span>
926
927 <span class="comment">// set the ambient light value</span>
928 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());
929 GlobalAmbient-&gt;setColor( smgr-&gt;getAmbientLight().toSColor() );
930
931 <span class="keywordflow">return</span> <span class="keyword">true</span>;
932 }
933
934 <span class="comment">// Update one frame</span>
935 <span class="keywordtype">bool</span> update()
936 {
937 <span class="keyword">using namespace </span>irr;
938
939 <a class="code" href="classirr_1_1video_1_1_i_video_driver.html" title="Interface to driver which is able to perform 2d and 3d graphics functions.">video::IVideoDriver</a>* videoDriver = Device-&gt;getVideoDriver();
940 <span class="keywordflow">if</span> ( !Device-&gt;run() )
941 <span class="keywordflow">return</span> <span class="keyword">false</span>;
942
943 <span class="keywordflow">if</span> ( Device-&gt;isWindowActive() || Config.RenderInBackground )
944 {
945 <a class="code" href="classirr_1_1gui_1_1_i_g_u_i_environment.html" title="GUI Environment. Used as factory and manager of all other GUI elements.">gui::IGUIEnvironment</a>* guiEnv = Device-&gt;getGUIEnvironment();
946 <a class="code" href="classirr_1_1scene_1_1_i_scene_manager.html" title="The Scene Manager manages scene nodes, mesh recources, cameras and all the other stuff.">scene::ISceneManager</a>* smgr = Device-&gt;getSceneManager();
947 <a class="code" href="classirr_1_1gui_1_1_i_g_u_i_skin.html" title="A skin modifies the look of the GUI elements.">gui::IGUISkin</a> * skin = guiEnv-&gt;<a class="code" href="classirr_1_1gui_1_1_i_g_u_i_environment.html#a54ce9072ea7b89cdaea65306e93ba90c" title="Returns pointer to the current gui skin.">getSkin</a>();
948
949 <span class="comment">// update our controls</span>
950 NodeLeft.update();
951 NodeRight.update();
952 LightControl.update();
953
954 <span class="comment">// update ambient light settings</span>
955 <span class="keywordflow">if</span> ( GlobalAmbient-&gt;isDirty() )
956 {
957 smgr-&gt;<a class="code" href="classirr_1_1scene_1_1_i_scene_manager.html#a8a424accb615c4f60fde59f55033a816" title="Sets ambient color of the scene.">setAmbientLight</a>( GlobalAmbient-&gt;getColor() );
958 GlobalAmbient-&gt;resetDirty();
959 }
960
961 <span class="comment">// draw everything</span>
962 <a class="code" href="classirr_1_1video_1_1_s_color.html" title="Class representing a 32 bit ARGB color.">video::SColor</a> bkColor( skin-&gt;<a class="code" href="classirr_1_1gui_1_1_i_g_u_i_skin.html#ad1afa2e5e34c30e0cbfb85b1dee2dbe3" title="returns default color">getColor</a>(<a class="code" href="namespaceirr_1_1gui.html#abd15860fde29833c48daff5f95d5467aa130f7af380737d820220cc59a716b04d" title="Background color of multiple document interface (MDI) applications.">gui::EGDC_APP_WORKSPACE</a>) );
963 videoDriver-&gt;beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, bkColor);
964
965 smgr-&gt;<a class="code" href="classirr_1_1scene_1_1_i_scene_manager.html#a04240262904667c821bd9de5e5fd9b02" title="Draws all the scene nodes.">drawAll</a>();
966 guiEnv-&gt;<a class="code" href="classirr_1_1gui_1_1_i_g_u_i_environment.html#aa6ba29bbf3121a5954cfa5a9ca72982f" title="Draws all gui elements by traversing the GUI environment starting at the root node.">drawAll</a>();
967
968 videoDriver-&gt;endScene();
969 }
970
971 <span class="keywordflow">return</span> <span class="keyword">true</span>;
972 }
973
974 <span class="comment">// Run the application. Our main loop.</span>
975 <span class="keywordtype">void</span> run()
976 {
977 IsRunning = <span class="keyword">true</span>;
978
979 <span class="keywordflow">if</span> ( !Device )
980 <span class="keywordflow">return</span>;
981
982 <span class="comment">// main application loop</span>
983 <span class="keywordflow">while</span>(IsRunning)
984 {
985 <span class="keywordflow">if</span> ( !update() )
986 <span class="keywordflow">break</span>;
987
988 Device-&gt;sleep( 5 );
989 }
990 }
991
992 <span class="comment">// Close down the application</span>
993 <span class="keywordtype">void</span> quit()
994 {
995 IsRunning = <span class="keyword">false</span>;
996 GlobalAmbient-&gt;drop();
997 GlobalAmbient = NULL;
998 <span class="keywordflow">if</span> ( Device )
999 {
1000 Device-&gt;closeDevice();
1001 Device-&gt;drop();
1002 Device = NULL;
1003 }
1004 }
1005
1006 <span class="comment">// Create some useful textures.</span>
1007 <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>
1008 <span class="keywordtype">void</span> createDefaultTextures(<a class="code" href="classirr_1_1video_1_1_i_video_driver.html" title="Interface to driver which is able to perform 2d and 3d graphics functions.">video::IVideoDriver</a> * driver)
1009 {
1010 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> width = 256;
1011 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> height = 256;
1012 <a class="code" href="classirr_1_1video_1_1_i_image.html" title="Interface for software image data.">video::IImage</a> * imageA8R8G8B8 = driver-&gt;<a class="code" href="classirr_1_1video_1_1_i_video_driver.html#aee1578fdd92118665755f31c0dd1dbb5" title="Creates an empty software image.">createImage</a> (<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>, <a class="code" href="classirr_1_1core_1_1dimension2d.html">core::dimension2d&lt;u32&gt;</a>(width, height));
1013 <span class="keywordflow">if</span> ( !imageA8R8G8B8 )
1014 <span class="keywordflow">return</span>;
1015 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> pitch = imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1video_1_1_i_image.html#aace497c2d12f217a795a546a735e2675" title="Returns pitch of image.">getPitch</a>();
1016
1017 <span class="comment">// some nice square-pattern with 9 typical colors</span>
1018 <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> y = 0; y &lt; height; ++ y )
1019 {
1020 <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> x = 0; x &lt; pitch; ++x )
1021 {
1022 <span class="keywordflow">if</span> ( y &lt; height/3 )
1023 {
1024 <span class="keywordflow">if</span> ( x &lt; width/3 )
1025 imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1video_1_1_i_image.html#a89bf6020ce6ac1066e4d585ce46f79bd" title="Sets a pixel.">setPixel</a> (x, y, SCOL_BLACK);
1026 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( x &lt; 2*width/3 )
1027 imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1video_1_1_i_image.html#a89bf6020ce6ac1066e4d585ce46f79bd" title="Sets a pixel.">setPixel</a> (x, y, SCOL_BLUE);
1028 <span class="keywordflow">else</span>
1029 imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1video_1_1_i_image.html#a89bf6020ce6ac1066e4d585ce46f79bd" title="Sets a pixel.">setPixel</a> (x, y, SCOL_CYAN);
1030 }
1031 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( y &lt; 2*height/3 )
1032 {
1033 <span class="keywordflow">if</span> ( x &lt; width/3 )
1034 imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1video_1_1_i_image.html#a89bf6020ce6ac1066e4d585ce46f79bd" title="Sets a pixel.">setPixel</a> (x, y, SCOL_GRAY);
1035 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( x &lt; 2*width/3 )
1036 imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1video_1_1_i_image.html#a89bf6020ce6ac1066e4d585ce46f79bd" title="Sets a pixel.">setPixel</a> (x, y, SCOL_GREEN);
1037 <span class="keywordflow">else</span>
1038 imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1video_1_1_i_image.html#a89bf6020ce6ac1066e4d585ce46f79bd" title="Sets a pixel.">setPixel</a> (x, y, SCOL_MAGENTA);
1039 }
1040 <span class="keywordflow">else</span>
1041 {
1042 <span class="keywordflow">if</span> ( x &lt; width/3 )
1043 imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1video_1_1_i_image.html#a89bf6020ce6ac1066e4d585ce46f79bd" title="Sets a pixel.">setPixel</a> (x, y, SCOL_RED);
1044 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( x &lt; 2*width/3 )
1045 imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1video_1_1_i_image.html#a89bf6020ce6ac1066e4d585ce46f79bd" title="Sets a pixel.">setPixel</a> (x, y, SCOL_YELLOW);
1046 <span class="keywordflow">else</span>
1047 imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1video_1_1_i_image.html#a89bf6020ce6ac1066e4d585ce46f79bd" title="Sets a pixel.">setPixel</a> (x, y, SCOL_WHITE);
1048 }
1049 }
1050 }
1051 driver-&gt;<a class="code" href="classirr_1_1video_1_1_i_video_driver.html#a8c02ee280bb738cdf38b77e7a798244e" title="Creates an empty texture of specified size.">addTexture</a> (<a class="code" href="classirr_1_1core_1_1string.html">io::path</a>(<span class="stringliteral">&quot;CARO_A8R8G8B8&quot;</span>), imageA8R8G8B8);
1052
1053 <span class="comment">// all white</span>
1054 imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1video_1_1_i_image.html#a04973e101790130f611c4c6790e5b352" title="fills the surface with given color">fill</a>(SCOL_WHITE);
1055 driver-&gt;<a class="code" href="classirr_1_1video_1_1_i_video_driver.html#a8c02ee280bb738cdf38b77e7a798244e" title="Creates an empty texture of specified size.">addTexture</a> (<a class="code" href="classirr_1_1core_1_1string.html">io::path</a>(<span class="stringliteral">&quot;WHITE_A8R8G8B8&quot;</span>), imageA8R8G8B8);
1056
1057 <span class="comment">// all black</span>
1058 imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1video_1_1_i_image.html#a04973e101790130f611c4c6790e5b352" title="fills the surface with given color">fill</a>(SCOL_BLACK);
1059 driver-&gt;<a class="code" href="classirr_1_1video_1_1_i_video_driver.html#a8c02ee280bb738cdf38b77e7a798244e" title="Creates an empty texture of specified size.">addTexture</a> (<a class="code" href="classirr_1_1core_1_1string.html">io::path</a>(<span class="stringliteral">&quot;BLACK_A8R8G8B8&quot;</span>), imageA8R8G8B8);
1060
1061 <span class="comment">// gray-scale</span>
1062 <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> y = 0; y &lt; height; ++ y )
1063 {
1064 <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> x = 0; x &lt; pitch; ++x )
1065 {
1066 imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1video_1_1_i_image.html#a89bf6020ce6ac1066e4d585ce46f79bd" title="Sets a pixel.">setPixel</a> (x, y, <a class="code" href="classirr_1_1video_1_1_s_color.html" title="Class representing a 32 bit ARGB color.">video::SColor</a>(y, x,x,x) );
1067 }
1068 }
1069 driver-&gt;<a class="code" href="classirr_1_1video_1_1_i_video_driver.html#a8c02ee280bb738cdf38b77e7a798244e" title="Creates an empty texture of specified size.">addTexture</a> (<a class="code" href="classirr_1_1core_1_1string.html">io::path</a>(<span class="stringliteral">&quot;GRAYSCALE_A8R8G8B8&quot;</span>), imageA8R8G8B8);
1070
1071 imageA8R8G8B8-&gt;<a class="code" href="classirr_1_1_i_reference_counted.html#afb169a857e0d2cdb96b8821cb9bff17a" title="Drops the object. Decrements the reference counter by one.">drop</a>();
1072 }
1073
1074 <span class="comment">// Load a texture and make sure nodes know it when more textures are available.</span>
1075 <span class="keywordtype">void</span> loadTexture(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1string.html">io::path</a> &amp;name)
1076 {
1077 Device-&gt;getVideoDriver()-&gt;getTexture(name);
1078 NodeLeft.updateTextures();
1079 NodeRight.updateTextures();
1080 }
1081
1082<span class="keyword">private</span>:
1083 SConfig Config;
1084 <span class="keyword">volatile</span> <span class="keywordtype">bool</span> IsRunning;
1085 <a class="code" href="classirr_1_1_irrlicht_device.html" title="The Irrlicht device. You can create it with createDevice() or createDeviceEx().">IrrlichtDevice</a> * Device;
1086 <a class="code" href="classirr_1_1scene_1_1_i_camera_scene_node.html" title="Scene Node which is a (controlable) camera.">scene::ICameraSceneNode</a> * Camera;
1087 SMeshNodeControl NodeLeft;
1088 SMeshNodeControl NodeRight;
1089 SLightNodeControl LightControl;
1090 CColorControl * GlobalAmbient;
1091};
1092</pre></div><p>A very short main as we do everything else in classes. </p>
1093<div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
1094{
1095 CApp APP;
1096
1097 <span class="keywordflow">if</span> ( !APP.init(argc, argv) )
1098 {
1099 printf(<span class="stringliteral">&quot;init failed\n&quot;</span>);
1100 <span class="keywordflow">return</span> 1;
1101 }
1102
1103 APP.run();
1104 APP.quit();
1105
1106 <span class="keywordflow">return</span> 0;
1107}
1108</pre></div> </div></div>
1109</div>
1110 <div id="nav-path" class="navpath">
1111 <ul>
1112<!-- window showing the filter options -->
1113<div id="MSearchSelectWindow"
1114 onmouseover="return searchBox.OnSearchSelectShow()"
1115 onmouseout="return searchBox.OnSearchSelectHide()"
1116 onkeydown="return searchBox.OnSearchSelectKey(event)">
1117<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>
1118
1119<!-- iframe showing the search results (closed by default) -->
1120<div id="MSearchResultsWindow">
1121<iframe src="javascript:void(0)" frameborder="0"
1122 name="MSearchResults" id="MSearchResults">
1123</iframe>
1124</div>
1125
1126
1127 <li class="footer">
1128<a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht
1129Engine</a> Documentation &copy; 2003-2012 by Nikolaus Gebhardt. Generated on Sun Nov 17 2013 20:18:41 for Irrlicht 3D Engine by
1130<a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li>
1131 </ul>
1132 </div>
1133
1134
1135</body>
1136</html>