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
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
|
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>nevrax.org : docs</TITLE>
<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD>
</TR>
</TABLE>
<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>
<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!------ Begin Box ------>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
<TABLE cellspacing=0 cellpadding=1 border=0>
<tr><td ALIGN=middle><a class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
</TABLE>
</TD></TR></TABLE></TD></TR></TABLE>
<!------ End Box ------>
</TD>
<TD WIDTH=15><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD ALIGN=left valign=top><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!-- title -->
<TABLE background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
<!-- block -->
<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
<TD><B>Documentation</B></TD>
<TD ALIGN=RIGHT> </td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>ps_ribbon.cpp</h1><a href="ps__ribbon_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__ribbon_8h.html">3d/ps_ribbon.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="particle__system_8h.html">3d/particle_system.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="ps__util_8h.html">3d/ps_util.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="matrix_8h.html">nel/misc/matrix.h</a>"</font>
00035
00036 <font class="keyword">namespace </font>NL3D
00037 {
00038
00039 <font class="keyword">static</font> <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> GradientB2W[] = {<a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>(0, 0, 0, 0), <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a>(255, 255, 255, 255) };
00040
00042 <font class="keyword">static</font> ITexture *<a class="code" href="namespaceNL3D.html#a445">CreateGradientTexture</a>()
00043 {
00044 std::auto_ptr<CTextureMem> tex(<font class="keyword">new</font> CTextureMem((uint8 *) &GradientB2W,
00045 <font class="keyword">sizeof</font>(GradientB2W),
00046 <font class="keyword">false</font>, <font class="comment">/* dont delete */</font>
00047 <font class="keyword">false</font>, <font class="comment">/* not a file */</font>
00048 2, 1)
00049 );
00050 tex->setWrapS(ITexture::Clamp);
00051 tex->setShareName(<font class="stringliteral">"#GradBW"</font>);
00052 <font class="keywordflow">return</font> tex.release();
00053 }
00054
00055
00057 <font class="comment">// ribbon implementation //</font>
00059 <font class="comment"></font>
00060 <font class="comment">// predifined shapes</font>
<a name="l00061"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z726_6">00061</a> <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> CPSRibbon::Triangle[] =
00062 {
00063 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(0, 1, 0),
00064 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(1, -1, 0),
00065 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(-1, -1, 0),
00066 };
00067
<a name="l00068"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z726_0">00068</a> <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> CPSRibbon::Losange[] =
00069 {
00070 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(0, 1.f, 0),
00071 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(1.f, 0, 0),
00072 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(0, -1.f, 0),
00073 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(-1.f, 0, 0)
00074 };
00075
<a name="l00076"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z726_2">00076</a> <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> CPSRibbon::HeightSides[] =
00077 {
00078 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(-0.5f, 1, 0),
00079 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(0.5f, 1, 0),
00080 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(1, 0.5f, 0),
00081 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(1, -0.5f, 0),
00082 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(0.5f, -1, 0),
00083 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(-0.5f, -1, 0),
00084 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(-1, -0.5f, 0),
00085 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(-1, 0.5f, 0)
00086 };
00087
00088
<a name="l00089"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z726_4">00089</a> <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> CPSRibbon::Pentagram[] =
00090 {
00091 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(0, 1, 0),
00092 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(1, -1, 0),
00093 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(-1, 0, 0),
00094 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(1, 0, 0),
00095 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>(-1, -1, 0)
00096 };
00097
<a name="l00098"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z726_7">00098</a> <font class="keyword">const</font> uint CPSRibbon::NbVerticesInTriangle = <font class="keyword">sizeof</font>(CPSRibbon::Triangle) / <font class="keyword">sizeof</font>(CVector);
<a name="l00099"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z726_1">00099</a> <font class="keyword">const</font> uint CPSRibbon::NbVerticesInLosange = <font class="keyword">sizeof</font>(Losange) / <font class="keyword">sizeof</font>(CVector);
<a name="l00100"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z726_3">00100</a> <font class="keyword">const</font> uint CPSRibbon::NbVerticesInHeightSide = <font class="keyword">sizeof</font>(CPSRibbon::HeightSides) / <font class="keyword">sizeof</font>(CVector);
<a name="l00101"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z726_5">00101</a> <font class="keyword">const</font> uint CPSRibbon::NbVerticesInPentagram = <font class="keyword">sizeof</font>(CPSRibbon::Pentagram) / <font class="keyword">sizeof</font>(CVector);
00102
00103
<a name="l00104"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z727_3">00104</a> CPSRibbon::TVBMap CPSRibbon::_VBMap; <font class="comment">// index / vertex buffers with no color</font>
<a name="l00105"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z727_4">00105</a> CPSRibbon::TVBMap CPSRibbon::_FadedVBMap; <font class="comment">// index / vertex buffers for constant color with fading</font>
<a name="l00106"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z727_5">00106</a> CPSRibbon::TVBMap CPSRibbon::_ColoredVBMap; <font class="comment">// index / vertex buffer + colors</font>
<a name="l00107"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z727_6">00107</a> CPSRibbon::TVBMap CPSRibbon::_FadedColoredVBMap; <font class="comment">// index / vertex buffer + faded colors</font>
00108
<a name="l00109"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z727_7">00109</a> CPSRibbon::TVBMap CPSRibbon::_TexVBMap; <font class="comment">// index / vertex buffers with no color + texture</font>
<a name="l00110"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z727_8">00110</a> CPSRibbon::TVBMap CPSRibbon::_TexFadedVBMap; <font class="comment">// index / vertex buffers for constant color with fading + texture</font>
<a name="l00111"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z727_9">00111</a> CPSRibbon::TVBMap CPSRibbon::_TexColoredVBMap; <font class="comment">// index / vertex buffer + colors + texture</font>
<a name="l00112"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z727_10">00112</a> CPSRibbon::TVBMap CPSRibbon::_TexFadedColoredVBMap; <font class="comment">// index / vertex buffer + faded colors + texture</font>
00113
00114
<a name="l00115"></a><a class="code" href="structNL3D_1_1CDummy2DAngle.html">00115</a> <font class="keyword">struct </font>CDummy2DAngle : CPSRotated2DParticle
00116 {
<a name="l00117"></a><a class="code" href="structNL3D_1_1CDummy2DAngle.html#a0">00117</a> CPSLocated *<a class="code" href="structNL3D_1_1CDummy2DAngle.html#a0">getAngle2DOwner</a>(<font class="keywordtype">void</font>) { <font class="keywordflow">return</font> NULL; }
00118 };
00119
<a name="l00121"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z724_2">00121</a> <font class="keywordtype">void</font> CPSRibbon::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00122 {
00123 sint ver = f.serialVersion(2);
00124 <font class="keywordflow">if</font> (ver == 1)
00125 {
00126 <a class="code" href="debug_8h.html#a6">nlassert</a>(f.isReading());
00127
00130 sint ver2 = f.serialVersion(2);
00131
00132 <font class="comment">// here is CPSLocatedBindable::serial(f)</font>
00133 sint ver3 = f.serialVersion(4);
00134 f.serialPtr(_Owner);
00135 <font class="keywordflow">if</font> (ver3 > 1) f.serialEnum(_LOD);
00136 <font class="keywordflow">if</font> (ver3 > 2) f.serial(_Name);
00137 <font class="keywordflow">if</font> (ver3 > 3)
00138 {
00139 <font class="keywordflow">if</font> (f.isReading())
00140 {
00141 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>;
00142 f.serial(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>);
00143 setExternID(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>);
00144 }
00145 <font class="keywordflow">else</font>
00146 {
00147 f.serial(_ExternID);
00148 }
00149 }
00150
00151 <font class="keywordflow">if</font> (ver2 >= 2)
00152 {
00153 <font class="keywordtype">bool</font> bDisableAutoLOD;
00154 f.serial(bDisableAutoLOD);
00155 disableAutoLOD(bDisableAutoLOD);
00156 }
00157
00158 uint32 tailNbSegs;
00159 <font class="keywordtype">bool</font> colorFading;
00160 <font class="keywordtype">bool</font> systemBasisEnabled;
00161 <font class="keywordtype">bool</font> drEnabled; <font class="comment">// dying ribbons, not supported in this version</font>
00162
00163 CPSColoredParticle::serialColorScheme(f);
00164 CPSSizedParticle::serialSizeScheme(f);
00165
00166 <font class="comment">// we dont use the 2d angle anymore...serial a dummy one</font>
00167 {
00168 CDummy2DAngle _Dummy2DAngle;
00169 _Dummy2DAngle.serialAngle2DScheme(f);
00170 }
00171
00172 f.serial(colorFading, systemBasisEnabled);
00173 serialMaterial(f);
00174
00175 f.serial(drEnabled);
00176 f.serial(tailNbSegs);
00177 ITexture *tex;
00178 f.serialPolyPtr(tex);
00179 _Tex = tex;
00180 <font class="keywordflow">if</font> (_Tex != NULL)
00181 {
00182 f.serial(_UFactor, _VFactor) ;
00183 }
00184
00185 <font class="comment">// shape serialization </font>
00186 f.serialCont(_Shape);
00187
00188
00189 _NbSegs = tailNbSegs >> 1;
00190 <font class="keywordflow">if</font> (_NbSegs < 1) _NbSegs = 2;
00191 setInterpolationMode(Linear);
00192
00193 <a class="code" href="debug_8h.html#a6">nlassert</a>(_Owner);
00194 resize(_Owner->getMaxSize());
00195 initDateVect();
00196 resetFromOwner();
00197 }
00198
00199
00200 <font class="keywordflow">if</font> (ver >= 2)
00201 {
00202 CPSRibbonBase::serial(f);
00203 CPSColoredParticle::serialColorScheme(f);
00204 CPSSizedParticle::serialSizeScheme(f);
00205 CPSMaterial::serialMaterial(f);
00206 f.serialCont(_Shape);
00207 <font class="keywordtype">bool</font> colorFading = _ColorFading;
00208 f.serial(colorFading);
00209 _ColorFading = colorFading;
00210 uint32 tailNbSegs = _NbSegs;
00211 f.serial(tailNbSegs);
00212 <font class="keywordflow">if</font> (f.isReading())
00213 {
00214 setTailNbSeg(_NbSegs);
00215 touch();
00216 }
00217 ITexture *tex = _Tex;
00218 f.serialPolyPtr(tex);
00219 _Tex = tex;
00220 <font class="keywordflow">if</font> (_Tex != NULL)
00221 {
00222 f.serial(_UFactor, _VFactor) ;
00223 }
00224 }
00225
00226 }
00227
00228
00229 <font class="comment">//======================================================= </font>
<a name="l00230"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z724_0">00230</a> CPSRibbon::CPSRibbon() : _UFactor(1.f),
00231 _VFactor(1.f),
00232 _ColorFading(true),
00233 _GlobalColor(false),
00234 _Touch(true)
00235 {
00236 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#z729_2">setInterpolationMode</a>(<a class="code" href="classNL3D_1_1CPSRibbonBase.html#s7s3">Linear</a>);
00237 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#z730_2">setSegDuration</a>(0.06f);
00238 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n3">_Name</a> = std::string(<font class="stringliteral">"Ribbon"</font>);
00239 <a class="code" href="classNL3D_1_1CPSRibbon.html#a10">setShape</a>(<a class="code" href="classNL3D_1_1CPSRibbon.html#z726_6">Triangle</a>, <a class="code" href="classNL3D_1_1CPSRibbon.html#z726_7">NbVerticesInTriangle</a>);
00240 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setDoubleSided(<font class="keyword">true</font>);
00241 }
00242
00243
00244 <font class="comment">//======================================================= </font>
<a name="l00245"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z724_1">00245</a> CPSRibbon::~CPSRibbon()
00246 {
00247 }
00248
00249
00250 <font class="comment">//========================================================================== </font>
<a name="l00251"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#c10">00251</a> <font class="keyword">inline</font> uint CPSRibbon::getNumVerticesInSlice()<font class="keyword"> const</font>
00252 <font class="keyword"></font>{
00253 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSRibbon.html#o1">_Shape</a>.size() + (<a class="code" href="classNL3D_1_1CPSRibbon.html#o0">_Tex</a> == NULL ? 0 : 1);
00254 }
00255
00256
00257
00258
00259
00260 <font class="comment">//======================================================= </font>
<a name="l00261"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#a0">00261</a> <font class="keywordtype">void</font> CPSRibbon::step(<a class="code" href="namespaceNL3D.html#a484">TPSProcessPass</a> pass, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> realEt)
00262 {
00263 <font class="keywordflow">if</font> (pass == <a class="code" href="namespaceNL3D.html#a484a168">PSMotion</a>)
00264 {
00265 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n2">_Parametric</a>)
00266 {
00267 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#b5">updateGlobals</a>();
00268 }
00269 }
00270 <font class="keywordflow">else</font>
00271 <font class="keywordflow">if</font> (
00272 (pass == <a class="code" href="namespaceNL3D.html#a484a170">PSBlendRender</a> && <a class="code" href="classNL3D_1_1CPSRibbon.html#a1">hasTransparentFaces</a>())
00273 || (pass == <a class="code" href="namespaceNL3D.html#a484a169">PSSolidRender</a> && <a class="code" href="classNL3D_1_1CPSRibbon.html#a2">hasOpaqueFaces</a>())
00274 )
00275 {
00276 uint32 <a class="code" href="classNL3D_1_1CPSRibbon.html#a0">step</a>;
00277 uint numToProcess;
00278 <a class="code" href="classNL3D_1_1CPSParticle.html#b4">computeSrcStep</a>(<a class="code" href="classNL3D_1_1CPSRibbon.html#a0">step</a>, numToProcess);
00279 <font class="keywordflow">if</font> (!numToProcess) <font class="keywordflow">return</font>;
00280
00282 CParticleSystem &ps = *(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner());
00283 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setColor(ps.getGlobalColor());
00284
00289 <a class="code" href="classNL3D_1_1CPSRibbon.html#c1">displayRibbons</a>(numToProcess, <a class="code" href="classNL3D_1_1CPSRibbon.html#a0">step</a>);
00290
00291 }
00292 <font class="keywordflow">else</font>
00293 <font class="keywordflow">if</font> (pass == <a class="code" href="namespaceNL3D.html#a484a171">PSToolRender</a>) <font class="comment">// edition mode only</font>
00294 {
00295 <font class="comment">//showTool();</font>
00296 }
00297 }
00298
00299
00300 <font class="comment">//======================================================= </font>
<a name="l00301"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#b0">00301</a> <font class="keywordtype">void</font> CPSRibbon::newElement(CPSLocated *emitterLocated, uint32 emitterIndex)
00302 {
00303 CPSRibbonBase::newElement(emitterLocated, emitterIndex);
00304 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b2">newColorElement</a>(emitterLocated, emitterIndex);
00305 <a class="code" href="classNL3D_1_1CPSSizedParticle.html#b1">newSizeElement</a>(emitterLocated, emitterIndex);
00306 }
00307
00308
00309 <font class="comment">//======================================================= </font>
<a name="l00310"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#b1">00310</a> <font class="keywordtype">void</font> CPSRibbon::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00311 {
00312 CPSRibbonBase::deleteElement(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00313 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b3">deleteColorElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00314 <a class="code" href="classNL3D_1_1CPSSizedParticle.html#b2">deleteSizeElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00315 }
00316
00317
00318 <font class="comment">//======================================================= </font>
<a name="l00319"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#b2">00319</a> <font class="keywordtype">void</font> CPSRibbon::resize(uint32 size)
00320 {
00321 <a class="code" href="debug_8h.html#a6">nlassert</a>(size < (1 << 16));
00322 CPSRibbonBase::resize(size);
00323 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#b4">resizeColor</a>(size);
00324 <a class="code" href="classNL3D_1_1CPSSizedParticle.html#b3">resizeSize</a>(size);
00325 }
00326
00327 <font class="comment">//======================================================= </font>
<a name="l00328"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#c0">00328</a> <font class="keywordtype">void</font> CPSRibbon::updateMatAndVbForColor(<font class="keywordtype">void</font>)
00329 {
00330 <a class="code" href="classNL3D_1_1CPSRibbon.html#c2">touch</a>();
00331 }
00332
00333
00335 <font class="comment">// Create the start slice of a ribbon (all vertices at the same pos)</font>
00336 <font class="keyword">static</font> <font class="keyword">inline</font> uint8 *<a class="code" href="namespaceNL3D.html#a446">BuildRibbonFirstSlice</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &pos,
00337 uint numVerts,
00338 uint8 *dest,
00339 uint vertexSize
00340 )
00341 {
00342 <font class="keywordflow">do</font>
00343 {
00344 * (<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) dest = pos;
00345 dest += vertexSize;
00346 }
00347 <font class="keywordflow">while</font> (--numVerts);
00348 <font class="keywordflow">return</font> dest;
00349 }
00350
00351
00353 <font class="comment">// This compute one slice of a ribbon, and return the next vertex to be filled</font>
00354 <font class="keyword">static</font> <font class="keyword">inline</font> uint8 *<a class="code" href="namespaceNL3D.html#a447">ComputeRibbonSlice</a>(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &prev,
00355 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &next,
00356 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *shape,
00357 uint numVerts,
00358 uint8 *dest,
00359 uint vertexSize,
00360 <font class="keywordtype">float</font> size
00361 )
00362 {
00363 <font class="comment">// compute a basis from the next and previous position.</font>
00364 <font class="comment">// (not optimized for now, but not widely used, either...) </font>
00365 <font class="keyword">static</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> m;
00366 m.<a class="code" href="classNLMISC_1_1CMatrix.html#z290_6">setPos</a>(next);
00367 CPSUtil::buildSchmidtBasis(next - prev, m);
00368 m.<a class="code" href="classNLMISC_1_1CMatrix.html#z292_6">scale</a>(size);
00369
00370 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *shapeEnd = shape + numVerts;
00371 <font class="keywordflow">do</font>
00372 {
00373 *(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) dest = m * (*shape);
00374 ++shape;
00375 dest += vertexSize;
00376 }
00377 <font class="keywordflow">while</font> (shape != shapeEnd);
00378 <font class="keywordflow">return</font> dest;
00379 }
00380
00381
00382
00384 <font class="comment">// This is used to compute a ribbon mesh from its curve and its base shape.</font>
00385 <font class="comment">// This is for untextured versions (no need to duplicate the last vertex of each slice)</font>
00386 <font class="keyword">static</font> <font class="keyword">inline</font> uint8 *<a class="code" href="namespaceNL3D.html#a448">ComputeUntexturedRibbonMesh</a>(uint8 *destVb,
00387 uint vertexSize,
00388 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *curve,
00389 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *shape,
00390 uint numSegs,
00391 uint numVerticesInShape,
00392 <font class="keywordtype">float</font> sizeIncrement,
00393 <font class="keywordtype">float</font> size
00394 )
00395 {
00396 <font class="keywordflow">do</font>
00397 {
00398 destVb = <a class="code" href="namespaceNL3D.html#a447">ComputeRibbonSlice</a>(curve[1],
00399 curve[0],
00400 shape,
00401 numVerticesInShape,
00402 destVb,
00403 vertexSize,
00404 size);
00405 ++ curve;
00406 size -= sizeIncrement;
00407 }
00408 <font class="keywordflow">while</font> (--numSegs);
00409 <font class="keywordflow">return</font> <a class="code" href="namespaceNL3D.html#a446">BuildRibbonFirstSlice</a>(curve[0], numVerticesInShape, destVb, vertexSize);
00410 }
00411
00413 <font class="comment">// This is used to compute a ribbon mesh from its curve and its base shape.</font>
00414 <font class="comment">// (Textured Version)</font>
00415 <font class="keyword">static</font> <font class="keyword">inline</font> uint8 *<a class="code" href="namespaceNL3D.html#a449">ComputeTexturedRibbonMesh</a>(uint8 *destVb,
00416 uint vertexSize,
00417 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *curve,
00418 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *shape,
00419 uint numSegs,
00420 uint numVerticesInShape,
00421 <font class="keywordtype">float</font> sizeIncrement,
00422 <font class="keywordtype">float</font> size
00423 )
00424 {
00425
00426 <font class="keywordflow">do</font>
00427 {
00428 uint8 *nextDestVb = <a class="code" href="namespaceNL3D.html#a447">ComputeRibbonSlice</a>(curve[1],
00429 curve[0],
00430 shape,
00431 numVerticesInShape,
00432 destVb,
00433 vertexSize,
00434 size
00435 );
00436 <font class="comment">// duplicate last vertex ( equal first)</font>
00437 * (<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) nextDestVb = * (<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) destVb;
00438 destVb = nextDestVb + vertexSize;
00439 <font class="comment">//</font>
00440 ++ curve;
00441 size -= sizeIncrement;
00442 }
00443 <font class="keywordflow">while</font> (--numSegs);
00444 <font class="keywordflow">return</font> <a class="code" href="namespaceNL3D.html#a446">BuildRibbonFirstSlice</a>(curve[0], numVerticesInShape + 1, destVb, vertexSize);
00445 }
00446
00447 <font class="comment">//========================================================================== </font>
<a name="l00448"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#c1">00448</a> <font class="keywordtype">void</font> CPSRibbon::displayRibbons(uint32 nbRibbons, uint32 srcStep)
00449 {
00450 <font class="keywordflow">if</font> (!nbRibbons) <font class="keywordflow">return</font>;
00451 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
00452 CPSRibbonBase::updateLOD();
00453 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> < 2) <font class="keywordflow">return</font>;
00454 <font class="keyword">const</font> <font class="keywordtype">float</font> date = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner()->getSystemDate();
00455 uint8 *currVert;
00456 CVBnPB &VBnPB = <a class="code" href="classNL3D_1_1CPSRibbon.html#z727_1">getVBnPB</a>(); <font class="comment">// get the appropriate vb (built it if needed)</font>
00457 CVertexBuffer &VB = VBnPB.VB;
00458 CPrimitiveBlock &PB = VBnPB.PB;
00459 <font class="keyword">const</font> uint32 vertexSize = VB.getVertexSize();
00460 uint colorOffset=0;
00461
00462 IDriver *drv = this-><a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>();
00463 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();
00464 drv->activeVertexBuffer(VB);
00465 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->incrementNbDrawnParticles(nbRibbons); <font class="comment">// for benchmark purpose </font>
00466 <font class="keyword">const</font> uint numRibbonBatch = <a class="code" href="classNL3D_1_1CPSRibbon.html#z727_2">getNumRibbonsInVB</a>(); <font class="comment">// number of ribons to process at once </font>
00467 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> == 0) <font class="keywordflow">return</font>;
00469 <font class="comment">// Material setup //</font>
00471 <font class="comment"> CParticleSystem &ps = *(_Owner->getOwner());</font>
00472 <font class="keywordtype">bool</font> useGlobalColor = ps.getColorAttenuationScheme() != NULL;
00473 <font class="keywordflow">if</font> (useGlobalColor != <a class="code" href="classNL3D_1_1CPSRibbon.html#o5">_GlobalColor</a>)
00474 {
00475 <a class="code" href="classNL3D_1_1CPSRibbon.html#c2">touch</a>();
00476 }
00477 <a class="code" href="classNL3D_1_1CPSRibbon.html#c3">updateMaterial</a>();
00478 <a class="code" href="classNL3D_1_1CPSRibbon.html#c6">setupGlobalColor</a>();
00479 <font class="comment">//</font>
00480 <font class="keywordflow">if</font> (_ColorScheme)
00481 {
00482 colorOffset = VB.getColorOff();
00483 }
00485 <font class="comment">// Compute ribbons //</font>
00487 <font class="comment"> const uint numVerticesInSlice = getNumVerticesInSlice();</font>
00488 <font class="keyword">const</font> uint numVerticesInShape = <a class="code" href="classNL3D_1_1CPSRibbon.html#o1">_Shape</a>.size();
00489 <font class="comment">//</font>
00490 <font class="keyword">static</font> std::vector<float> sizes;
00491 <font class="keyword">static</font> std::vector<NLMISC::CVector> ribbonPos; <font class="comment">// this is where the position of each ribbon slice center i stored</font>
00492 ribbonPos.resize(<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1); <font class="comment">// make sure we have enough room</font>
00493 sizes.resize(numRibbonBatch);
00494
00495 <font class="comment">//</font>
00496 uint toProcess;
00497 uint ribbonIndex = 0; <font class="comment">// index of the first ribbon in the batch being processed </font>
00498 uint32 fpRibbonIndex = 0; <font class="comment">// fixed point index in source</font>
00499 <font class="keywordflow">do</font>
00500 {
00501 toProcess = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>((uint) (nbRibbons - ribbonIndex) , numRibbonBatch);
00502 currVert = (uint8 *) VB.getVertexCoordPointer();
00503
00505 <font class="keyword">const</font> <font class="keywordtype">float</font> *ptCurrSize;
00506 uint32 ptCurrSizeIncrement;
00507 <font class="keywordflow">if</font> (_SizeScheme)
00508 {
00509 ptCurrSize = (<font class="keywordtype">float</font> *) <a class="code" href="classNL3D_1_1CPSSizedParticle.html#n1">_SizeScheme</a>->make(this->_Owner, ribbonIndex, &sizes[0], <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>, srcStep);
00510 ptCurrSizeIncrement = 1;
00511 }
00512 <font class="keywordflow">else</font>
00513 {
00514 ptCurrSize = &<a class="code" href="classNL3D_1_1CPSSizedParticle.html#n0">_ParticleSize</a>;
00515 ptCurrSizeIncrement = 0;
00516 }
00517
00519 <font class="keywordflow">if</font> (_ColorScheme)
00520 {
00521 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a>->makeN(this->_Owner, ribbonIndex, currVert + colorOffset, vertexSize, toProcess, numVerticesInSlice * (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1), srcStep);
00522 }
00523 uint k = toProcess;
00525 <font class="comment">// interpolate and project points the result is directly setup in the vertex buffer //</font>
00527 <font class="comment"> if (!_Parametric)</font>
00528 {
00530 <font class="comment">// INCREMENTAL CASE //</font>
00532 <font class="comment"> if (_Tex != NULL) // textured case</font>
00533 {
00534 <font class="keywordflow">do</font>
00535 {
00536 <font class="keyword">const</font> <font class="keywordtype">float</font> ribbonSizeIncrement = *ptCurrSize / (float) <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>;
00537 ptCurrSize += ptCurrSizeIncrement;
00538 <font class="comment">// the parent class has a method to get the ribbons positions</font>
00539 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#b4">computeRibbon</a>((uint) (fpRibbonIndex >> 16), &ribbonPos[0], <font class="keyword">sizeof</font>(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>));
00540 currVert = <a class="code" href="namespaceNL3D.html#a449">ComputeTexturedRibbonMesh</a>(currVert,
00541 vertexSize,
00542 &ribbonPos[0],
00543 &<a class="code" href="classNL3D_1_1CPSRibbon.html#o1">_Shape</a>[0],
00544 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>,
00545 numVerticesInShape,
00546 ribbonSizeIncrement,
00547 *ptCurrSize
00548 );
00549 fpRibbonIndex += srcStep;
00550 }
00551 <font class="keywordflow">while</font> (--k);
00552 }
00553 <font class="keywordflow">else</font> <font class="comment">// untextured case</font>
00554 {
00555 <font class="keywordflow">do</font>
00556 {
00557 <font class="keyword">const</font> <font class="keywordtype">float</font> ribbonSizeIncrement = *ptCurrSize / (float) <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>;
00558 ptCurrSize += ptCurrSizeIncrement;
00559 <font class="comment">// the parent class has a method to get the ribbons positions</font>
00560 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#b4">computeRibbon</a>((uint) (fpRibbonIndex >> 16), &ribbonPos[0], <font class="keyword">sizeof</font>(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a>));
00561 currVert = <a class="code" href="namespaceNL3D.html#a448">ComputeUntexturedRibbonMesh</a>(currVert,
00562 vertexSize,
00563 &ribbonPos[0],
00564 &<a class="code" href="classNL3D_1_1CPSRibbon.html#o1">_Shape</a>[0],
00565 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>,
00566 numVerticesInShape,
00567 ribbonSizeIncrement,
00568 *ptCurrSize
00569 );
00570 fpRibbonIndex += srcStep;
00571 }
00572 <font class="keywordflow">while</font> (--k);
00573 }
00574 }
00575 <font class="keywordflow">else</font>
00576 {
00578 <font class="comment">// PARAMETRIC CASE //</font>
00580 <font class="comment"> if (_Tex != NULL) // textured case</font>
00581 {
00582 <font class="keywordflow">do</font>
00583 {
00584 <font class="keyword">const</font> <font class="keywordtype">float</font> ribbonSizeIncrement = *ptCurrSize / (float) <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>;
00585 ptCurrSize += ptCurrSizeIncrement;
00586 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->integrateSingle(date - <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n4">_UsedSegDuration</a> * (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1),
00587 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n4">_UsedSegDuration</a>,
00588 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1,
00589 (uint) (fpRibbonIndex >> 16),
00590 &ribbonPos[0]);
00591
00592 currVert = <a class="code" href="namespaceNL3D.html#a449">ComputeTexturedRibbonMesh</a>(currVert,
00593 vertexSize,
00594 &ribbonPos[0],
00595 &<a class="code" href="classNL3D_1_1CPSRibbon.html#o1">_Shape</a>[0],
00596 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>,
00597 numVerticesInShape,
00598 ribbonSizeIncrement,
00599 *ptCurrSize
00600 );
00601 fpRibbonIndex += srcStep;
00602 }
00603 <font class="keywordflow">while</font> (--k);
00604 }
00605 <font class="keywordflow">else</font> <font class="comment">// untextured case</font>
00606 {
00607 <font class="keywordflow">do</font>
00608 {
00609 <font class="keyword">const</font> <font class="keywordtype">float</font> ribbonSizeIncrement = *ptCurrSize / (float) <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>;
00610 ptCurrSize += ptCurrSizeIncrement;
00611 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->integrateSingle(date - <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n4">_UsedSegDuration</a> * (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1),
00612 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n4">_UsedSegDuration</a>,
00613 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1,
00614 (uint) (fpRibbonIndex >> 16),
00615 &ribbonPos[0]);
00616
00617 currVert = <a class="code" href="namespaceNL3D.html#a448">ComputeUntexturedRibbonMesh</a>(currVert,
00618 vertexSize,
00619 &ribbonPos[0],
00620 &<a class="code" href="classNL3D_1_1CPSRibbon.html#o1">_Shape</a>[0],
00621 <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>,
00622 numVerticesInShape,
00623 ribbonSizeIncrement,
00624 *ptCurrSize
00625 );
00626 fpRibbonIndex += srcStep;
00627 }
00628 <font class="keywordflow">while</font> (--k);
00629 }
00630 }
00631 <font class="comment">// display the result</font>
00632 PB.setNumTri((numVerticesInShape * <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> * toProcess) << 1);
00633 drv->render(PB, <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>);
00634 ribbonIndex += toProcess;
00635 }
00636 <font class="keywordflow">while</font> (ribbonIndex != nbRibbons);
00637
00638 }
00639
00640 <font class="comment">//========================================================================== </font>
<a name="l00641"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#a1">00641</a> <font class="keywordtype">bool</font> CPSRibbon::hasTransparentFaces(<font class="keywordtype">void</font>)
00642 {
00643 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSMaterial.html#a3">getBlendingMode</a>() != CPSMaterial::alphaTest ;
00644 }
00645
00646
00647 <font class="comment">//========================================================================== </font>
<a name="l00648"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#a2">00648</a> <font class="keywordtype">bool</font> CPSRibbon::hasOpaqueFaces(<font class="keywordtype">void</font>)
00649 {
00650 <font class="keywordflow">return</font> !<a class="code" href="classNL3D_1_1CPSRibbon.html#a1">hasTransparentFaces</a>();
00651 }
00652
00653 <font class="comment">//========================================================================== </font>
<a name="l00654"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#a3">00654</a> uint32 CPSRibbon::getMaxNumFaces(<font class="keywordtype">void</font>)<font class="keyword"> const</font>
00655 <font class="keyword"></font>{
00656 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
00657 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getMaxSize() * <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n0">_NbSegs</a>;
00658 }
00659
00660 <font class="comment">//========================================================================== </font>
<a name="l00661"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z727_1">00661</a> CPSRibbon::CVBnPB &CPSRibbon::getVBnPB()
00662 {
00663 <font class="keyword">static</font> <a class="code" href="classNL3D_1_1CPSRibbon.html#z727_0">TVBMap</a> * <font class="keyword">const</font> vbMaps[] =
00664 {
00666 &<a class="code" href="classNL3D_1_1CPSRibbon.html#z727_3">_VBMap</a>,
00667 &<a class="code" href="classNL3D_1_1CPSRibbon.html#z727_4">_FadedVBMap</a>,
00668 &<a class="code" href="classNL3D_1_1CPSRibbon.html#z727_5">_ColoredVBMap</a>,
00669 &<a class="code" href="classNL3D_1_1CPSRibbon.html#z727_6">_FadedColoredVBMap</a>,
00671 &<a class="code" href="classNL3D_1_1CPSRibbon.html#z727_7">_TexVBMap</a>,
00672 &<a class="code" href="classNL3D_1_1CPSRibbon.html#z727_8">_TexFadedVBMap</a>,
00673 &<a class="code" href="classNL3D_1_1CPSRibbon.html#z727_9">_TexColoredVBMap</a>,
00674 &<a class="code" href="classNL3D_1_1CPSRibbon.html#z727_10">_TexFadedColoredVBMap</a>
00675 };
00676
00678 <a class="code" href="classNL3D_1_1CPSRibbon.html#z727_0">TVBMap</a> &map = *vbMaps[ (<a class="code" href="classNL3D_1_1CPSRibbon.html#o0">_Tex</a> != NULL ? (1 << 2) : 0) | <font class="comment">// set bit 2 if textured</font>
00679 (<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> != NULL ? (1 << 1) : 0) | <font class="comment">// set bit 1 if per ribbon color</font>
00680 (<a class="code" href="classNL3D_1_1CPSRibbon.html#o4">_ColorFading</a> ? 1 : 0) <font class="comment">// set bit 0 if color fading</font>
00681 ];
00682
00683 <font class="keyword">const</font> uint numVerticesInSlice = <a class="code" href="classNL3D_1_1CPSRibbon.html#c10">getNumVerticesInSlice</a>();
00684 <font class="keyword">const</font> uint numVerticesInShape = <a class="code" href="classNL3D_1_1CPSRibbon.html#o1">_Shape</a>.size();
00685
00686
00687 <font class="comment">// The number of slice is encoded in the upper word of the vb index</font>
00688 <font class="comment">// The number of vertices per slices is encoded in the lower word</font>
00689 uint VBnPDIndex = ((<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1) << 16) | numVerticesInSlice;
00690 TVBMap::iterator it = map.find(VBnPDIndex);
00691 <font class="keywordflow">if</font> (it != map.end())
00692 {
00693 <font class="keywordflow">return</font> it->second;
00694 }
00695 <font class="keywordflow">else</font> <font class="comment">// must create this vb, with few different size, it is still interseting, though they are only destroyed at exit</font>
00696 {
00697 <font class="keyword">const</font> uint numRibbonInVB = <a class="code" href="classNL3D_1_1CPSRibbon.html#z727_2">getNumRibbonsInVB</a>();
00698 CVBnPB &VBnPB = map[VBnPDIndex]; <font class="comment">// make an entry</font>
00699
00703 CVertexBuffer &vb = VBnPB.VB;
00704 vb.setVertexFormat(CVertexBuffer::PositionFlag | <font class="comment">/* alway need position */</font>
00705 (<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> || <a class="code" href="classNL3D_1_1CPSRibbon.html#o4">_ColorFading</a> ? CVertexBuffer::PrimaryColorFlag : 0) | <font class="comment">/* need a color ? */</font>
00706 ((<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> && <a class="code" href="classNL3D_1_1CPSRibbon.html#o4">_ColorFading</a>) || <a class="code" href="classNL3D_1_1CPSRibbon.html#o0">_Tex</a> != NULL ? CVertexBuffer::TexCoord0Flag : 0) | <font class="comment">/* need texture coordinates ? */</font>
00707 (<a class="code" href="classNL3D_1_1CPSRibbon.html#o0">_Tex</a> != NULL && <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> && <a class="code" href="classNL3D_1_1CPSRibbon.html#o4">_ColorFading</a> ? CVertexBuffer::TexCoord1Flag : 0) <font class="comment">/* need 2nd texture coordinates ? */</font>
00708 );
00709 vb.setNumVertices((<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1) * numRibbonInVB * numVerticesInSlice); <font class="comment">// 1 seg = 1 line + terminal vertices</font>
00710
00711 <font class="comment">// set the primitive block size</font>
00712 CPrimitiveBlock &pb = VBnPB.PB;
00713 pb.setNumTri((<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> * numRibbonInVB * <a class="code" href="classNL3D_1_1CPSRibbon.html#o1">_Shape</a>.size()) << 1);
00715 uint vbIndex = 0;
00716 uint pbIndex = 0;
00717 uint i, k, <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>;
00718 <font class="keywordflow">for</font> (i = 0; i < numRibbonInVB; ++i)
00719 {
00720 <font class="keywordflow">for</font> (k = 0; k < (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1); ++k)
00721 {
00722
00724 <font class="keywordflow">if</font> (k != <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>)
00725 {
00726 uint vIndex = vbIndex;
00727 <font class="keywordflow">for</font> (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = 0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> < (numVerticesInShape - 1); ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
00728 {
00729 pb.setTri(pbIndex ++, vIndex, vIndex + numVerticesInSlice, vIndex + numVerticesInSlice + 1);
00730 pb.setTri(pbIndex ++, vIndex, vIndex + numVerticesInSlice + 1, vIndex + 1);
00731 ++ vIndex;
00732 }
00733
00735 uint nextVertexIndex = (numVerticesInShape == numVerticesInSlice) ? vIndex + 1 - numVerticesInShape <font class="comment">// no texture -> we loop </font>
00736 : vIndex + 1; <font class="comment">// a texture is used : use onemore vertex </font>
00737 pb.setTri(pbIndex ++, vIndex, vIndex + numVerticesInSlice, nextVertexIndex + numVerticesInSlice);
00738 pb.setTri(pbIndex ++, vIndex, nextVertexIndex + numVerticesInSlice, nextVertexIndex);
00739
00740 }
00741
00743 <font class="keywordflow">for</font> (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = 0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> < numVerticesInSlice; ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
00744 {
00745 <a class="code" href="debug_8h.html#a6">nlassert</a>(vbIndex < vb.getNumVertices());
00747 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSRibbon.html#o0">_Tex</a> != NULL)
00748 {
00749 vb.setTexCoord(vbIndex,
00750 <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> && <a class="code" href="classNL3D_1_1CPSRibbon.html#o4">_ColorFading</a> ? 1 : 0, <font class="comment">// must we use the second texture coord ? (when 1st one used by the gradient texture : we can't encode it in the diffuse as it encodes each ribbon color)</font>
00751 (<font class="keywordtype">float</font>) k / <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>, <font class="comment">// u</font>
00752 1.f - (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> / (<font class="keywordtype">float</font>) numVerticesInShape) <font class="comment">// v</font>
00753 );
00754 }
00755
00757 <font class="keywordflow">if</font> (_ColorFading)
00758 {
00759 <font class="comment">// If not per ribbon color, we can encode it in the diffuse</font>
00760 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> == NULL)
00761 {
00762 uint8 intensity = (uint8) (255 * (1.f - ((float) k / <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>)));
00763 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> col(intensity, intensity, intensity, intensity);
00764 vb.setColor(vbIndex, col);
00765 }
00766 <font class="keywordflow">else</font> <font class="comment">// encode it in the first texture</font>
00767 {
00768 vb.setTexCoord(vbIndex, 0, 0.5f - 0.5f * ((<font class="keywordtype">float</font>) k / <a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a>), 0);
00769 }
00770 }
00771 ++ vbIndex;
00772 }
00773
00774 }
00775 }
00776 <font class="keywordflow">return</font> VBnPB;
00777 }
00778 }
00779
00780 <font class="comment">//========================================================================== </font>
<a name="l00781"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#z727_2">00781</a> uint CPSRibbon::getNumRibbonsInVB()<font class="keyword"> const</font>
00782 <font class="keyword"></font>{
00783 <font class="keyword">const</font> uint numVerticesInSlice = <a class="code" href="classNL3D_1_1CPSRibbon.html#c10">getNumVerticesInSlice</a>();
00784 <font class="keyword">const</font> uint vertexInVB = 512;
00785 <font class="keywordflow">return</font> std::max(1u, (uint) (vertexInVB / (numVerticesInSlice * (<a class="code" href="classNL3D_1_1CPSRibbonBase.html#n3">_UsedNbSegs</a> + 1))));
00786 }
00787
00788
00789 <font class="comment">//========================================================================== </font>
<a name="l00790"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#c5">00790</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CPSRibbon::updateUntexturedMaterial()
00791 {
00793 <font class="comment">// UNTEXTURED RIBBON //</font>
00795 <font class="comment"></font>
00796 <font class="keyword">static</font> <a class="code" href="classNLMISC_1_1CRefPtr.html">NLMISC::CRefPtr<ITexture></a> ptGradTexture;
00797
00798 CParticleSystem &ps = *(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner());
00799 <font class="keywordflow">if</font> (_ColorScheme)
00800 { <font class="comment">// PER RIBBON COLOR</font>
00801 <font class="keywordflow">if</font> (ps.getColorAttenuationScheme())
00802 {
00803 <font class="keywordflow">if</font> (_ColorFading) <font class="comment">// global color + fading + per ribbon color</font>
00804 {
00805 <font class="comment">// the first stage is used to get fading * global color</font>
00806 <font class="comment">// the second stage multiply the result by the diffuse colot</font>
00807 <font class="keywordflow">if</font> (ptGradTexture == NULL) <font class="comment">// have we got a gradient texture ?</font>
00808 {
00809 ptGradTexture = <a class="code" href="namespaceNL3D.html#a445">CreateGradientTexture</a>();
00810 }
00811 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(0, ptGradTexture);
00812 CPSMaterial::forceTexturedMaterialStages(2); <font class="comment">// use constant color 0 * diffuse, 1 stage needed</font>
00813 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Texture, CMaterial::Constant);
00814 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 1, CMaterial::Previous, CMaterial::Diffuse);
00815 }
00816 <font class="keywordflow">else</font> <font class="comment">// per ribbon color with global color </font>
00817 {
00818 CPSMaterial::forceTexturedMaterialStages(1); <font class="comment">// use constant color 0 * diffuse, 1 stage needed</font>
00819 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Diffuse, CMaterial::Constant);
00820 }
00821 }
00822 <font class="keywordflow">else</font>
00823 {
00824 <font class="keywordflow">if</font> (_ColorFading) <font class="comment">// per ribbon color, no fading</font>
00825 {
00826 <font class="keywordflow">if</font> (ptGradTexture == NULL) <font class="comment">// have we got a gradient texture ?</font>
00827 {
00828 ptGradTexture = <a class="code" href="namespaceNL3D.html#a445">CreateGradientTexture</a>();
00829 }
00830 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(0, ptGradTexture);
00831 CPSMaterial::forceTexturedMaterialStages(1);
00832 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Texture, CMaterial::Diffuse);
00833 }
00834 <font class="keywordflow">else</font> <font class="comment">// per color ribbon with no fading, and no global color</font>
00835 {
00836 CPSMaterial::forceTexturedMaterialStages(0); <font class="comment">// no texture use constant diffuse only</font>
00837 }
00838 }
00839 }
00840 <font class="keywordflow">else</font> <font class="comment">// GLOBAL COLOR</font>
00841 {
00842 <font class="keywordflow">if</font> (_ColorFading)
00843 {
00844 CPSMaterial::forceTexturedMaterialStages(1); <font class="comment">// use constant color 0 * diffuse, 1 stage needed </font>
00845 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Diffuse, CMaterial::Constant);
00846 }
00847 <font class="keywordflow">else</font> <font class="comment">// color attenuation, no fading : </font>
00848 {
00849 CPSMaterial::forceTexturedMaterialStages(0); <font class="comment">// no texture use constant diffuse only </font>
00850 }
00851 }
00852 <a class="code" href="classNL3D_1_1CPSRibbon.html#o6">_Touch</a> = <font class="keyword">false</font>;
00853 }
00854
00855 <font class="comment">//========================================================================== </font>
<a name="l00856"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#c4">00856</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CPSRibbon::updateTexturedMaterial()
00857 {
00859 <font class="comment">// TEXTURED RIBBON //</font>
00861 <font class="comment"></font>
00862 <font class="keyword">static</font> <a class="code" href="classNLMISC_1_1CRefPtr.html">NLMISC::CRefPtr<ITexture></a> ptGradTexture;
00863 CParticleSystem &ps = *(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner());
00864 <font class="keywordflow">if</font> (_ColorScheme)
00865 { <font class="comment">// PER RIBBON COLOR</font>
00866 <font class="keywordflow">if</font> (ps.getColorAttenuationScheme())
00867 {
00868 <font class="keywordflow">if</font> (_ColorFading) <font class="comment">// global color + fading + per ribbon color</font>
00869 {
00870 <font class="keywordflow">if</font> (ptGradTexture == NULL) <font class="comment">// have we got a gradient texture ?</font>
00871 {
00872 ptGradTexture = <a class="code" href="namespaceNL3D.html#a445">CreateGradientTexture</a>(); <font class="comment">// create it</font>
00873 }
00875 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(0, ptGradTexture);
00876 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(1, <a class="code" href="classNL3D_1_1CPSRibbon.html#o0">_Tex</a>);
00877 CPSMaterial::forceTexturedMaterialStages(3); <font class="comment">// use constant color 0 * diffuse, 1 stage needed </font>
00878 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Texture, CMaterial::Diffuse);
00879 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 1, CMaterial::Texture, CMaterial::Previous);
00880 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 2, CMaterial::Previous, CMaterial::Constant);
00881 }
00882 <font class="keywordflow">else</font> <font class="comment">// per ribbon color with global color </font>
00883 {
00884 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(0, <a class="code" href="classNL3D_1_1CPSRibbon.html#o0">_Tex</a>);
00885 CPSMaterial::forceTexturedMaterialStages(2); <font class="comment">// use constant color 0 * diffuse, 1 stage needed </font>
00886 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Texture, CMaterial::Diffuse);
00887 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 1, CMaterial::Previous, CMaterial::Constant);
00888 }
00889 }
00890 <font class="keywordflow">else</font>
00891 {
00892 <font class="keywordflow">if</font> (_ColorFading) <font class="comment">// per ribbon color, fading : 2 textures needed</font>
00893 {
00894 <font class="keywordflow">if</font> (ptGradTexture == NULL) <font class="comment">// have we got a gradient texture ?</font>
00895 {
00896 ptGradTexture = <a class="code" href="namespaceNL3D.html#a445">CreateGradientTexture</a>(); <font class="comment">// create it</font>
00897 }
00898 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(0, ptGradTexture);
00899 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(1, <a class="code" href="classNL3D_1_1CPSRibbon.html#o0">_Tex</a>);
00900 CPSMaterial::forceTexturedMaterialStages(2);
00901 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Texture, CMaterial::Diffuse); <font class="comment">// texture * ribbon color</font>
00902 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 1, CMaterial::Texture, CMaterial::Previous); <font class="comment">// * gradient</font>
00903 }
00904 <font class="keywordflow">else</font> <font class="comment">// per color ribbon with no fading, and no global color</font>
00905 {
00906 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(0, <a class="code" href="classNL3D_1_1CPSRibbon.html#o0">_Tex</a>);
00907 CPSMaterial::forceTexturedMaterialStages(1); <font class="comment">// no texture use constant diffuse only</font>
00908 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Texture, CMaterial::Diffuse);
00909 }
00910 }
00911 }
00912 <font class="keywordflow">else</font> <font class="comment">// GLOBAL COLOR</font>
00913 {
00914
00915 <font class="keywordflow">if</font> (_ColorFading) <font class="comment">// gradient is encoded in diffuse</font>
00916 {
00917 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(0, <a class="code" href="classNL3D_1_1CPSRibbon.html#o0">_Tex</a>);
00918 CPSMaterial::forceTexturedMaterialStages(2); <font class="comment">// use constant color 0 * diffuse, 1 stage needed </font>
00919 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Texture, CMaterial::Diffuse);
00920 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 1, CMaterial::Previous, CMaterial::Constant);
00921 }
00922 <font class="keywordflow">else</font> <font class="comment">// constant color</font>
00923 {
00924 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setTexture(0, <a class="code" href="classNL3D_1_1CPSRibbon.html#o0">_Tex</a>);
00925 CPSMaterial::forceTexturedMaterialStages(1); <font class="comment">// no texture use constant diffuse only </font>
00926 <a class="code" href="namespaceNL3D.html#a439">SetupModulatedStage</a>(<a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>, 0, CMaterial::Texture, CMaterial::Diffuse);
00927 }
00928 }
00929 <a class="code" href="classNL3D_1_1CPSRibbon.html#o6">_Touch</a> = <font class="keyword">false</font>;
00930 }
00931
00932 <font class="comment">//========================================================================== </font>
<a name="l00933"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#c3">00933</a> <font class="keywordtype">void</font> CPSRibbon::updateMaterial()
00934 {
00935 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSRibbon.html#o6">_Touch</a>) <font class="keywordflow">return</font>;
00936 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSRibbon.html#o0">_Tex</a> != NULL)
00937 {
00938 <a class="code" href="classNL3D_1_1CPSRibbon.html#c4">updateTexturedMaterial</a>();
00939 <a class="code" href="classNL3D_1_1CPSRibbon.html#c9">setupTextureMatrix</a>();
00940 }
00941 <font class="keywordflow">else</font>
00942 {
00943 <a class="code" href="classNL3D_1_1CPSRibbon.html#c5">updateUntexturedMaterial</a>();
00944 }
00945 }
00946
00947
00948
00949 <font class="comment">//========================================================================== </font>
<a name="l00950"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#c8">00950</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CPSRibbon::setupUntexturedGlobalColor()
00951 {
00953 CParticleSystem &ps = *(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner());
00954 <font class="keywordflow">if</font> (_ColorScheme)
00955 {
00956 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texConstantColor(0, ps.getGlobalColor());
00957 }
00958 <font class="keywordflow">else</font> <font class="comment">// GLOBAL COLOR with / without fading</font>
00959 {
00960 <font class="keywordflow">if</font> (ps.getColorAttenuationScheme())
00961 {
00962 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> col;
00963 col.<a class="code" href="classNLMISC_1_1CRGBA.html#a9">modulateFromColor</a>(ps.getGlobalColor(), <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n0">_Color</a>);
00964 <font class="keywordflow">if</font> (_ColorFading)
00965 {
00966 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texConstantColor(0, col);
00967 }
00968 <font class="keywordflow">else</font> <font class="comment">// color attenuation, no fading : </font>
00969 {
00970 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setColor(col);
00971 }
00972 }
00973 <font class="keywordflow">else</font>
00974 {
00975 <font class="keywordflow">if</font> (_ColorFading)
00976 {
00977 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texConstantColor(0, <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n0">_Color</a>);
00978 }
00979 <font class="keywordflow">else</font> <font class="comment">// constant color</font>
00980 {
00981 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setColor(<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n0">_Color</a>);
00982 }
00983 }
00984 }
00985 }
00986
00987 <font class="comment">//========================================================================== </font>
<a name="l00988"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#c7">00988</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CPSRibbon::setupTexturedGlobalColor()
00989 {
00991 CParticleSystem &ps = *(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner());
00992 <font class="keywordflow">if</font> (_ColorScheme)
00993 {
00994 <font class="keywordflow">if</font> (ps.getColorAttenuationScheme() && <a class="code" href="classNL3D_1_1CPSRibbon.html#o4">_ColorFading</a>)
00995 {
00996 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texConstantColor(2, ps.getGlobalColor());
00997 }
00998 <font class="keywordflow">else</font>
00999 {
01000 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texConstantColor(1, ps.getGlobalColor());
01001 }
01002 }
01003 <font class="keywordflow">else</font> <font class="comment">// GLOBAL COLOR with / without fading</font>
01004 {
01005 <font class="keywordflow">if</font> (ps.getColorAttenuationScheme())
01006 {
01007 <a class="code" href="classNLMISC_1_1CRGBA.html">NLMISC::CRGBA</a> col;
01008 col.<a class="code" href="classNLMISC_1_1CRGBA.html#a9">modulateFromColor</a>(ps.getGlobalColor(), <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n0">_Color</a>);
01009 <font class="keywordflow">if</font> (_ColorFading)
01010 {
01011 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texConstantColor(1, col);
01012 }
01013 <font class="keywordflow">else</font> <font class="comment">// color attenuation, no fading : </font>
01014 {
01015 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setColor(col);
01016 }
01017 }
01018 <font class="keywordflow">else</font>
01019 {
01020 <font class="keywordflow">if</font> (_ColorFading)
01021 {
01022 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.texConstantColor(1, <a class="code" href="classNL3D_1_1CPSColoredParticle.html#n0">_Color</a>);
01023 }
01024 <font class="keywordflow">else</font> <font class="comment">// constant color</font>
01025 {
01026 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setColor(<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n0">_Color</a>);
01027 }
01028 }
01029 }
01030 }
01031
01032
01033 <font class="comment">//========================================================================== </font>
<a name="l01034"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#c6">01034</a> <font class="keywordtype">void</font> CPSRibbon::setupGlobalColor()
01035 {
01036 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSRibbon.html#o0">_Tex</a> != NULL) <a class="code" href="classNL3D_1_1CPSRibbon.html#c7">setupTexturedGlobalColor</a>();
01037 <font class="keywordflow">else</font> <a class="code" href="classNL3D_1_1CPSRibbon.html#c8">setupUntexturedGlobalColor</a>();
01038 }
01039
01040 <font class="comment">//========================================================================== </font>
<a name="l01041"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#c9">01041</a> <font class="keywordtype">void</font> CPSRibbon::setupTextureMatrix()
01042 {
01043 uint stage = (<a class="code" href="classNL3D_1_1CPSColoredParticle.html#n1">_ColorScheme</a> != NULL && <a class="code" href="classNL3D_1_1CPSRibbon.html#o4">_ColorFading</a> == <font class="keyword">true</font>) ? 1 : 0;
01044 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSRibbon.html#o2">_UFactor</a> != 1.f || <a class="code" href="classNL3D_1_1CPSRibbon.html#o3">_VFactor</a> != 1.f)
01045 {
01046 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.enableUserTexMat(stage);
01047 CMatrix texMat;
01048 texMat.setRot(<a class="code" href="classNL3D_1_1CPSRibbon.html#o2">_UFactor</a> * <a class="code" href="classNLMISC_1_1CVector.html#p1">NLMISC::CVector::I</a>,
01049 <a class="code" href="classNL3D_1_1CPSRibbon.html#o3">_VFactor</a> * <a class="code" href="classNLMISC_1_1CVector.html#p2">NLMISC::CVector::J</a>,
01050 <a class="code" href="classNLMISC_1_1CVector.html#p3">NLMISC::CVector::K</a>
01051 );
01052 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.setUserTexMat(stage, texMat);
01053 }
01054 <font class="keywordflow">else</font>
01055 {
01056 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.enableUserTexMat(stage, <font class="keyword">false</font>);
01057 }
01058 <a class="code" href="classNL3D_1_1CPSMaterial.html#n0">_Mat</a>.enableUserTexMat(1 - stage, <font class="keyword">false</font>);
01059 }
01060
01061 <font class="comment">//========================================================================== </font>
<a name="l01063"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#a10">01063</a> <font class="comment">void CPSRibbon::setShape(const CVector *shape, uint32 nbPointsInShape)</font>
01064 {
01065 <a class="code" href="debug_8h.html#a6">nlassert</a>(nbPointsInShape >= 3);
01066 _Shape.resize(nbPointsInShape);
01067 std::copy(shape, shape + nbPointsInShape, _Shape.begin());
01068 }
01069
<a name="l01071"></a><a class="code" href="classNL3D_1_1CPSRibbon.html#a12">01071</a> <font class="keywordtype">void</font> CPSRibbon::getShape(CVector *shape)<font class="keyword"> const</font>
01072 <font class="keyword"></font>{
01073 std::copy(<a class="code" href="classNL3D_1_1CPSRibbon.html#o1">_Shape</a>.begin(), <a class="code" href="classNL3D_1_1CPSRibbon.html#o1">_Shape</a>.end(), shape);
01074 }
01075
01076
01077
01078 } <font class="comment">// NL3D</font>
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|