aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/ps__particle__basic_8cpp-source.html
blob: 504187a7686c3f7868e63b09fc0dd912154c6f2a (plain)
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
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
<!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>&nbsp;<A CLASS=uplinks HREF='/'><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF='/'><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</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>
&nbsp;

<!-- 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>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>ps_particle_basic.cpp</h1><a href="ps__particle__basic_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="ps__particle__basic_8h.html">3d/ps_particle_basic.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="ps__macro_8h.html">3d/ps_macro.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="driver_8h.html">3d/driver.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="texture__grouped_8h.html">3d/texture_grouped.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="texture__bump_8h.html">3d/texture_bump.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="texture__mem_8h.html">3d/texture_mem.h</a>"</font>
00034 <font class="preprocessor">#include "<a class="code" href="particle__system_8h.html">3d/particle_system.h</a>"</font>
00035 
00036 
00037 
00038 <font class="keyword">namespace </font>NL3D 
00039 {
00040 
00041 
00042 
00044 <font class="comment">// CPSParticle implementation  //</font>
00046 <font class="comment"></font>
00047 <font class="comment">//=======================================</font>
<a name="l00048"></a><a class="code" href="classNL3D_1_1CPSParticle.html#a0">00048</a>         CPSParticle::CPSParticle() : _DisableAutoLOD(false)
00049 {
00050 
00051 }
00052 
00053 <font class="comment">//=======================================</font>
<a name="l00054"></a><a class="code" href="classNL3D_1_1CPSParticle.html#a8">00054</a> <font class="keywordtype">void</font> CPSParticle::showTool()
00055 {
00056         PARTICLES_CHECK_MEM;
00057 
00058         CVector I = CVector::I;
00059         CVector J = CVector::J;
00060 
00061         <font class="keyword">const</font> CVector tab[] = { 2 * J, I + J
00062                                                         , I + J, 2 * I + J
00063                                                         , 2 * I + J, I
00064                                                         , I,  2 * I - J
00065                                                         , 2 * I - J, - .5f * J
00066                                                         , - .5f * J, -2 * I - J
00067                                                         , -2 * I - J, - I
00068                                                         , - I, -2 * I + J
00069                                                         , -2 * I + J, - I + J
00070                                                         , - I + J, 2 * J
00071                                                 };
00072         <font class="keyword">const</font> uint tabSize = <font class="keyword">sizeof</font>(tab) / (2 * <font class="keyword">sizeof</font>(CVector));
00073 
00074         <font class="keyword">const</font> <font class="keywordtype">float</font> sSize = 0.1f;
00075         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#b4">displayIcon2d</a>(tab, tabSize, sSize);
00076 
00077         PARTICLES_CHECK_MEM;
00078 }
00079 
00080 <font class="comment">//=======================================</font>
<a name="l00081"></a><a class="code" href="classNL3D_1_1CPSParticle.html#b4">00081</a> <font class="keywordtype">void</font> CPSParticle::computeSrcStep(uint32 &amp;step, uint &amp;numToProcess)
00082 {               
00083         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> &amp;&amp; <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getOwner());
00084         <font class="keyword">const</font> CParticleSystem &amp;ps = *(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getOwner());
00085         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSParticle.html#o0">_DisableAutoLOD</a> || !ps.isAutoLODEnabled() || <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize() == 0) <font class="comment">// Should Auto-LOD be used ?</font>
00086         {
00087                 <a class="code" href="classNL3D_1_1CPSParticle.html#a4">step</a> = (1 &lt;&lt; 16);
00088                 numToProcess = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize();
00089         }
00090         <font class="keywordflow">else</font>
00091         {
00092                 <font class="keywordtype">float</font> oneMinusLODRatio = ps.getOneMinusCurrentLODRatio();
00093                 <font class="keywordtype">float</font> LODRatio = 1.f - oneMinusLODRatio;  
00094                 <font class="keywordflow">if</font> (LODRatio &gt; ps.getAutoLODStartDistPercent())
00095                 {
00096                         <font class="keywordtype">float</font> factor = (LODRatio - 1.f) / (ps.getAutoLODStartDistPercent() - 1.f);
00097                         <a class="code" href="namespaceNLMISC.html#a215">NLMISC::clamp</a>(factor, 0.f, 1.f);
00098                         <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a> = factor;
00099                         <font class="keywordflow">for</font> (uint k = 0; k &lt; ps.getAutoLODDegradationExponent(); ++k)
00100                         {
00101                                 <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a> *= factor;
00102                         }
00103                         numToProcess = (uint) (<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize() * <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a>);
00104                         <font class="keywordflow">if</font> (numToProcess &lt; 1) { numToProcess = 1; }
00105 
00106                         <a class="code" href="classNL3D_1_1CPSParticle.html#a4">step</a> =   ps.getAutoLODMode() ?                             <font class="comment">// skip or limit number, depending on the mode</font>
00107                                 (<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize() &lt;&lt; 16) / numToProcess : <font class="comment">// skip particles</font>
00108                                 (1&lt;&lt;16);                                                           <font class="comment">// just display less particles</font>
00109                 }
00110                 <font class="keywordflow">else</font>
00111                 {
00112                         <a class="code" href="classNL3D_1_1CPSParticle.html#a4">step</a> = (1 &lt;&lt; 16);
00113                         numToProcess = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize();
00114                 }
00115         }
00116 
00117 }
00118 
00120 <font class="comment">// coloured particle implementation //</font>
00122 <font class="comment"></font>
00123 <font class="comment">//=======================================</font>
<a name="l00124"></a><a class="code" href="classNL3D_1_1CPSColoredParticle.html#a0">00124</a> <font class="keywordtype">void</font> CPSColoredParticle::setColorScheme(CPSAttribMaker&lt;CRGBA&gt; *col)
00125 {       
00126         <a class="code" href="debug_8h.html#a6">nlassert</a>(col);
00127         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a>;            
00128         <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> = col;
00129         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSColoredParticle.html#b0">getColorOwner</a>() &amp;&amp; col-&gt;hasMemory()) col-&gt;resize(<a class="code" href="classNL3D_1_1CPSColoredParticle.html#b0">getColorOwner</a>()-&gt;getMaxSize(), <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b0">getColorOwner</a>()-&gt;getSize());
00130         <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b1">updateMatAndVbForColor</a>();
00131 }
00132 
00133 <font class="comment">//=======================================</font>
<a name="l00134"></a><a class="code" href="classNL3D_1_1CPSColoredParticle.html#a3">00134</a> <font class="keywordtype">void</font> CPSColoredParticle::setColor(<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> col)
00135 {       
00136         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a>;
00137         <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> = NULL;
00138         <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n0">_Color</a> = col;
00139         <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b1">updateMatAndVbForColor</a>();
00140 }
00141 
00142 <font class="comment">//=======================================</font>
<a name="l00143"></a><a class="code" href="classNL3D_1_1CPSColoredParticle.html#a5">00143</a> CPSColoredParticle::CPSColoredParticle() : _Color(CRGBA(255, 255, 255)), _ColorScheme(NULL)
00144 {       
00145 }
00146 
00147 <font class="comment">//=======================================</font>
<a name="l00148"></a><a class="code" href="classNL3D_1_1CPSColoredParticle.html#a6">00148</a> CPSColoredParticle::~CPSColoredParticle()
00149 {       
00150         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a>;    
00151 }
00152 
00153 <font class="comment">//=======================================</font>
<a name="l00154"></a><a class="code" href="classNL3D_1_1CPSColoredParticle.html#a7">00154</a> <font class="keywordtype">void</font> CPSColoredParticle::serialColorScheme(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00155 {       
00156         f.serialVersion(1);     
00157         <font class="keywordflow">if</font> (f.isReading())
00158         {
00159                 <font class="keywordflow">if</font> (_ColorScheme)
00160                 {
00161                         <font class="keyword">delete</font> _ColorScheme;
00162                         _ColorScheme = NULL;
00163                 }
00164         }
00165         <font class="keywordtype">bool</font> useColorScheme = _ColorScheme != NULL;
00166         f.serial(useColorScheme);
00167         <font class="keywordflow">if</font> (useColorScheme)
00168         {
00169                 f.serialPolyPtr(_ColorScheme);
00170         }
00171         <font class="keywordflow">else</font>
00172         {
00173                 f.serial(_Color);
00174         }
00175 }
00176 
00178 <font class="comment">// sized particle implementation //</font>
00180 <font class="comment"></font>
00181 <font class="comment">//=======================================</font>
<a name="l00182"></a><a class="code" href="classNL3D_1_1CPSSizedParticle.html#a0">00182</a> <font class="keywordtype">void</font> CPSSizedParticle::setSizeScheme(CPSAttribMaker&lt;float&gt; *size)
00183 {       
00184         <a class="code" href="debug_8h.html#a6">nlassert</a>(size != NULL);
00185         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSSizedParticle.html#n1">_SizeScheme</a>;     
00186         <a class="code" href="classNL3D_1_1CPSSizedParticle.html#n1">_SizeScheme</a> = size;
00187         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSSizedParticle.html#b0">getSizeOwner</a>() &amp;&amp; size-&gt;hasMemory()) size-&gt;resize(<a class="code" href="classNL3D_1_1CPSSizedParticle.html#b0">getSizeOwner</a>()-&gt;getMaxSize(), <a class="code" href="classNL3D_1_1CPSSizedParticle.html#b0">getSizeOwner</a>()-&gt;<a class="code" href="classNL3D_1_1CPSSizedParticle.html#a4">getSize</a>());
00188 }
00189 
00190 <font class="comment">//=======================================</font>
<a name="l00191"></a><a class="code" href="classNL3D_1_1CPSSizedParticle.html#a3">00191</a> <font class="keywordtype">void</font> CPSSizedParticle::setSize(<font class="keywordtype">float</font> size)
00192 {       
00193         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSSizedParticle.html#n1">_SizeScheme</a>;
00194         <a class="code" href="classNL3D_1_1CPSSizedParticle.html#n1">_SizeScheme</a> = NULL;     
00195         <a class="code" href="classNL3D_1_1CPSSizedParticle.html#n0">_ParticleSize</a> = size;
00196 }
00197 
00198 <font class="comment">//=======================================</font>
<a name="l00199"></a><a class="code" href="classNL3D_1_1CPSSizedParticle.html#a5">00199</a> CPSSizedParticle::CPSSizedParticle() : _ParticleSize(0.3f), _SizeScheme(NULL)
00200 {
00201 }
00202 
00203 <font class="comment">//=======================================</font>
<a name="l00204"></a><a class="code" href="classNL3D_1_1CPSSizedParticle.html#a6">00204</a> CPSSizedParticle::~CPSSizedParticle()
00205 {       
00206         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSSizedParticle.html#n1">_SizeScheme</a>;     
00207 }
00208 
00209 <font class="comment">//=======================================</font>
<a name="l00210"></a><a class="code" href="classNL3D_1_1CPSSizedParticle.html#a7">00210</a> <font class="keywordtype">void</font> CPSSizedParticle::serialSizeScheme(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00211 {
00212         f.serialVersion(1);     
00213         <font class="keywordflow">if</font> (f.isReading())
00214         {
00215                 <font class="keywordflow">if</font> (_SizeScheme)
00216                 {
00217                         <font class="keyword">delete</font> _SizeScheme;
00218                         _SizeScheme = NULL;
00219                 }
00220         }
00221         <font class="keywordtype">bool</font> useSizeScheme = _SizeScheme != NULL;
00222         f.serial(useSizeScheme);
00223         <font class="keywordflow">if</font> (useSizeScheme)
00224         {               
00225                 f.serialPolyPtr(_SizeScheme);
00226         }
00227         <font class="keywordflow">else</font>
00228         {
00229                 f.serial(_ParticleSize);
00230         }       
00231 };
00232 
00234 <font class="comment">// rotated particle implementation //</font>
00236 <font class="comment"></font>
<a name="l00237"></a><a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#q0">00237</a> <font class="keywordtype">float</font> CPSRotated2DParticle::_RotTable[256 * 4];
<a name="l00238"></a><a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#q1">00238</a> <font class="keywordtype">bool</font> CPSRotated2DParticle::_InitializedRotTab = <font class="keyword">false</font>;
00239 
<a name="l00241"></a><a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#a0">00241</a> <font class="keywordtype">void</font> CPSRotated2DParticle::setAngle2DScheme(CPSAttribMaker&lt;float&gt; *angle2DScheme)
00242 {
00243         <a class="code" href="debug_8h.html#a6">nlassert</a>(angle2DScheme);
00244         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#n1">_Angle2DScheme</a>;  
00245         <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#n1">_Angle2DScheme</a> = angle2DScheme;
00246         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#b0">getAngle2DOwner</a>() &amp;&amp; angle2DScheme-&gt;hasMemory()) angle2DScheme-&gt;resize(<a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#b0">getAngle2DOwner</a>()-&gt;getMaxSize(), <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#b0">getAngle2DOwner</a>()-&gt;getSize());
00247 }
00248 
<a name="l00250"></a><a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#a3">00250</a> <font class="keywordtype">void</font> CPSRotated2DParticle::setAngle2D(<font class="keywordtype">float</font> angle2DScheme)
00251 {       
00252         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#n1">_Angle2DScheme</a>;
00253         <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#n1">_Angle2DScheme</a> = NULL;  
00254         <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#n0">_Angle2D</a> = angle2DScheme;
00255 }
00256 
<a name="l00258"></a><a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#a5">00258</a> CPSRotated2DParticle::CPSRotated2DParticle() : _Angle2D(0), _Angle2DScheme(NULL)
00259 {
00260 }
00261 
<a name="l00263"></a><a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#a6">00263</a> CPSRotated2DParticle::~CPSRotated2DParticle()
00264 {       
00265         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#n1">_Angle2DScheme</a>;  
00266 }
00267 
<a name="l00269"></a><a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#a7">00269</a> <font class="keywordtype">void</font> CPSRotated2DParticle::serialAngle2DScheme(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00270 {
00271         f.serialVersion(1);     
00272         <font class="keywordflow">if</font> (f.isReading())
00273         {
00274                 <font class="keywordflow">if</font> (_Angle2DScheme)
00275                 {
00276                         <font class="keyword">delete</font> _Angle2DScheme;
00277                         _Angle2DScheme = NULL;
00278                 }
00279         }
00280         <font class="keywordtype">bool</font> useAngle2DScheme = _Angle2DScheme != NULL;
00281         f.serial(useAngle2DScheme);
00282         <font class="keywordflow">if</font> (useAngle2DScheme)
00283         {
00284                 f.serialPolyPtr(_Angle2DScheme);
00285         }
00286         <font class="keywordflow">else</font>
00287         {               
00288                 f.serial(_Angle2D);
00289         }       
00290 }
00291 
<a name="l00293"></a><a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#d1">00293</a> <font class="keywordtype">void</font> CPSRotated2DParticle::initRotTable(<font class="keywordtype">void</font>)
00294 {
00295         <font class="keywordtype">float</font> *ptFloat = <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#q0">_RotTable</a>;
00296         <font class="keywordflow">for</font> (uint32 k = 0; k &lt; 256; ++k)
00297         {
00298                 <font class="keyword">const</font> <font class="keywordtype">float</font> ca = (float) cos(k * (1.0f / 256.0f) * 2.0f * NLMISC::Pi);
00299                 <font class="keyword">const</font> <font class="keywordtype">float</font> sa = (float) sin(k * (1.0f / 256.0f) * 2.0f * NLMISC::Pi);
00300 
00301                 *ptFloat++ = -ca - sa;
00302                 *ptFloat++ = -sa + ca;
00303 
00304                 *ptFloat++ = ca - sa;
00305                 *ptFloat++ = sa + ca;
00306         }
00307         <a class="code" href="classNL3D_1_1CPSRotated2DParticle.html#q1">_InitializedRotTab</a> = <font class="keyword">true</font>;
00308 }
00309 
00311 <font class="comment">// textured particle implementation //</font>
00313 <font class="comment"></font>
<a name="l00315"></a><a class="code" href="classNL3D_1_1CPSTexturedParticle.html#a0">00315</a> <font class="comment">void CPSTexturedParticle::setTextureIndexScheme(CPSAttribMaker&lt;sint32&gt; *animOrder)</font>
00316 {
00317         <a class="code" href="debug_8h.html#a6">nlassert</a>(animOrder);
00318         <a class="code" href="debug_8h.html#a6">nlassert</a>(_TexGroup); <font class="comment">// setTextureGroup must have been called before this       </font>
00319         <font class="keyword">delete</font> _TextureIndexScheme;             
00320         _TextureIndexScheme = animOrder;
00321         <font class="keywordflow">if</font> (getTextureIndexOwner() &amp;&amp; animOrder-&gt;hasMemory()) animOrder-&gt;resize(getTextureIndexOwner()-&gt;getMaxSize(), getTextureIndexOwner()-&gt;getSize());
00322 
00323 
00324         updateMatAndVbForTexture();
00325 }
00326 
<a name="l00328"></a><a class="code" href="classNL3D_1_1CPSTexturedParticle.html#a3">00328</a> <font class="keywordtype">void</font> CPSTexturedParticle::setTextureIndex(sint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00329 {       
00330         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSTexturedParticle.html#n2">_TextureIndexScheme</a>;     
00331         <a class="code" href="classNL3D_1_1CPSTexturedParticle.html#n2">_TextureIndexScheme</a> = NULL;     
00332         <a class="code" href="classNL3D_1_1CPSTexturedParticle.html#n3">_TextureIndex</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>;
00333 }
00334 
<a name="l00336"></a><a class="code" href="classNL3D_1_1CPSTexturedParticle.html#a5">00336</a> <font class="keywordtype">void</font> CPSTexturedParticle::setTextureGroup(<a class="code" href="classNLMISC_1_1CSmartPtr.html">NLMISC::CSmartPtr&lt;CTextureGrouped&gt;</a> texGroup)
00337 {
00338         <a class="code" href="debug_8h.html#a6">nlassert</a>(texGroup);
00339         <font class="keywordflow">if</font> (_Tex)
00340         {
00341                 <a class="code" href="classNL3D_1_1CPSTexturedParticle.html#n0">_Tex</a> = NULL;
00342         }
00343         <a class="code" href="classNL3D_1_1CPSTexturedParticle.html#n1">_TexGroup</a> = texGroup;
00344 }
00345 
<a name="l00347"></a><a class="code" href="classNL3D_1_1CPSTexturedParticle.html#a8">00347</a> <font class="keywordtype">void</font> CPSTexturedParticle::setTexture(CSmartPtr&lt;ITexture&gt; tex)
00348 {       
00349         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSTexturedParticle.html#n2">_TextureIndexScheme</a>;
00350         <a class="code" href="classNL3D_1_1CPSTexturedParticle.html#n2">_TextureIndexScheme</a> = NULL;     
00351         <a class="code" href="classNL3D_1_1CPSTexturedParticle.html#n0">_Tex</a> = tex;
00352         <a class="code" href="classNL3D_1_1CPSTexturedParticle.html#n1">_TexGroup</a> = NULL; <font class="comment">// release any grouped texture if one was set before</font>
00353         <a class="code" href="classNL3D_1_1CPSTexturedParticle.html#b1">updateMatAndVbForTexture</a>();
00354 }
00355 
<a name="l00357"></a><a class="code" href="classNL3D_1_1CPSTexturedParticle.html#a11">00357</a> CPSTexturedParticle::CPSTexturedParticle() : _TexGroup(NULL),
00358                                                                                          _TextureIndexScheme(NULL),
00359                                                                                          _TextureIndex(0)
00360 {
00361 }
00362 
<a name="l00364"></a><a class="code" href="classNL3D_1_1CPSTexturedParticle.html#a12">00364</a> CPSTexturedParticle::~CPSTexturedParticle()
00365 {       
00366         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSTexturedParticle.html#n2">_TextureIndexScheme</a>;     
00367 }
00368 
<a name="l00370"></a><a class="code" href="classNL3D_1_1CPSTexturedParticle.html#a13">00370</a> <font class="keywordtype">void</font> CPSTexturedParticle::serialTextureScheme(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00371 {
00372         f.serialVersion(1);     
00373         <font class="keywordflow">if</font> (f.isReading())
00374         {
00375                 <font class="keywordflow">if</font> (_TextureIndexScheme)
00376                 {
00377                         <font class="keyword">delete</font> _TextureIndexScheme;
00378                         _TextureIndexScheme = NULL;                     
00379                         _Tex = NULL;
00380                         _TexGroup = NULL;
00381                 }
00382         }
00383 
00384         <font class="keywordtype">bool</font> useAnimatedTexture;        
00385         <font class="keywordflow">if</font> (!f.isReading())
00386         {
00387                 useAnimatedTexture = (_TexGroup != NULL);
00388         }
00389         f.serial(useAnimatedTexture);
00390         <font class="keywordflow">if</font> (useAnimatedTexture)
00391         {
00392                 <font class="keywordflow">if</font> (f.isReading())
00393                 {
00394                         CTextureGrouped *ptTex = NULL;
00395                         f.serialPolyPtr(ptTex);
00396                         _TexGroup = ptTex;
00397                 }
00398                 <font class="keywordflow">else</font>
00399                 {
00400                         CTextureGrouped *ptTex = _TexGroup;
00401                         f.serialPolyPtr(ptTex);
00402                 }
00403                 
00404                 <font class="keywordtype">bool</font> useTextureIndexScheme = _TextureIndexScheme != NULL;               
00405                 f.serial(useTextureIndexScheme);
00406                 <font class="keywordflow">if</font> (useTextureIndexScheme)
00407                 {
00408                         f.serialPolyPtr(_TextureIndexScheme);
00409                         _TextureIndex = 0;                      
00410                 }
00411                 <font class="keywordflow">else</font>
00412                 {                       
00413                         f.serial(_TextureIndex);
00414                 }
00415         }
00416         <font class="keywordflow">else</font>
00417         {
00418                 <font class="keywordflow">if</font> (f.isReading())
00419                 {
00420                         ITexture *ptTex = NULL;
00421                         f.serialPolyPtr(ptTex);
00422                         _Tex = ptTex;
00423                 }
00424                 <font class="keywordflow">else</font>
00425                 {
00426                         ITexture *ptTex = _Tex;
00427                         f.serialPolyPtr(ptTex);
00428                 }
00429         }       
00430 }
00431 
00433 <font class="comment">//       CPSRotated3DPlaneParticle  implementation    //</font>
00435 <font class="comment"></font>
<a name="l00437"></a><a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#a0">00437</a> <font class="comment">void CPSRotated3DPlaneParticle::setPlaneBasisScheme(CPSAttribMaker&lt;CPlaneBasis&gt; *basisMaker)</font>
00438 {
00439         <a class="code" href="debug_8h.html#a6">nlassert</a>(basisMaker);
00440         <font class="keyword">delete</font> _PlaneBasisScheme;       
00441         _PlaneBasisScheme = basisMaker;
00442         <font class="keywordflow">if</font> (getPlaneBasisOwner() &amp;&amp; basisMaker-&gt;hasMemory()) basisMaker-&gt;resize(getPlaneBasisOwner()-&gt;getMaxSize(), getPlaneBasisOwner()-&gt;getSize());
00443 }
00444 
<a name="l00446"></a><a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#a3">00446</a> <font class="keywordtype">void</font> CPSRotated3DPlaneParticle::setPlaneBasis(<font class="keyword">const</font> CPlaneBasis &amp;basis)
00447 {       
00448         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#n0">_PlaneBasisScheme</a>;               
00449         <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#n0">_PlaneBasisScheme</a> = NULL;       
00450         <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#n1">_PlaneBasis</a> = basis;
00451 }
00452 
<a name="l00454"></a><a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#a5">00454</a> CPSRotated3DPlaneParticle::CPSRotated3DPlaneParticle() : _PlaneBasisScheme(NULL)                                                                                                                
00455 {
00456         <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#n1">_PlaneBasis</a>.X = CVector::I;
00457         <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#n1">_PlaneBasis</a>.Y = CVector::J;
00458 }
00459 
<a name="l00461"></a><a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#a6">00461</a> CPSRotated3DPlaneParticle::~CPSRotated3DPlaneParticle()
00462 {       
00463         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#n0">_PlaneBasisScheme</a>;       
00464 }
00465 
<a name="l00467"></a><a class="code" href="classNL3D_1_1CPSRotated3DPlaneParticle.html#a7">00467</a> <font class="keywordtype">void</font> CPSRotated3DPlaneParticle::serialPlaneBasisScheme(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00468 {
00469         f.serialVersion(1);     
00470         f.serialPolyPtr(_PlaneBasisScheme);     
00471         <font class="keywordtype">bool</font> usePlaneBasisScheme = _PlaneBasisScheme != NULL;   
00472         <font class="keywordflow">if</font> (!usePlaneBasisScheme)
00473         {
00474                 f.serial(_PlaneBasis);
00475         }
00476 }
00477 
00479 <font class="comment">// CPSMaterial implementation //</font>
00481 <font class="comment"></font>
<a name="l00483"></a><a class="code" href="classNL3D_1_1CPSMaterial.html#a0">00483</a> <font class="comment">CPSMaterial::CPSMaterial()</font>
00484 {
00485         _Mat.setBlend(<font class="keyword">true</font>);
00486         _Mat.setBlendFunc(CMaterial::one, CMaterial::one);
00487         _Mat.setZWrite(<font class="keyword">false</font>);  
00488 }
00489 
<a name="l00491"></a><a class="code" href="classNL3D_1_1CPSMaterial.html#a1">00491</a> <font class="keywordtype">void</font> CPSMaterial::serialMaterial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00492 {
00493         f.serialVersion(1);     
00494         TBlendingMode m = getBlendingMode();
00495         f.serialEnum(m);
00496         setBlendingMode(m);     
00497 }
00498 
<a name="l00500"></a><a class="code" href="classNL3D_1_1CPSMaterial.html#a2">00500</a> <font class="keywordtype">void</font> CPSMaterial::setBlendingMode(CPSMaterial::TBlendingMode mode)
00501 {
00502         <font class="keywordflow">switch</font> (mode)
00503         {               
00504                 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CPSMaterial.html#s4s0">add</a>:
00505                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setBlend(<font class="keyword">true</font>);
00506                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setBlendFunc(CMaterial::one, CMaterial::one);
00507                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setZWrite(<font class="keyword">false</font>);
00508                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setAlphaTest(<font class="keyword">false</font>);
00509                 <font class="keywordflow">break</font>;
00510                 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CPSMaterial.html#s4s1">modulate</a>:
00511                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setBlend(<font class="keyword">true</font>);
00512                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setBlendFunc(CMaterial::zero, CMaterial::srccolor);
00513                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setZWrite(<font class="keyword">false</font>);
00514                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setAlphaTest(<font class="keyword">false</font>);
00515                 <font class="keywordflow">break</font>;
00516                 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CPSMaterial.html#s4s2">alphaBlend</a>:
00517                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setBlend(<font class="keyword">true</font>);
00518                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setBlendFunc(CMaterial::srcalpha, CMaterial::invsrcalpha);
00519                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setZWrite(<font class="keyword">false</font>);
00520                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setAlphaTest(<font class="keyword">false</font>);
00521                 <font class="keywordflow">break</font>;
00522                 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CPSMaterial.html#s4s3">alphaTest</a>:
00523                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setBlend(<font class="keyword">false</font>);
00524                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setZWrite(<font class="keyword">true</font>);
00525                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setAlphaTest(<font class="keyword">true</font>);
00526                 <font class="keywordflow">break</font>;
00527         }
00528 }
00529 
<a name="l00531"></a><a class="code" href="classNL3D_1_1CPSMaterial.html#a3">00531</a> CPSMaterial::TBlendingMode CPSMaterial::getBlendingMode(<font class="keywordtype">void</font>)<font class="keyword"> const</font>
00532 <font class="keyword"></font>{
00533         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.getBlend())
00534         {
00535                 CMaterial::TBlend srcBlend = <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.getSrcBlend();        
00536                 CMaterial::TBlend destBlend = <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.getDstBlend();
00537 
00538                 <font class="keywordflow">if</font> (srcBlend == CMaterial::one &amp;&amp; destBlend == CMaterial::one) <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSMaterial.html#s4s0">add</a>;
00539                 <font class="keywordflow">if</font> (srcBlend == CMaterial::zero &amp;&amp; destBlend == CMaterial::srccolor) <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSMaterial.html#s4s1">modulate</a>;
00540                 <font class="keywordflow">if</font> (srcBlend == CMaterial::srcalpha &amp;&amp; destBlend == CMaterial::invsrcalpha) <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSMaterial.html#s4s2">alphaBlend</a>;
00541 
00542                 <font class="comment">// unrecognized mode</font>
00543                 <a class="code" href="debug_8h.html#a6">nlassert</a>(0);
00544                 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSMaterial.html#s4s3">alphaTest</a>; <font class="comment">// to avoid a warning only ...</font>
00545         }
00546         <font class="keywordflow">else</font>
00547         {
00548                 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSMaterial.html#s4s3">alphaTest</a>;
00549         }
00550 }
00551 
<a name="l00553"></a><a class="code" href="classNL3D_1_1CPSMaterial.html#a4">00553</a> <font class="keywordtype">void</font> CPSMaterial::forceModulateConstantColor(<font class="keywordtype">bool</font> force, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> &amp;col)
00554 {
00555         <font class="keywordflow">if</font> (force)
00556         {
00558                 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texConstantColor(1, col);
00559                 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texEnvOpRGB(1, CMaterial::Modulate);
00560                 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texEnvOpAlpha(1, CMaterial::Modulate);
00561                 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texEnvArg0RGB(1, CMaterial::Previous, CMaterial::SrcColor);
00562                 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texEnvArg1RGB(1, CMaterial::Constant, CMaterial::SrcColor);
00563                 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texEnvArg0Alpha(1, CMaterial::Previous, CMaterial::SrcAlpha);
00564                 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texEnvArg1Alpha(1, CMaterial::Constant, CMaterial::SrcAlpha);
00565                 <a class="code" href="classNL3D_1_1CPSMaterial.html#a5">forceTexturedMaterialStages</a>(2);
00566         }
00567         <font class="keywordflow">else</font>
00568         {               
00569                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.getTexture(1) != NULL)
00570                 {
00571                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(1, NULL);
00572                 }
00573         }
00574 }
00575 
00576 
<a name="l00578"></a><a class="code" href="classNL3D_1_1CPSMaterial.html#a5">00578</a> <font class="keywordtype">void</font> CPSMaterial::forceTexturedMaterialStages(uint numStages)
00579 {
00580         ITexture *blankTex = NULL;
00581         uint k;
00582         <font class="keywordflow">for</font> (k = 0; k &lt; numStages; ++k)
00583         {
00584                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.getTexture(k) == NULL)
00585                 {
00586                         <font class="keywordflow">if</font> (!blankTex)
00587                         {
00588                                 blankTex = CTextureMem::Create1x1WhiteTex();
00589                         }
00590                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(k, blankTex);
00591                 }
00592         }
00593         <font class="keywordflow">for</font> (; k &lt; <a class="code" href="namespaceNL3D.html#a94">IDRV_MAT_MAXTEXTURES</a>; ++k)
00594         {
00595                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.getTexture(k) != NULL)
00596                 {
00597                         <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(k, NULL);
00598                 }               
00599         }
00600 }
00601 
00602 
00604 <font class="comment">// CPSMultiTexturedParticle implementation //</font>
00606 <font class="comment"></font>
00607 <font class="comment">//=======================================</font>
<a name="l00608"></a><a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#q0">00608</a> <font class="keywordtype">bool</font> CPSMultiTexturedParticle::_ForceBasicCaps  = <font class="keyword">false</font>;
00609 
00610 <font class="comment">//=======================================</font>
<a name="l00611"></a><a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a0">00611</a> CPSMultiTexturedParticle::CPSMultiTexturedParticle() : _MultiTexState(TouchFlag), _BumpFactor(1.f)
00612 {       
00613 }
00614 
00615 <font class="comment">//=======================================</font>
<a name="l00616"></a><a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a1">00616</a> <font class="keywordtype">void</font>    CPSMultiTexturedParticle::enableMultiTexture(<font class="keywordtype">bool</font> enabled <font class="comment">/*= true*/</font>)
00617 {
00618         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a2">isMultiTextureEnabled</a>() == enabled) <font class="keywordflow">return</font>;
00619         <font class="keywordflow">if</font> (!enabled)
00620         {
00621                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n2">_Texture2</a>                  = NULL;
00622                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n3">_AlternateTexture2</a> = NULL;
00623                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> = 0;
00624         }
00625         <font class="keywordflow">else</font>
00626         {               
00627                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n0">_MainOp</a> = <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#s5s1">Modulate</a>;
00628                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n4">_TexScroll</a>[0].<a class="code" href="classNLMISC_1_1CVector2f.html#z340_0">set</a>(0, 0);
00629                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n4">_TexScroll</a>[1].<a class="code" href="classNLMISC_1_1CVector2f.html#z340_0">set</a>(0, 0);
00630                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> = (uint8) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#t8t1">MultiTextureEnabled</a>;
00631         }
00632         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b3">touch</a>();        
00633 }
00634 
00635 <font class="comment">//=======================================</font>
<a name="l00636"></a><a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a8">00636</a> <font class="keywordtype">void</font>    CPSMultiTexturedParticle::enableAlternateTex(<font class="keywordtype">bool</font> enabled <font class="comment">/*= true*/</font>)
00637 {       
00638         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a2">isMultiTextureEnabled</a>()); <font class="comment">// multitexturing must have been enabled first</font>
00639         <font class="keywordflow">if</font> (enabled == <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a9">isAlternateTexEnabled</a>()) <font class="keywordflow">return</font>;
00640 
00641         <font class="keywordflow">if</font> (enabled)
00642         {
00643                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n5">_TexScrollAlternate</a>[0].<a class="code" href="classNLMISC_1_1CVector2f.html#z340_0">set</a>(0, 0);
00644                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n5">_TexScrollAlternate</a>[1].<a class="code" href="classNLMISC_1_1CVector2f.html#z340_0">set</a>(0, 0);
00645                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n1">_AlternateOp</a> = <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#s5s1">Modulate</a>;
00646                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> |= (uint8) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#t8t2">AlternateTextureEnabled</a>;
00647         }
00648         <font class="keywordflow">else</font>
00649         {
00650                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n2">_Texture2</a> = NULL;
00651                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> &amp;= ~(uint8) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#t8t2">AlternateTextureEnabled</a>;
00652         }
00653         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b3">touch</a>();
00654 }
00655 
00656 <font class="comment">//=======================================</font>
<a name="l00657"></a><a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a19">00657</a> <font class="keywordtype">void</font>    CPSMultiTexturedParticle::serialMultiTex(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00658 {
00660         sint ver = f.serialVersion(1);
00661         f.serial(_MultiTexState);
00662         <font class="keywordflow">if</font> (isMultiTextureEnabled())
00663         {
00664                 f.serialEnum(_MainOp);
00665                 <font class="keywordflow">if</font> (_MainOp == EnvBumpMap &amp;&amp; ver &gt;= 1)
00666                 {
00667                         f.serial(_BumpFactor);
00668                 }
00669                 ITexture *tex = NULL;
00670                 <font class="keywordflow">if</font> (f.isReading())
00671                 {
00672                         f.serialPolyPtr(tex);
00673                         _Texture2 = tex;
00674                 }
00675                 <font class="keywordflow">else</font>
00676                 {
00677                         tex = _Texture2;
00678                         f.serialPolyPtr(tex);
00679                 }
00680                 f.serial(_TexScroll[0], _TexScroll[1]);
00681                 
00682                 <font class="keywordflow">if</font> (isAlternateTexEnabled())
00683                 {
00684                         f.serialEnum(_AlternateOp);                     
00685                         <font class="keywordflow">if</font> (f.isReading())
00686                         {
00687                                 f.serialPolyPtr(tex);
00688                                 _AlternateTexture2 = tex;
00689                         }
00690                         <font class="keywordflow">else</font>
00691                         {
00692                                 tex = _AlternateTexture2;
00693                                 f.serialPolyPtr(tex);
00694                         }
00695                         f.serial(_TexScrollAlternate[0], _TexScrollAlternate[1]);
00696                 }
00697                 <font class="keywordflow">else</font>
00698                 {
00699                         _AlternateTexture2 = NULL;
00700                 }
00701         }
00702         <font class="keywordflow">else</font>
00703         {
00704                 <font class="keywordflow">if</font> (f.isReading())
00705                 {
00706                         _Texture2                  = NULL;
00707                         _AlternateTexture2 = NULL;
00708                 }
00709         }       
00710 }
00711 
00712 <font class="comment">//=======================================</font>
<a name="l00713"></a><a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a20">00713</a> <font class="keywordtype">void</font> CPSMultiTexturedParticle::setupMaterial(ITexture *primary, IDriver *driver, CMaterial &amp;mat)
00714 {
00716         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a2">isMultiTextureEnabled</a>() &amp;&amp; <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n0">_MainOp</a>  == <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#s5s3">EnvBumpMap</a> &amp;&amp; driver-&gt;isTextureAddrModeSupported(CMaterial::OffsetTexture))
00717         {
00718                 CTextureBump *tb = dynamic_cast&lt;CTextureBump *&gt;((ITexture *) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n2">_Texture2</a>);
00719                 <font class="keywordflow">if</font> (tb != NULL)
00720                 {                                       
00721                         <font class="keywordtype">float</font> normFactor = tb-&gt;getNormalizationFactor();
00722                         <font class="keywordflow">if</font> (normFactor == 0.f) <font class="comment">// have we computed the normalization factor ?</font>
00723                         {
00725                                 tb-&gt;generate();
00726                                 normFactor = tb-&gt;getNormalizationFactor();
00727                                 tb-&gt;release();
00728                         }
00729                         <font class="keyword">const</font> <font class="keywordtype">float</font> bMat[] = { <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n7">_BumpFactor</a> * normFactor, 0.f, 0.f, <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n7">_BumpFactor</a> * normFactor};   
00730                         driver-&gt;setMatrix2DForTextureOffsetAddrMode(1, bMat);
00731                 }               
00732         }
00733 
00734         <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b5">isTouched</a>() &amp;&amp; <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b6">areBasicCapsForcedLocal</a>() == <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#d1">areBasicCapsForced</a>()) <font class="keywordflow">return</font>;
00735         <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a2">isMultiTextureEnabled</a>())           
00736         {               
00737                 mat.setTexture(0, primary);
00738                 mat.texEnvOpRGB(0, CMaterial::Modulate);
00739                 mat.setTexture(1, NULL);
00740         }
00741         <font class="keywordflow">else</font>
00742         {                               
00743                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n0">_MainOp</a>  != <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#s5s3">EnvBumpMap</a>)
00744                 {                       
00745                         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b0">setupMultiTexEnv</a>(<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n0">_MainOp</a>, primary, <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n2">_Texture2</a>, mat);
00746                         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> &amp;= ~(uint8) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#t8t4">EnvBumpMapUsed</a>;
00747                         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> &amp;= ~(uint8) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#t8t3">AlternateTextureUsed</a>;
00748                 }
00749                 <font class="keywordflow">else</font>
00750                 {
00751                         <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#q0">_ForceBasicCaps</a> &amp;&amp; driver-&gt;isTextureAddrModeSupported(CMaterial::OffsetTexture)) <font class="comment">// envbumpmap supported ?</font>
00752                         {
00753                                 CTextureBump *tb = dynamic_cast&lt;CTextureBump *&gt;((ITexture *) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n2">_Texture2</a>);
00754                                 <font class="keywordflow">if</font> (tb != NULL)
00755                                 {                                       
00756                                         <font class="keywordtype">float</font> normFactor = tb-&gt;getNormalizationFactor();
00757                                         <font class="keywordflow">if</font> (normFactor == 0.f) <font class="comment">// have we computed the normalization factor ?</font>
00758                                         {
00760                                                 tb-&gt;generate();
00761                                                 normFactor = tb-&gt;getNormalizationFactor();
00762                                                 tb-&gt;release();
00763                                         }                                       
00764                                         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b0">setupMultiTexEnv</a>(<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n0">_MainOp</a>, primary, <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n2">_Texture2</a>, mat);     
00765                                 }
00766                                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> &amp;= ~(uint8) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#t8t3">AlternateTextureUsed</a>;
00767                                 <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> |= (uint8) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#t8t4">EnvBumpMapUsed</a>;                               
00768                         }
00769                         <font class="keywordflow">else</font> <font class="comment">// switch to alternate</font>
00770                         {
00771                                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a9">isAlternateTexEnabled</a>())
00772                                 {
00773                                         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> |= (uint8) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#t8t3">AlternateTextureUsed</a>;
00774                                         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b0">setupMultiTexEnv</a>(<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n1">_AlternateOp</a>, primary, <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n3">_AlternateTexture2</a>, mat);
00775                                         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> &amp;= ~(uint8) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#t8t4">EnvBumpMapUsed</a>;
00776                                 }
00777                                 <font class="keywordflow">else</font> <font class="comment">// display the texture as it</font>
00778                                 {
00779                                         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b0">setupMultiTexEnv</a>(<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#s5s2">Decal</a>, primary, NULL, mat);
00780                                         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> &amp;= ~(uint8) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#t8t3">AlternateTextureUsed</a>;
00781                                         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> &amp;= ~(uint8) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#t8t4">EnvBumpMapUsed</a>;
00782                                 }
00783                         }
00784                 }
00785         }
00786         
00787         (<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#d1">areBasicCapsForced</a>());
00788         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b4">unTouch</a>();
00789 }
00790 
00791 <font class="comment">//=======================================</font>
<a name="l00792"></a><a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b0">00792</a> <font class="keywordtype">void</font>    CPSMultiTexturedParticle::setupMultiTexEnv(TOperator op, ITexture *tex1, ITexture *tex2, CMaterial &amp;mat)
00793 {
00794         <font class="keywordflow">switch</font> (op)
00795         {
00796                 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#s5s0">Add</a>:                       
00797                         mat.setTexture(0, tex1);
00798                         mat.setTexture(1, tex2);
00799                         mat.texEnvOpRGB(0, CMaterial::Modulate);
00800                         mat.texEnvOpRGB(1, CMaterial::Add);
00801                         mat.enableTexAddrMode(<font class="keyword">false</font>);
00802                         <font class="keywordflow">break</font>;
00803                 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#s5s1">Modulate</a>:
00804                         mat.setTexture(0, tex1);
00805                         mat.setTexture(1, tex2);
00806                         mat.texEnvOpRGB(0, CMaterial::Modulate);
00807                         mat.texEnvOpRGB(1, CMaterial::Modulate);
00808                         mat.enableTexAddrMode(<font class="keyword">false</font>);
00809                         <font class="keywordflow">break</font>;
00810                 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#s5s3">EnvBumpMap</a>:
00811                         mat.setTexture(0, tex2);
00812                         mat.setTexture(1, tex1);
00813                         mat.texEnvOpRGB(0, CMaterial::Replace);
00814                         mat.texEnvOpRGB(1, CMaterial::Modulate);
00815                         mat.enableTexAddrMode(<font class="keyword">true</font>);
00816                         mat.setTexAddressingMode(0, CMaterial::FetchTexture);           
00817                         mat.setTexAddressingMode(1, CMaterial::OffsetTexture);
00818                         <font class="keywordflow">break</font>;
00819                 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#s5s2">Decal</a>:
00820                         mat.setTexture(0, tex1);
00821                         mat.texEnvOpRGB(0, CMaterial::Replace);
00822                         mat.setTexture(1, NULL);
00823                         mat.enableTexAddrMode(<font class="keyword">false</font>);
00824                         <font class="keywordflow">break</font>;
00825                 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
00826         }
00827 }
00828 
00829 <font class="comment">//=====static func to convert a texture to a bumpmap</font>
00830 <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a437">ConvertToBumpMap</a>(<a class="code" href="classNLMISC_1_1CSmartPtr.html">NLMISC::CSmartPtr&lt;ITexture&gt;</a> &amp;ptr)
00831 {
00832         <font class="keywordflow">if</font> (!dynamic_cast&lt;CTextureBump *&gt;( (ITexture *) ptr))
00833         {
00834                 <font class="comment">// convert to a bumpmap</font>
00835                 CTextureBump *tb = <font class="keyword">new</font> CTextureBump;
00836                 tb-&gt;setAbsoluteOffsets();
00837                 tb-&gt;setHeightMap((ITexture *) ptr);
00838                 ptr = tb;
00839         }       
00840 }
00841 
00842 <font class="comment">//=====static func to convert a bumpmap to a texture (its heightmap)</font>
00843 <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a438">ConvertFromBumpMap</a>(<a class="code" href="classNLMISC_1_1CSmartPtr.html">NLMISC::CSmartPtr&lt;ITexture&gt;</a> &amp;ptr)
00844 {
00845         CTextureBump *bm = dynamic_cast&lt;CTextureBump *&gt;( (ITexture *) ptr);
00846         <font class="keywordflow">if</font> (bm)
00847         {
00848                 <font class="comment">// retrieve the heightmap from the bumpmap</font>
00849                 <a class="code" href="classNLMISC_1_1CSmartPtr.html">NLMISC::CSmartPtr&lt;ITexture&gt;</a> hm = bm-&gt;getHeightMap();            
00850                 ptr = hm;
00851         }
00852 }
00853 
00854 <font class="comment">//=========================================</font>
<a name="l00855"></a><a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a10">00855</a> <font class="keywordtype">void</font>    CPSMultiTexturedParticle::setTexture2Alternate(ITexture *tex)
00856 { 
00857         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n3">_AlternateTexture2</a> = tex;
00858         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n1">_AlternateOp</a> != <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#s5s3">EnvBumpMap</a>)
00859         {               
00860                 <a class="code" href="namespaceNL3D.html#a438">ConvertFromBumpMap</a>(<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n3">_AlternateTexture2</a>);
00861         }
00862         <font class="keywordflow">else</font>
00863         {
00864                 <a class="code" href="namespaceNL3D.html#a437">ConvertToBumpMap</a>(<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n3">_AlternateTexture2</a>);           
00865         }
00866         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b3">touch</a>();
00867 }
00868 
00869 <font class="comment">//==========================================</font>
<a name="l00870"></a><a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a3">00870</a> <font class="keywordtype">void</font>    CPSMultiTexturedParticle::setTexture2(ITexture *tex) 
00871 { 
00872         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n2">_Texture2</a> = tex;
00873         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n0">_MainOp</a> != <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#s5s3">EnvBumpMap</a>)
00874         {               
00875                 <a class="code" href="namespaceNL3D.html#a438">ConvertFromBumpMap</a>(<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n2">_Texture2</a>);
00876         }
00877         <font class="keywordflow">else</font>
00878         {
00879                 <font class="keywordflow">if</font> (!dynamic_cast&lt;NL3D::CTextureBump *&gt;((ITexture *) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n2">_Texture2</a>))
00880                 {
00881                         <a class="code" href="namespaceNL3D.html#a437">ConvertToBumpMap</a>(<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n2">_Texture2</a>);
00882                 }
00883         }
00884         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b3">touch</a>();
00885 }
00886 
00887 <font class="comment">//==========================================</font>
<a name="l00888"></a><a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a6">00888</a> <font class="keywordtype">void</font>    CPSMultiTexturedParticle::setMainTexOp(TOperator op)
00889 { 
00890         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n0">_MainOp</a> = op;
00891         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n0">_MainOp</a> == <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#s5s3">EnvBumpMap</a>)
00892         {
00893                 <a class="code" href="namespaceNL3D.html#a437">ConvertToBumpMap</a>(<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n2">_Texture2</a>);
00894         }
00895         <font class="keywordflow">else</font>
00896         {
00897                 <a class="code" href="namespaceNL3D.html#a438">ConvertFromBumpMap</a>(<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n2">_Texture2</a>);
00898         }
00899         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b3">touch</a>();
00900 }
00901 
00902 <font class="comment">//==========================================</font>
<a name="l00903"></a><a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a13">00903</a> <font class="keywordtype">void</font>    CPSMultiTexturedParticle::setAlternateTexOp(TOperator op)
00904 { 
00905         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n1">_AlternateOp</a> = op;
00906         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n1">_AlternateOp</a> == <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#s5s3">EnvBumpMap</a>)
00907         {
00908                 <a class="code" href="namespaceNL3D.html#a437">ConvertToBumpMap</a>(<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n3">_AlternateTexture2</a>);
00909         }
00910         <font class="keywordflow">else</font>
00911         {
00912                 <a class="code" href="namespaceNL3D.html#a438">ConvertFromBumpMap</a>(<a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n3">_AlternateTexture2</a>);
00913         }
00914         <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#b3">touch</a>();
00915 }
00916 
00917 
00918 
00919 <font class="comment">//==========================================</font>
<a name="l00920"></a><a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a21">00920</a> <font class="keywordtype">void</font>    CPSMultiTexturedParticle::setUseLocalDate(<font class="keywordtype">bool</font> use)
00921 {
00922         <font class="keywordflow">if</font> (use) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> |= <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#t8t6">ScrollUseLocalDate</a>;
00923         <font class="keywordflow">else</font> <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> &amp;= ~ ScrollUseLocalDate;
00924 }
00925 
00926 
00927 <font class="comment">//==========================================</font>
<a name="l00928"></a><a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#a23">00928</a> <font class="keywordtype">void</font>    CPSMultiTexturedParticle::setUseLocalDateAlt(<font class="keywordtype">bool</font> use)
00929 {
00930         <font class="keywordflow">if</font> (use) <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> |= <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#t8t7">ScrollUseLocalDateAlternate</a>;
00931         <font class="keywordflow">else</font> <a class="code" href="classNL3D_1_1CPSMultiTexturedParticle.html#n6">_MultiTexState</a> &amp;= ~ ScrollUseLocalDateAlternate;
00932 }
00933 
00934 } <font class="comment">// NL3D</font>
00935 
00936 
00937 
00938 
00939 
</pre></div>

<!-- footer -->
<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
</TD>
<TD WIDTH=15><IMG  SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>