1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
|
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>nevrax.org : docs</TITLE>
<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD>
</TR>
</TABLE>
<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>
<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!------ Begin Box ------>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
<TABLE cellspacing=0 cellpadding=1 border=0>
<tr><td ALIGN=middle><a class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
</TABLE>
</TD></TR></TABLE></TD></TR></TABLE>
<!------ End Box ------>
</TD>
<TD WIDTH=15><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD ALIGN=left valign=top><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!-- title -->
<TABLE background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
<!-- block -->
<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
<TD><B>Documentation</B></TD>
<TD ALIGN=RIGHT> </td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>mesh_base.cpp</h1><a href="mesh__base_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025
00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font>
00027
00028 <font class="preprocessor">#include "<a class="code" href="mesh__base_8h.html">3d/mesh_base.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="mesh__base__instance_8h.html">3d/mesh_base_instance.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="lod__character__texture_8h.html">3d/lod_character_texture.h</a>"</font>
00031
00032
00033 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00034 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00035
00036
00037 <font class="keyword">namespace </font>NL3D
00038 {
00039
00040
00041
00042 <font class="comment">// ***************************************************************************</font>
<a name="l00043"></a><a class="code" href="classNL3D_1_1CMeshBase.html#a0">00043</a> CMeshBase::CMeshBase()
00044 {
00045 <a class="code" href="classNL3D_1_1CMeshBase.html#n10">_UseLightingLocalAttenuation</a>= <font class="keyword">false</font>;
00046
00047 <font class="comment">// To have same functionnality than previous version, init to identity.</font>
00048 <a class="code" href="classNL3D_1_1CMeshBase.html#n2">_DefaultPos</a>.setValue(CVector(0,0,0));
00049 <a class="code" href="classNL3D_1_1CMeshBase.html#n3">_DefaultPivot</a>.setValue(CVector(0,0,0));
00050 <a class="code" href="classNL3D_1_1CMeshBase.html#n4">_DefaultRotEuler</a>.setValue(CVector(0,0,0));
00051 <a class="code" href="classNL3D_1_1CMeshBase.html#n5">_DefaultRotQuat</a>.setValue(CQuat::Identity);
00052 <a class="code" href="classNL3D_1_1CMeshBase.html#n6">_DefaultScale</a>.setValue(CVector(1,1,1));
00053 <a class="code" href="classNL3D_1_1CMeshBase.html#n7">_DefaultLMFactor</a>.setValue(CRGBA(255,255,255,255));
00054
00055 <a class="code" href="classNL3D_1_1CMeshBase.html#n11">_AutoAnim</a> = <font class="keyword">false</font>;
00056
00057 <a class="code" href="classNL3D_1_1CMeshBase.html#o0">_LodCharacterTexture</a>= NULL;
00058 }
00059
00060
00061 <font class="comment">// ***************************************************************************</font>
<a name="l00062"></a><a class="code" href="classNL3D_1_1CMeshBase.html#a1">00062</a> CMeshBase::~CMeshBase()
00063 {
00064 <font class="comment">// free if exist</font>
00065 <a class="code" href="classNL3D_1_1CMeshBase.html#z576_0">resetLodCharacterTexture</a>();
00066 }
00067
00068
00069 <font class="comment">// ***************************************************************************</font>
00070 <font class="comment">// ***************************************************************************</font>
00071 <font class="comment">// Animated material.</font>
00072 <font class="comment">// ***************************************************************************</font>
00073 <font class="comment">// ***************************************************************************</font>
00074
00075
00076 <font class="comment">// ***************************************************************************</font>
<a name="l00077"></a><a class="code" href="classNL3D_1_1CMeshBase.html#z572_0">00077</a> <font class="keywordtype">void</font> CMeshBase::setAnimatedMaterial(uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, <font class="keyword">const</font> std::string &matName)
00078 {
00079 <a class="code" href="debug_8h.html#a6">nlassert</a>(!matName.empty());
00080 <font class="keywordflow">if</font>(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a><<a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>.size())
00081 {
00082 <font class="comment">// add / replace animated material.</font>
00083 <a class="code" href="classNL3D_1_1CMeshBase.html#n1">_AnimatedMaterials</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>].Name= matName;
00084 <font class="comment">// copy Material default.</font>
00085 <a class="code" href="classNL3D_1_1CMeshBase.html#n1">_AnimatedMaterials</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>].copyFromMaterial(&<a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>]);
00086 }
00087 }
00088
00089 <font class="comment">// ***************************************************************************</font>
<a name="l00090"></a><a class="code" href="classNL3D_1_1CMeshBase.html#z572_1">00090</a> CMaterialBase *CMeshBase::getAnimatedMaterial(uint <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>)
00091 {
00092 TAnimatedMaterialMap::iterator it;
00093 it= <a class="code" href="classNL3D_1_1CMeshBase.html#n1">_AnimatedMaterials</a>.find(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>);
00094 <font class="keywordflow">if</font>(it!=<a class="code" href="classNL3D_1_1CMeshBase.html#n1">_AnimatedMaterials</a>.end())
00095 <font class="keywordflow">return</font> &it->second;
00096 <font class="keywordflow">else</font>
00097 <font class="keywordflow">return</font> NULL;
00098 }
00099
00100
00101 <font class="comment">// ***************************************************************************</font>
00102 <font class="comment">// ***************************************************************************</font>
00103 <font class="comment">// Serial - buildBase.</font>
00104 <font class="comment">// ***************************************************************************</font>
00105 <font class="comment">// ***************************************************************************</font>
00106
00107
00108 <font class="comment">// ***************************************************************************</font>
<a name="l00109"></a><a class="code" href="structNL3D_1_1CMeshBase_1_1CMeshBaseBuild.html#a0">00109</a> CMeshBase::CMeshBaseBuild::CMeshBaseBuild()
00110 {
00111 <a class="code" href="structNL3D_1_1CMeshBase_1_1CMeshBaseBuild.html#m3">DefaultPos</a>.set(0,0,0);
00112 <a class="code" href="structNL3D_1_1CMeshBase_1_1CMeshBaseBuild.html#m4">DefaultPivot</a>.set(0,0,0);
00113 <a class="code" href="structNL3D_1_1CMeshBase_1_1CMeshBaseBuild.html#m5">DefaultRotEuler</a>.set(0,0,0);
00114 <a class="code" href="structNL3D_1_1CMeshBase_1_1CMeshBaseBuild.html#m7">DefaultScale</a>.set(1,1,1);
00115
00116 <a class="code" href="structNL3D_1_1CMeshBase_1_1CMeshBaseBuild.html#m0">bCastShadows</a>= <font class="keyword">false</font>;
00117 <a class="code" href="structNL3D_1_1CMeshBase_1_1CMeshBaseBuild.html#m1">bRcvShadows</a>= <font class="keyword">false</font>;
00118 <a class="code" href="structNL3D_1_1CMeshBase_1_1CMeshBaseBuild.html#m2">UseLightingLocalAttenuation</a>= <font class="keyword">false</font>;
00119 }
00120
00121 <font class="comment">// ***************************************************************************</font>
00122 <font class="preprocessor">#if 0</font>
00123 <font class="preprocessor"></font><font class="keywordtype">void</font> CMeshBase::CMeshBaseBuild::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00124 {
00125 <font class="comment">/*</font>
00126 <font class="comment"> Version 1:</font>
00127 <font class="comment"> - Cut in version because of badly coded ITexture* serialisation. throw an exception if </font>
00128 <font class="comment"> find a version < 1.</font>
00129 <font class="comment"> Version 0:</font>
00130 <font class="comment"> - 1st version.</font>
00131 <font class="comment"> */</font>
00132 sint ver= f.serialVersion(1);
00133
00134 <font class="keywordflow">if</font>(ver<1)
00135 <font class="keywordflow">throw</font> <a class="code" href="structNLMISC_1_1EStream.html">NLMISC::EStream</a>(f, <font class="stringliteral">"MeshBuild in Stream is too old (MeshBaseBuild version < 1)"</font>);
00136
00137 f.serial( DefaultPos );
00138 f.serial( DefaultPivot );
00139 f.serial( DefaultRotEuler );
00140 f.serial( DefaultRotQuat );
00141 f.serial( DefaultScale );
00142
00143 f.serialCont( Materials );
00144 }
00145 <font class="preprocessor">#endif</font>
00146 <font class="preprocessor"></font>
00147
00148 <font class="comment">// ***************************************************************************</font>
<a name="l00149"></a><a class="code" href="classNL3D_1_1CMeshBase.html#a2">00149</a> <font class="keywordtype">void</font> CMeshBase::serialMeshBase(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00150 {
00151 <font class="comment">/*</font>
00152 <font class="comment"> Version 7:</font>
00153 <font class="comment"> - _LodCharacterTexture</font>
00154 <font class="comment"> Version 6:</font>
00155 <font class="comment"> - _DistMax</font>
00156 <font class="comment"> Version 5:</font>
00157 <font class="comment"> - _AutoAnim</font>
00158 <font class="comment"> Version 4:</font>
00159 <font class="comment"> - _UseLightingLocalAttenuation</font>
00160 <font class="comment"> Version 3:</font>
00161 <font class="comment"> - _IsLightable</font>
00162 <font class="comment"> Version 2:</font>
00163 <font class="comment"> - Added Blend Shapes factors</font>
00164 <font class="comment"> Version 1:</font>
00165 <font class="comment"> - Cut in version because of badly coded ITexture* serialisation. throw an exception if </font>
00166 <font class="comment"> find a version < 1.</font>
00167 <font class="comment"> Version 0:</font>
00168 <font class="comment"> - 1st version.</font>
00169 <font class="comment"> */</font>
00170 sint ver = f.serialVersion(7);
00171
00172 <font class="keywordflow">if</font> (ver >= 2)
00173 {
00174 f.serialCont (<a class="code" href="classNL3D_1_1CMeshBase.html#n8">_AnimatedMorph</a>);
00175 }
00176
00177 <font class="keywordflow">if</font>(ver<1)
00178 <font class="keywordflow">throw</font> <a class="code" href="structNLMISC_1_1EStream.html">NLMISC::EStream</a>(f, <font class="stringliteral">"Mesh in Stream is too old (MeshBase version < 1)"</font>);
00179
00180 f.serial (<a class="code" href="classNL3D_1_1CMeshBase.html#n2">_DefaultPos</a>);
00181 f.serial (<a class="code" href="classNL3D_1_1CMeshBase.html#n3">_DefaultPivot</a>);
00182 f.serial (<a class="code" href="classNL3D_1_1CMeshBase.html#n4">_DefaultRotEuler</a>);
00183 f.serial (<a class="code" href="classNL3D_1_1CMeshBase.html#n5">_DefaultRotQuat</a>);
00184 f.serial (<a class="code" href="classNL3D_1_1CMeshBase.html#n6">_DefaultScale</a>);
00185
00186 f.serialCont(<a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>);
00187 f.serialCont(<a class="code" href="classNL3D_1_1CMeshBase.html#n1">_AnimatedMaterials</a>);
00188 f.serialCont(<a class="code" href="classNL3D_1_1CMeshBase.html#m0">_LightInfos</a>);
00189
00190 <font class="keywordflow">if</font>(ver>=3)
00191 <font class="comment">// read/write _IsLightable flag.</font>
00192 f.serial(<a class="code" href="classNL3D_1_1CMeshBase.html#n9">_IsLightable</a>);
00193 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( f.isReading() )
00194 <font class="comment">// update _IsLightable flag.</font>
00195 <a class="code" href="classNL3D_1_1CMeshBase.html#c0">computeIsLightable</a>();
00196
00197 <font class="keywordflow">if</font>(ver>=4)
00198 f.serial(<a class="code" href="classNL3D_1_1CMeshBase.html#n10">_UseLightingLocalAttenuation</a>);
00199 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( f.isReading() )
00200 <a class="code" href="classNL3D_1_1CMeshBase.html#n10">_UseLightingLocalAttenuation</a>= <font class="keyword">false</font>;
00201
00202 <font class="keywordflow">if</font> (ver >= 5)
00203 {
00204 f.serial(<a class="code" href="classNL3D_1_1CMeshBase.html#n11">_AutoAnim</a>);
00205 }
00206
00207 <font class="keywordflow">if</font>(ver >= 6)
00208 f.serial(<a class="code" href="classNL3D_1_1IShape.html#n0">_DistMax</a>);
00209
00210 <font class="keywordflow">if</font>(ver >= 7)
00211 f.serialPtr(<a class="code" href="classNL3D_1_1CMeshBase.html#o0">_LodCharacterTexture</a>);
00212
00213 }
00214
00215
00216 <font class="comment">// ***************************************************************************</font>
<a name="l00217"></a><a class="code" href="classNL3D_1_1CMeshBase.html#b0">00217</a> <font class="keywordtype">void</font> CMeshBase::buildMeshBase(CMeshBaseBuild &m)
00218 {
00219 <font class="comment">// Copy light information</font>
00220 <a class="code" href="classNL3D_1_1CMeshBase.html#m0">_LightInfos</a> = m.LightInfoMap;
00221
00222 <font class="comment">// copy the materials.</font>
00223 <a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>= m.Materials;
00224
00225 <font class="comment">// clear the animated materials.</font>
00226 <a class="code" href="classNL3D_1_1CMeshBase.html#n1">_AnimatedMaterials</a>.clear();
00227
00229 <a class="code" href="classNL3D_1_1CMeshBase.html#n2">_DefaultPos</a>.setValue (m.DefaultPos);
00230 <a class="code" href="classNL3D_1_1CMeshBase.html#n3">_DefaultPivot</a>.setValue (m.DefaultPivot);
00231 <a class="code" href="classNL3D_1_1CMeshBase.html#n4">_DefaultRotEuler</a>.setValue (m.DefaultRotEuler);
00232 <a class="code" href="classNL3D_1_1CMeshBase.html#n5">_DefaultRotQuat</a>.setValue (m.DefaultRotQuat);
00233 <a class="code" href="classNL3D_1_1CMeshBase.html#n6">_DefaultScale</a>.setValue (m.DefaultScale);
00234
00235 <a class="code" href="classNL3D_1_1CMeshBase.html#n8">_AnimatedMorph</a> .resize(m.DefaultBSFactors.size());
00236 <font class="keywordflow">for</font> (uint32 i = 0; i < m.DefaultBSFactors.size(); ++i)
00237 {
00238 <a class="code" href="classNL3D_1_1CMeshBase.html#n8">_AnimatedMorph</a>[i].DefaultFactor.setValue (m.DefaultBSFactors[i]);
00239 <a class="code" href="classNL3D_1_1CMeshBase.html#n8">_AnimatedMorph</a>[i].Name = m.BSNames[i];
00240 }
00241
00242 <font class="comment">// update _IsLightable flag.</font>
00243 <a class="code" href="classNL3D_1_1CMeshBase.html#c0">computeIsLightable</a>();
00244 <font class="comment">// copy _UseLightingLocalAttenuation</font>
00245 <a class="code" href="classNL3D_1_1CMeshBase.html#n10">_UseLightingLocalAttenuation</a>= m.UseLightingLocalAttenuation;
00246 }
00247
00248
00249
00250
00251 <font class="comment">// ***************************************************************************</font>
<a name="l00252"></a><a class="code" href="classNL3D_1_1CMeshBase.html#b1">00252</a> <font class="keywordtype">void</font> CMeshBase::instanciateMeshBase(CMeshBaseInstance *mi, CScene *ownerScene)
00253 {
00254 uint32 i;
00255
00256
00257 <font class="comment">// Copy ownerScene.</font>
00258 mi->_OwnerScene= ownerScene;
00259
00260
00261 <font class="comment">// setup animated blendShapes</font>
00262 <font class="comment">//===========================</font>
00263 mi->_AnimatedMorphFactor.reserve(<a class="code" href="classNL3D_1_1CMeshBase.html#n8">_AnimatedMorph</a>.size());
00264 <font class="keywordflow">for</font>(i = 0; i < <a class="code" href="classNL3D_1_1CMeshBase.html#n8">_AnimatedMorph</a>.size(); ++i)
00265 {
00266 CAnimatedMorph am(&<a class="code" href="classNL3D_1_1CMeshBase.html#n8">_AnimatedMorph</a>[i]);
00267 mi->_AnimatedMorphFactor.push_back (am);
00268 }
00269
00270 <font class="comment">// setup materials.</font>
00271 <font class="comment">//=================</font>
00272 <font class="comment">// Copy material. Textures are referenced only</font>
00273 mi->Materials= <a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>;
00274
00275 <font class="comment">// Instanciate selectable textures (use default set)</font>
00276 mi->selectTextureSet(0);
00277
00278 <font class="comment">// prepare possible AsyncTextures</font>
00279 mi->AsyncTextures.resize(<a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>.size());
00280
00281 <font class="comment">// setup animated materials.</font>
00282 <font class="comment">//==========================</font>
00283 TAnimatedMaterialMap::iterator it;
00284 mi->_AnimatedMaterials.reserve(<a class="code" href="classNL3D_1_1CMeshBase.html#n1">_AnimatedMaterials</a>.size());
00285 <font class="keywordflow">for</font>(it= <a class="code" href="classNL3D_1_1CMeshBase.html#n1">_AnimatedMaterials</a>.begin(); it!= <a class="code" href="classNL3D_1_1CMeshBase.html#n1">_AnimatedMaterials</a>.end(); it++)
00286 {
00287 CAnimatedMaterial aniMat(&it->second);
00288
00289 <font class="comment">// set the target instance material.</font>
00290 <a class="code" href="debug_8h.html#a6">nlassert</a>(it->first < mi->Materials.size());
00291 aniMat.setMaterial(&mi->Materials[it->first]);
00292
00293 <font class="comment">// Must set the Animatable father of the animated material (the mesh_base_instance!).</font>
00294 aniMat.setFather(mi, CMeshBaseInstance::OwnerBit);
00295
00296 <font class="comment">// Append this animated material.</font>
00297 mi->_AnimatedMaterials.push_back(aniMat);
00298 }
00299
00300 <font class="comment">// Misc</font>
00301 <font class="comment">//==========================</font>
00302
00303 <font class="comment">// Setup position with the default value</font>
00304 mi->ITransformable::setPos( ((<a class="code" href="namespaceNL3D.html#a14">CAnimatedValueVector</a>&)<a class="code" href="classNL3D_1_1CMeshBase.html#n2">_DefaultPos</a>.getValue()).Value );
00305 mi->ITransformable::setRotQuat( ((<a class="code" href="namespaceNL3D.html#a16">CAnimatedValueQuat</a>&)<a class="code" href="classNL3D_1_1CMeshBase.html#n5">_DefaultRotQuat</a>.getValue()).Value );
00306 mi->ITransformable::setScale( ((<a class="code" href="namespaceNL3D.html#a14">CAnimatedValueVector</a>&)<a class="code" href="classNL3D_1_1CMeshBase.html#n6">_DefaultScale</a>.getValue()).Value );
00307 mi->ITransformable::setPivot( ((<a class="code" href="namespaceNL3D.html#a14">CAnimatedValueVector</a>&)<a class="code" href="classNL3D_1_1CMeshBase.html#n3">_DefaultPivot</a>.getValue()).Value );
00308
00309 <font class="comment">// Check materials for transparency</font>
00310 mi->setTransparency( <font class="keyword">false</font> );
00311 mi->setOpacity( <font class="keyword">false</font> );
00312 <font class="keywordflow">for</font>( i = 0; i < mi->Materials.size(); ++i )
00313 <font class="keywordflow">if</font>( mi->Materials[i].getBlend() )
00314 mi->setTransparency( <font class="keyword">true</font> );
00315 <font class="keywordflow">else</font>
00316 mi->setOpacity( <font class="keyword">true</font> );
00317
00318 <font class="comment">// if the mesh is lightable, then the instance is</font>
00319 mi->setIsLightable(this->isLightable());
00320
00321 <font class="comment">// a mesh is considered big for lightable if it uses localAttenuation</font>
00322 mi->setIsBigLightable(this->useLightingLocalAttenuation());
00323
00324 }
00325
00326
00327 <font class="comment">// ***************************************************************************</font>
<a name="l00328"></a><a class="code" href="classNL3D_1_1CMeshBase.html#b2">00328</a> <font class="keywordtype">void</font> CMeshBase::applyMaterialUsageOptim(<font class="keyword">const</font> std::vector<bool> &materialUsed, std::vector<sint> &remap)
00329 {
00330 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>.size()==materialUsed.size());
00331
00332 <font class="comment">// security reset</font>
00333 <a class="code" href="classNL3D_1_1CMeshBase.html#z576_0">resetLodCharacterTexture</a>();
00334 <a class="code" href="classNL3D_1_1CMeshBase.html#n1">_AnimatedMaterials</a>.clear();
00335
00336 <font class="comment">// init all ids to "Not Used"</font>
00337 remap.clear();
00338 remap.resize(<a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>.size(), -1);
00339
00340 <font class="comment">// remove unused materials and build remap</font>
00341 vector<CMaterial>::iterator itMat= <a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>.begin();
00342 uint dstIdx= 0;
00343 <font class="keywordflow">for</font>(uint i=0;i<materialUsed.size();i++)
00344 {
00345 <font class="comment">// if used, still use it, and remap.</font>
00346 <font class="keywordflow">if</font>(materialUsed[i])
00347 {
00348 remap[i]= dstIdx;
00349 itMat++;
00350 dstIdx++;
00351 }
00352 <font class="comment">// remove from the array</font>
00353 <font class="keywordflow">else</font>
00354 {
00355 itMat= <a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>.erase(itMat);
00356 }
00357 }
00358
00359 <font class="comment">// apply the remap to LightMaps infos</font>
00360 TLightInfoMap::iterator itLight;
00361 <font class="keywordflow">for</font>(itLight= <a class="code" href="classNL3D_1_1CMeshBase.html#m0">_LightInfos</a>.begin();itLight!= <a class="code" href="classNL3D_1_1CMeshBase.html#m0">_LightInfos</a>.end();itLight++)
00362 {
00363 CLightInfoMapList::iterator itList= itLight->second.begin();
00364 <font class="keywordflow">for</font>(;itList!=itLight->second.end();)
00365 {
00366 sint newId= remap[itList->nMatNb];
00367 <font class="comment">// If material used</font>
00368 <font class="keywordflow">if</font>(newId>=0)
00369 {
00370 <font class="comment">// apply remap on the material id</font>
00371 itList->nMatNb= newId;
00372 itList++;
00373 }
00374 <font class="keywordflow">else</font>
00375 {
00376 <font class="comment">// remove it from list of light infos</font>
00377 itList= itLight->second.erase(itList);
00378 }
00379 }
00380 }
00381 }
00382
00383
00384 <font class="comment">// ***************************************************************************</font>
<a name="l00385"></a><a class="code" href="classNL3D_1_1CMeshBase.html#a3">00385</a> <font class="keywordtype">void</font> CMeshBase::flushTextures(IDriver &driver)
00386 {
00387 <font class="comment">// Mat count</font>
00388 uint matCount=<a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>.size();
00389
00390 <font class="comment">// Flush each material textures</font>
00391 <font class="keywordflow">for</font> (uint mat=0; mat<matCount; mat++)
00392 {
00394 <a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>[mat].flushTextures (driver);
00395 }
00396 }
00397
00398
00399 <font class="comment">// ***************************************************************************</font>
<a name="l00400"></a><a class="code" href="classNL3D_1_1CMeshBase.html#c0">00400</a> <font class="keywordtype">void</font> CMeshBase::computeIsLightable()
00401 {
00402 <font class="comment">// by default the mesh is not lightable</font>
00403 <a class="code" href="classNL3D_1_1CMeshBase.html#n9">_IsLightable</a>= <font class="keyword">false</font>;
00404
00405 <font class="comment">// Mat count</font>
00406 uint matCount=<a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>.size();
00407
00408 <font class="comment">// for each material </font>
00409 <font class="keywordflow">for</font> (uint mat=0; mat<matCount; mat++)
00410 {
00411 <font class="comment">// if this one is not a lightmap, then OK, the mesh is lightable</font>
00412 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CMeshBase.html#n0">_Materials</a>[mat].getShader()!=CMaterial::LightMap )
00413 {
00414 <a class="code" href="classNL3D_1_1CMeshBase.html#n9">_IsLightable</a>= <font class="keyword">true</font>;
00415 <font class="keywordflow">break</font>;
00416 }
00417 }
00418 }
00419
00420
00421 <font class="comment">// ***************************************************************************</font>
<a name="l00422"></a><a class="code" href="classNL3D_1_1CMeshBase.html#a5">00422</a> <font class="keywordtype">bool</font> CMeshBase::useLightingLocalAttenuation ()<font class="keyword"> const</font>
00423 <font class="keyword"></font>{
00424 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CMeshBase.html#n10">_UseLightingLocalAttenuation</a>;
00425 }
00426
00427
00428 <font class="comment">// ***************************************************************************</font>
<a name="l00429"></a><a class="code" href="classNL3D_1_1CMeshBase.html#z576_0">00429</a> <font class="keywordtype">void</font> CMeshBase::resetLodCharacterTexture()
00430 {
00431 <font class="keywordflow">if</font>(_LodCharacterTexture)
00432 {
00433 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CMeshBase.html#o0">_LodCharacterTexture</a>;
00434 <a class="code" href="classNL3D_1_1CMeshBase.html#o0">_LodCharacterTexture</a>= NULL;
00435 }
00436 }
00437
00438 <font class="comment">// ***************************************************************************</font>
<a name="l00439"></a><a class="code" href="classNL3D_1_1CMeshBase.html#z576_1">00439</a> <font class="keywordtype">void</font> CMeshBase::setupLodCharacterTexture(CLodCharacterTexture &lodText)
00440 {
00441 <font class="comment">// delete old</font>
00442 <a class="code" href="classNL3D_1_1CMeshBase.html#z576_0">resetLodCharacterTexture</a>();
00443 <font class="comment">// seutp new</font>
00444 <a class="code" href="classNL3D_1_1CMeshBase.html#o0">_LodCharacterTexture</a>= <font class="keyword">new</font> CLodCharacterTexture;
00445 *<a class="code" href="classNL3D_1_1CMeshBase.html#o0">_LodCharacterTexture</a>= lodText;
00446 }
00447
00448
00449 } <font class="comment">// NL3D</font>
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|