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
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
|
<!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='/'><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>material.cpp</h1><a href="material_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00007 <font class="comment">/* Copyright, 2000 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="material_8h.html">3d/material.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="texture_8h.html">3d/texture.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="shader_8h.html">3d/shader.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="driver_8h.html">3d/driver.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="stream_8h.html">nel/misc/stream.h</a>"</font>
00033
00034 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00035 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00036
00037 <font class="keyword">namespace </font>NL3D
00038 {
00039
00040 <font class="comment">// ***************************************************************************</font>
<a name="l00041"></a><a class="code" href="classNL3D_1_1CMaterial.html#z540_0">00041</a> CMaterial::CMaterial()
00042 {
00043 <a class="code" href="classNL3D_1_1CMaterial.html#o13">_Touched</a>= 0;
00044 <a class="code" href="classNL3D_1_1CMaterial.html#o1">_Flags</a>= <a class="code" href="namespaceNL3D.html#a112">IDRV_MAT_ZWRITE</a>;
00045 <font class="comment">// Must init All the flags by default.</font>
00046 <a class="code" href="classNL3D_1_1CMaterial.html#o0">_ShaderType</a>= <a class="code" href="classNL3D_1_1CMaterial.html#s66s21">Normal</a>;
00047 <a class="code" href="classNL3D_1_1CMaterial.html#o2">_SrcBlend</a>= <a class="code" href="classNL3D_1_1CMaterial.html#s65s12">srcalpha</a>;
00048 <a class="code" href="classNL3D_1_1CMaterial.html#o3">_DstBlend</a>= <a class="code" href="classNL3D_1_1CMaterial.html#s65s13">invsrcalpha</a>;
00049 <a class="code" href="classNL3D_1_1CMaterial.html#o4">_ZFunction</a>= <a class="code" href="classNL3D_1_1CMaterial.html#s64s6">lessequal</a>;
00050 <a class="code" href="classNL3D_1_1CMaterial.html#o5">_ZBias</a>= 0;
00051 <a class="code" href="classNL3D_1_1CMaterial.html#o6">_Color</a>.set(255,255,255,255);
00052 <a class="code" href="classNL3D_1_1CMaterial.html#o14">_StainedGlassWindow</a> = <font class="keyword">false</font>;
00053 <a class="code" href="classNL3D_1_1CMaterial.html#o12">_AlphaTestThreshold</a>= 0.5f;
00054 }
00055
00056 <font class="comment">// ***************************************************************************</font>
<a name="l00057"></a><a class="code" href="classNL3D_1_1CMaterial.html#z551_0">00057</a> <font class="keywordtype">void</font> CMaterial::initUnlit()
00058 {
00059 <a class="code" href="classNL3D_1_1CMaterial.html#a0">setShader</a>(<a class="code" href="classNL3D_1_1CMaterial.html#s66s21">Normal</a>);
00060 <a class="code" href="classNL3D_1_1CMaterial.html#z547_1">setLighting</a>(<font class="keyword">false</font>);
00061 <a class="code" href="classNL3D_1_1CMaterial.html#z547_0">setColor</a>(CRGBA(255,255,255,255));
00062 <font class="keywordflow">for</font>(uint32 i=0;i<<a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>;i++)
00063 <a class="code" href="classNL3D_1_1CMaterial.html#z541_0">setTexture</a>((uint8)i ,NULL);
00064 <a class="code" href="classNL3D_1_1CMaterial.html#z546_2">setZBias</a>(0);
00065 <a class="code" href="classNL3D_1_1CMaterial.html#z546_0">setZFunc</a>(<a class="code" href="classNL3D_1_1CMaterial.html#s64s6">lessequal</a>);
00066 <a class="code" href="classNL3D_1_1CMaterial.html#z546_1">setZWrite</a>(<font class="keyword">true</font>);
00067 <a class="code" href="classNL3D_1_1CMaterial.html#z542_0">setBlend</a>(<font class="keyword">false</font>);
00068 <a class="code" href="classNL3D_1_1CMaterial.html#z545_2">setAlphaTestThreshold</a>(0.5f);
00069 }
00070
00071 <font class="comment">// ***************************************************************************</font>
00072
<a name="l00073"></a><a class="code" href="classNL3D_1_1CMaterial.html#z551_1">00073</a> <font class="keywordtype">void</font> CMaterial::initLighted()
00074 {
00075 <a class="code" href="classNL3D_1_1CMaterial.html#z551_0">initUnlit</a>();
00076 <a class="code" href="classNL3D_1_1CMaterial.html#z547_1">setLighting</a>(<font class="keyword">true</font>);
00077 }
00078
00079
00080 <font class="comment">// ***************************************************************************</font>
<a name="l00081"></a><a class="code" href="classNL3D_1_1CMaterial.html#z540_3">00081</a> CMaterial &CMaterial::operator=(<font class="keyword">const</font> CMaterial &mat)
00082 {
00083 <a class="code" href="classNL3D_1_1CMaterial.html#o0">_ShaderType</a>= mat._ShaderType;
00084 <a class="code" href="classNL3D_1_1CMaterial.html#o1">_Flags</a>= mat._Flags;
00085 <a class="code" href="classNL3D_1_1CMaterial.html#o2">_SrcBlend</a>= mat._SrcBlend;
00086 <a class="code" href="classNL3D_1_1CMaterial.html#o3">_DstBlend</a>= mat._DstBlend;
00087 <a class="code" href="classNL3D_1_1CMaterial.html#o4">_ZFunction</a>= mat._ZFunction;
00088 <a class="code" href="classNL3D_1_1CMaterial.html#o5">_ZBias</a>= mat._ZBias;
00089 <a class="code" href="classNL3D_1_1CMaterial.html#o6">_Color</a>= mat._Color;
00090 <a class="code" href="classNL3D_1_1CMaterial.html#o7">_Emissive</a>= mat._Emissive;
00091 <a class="code" href="classNL3D_1_1CMaterial.html#o8">_Ambient</a>= mat._Ambient;
00092 <a class="code" href="classNL3D_1_1CMaterial.html#o9">_Diffuse</a>= mat._Diffuse;
00093 <a class="code" href="classNL3D_1_1CMaterial.html#o10">_Specular</a>= mat._Specular;
00094 <a class="code" href="classNL3D_1_1CMaterial.html#o11">_Shininess</a>= mat._Shininess;
00095 <a class="code" href="classNL3D_1_1CMaterial.html#o12">_AlphaTestThreshold</a>= mat._AlphaTestThreshold;
00096
00097 <font class="keywordflow">for</font>(uint32 i=0;i<<a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>;i++)
00098 {
00099 <a class="code" href="classNL3D_1_1CMaterial.html#o16">_Textures</a>[i]= mat._Textures[i];
00100 <a class="code" href="classNL3D_1_1CMaterial.html#m1">_TexEnvs</a>[i]= mat._TexEnvs[i];
00101 <a class="code" href="classNL3D_1_1CMaterial.html#m0">_TexAddrMode</a>[i] = mat._TexAddrMode[i];
00102 }
00103
00104 <font class="comment">// copy lightmaps.</font>
00105 <a class="code" href="classNL3D_1_1CMaterial.html#m3">_LightMaps</a>= mat._LightMaps;
00106
00107 <font class="comment">// copy texture matrix if there.</font>
00108 <font class="keywordflow">if</font> (mat._TexUserMat.get())
00109 {
00110 std::auto_ptr<CUserTexMat> texMatClone( <font class="keyword">new</font> CUserTexMat(*(mat._TexUserMat))); <font class="comment">// make cpy</font>
00111 std::swap(texMatClone, <a class="code" href="classNL3D_1_1CMaterial.html#o15">_TexUserMat</a>); <font class="comment">// swap with old</font>
00112 }
00113 <font class="keywordflow">else</font>
00114 {
00115 <a class="code" href="classNL3D_1_1CMaterial.html#o15">_TexUserMat</a>.reset();
00116 }
00117
00118 <font class="comment">// Must do not copy drv info.</font>
00119
00120 <font class="comment">// All states of material is modified.</font>
00121 <a class="code" href="classNL3D_1_1CMaterial.html#o13">_Touched</a>= <a class="code" href="namespaceNL3D.html#a109">IDRV_TOUCHED_ALL</a>;
00122
00123 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
00124 }
00125
00126
00127 <font class="comment">// ***************************************************************************</font>
<a name="l00128"></a><a class="code" href="classNL3D_1_1CMaterial.html#z540_2">00128</a> CMaterial::~CMaterial()
00129 {
00130 <font class="comment">// Must kill the drv mirror of this material.</font>
00131 <a class="code" href="classNL3D_1_1CMaterial.html#m2">pShader</a>.kill();
00132 }
00133
00134
00135 <font class="comment">// ***************************************************************************</font>
<a name="l00136"></a><a class="code" href="classNL3D_1_1CMaterial.html#a5">00136</a> <font class="keywordtype">void</font> CMaterial::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f)
00137 {
00138 <font class="comment">/*</font>
00139 <font class="comment"> Version 6:</font>
00140 <font class="comment"> - Texture matrix animation</font>
00141 <font class="comment"> Version 5:</font>
00142 <font class="comment"> - AlphaTest threshold</font>
00143 <font class="comment"> Version 4:</font>
00144 <font class="comment"> - Texture Addressing modes</font>
00145 <font class="comment"> Version 3:</font>
00146 <font class="comment"> - LightMaps.</font>
00147 <font class="comment"> Version 2:</font>
00148 <font class="comment"> - Shininess.</font>
00149 <font class="comment"> Version 1:</font>
00150 <font class="comment"> - texture environement.</font>
00151 <font class="comment"> Version 0:</font>
00152 <font class="comment"> - base version.</font>
00153 <font class="comment"> */</font>
00154
00155 sint ver= f.<a class="code" href="classNLMISC_1_1IStream.html#a29">serialVersion</a>(6);
00156 <font class="comment">// For the version <=1:</font>
00157 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>==4);
00158
00159 f.<a class="code" href="classNLMISC_1_1IStream.html#a6">serialEnum</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o0">_ShaderType</a>);
00160 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o1">_Flags</a>);
00161 f.<a class="code" href="classNLMISC_1_1IStream.html#a6">serialEnum</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o2">_SrcBlend</a>);
00162 f.<a class="code" href="classNLMISC_1_1IStream.html#a6">serialEnum</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o3">_DstBlend</a>);
00163 f.<a class="code" href="classNLMISC_1_1IStream.html#a6">serialEnum</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o4">_ZFunction</a>);
00164 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o5">_ZBias</a>);
00165 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o6">_Color</a>);
00166 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o7">_Emissive</a>, <a class="code" href="classNL3D_1_1CMaterial.html#o8">_Ambient</a>, <a class="code" href="classNL3D_1_1CMaterial.html#o9">_Diffuse</a>, <a class="code" href="classNL3D_1_1CMaterial.html#o10">_Specular</a>);
00167 <font class="keywordflow">if</font>(ver>=2)
00168 {
00169 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o11">_Shininess</a>);
00170 }
00171 <font class="keywordflow">if</font>(ver>=5)
00172 {
00173 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o12">_AlphaTestThreshold</a>);
00174 }
00175
00176
00177 <font class="keywordflow">for</font>(uint32 i=0;i<<a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>;i++)
00178 {
00179 <font class="comment">// Serial texture descriptor.</font>
00180 ITexture* text;
00181 <font class="keywordflow">if</font>(f.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>())
00182 {
00183 f.<a class="code" href="classNLMISC_1_1IStream.html#a28">serialPolyPtr</a>(text);
00184 <a class="code" href="classNL3D_1_1CMaterial.html#o16">_Textures</a>[i]= text;
00185 }
00186 <font class="keywordflow">else</font>
00187 {
00188 text= <a class="code" href="classNL3D_1_1CMaterial.html#o16">_Textures</a>[i];
00189 f.<a class="code" href="classNLMISC_1_1IStream.html#a28">serialPolyPtr</a>(text);
00190 }
00191
00192 <font class="comment">// Read texture environnement, or setup them.</font>
00193 <font class="keywordflow">if</font>(ver>=1)
00194 {
00195 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNL3D_1_1CMaterial.html#m1">_TexEnvs</a>[i]);
00196 }
00197 <font class="keywordflow">else</font>
00198 {
00199 <font class="comment">// Else setup as default behavior, like before...</font>
00200 <font class="keywordflow">if</font>(f.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>())
00201 <a class="code" href="classNL3D_1_1CMaterial.html#m1">_TexEnvs</a>[i].<a class="code" href="structNL3D_1_1CMaterial_1_1CTexEnv.html#a0">setDefault</a>();
00202 }
00203 }
00204
00205 <font class="keywordflow">if</font>(ver>=3)
00206 {
00207 f.<a class="code" href="classNLMISC_1_1IStream.html#a7">serialCont</a>(<a class="code" href="classNL3D_1_1CMaterial.html#m3">_LightMaps</a>);
00208 }
00209
00210 <font class="keywordflow">if</font> (ver >= 4)
00211 {
00212 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMaterial.html#o1">_Flags</a> & <a class="code" href="namespaceNL3D.html#a120">IDRV_MAT_TEX_ADDR</a>)
00213 {
00214 <font class="keywordflow">for</font>(uint32 i=0;i<<a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>;i++)
00215 {
00216 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNL3D_1_1CMaterial.html#m0">_TexAddrMode</a>[i]);
00217 }
00218 }
00219 }
00220
00221 <font class="keywordflow">if</font>(f.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>())
00222 {
00223 <font class="comment">// Converte Deprecated DEFMAT to std Mat.</font>
00224 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CMaterial.html#o1">_Flags</a> & <a class="code" href="namespaceNL3D.html#a116">IDRV_MAT_DEFMAT</a>)
00225 {
00226 <a class="code" href="classNL3D_1_1CMaterial.html#z547_2">setEmissive</a>(CRGBA::Black);
00227 <a class="code" href="classNL3D_1_1CMaterial.html#z547_3">setAmbient</a>(CRGBA::White);
00228 <a class="code" href="classNL3D_1_1CMaterial.html#z547_4">setDiffuse</a>(CRGBA::White);
00229 <a class="code" href="classNL3D_1_1CMaterial.html#z547_6">setSpecular</a>(CRGBA::Black);
00230 }
00231
00232 <font class="comment">// All states of material are modified.</font>
00233 <a class="code" href="classNL3D_1_1CMaterial.html#o13">_Touched</a>= <a class="code" href="namespaceNL3D.html#a109">IDRV_TOUCHED_ALL</a>;
00234
00235 <font class="keywordflow">if</font> ((<a class="code" href="classNL3D_1_1CMaterial.html#o1">_Flags</a> & <a class="code" href="namespaceNL3D.html#a138">IDRV_MAT_USER_TEX_MAT_ALL</a>)) <font class="comment">// are there user textrue coordinates matrix ?</font>
00236 {
00237 std::auto_ptr<CUserTexMat> newPtr(<font class="keyword">new</font> CUserTexMat); <font class="comment">// create new </font>
00238 std::swap(<a class="code" href="classNL3D_1_1CMaterial.html#o15">_TexUserMat</a>, newPtr); <font class="comment">// replace old</font>
00239 }
00240 }
00241
00242 <font class="keywordflow">if</font> (ver >= 6)
00243 {
00244 <font class="keywordflow">for</font>(uint i=0; i < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>; ++i)
00245 {
00246 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMaterial.html#z548_13">isUserTexMatEnabled</a>(i))
00247 {
00248 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o15">_TexUserMat</a>->TexMat[i]);
00249 }
00250 }
00251 }
00252
00253 }
00254
00255
00256 <font class="comment">// ***************************************************************************</font>
<a name="l00257"></a><a class="code" href="classNL3D_1_1CMaterial.html#a0">00257</a> <font class="keywordtype">void</font> CMaterial::setShader(TShader val)
00258 {
00259 <font class="comment">// First, reset all textures.</font>
00260 uint nTexts= <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>;
00261 <font class="comment">// If user color or lightmap, set only the 1st.</font>
00262 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CMaterial.html#o0">_ShaderType</a>==<a class="code" href="classNL3D_1_1CMaterial.html#s66s24">LightMap</a> || <a class="code" href="classNL3D_1_1CMaterial.html#o0">_ShaderType</a>==<a class="code" href="classNL3D_1_1CMaterial.html#s66s23">UserColor</a>)
00263 nTexts=1;
00264 <font class="comment">// reset all needed</font>
00265 <font class="keywordflow">for</font>(uint i=0;i<nTexts;i++)
00266 <a class="code" href="classNL3D_1_1CMaterial.html#z541_0">setTexture</a>(i ,NULL);
00267
00268 <font class="comment">// If userColor, use TexEnv caps (we got it, so use it :) ).</font>
00269 <font class="keywordflow">if</font>(val== CMaterial::UserColor)
00270 {
00271 <font class="comment">// force normal, to setup TexEnvMode correclty. </font>
00272 <a class="code" href="classNL3D_1_1CMaterial.html#o0">_ShaderType</a>=CMaterial::Normal;
00273
00274 <font class="comment">// First stage, interpolate Constant and texture with Alpha of texture.</font>
00275 <a class="code" href="classNL3D_1_1CMaterial.html#z548_0">texEnvOpRGB</a>(0, <a class="code" href="classNL3D_1_1CMaterial.html#z538_0s35">InterpolateTexture</a>);
00276 <a class="code" href="classNL3D_1_1CMaterial.html#z548_1">texEnvArg0RGB</a>(0, <a class="code" href="classNL3D_1_1CMaterial.html#z538_1s40">Texture</a>, <a class="code" href="classNL3D_1_1CMaterial.html#z538_2s44">SrcColor</a>);
00277 <a class="code" href="classNL3D_1_1CMaterial.html#z548_2">texEnvArg1RGB</a>(0, <a class="code" href="classNL3D_1_1CMaterial.html#z538_1s43">Constant</a>, <a class="code" href="classNL3D_1_1CMaterial.html#z538_2s44">SrcColor</a>);
00278 <font class="comment">// And just use Alpha Diffuse.</font>
00279 <a class="code" href="classNL3D_1_1CMaterial.html#z548_3">texEnvOpAlpha</a>(0, <a class="code" href="classNL3D_1_1CMaterial.html#z538_0s31">Replace</a>);
00280 <a class="code" href="classNL3D_1_1CMaterial.html#z548_4">texEnvArg0Alpha</a>(0, <a class="code" href="classNL3D_1_1CMaterial.html#z538_1s41">Previous</a>, <a class="code" href="classNL3D_1_1CMaterial.html#z538_2s46">SrcAlpha</a>);
00281
00282 <font class="comment">// Second stage, modulate result with diffuse color.</font>
00283 <a class="code" href="classNL3D_1_1CMaterial.html#z548_0">texEnvOpRGB</a>(1, <a class="code" href="classNL3D_1_1CMaterial.html#z538_0s32">Modulate</a>);
00284 <a class="code" href="classNL3D_1_1CMaterial.html#z548_1">texEnvArg0RGB</a>(1, <a class="code" href="classNL3D_1_1CMaterial.html#z538_1s41">Previous</a>, <a class="code" href="classNL3D_1_1CMaterial.html#z538_2s44">SrcColor</a>);
00285 <a class="code" href="classNL3D_1_1CMaterial.html#z548_2">texEnvArg1RGB</a>(1, <a class="code" href="classNL3D_1_1CMaterial.html#z538_1s42">Diffuse</a>, <a class="code" href="classNL3D_1_1CMaterial.html#z538_2s44">SrcColor</a>);
00286 <font class="comment">// And just use Alpha Diffuse.</font>
00287 <a class="code" href="classNL3D_1_1CMaterial.html#z548_3">texEnvOpAlpha</a>(1, <a class="code" href="classNL3D_1_1CMaterial.html#z538_0s31">Replace</a>);
00288 <a class="code" href="classNL3D_1_1CMaterial.html#z548_4">texEnvArg0Alpha</a>(1, <a class="code" href="classNL3D_1_1CMaterial.html#z538_1s41">Previous</a>, <a class="code" href="classNL3D_1_1CMaterial.html#z538_2s46">SrcAlpha</a>);
00289 }
00290
00291 <a class="code" href="classNL3D_1_1CMaterial.html#o0">_ShaderType</a>= val;
00292 <a class="code" href="classNL3D_1_1CMaterial.html#o13">_Touched</a>|=<a class="code" href="namespaceNL3D.html#a97">IDRV_TOUCHED_SHADER</a>;
00293 }
00294
00295
00296 <font class="comment">// ***************************************************************************</font>
<a name="l00297"></a><a class="code" href="classNL3D_1_1CMaterial.html#z541_0">00297</a> <font class="keywordtype">void</font> CMaterial::setTexture(uint8 n, ITexture* ptex)
00298 {
00299 <a class="code" href="debug_8h.html#a6">nlassert</a>(n<<a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>);
00300
00301 <font class="comment">// User Color material?</font>
00302 <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CMaterial.html#o0">_ShaderType</a>== CMaterial::UserColor)
00303 {
00304 <font class="comment">// user color. Only texture 0 can be set.</font>
00305 <a class="code" href="debug_8h.html#a6">nlassert</a>( n==0 );
00306
00307 <font class="comment">// Affect the 2 first textures.</font>
00308 <a class="code" href="classNL3D_1_1CMaterial.html#o16">_Textures</a>[0]=ptex;
00309 <a class="code" href="classNL3D_1_1CMaterial.html#o16">_Textures</a>[1]=ptex;
00310 <a class="code" href="classNL3D_1_1CMaterial.html#o13">_Touched</a>|=<a class="code" href="namespaceNL3D.html#a108">IDRV_TOUCHED_TEX</a>[0];
00311 <a class="code" href="classNL3D_1_1CMaterial.html#o13">_Touched</a>|=<a class="code" href="namespaceNL3D.html#a108">IDRV_TOUCHED_TEX</a>[1];
00312 }
00313 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( <a class="code" href="classNL3D_1_1CMaterial.html#o0">_ShaderType</a>== CMaterial::LightMap)
00314 {
00315 <font class="comment">// Only texture 0 can be set.</font>
00316 <a class="code" href="debug_8h.html#a6">nlassert</a>( n==0 );
00317 <a class="code" href="classNL3D_1_1CMaterial.html#o16">_Textures</a>[n]=ptex;
00318 <a class="code" href="classNL3D_1_1CMaterial.html#o13">_Touched</a>|=<a class="code" href="namespaceNL3D.html#a108">IDRV_TOUCHED_TEX</a>[n];
00319 }
00320 <font class="comment">// Normal material?</font>
00321 <font class="keywordflow">else</font>
00322 {
00323 <a class="code" href="classNL3D_1_1CMaterial.html#o16">_Textures</a>[n]=ptex;
00324 <a class="code" href="classNL3D_1_1CMaterial.html#o13">_Touched</a>|=<a class="code" href="namespaceNL3D.html#a108">IDRV_TOUCHED_TEX</a>[n];
00325 }
00326 }
00327
00328
00329 <font class="comment">// ***************************************************************************</font>
<a name="l00330"></a><a class="code" href="classNL3D_1_1CMaterial.html#a4">00330</a> <font class="keywordtype">void</font> CMaterial::flushTextures (IDriver &driver)
00331 {
00332 <font class="comment">// For each textures</font>
00333 <font class="keywordflow">for</font> (uint tex=0; tex<<a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>; tex++)
00334 {
00335 <font class="comment">// Texture exist ?</font>
00336 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMaterial.html#o16">_Textures</a>[tex])
00337 {
00338 <font class="comment">// Force setup texture</font>
00339 driver.setupTexture (*<a class="code" href="classNL3D_1_1CMaterial.html#o16">_Textures</a>[tex]);
00340 }
00341 }
00342
00343 <font class="comment">// If Lightmap material</font>
00344 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CMaterial.html#o0">_ShaderType</a>==<a class="code" href="classNL3D_1_1CMaterial.html#s66s24">LightMap</a>)
00345 {
00346 <font class="comment">// For each lightmap</font>
00347 <font class="keywordflow">for</font> (uint lmap=0; lmap<<a class="code" href="classNL3D_1_1CMaterial.html#m3">_LightMaps</a>.size(); lmap++)
00348 {
00349 <font class="comment">// Texture exist?</font>
00350 <font class="keywordflow">if</font>(<a class="code" href="classNL3D_1_1CMaterial.html#m3">_LightMaps</a>[lmap].Texture)
00351 {
00352 <font class="comment">// Force setup texture</font>
00353 driver.setupTexture (*<a class="code" href="classNL3D_1_1CMaterial.html#m3">_LightMaps</a>[lmap].<a class="code" href="classNL3D_1_1CMaterial.html#z538_1s40">Texture</a>);
00354 }
00355 }
00356 }
00357
00358 }
00359
00360
00361 <font class="comment">// ***************************************************************************</font>
<a name="l00362"></a><a class="code" href="classNL3D_1_1CMaterial.html#z550_0">00362</a> <font class="keywordtype">void</font> CMaterial::setLightMap(uint lmapId, ITexture *lmap)
00363 {
00364 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o0">_ShaderType</a>==CMaterial::LightMap);
00365 <font class="keywordflow">if</font>(lmapId>=<a class="code" href="classNL3D_1_1CMaterial.html#m3">_LightMaps</a>.size())
00366 <a class="code" href="classNL3D_1_1CMaterial.html#m3">_LightMaps</a>.resize(lmapId+1);
00367 <a class="code" href="classNL3D_1_1CMaterial.html#m3">_LightMaps</a>[lmapId].Texture= lmap;
00368
00369 <a class="code" href="classNL3D_1_1CMaterial.html#o13">_Touched</a>|=<a class="code" href="namespaceNL3D.html#a105">IDRV_TOUCHED_LIGHTMAP</a>;
00370 }
00371
00372 <font class="comment">// ***************************************************************************</font>
<a name="l00373"></a><a class="code" href="classNL3D_1_1CMaterial.html#z550_1">00373</a> ITexture *CMaterial::getLightMap(uint lmapId)<font class="keyword"> const</font>
00374 <font class="keyword"></font>{
00375 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o0">_ShaderType</a>==CMaterial::LightMap);
00376 <font class="keywordflow">if</font>(lmapId<<a class="code" href="classNL3D_1_1CMaterial.html#m3">_LightMaps</a>.size())
00377 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CMaterial.html#m3">_LightMaps</a>[lmapId].Texture;
00378 <font class="keywordflow">else</font>
00379 <font class="keywordflow">return</font> NULL;
00380 }
00381
00382 <font class="comment">// ***************************************************************************</font>
<a name="l00383"></a><a class="code" href="classNL3D_1_1CMaterial.html#z550_2">00383</a> <font class="keywordtype">void</font> CMaterial::setLightMapFactor(uint lmapId, CRGBA factor)
00384 {
00385 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMaterial.html#o0">_ShaderType</a>==CMaterial::LightMap)
00386 {
00387 <font class="keywordflow">if</font>(lmapId>=<a class="code" href="classNL3D_1_1CMaterial.html#m3">_LightMaps</a>.size())
00388 <a class="code" href="classNL3D_1_1CMaterial.html#m3">_LightMaps</a>.resize(lmapId+1);
00389 <a class="code" href="classNL3D_1_1CMaterial.html#m3">_LightMaps</a>[lmapId].Factor= factor;
00390
00391 <a class="code" href="classNL3D_1_1CMaterial.html#o13">_Touched</a>|=<a class="code" href="namespaceNL3D.html#a105">IDRV_TOUCHED_LIGHTMAP</a>;
00392 }
00393 }
00394
00395
00396 <font class="comment">// ***************************************************************************</font>
<a name="l00397"></a><a class="code" href="structNL3D_1_1CMaterial_1_1CLightMap.html#a1">00397</a> <font class="keywordtype">void</font> CMaterial::CLightMap::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f)
00398 {
00399 f.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>(<a class="code" href="structNL3D_1_1CMaterial_1_1CLightMap.html#m1">Factor</a>);
00400 <font class="comment">// Serial texture descriptor.</font>
00401 ITexture* text= NULL;
00402 <font class="keywordflow">if</font>(f.<a class="code" href="classNLMISC_1_1IStream.html#a4">isReading</a>())
00403 {
00404 f.<a class="code" href="classNLMISC_1_1IStream.html#a28">serialPolyPtr</a>(text);
00405 <a class="code" href="structNL3D_1_1CMaterial_1_1CLightMap.html#m0">Texture</a>= text;
00406 }
00407 <font class="keywordflow">else</font>
00408 {
00409 text= <a class="code" href="structNL3D_1_1CMaterial_1_1CLightMap.html#m0">Texture</a>;
00410 f.<a class="code" href="classNLMISC_1_1IStream.html#a28">serialPolyPtr</a>(text);
00411 }
00412 }
00413
00414
00415
00416 <font class="comment">// ***************************************************************************</font>
<a name="l00417"></a><a class="code" href="classNL3D_1_1CMaterial.html#z543_0">00417</a> <font class="keywordtype">void</font> CMaterial::enableTexAddrMode(<font class="keywordtype">bool</font> enable <font class="comment">/*= true*/</font>)
00418 {
00419 <font class="keywordflow">if</font> (enable)
00420 {
00421 <font class="keywordflow">if</font> (!(<a class="code" href="classNL3D_1_1CMaterial.html#o1">_Flags</a> & <a class="code" href="namespaceNL3D.html#a120">IDRV_MAT_TEX_ADDR</a>))
00422 {
00423 <a class="code" href="classNL3D_1_1CMaterial.html#o1">_Flags</a> |= <a class="code" href="namespaceNL3D.html#a120">IDRV_MAT_TEX_ADDR</a>;
00424 <font class="keywordflow">for</font> (uint32 k = 0; k < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>; ++k)
00425 {
00426 <a class="code" href="classNL3D_1_1CMaterial.html#m0">_TexAddrMode</a>[k] = (uint8) <a class="code" href="classNL3D_1_1CMaterial.html#z539_0s49">FetchTexture</a>;
00427 }
00428 }
00429 }
00430 <font class="keywordflow">else</font>
00431 {
00432 <a class="code" href="classNL3D_1_1CMaterial.html#o1">_Flags</a> &= ~<a class="code" href="namespaceNL3D.html#a120">IDRV_MAT_TEX_ADDR</a>;
00433 }
00434 }
00435
00436 <font class="comment">// ***************************************************************************</font>
<a name="l00437"></a><a class="code" href="classNL3D_1_1CMaterial.html#z543_1">00437</a> <font class="keywordtype">bool</font> CMaterial::texAddrEnabled()<font class="keyword"> const</font>
00438 <font class="keyword"></font>{
00439 <font class="keywordflow">return</font>( <a class="code" href="classNL3D_1_1CMaterial.html#o1">_Flags</a> & <a class="code" href="namespaceNL3D.html#a120">IDRV_MAT_TEX_ADDR</a>) != 0;
00440 }
00441
00442 <font class="comment">// ***************************************************************************</font>
<a name="l00443"></a><a class="code" href="classNL3D_1_1CMaterial.html#z543_2">00443</a> <font class="keywordtype">void</font> CMaterial::setTexAddressingMode(uint8 stage, TTexAddressingMode mode)
00444 {
00445 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o1">_Flags</a> & <a class="code" href="namespaceNL3D.html#a120">IDRV_MAT_TEX_ADDR</a>);
00446 <a class="code" href="debug_8h.html#a6">nlassert</a>(stage < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>);
00447 <a class="code" href="debug_8h.html#a6">nlassert</a>(mode < <a class="code" href="classNL3D_1_1CMaterial.html#z539_0s63">TexAddrCount</a>);
00448 <a class="code" href="classNL3D_1_1CMaterial.html#m0">_TexAddrMode</a>[stage] = (uint8) mode;
00449 }
00450
00451
00452 <font class="comment">// ***************************************************************************</font>
<a name="l00453"></a><a class="code" href="classNL3D_1_1CMaterial.html#z543_3">00453</a> CMaterial::TTexAddressingMode CMaterial::getTexAddressingMode(uint8 stage)
00454 {
00455 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CMaterial.html#o1">_Flags</a> & <a class="code" href="namespaceNL3D.html#a120">IDRV_MAT_TEX_ADDR</a>);
00456 <a class="code" href="debug_8h.html#a6">nlassert</a>(stage < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>);
00457 <font class="keywordflow">return</font> (TTexAddressingMode) <a class="code" href="classNL3D_1_1CMaterial.html#m0">_TexAddrMode</a>[stage];
00458 }
00459
00460 <font class="comment">// ***************************************************************************</font>
<a name="l00461"></a><a class="code" href="classNL3D_1_1CMaterial.html#z548_16">00461</a> <font class="keywordtype">void</font> CMaterial::decompUserTexMat(uint stage, <font class="keywordtype">float</font> &uTrans, <font class="keywordtype">float</font> &vTrans, <font class="keywordtype">float</font> &wRot, <font class="keywordtype">float</font> &uScale, <font class="keywordtype">float</font> &vScale)
00462 {
00463 <a class="code" href="debug_8h.html#a6">nlassert</a>(stage < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>);
00464 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CMaterial.html#z548_13">isUserTexMatEnabled</a>(stage)); <font class="comment">// must activate animated texture matrix for this stage</font>
00465 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> texMat = <a class="code" href="classNL3D_1_1CMaterial.html#o15">_TexUserMat</a>->TexMat[stage];
00466 uTrans = texMat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>().x;
00467 vTrans = texMat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>().y;
00469 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> i = texMat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_7">getI</a>();
00470 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> j = texMat.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_8">getJ</a>();
00471 <font class="keywordtype">float</font> normI = i.<a class="code" href="classNLMISC_1_1CVector.html#z331_2">norm</a>();
00472 <font class="keywordtype">float</font> normJ = i.<a class="code" href="classNLMISC_1_1CVector.html#z331_2">norm</a>();
00473 i /= normI;
00474 j /= normJ;
00475 <font class="keywordtype">float</font> angle = ::acosf(i.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>);
00476 <font class="keywordflow">if</font> (i.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> < 0)
00477 {
00478 angle = 2.f * (float) NLMISC::Pi - angle;
00479 }
00480 wRot = angle;
00481 uScale = normI;
00482 vScale = normJ;
00483 }
00484
00485 <font class="comment">// ***************************************************************************</font>
<a name="l00486"></a><a class="code" href="classNL3D_1_1CMaterial.html#z552_0">00486</a> <font class="keywordtype">void</font> CMaterial::selectTextureSet(uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00487 {
00488 <font class="keywordflow">for</font> (uint k = 0; k < <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>; ++k)
00489 {
00490 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CMaterial.html#o16">_Textures</a>[k] != NULL) <a class="code" href="classNL3D_1_1CMaterial.html#o16">_Textures</a>[k]->selectTexture(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00491 }
00492 }
00493
00494 }
00495
</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>
|