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
|
<!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>particle_system.cpp</h1><a href="particle__system_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="particle__system_8h.html">3d/particle_system.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="ps__located_8h.html">3d/ps_located.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="vertex__buffer_8h.html">3d/vertex_buffer.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="material_8h.html">3d/material.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="3d_2primitive__block_8h.html">3d/primitive_block.h</a>"</font>
00034 <font class="preprocessor">#include "<a class="code" href="nelu_8h.html">3d/nelu.h</a>"</font>
00035 <font class="preprocessor">#include "<a class="code" href="ps__util_8h.html">3d/ps_util.h</a>"</font>
00036 <font class="preprocessor">#include "<a class="code" href="ps__particle_8h.html">3d/ps_particle.h</a>"</font>
00037 <font class="preprocessor">#include "<a class="code" href="ps__sound_8h.html">3d/ps_sound.h</a>"</font>
00038 <font class="preprocessor">#include "<a class="code" href="particle__system__shape_8h.html">3d/particle_system_shape.h</a>"</font>
00039 <font class="preprocessor">#include "<a class="code" href="aabbox_8h.html">nel/misc/aabbox.h</a>"</font>
00040 <font class="preprocessor">#include "<a class="code" href="file_8h.html">nel/misc/file.h</a>"</font>
00041 <font class="preprocessor">#include "<a class="code" href="stream_8h.html">nel/misc/stream.h</a>"</font>
00042
00043
00044
00045
00046 <font class="keyword">namespace </font>NL3D
00047 {
00048
<a name="l00049"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#p0">00049</a> uint32 CParticleSystem::NbParticlesDrawn = 0;
<a name="l00050"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#r2">00050</a> UPSSoundServer * CParticleSystem::_SoundServer = NULL;
<a name="l00051"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#r0">00051</a> CParticleSystem::TGlobalValuesMap CParticleSystem::_GlobalValuesMap;
<a name="l00052"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#r1">00052</a> CParticleSystem::TGlobalVectorValuesMap CParticleSystem::_GlobalVectorValuesMap;
00053
00054
00056 <font class="comment">// CPaticleSystem implementation //</font>
00058 <font class="comment"></font>
00059
00061 <font class="keyword">const</font> <font class="keywordtype">float</font> <a class="code" href="namespaceNL3D.html#a164">PSDefaultMaxViewDist</a> = 300.f;
00062
00063 <font class="comment">/*</font>
00064 <font class="comment"> * Constructor</font>
00065 <font class="comment"> */</font>
<a name="l00066"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z633_0">00066</a> CParticleSystem::CParticleSystem() : _Driver(NULL),
00067 _FontGenerator(NULL),
00068 _FontManager(NULL),
00069 _Date(0),
00070 _LastUpdateDate(-1),
00071 _CurrEditedElementLocated(NULL),
00072 _CurrEditedElementIndex(0),
00073 _Scene(NULL),
00074 _TimeThreshold(0.15f),
00075 _SystemDate(0.f),
00076 _MaxNbIntegrations(2),
00077 _LODRatio(0.5f),
00078 _OneMinusCurrentLODRatio(0),
00079 _MaxViewDist(<a class="code" href="namespaceNL3D.html#a164">PSDefaultMaxViewDist</a>),
00080 _InvMaxViewDist(1.f / <a class="code" href="namespaceNL3D.html#a164">PSDefaultMaxViewDist</a>),
00081 _InvCurrentViewDist(1.f / <a class="code" href="namespaceNL3D.html#a164">PSDefaultMaxViewDist</a>),
00082 _DieCondition(none),
00083 _DelayBeforeDieTest(0.2f),
00084 _MaxNumFacesWanted(0),
00085 _AnimType(AnimInCluster),
00086 _UserParamGlobalValue(NULL),
00087 _BypassGlobalUserParam(0),
00088 _PresetBehaviour(UserBehaviour),
00089 _AutoLODStartDistPercent(0.3f),
00090 _AutoLODDegradationExponent(1),
00091 _ColorAttenuationScheme(NULL),
00092 _GlobalColor(NLMISC::CRGBA::White),
00093 _ComputeBBox(true),
00094 _BBoxTouched(true),
00095 _AccurateIntegration(true),
00096 _CanSlowDown(true),
00097 _DestroyModelWhenOutOfRange(false),
00098 _DestroyWhenOutOfFrustum(false),
00099 _Sharing(false),
00100 _AutoLOD(false),
00101 _KeepEllapsedTimeForLifeUpdate(false),
00102 _AutoLODSkipParticles(false),
00103 _EnableLoadBalancing(true),
00104 _InverseEllapsedTime(0.f),
00105 _CurrentDeltaPos(NLMISC::CVector::Null),
00106 _DeltaPos(NLMISC::CVector::Null)
00107
00108 {
00109 std::fill(<a class="code" href="classNL3D_1_1CParticleSystem.html#o31">_UserParam</a>, <a class="code" href="classNL3D_1_1CParticleSystem.html#o31">_UserParam</a> + <a class="code" href="namespaceNL3D.html#a165">MaxPSUserParam</a>, 0);
00110 }
00111
00112
<a name="l00115"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z649_0">00115</a> <font class="keywordtype">void</font> CParticleSystem::stopSound()
00116 {
00117 <font class="keywordflow">for</font> (uint k = 0; k < this-><a class="code" href="classNL3D_1_1CParticleSystem.html#z639_5">getNbProcess</a>(); ++k)
00118 {
00119 CPSLocated *psl = dynamic_cast<NL3D::CPSLocated *>(this-><a class="code" href="classNL3D_1_1CParticleSystem.html#z639_6">getProcess</a>(k));
00120 <font class="keywordflow">if</font> (psl)
00121 {
00122 <font class="keywordflow">for</font> (uint <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = 0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> < psl->getNbBoundObjects(); ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
00123 {
00124 <font class="keywordflow">if</font> (psl->getBoundObject(l)->getType() == <a class="code" href="namespaceNL3D.html#a207">PSSound</a>)
00125 {
00126 static_cast<CPSSound *>(psl->getBoundObject(<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>))->stopSound();
00127
00128 }
00129 }
00130 }
00131 }
00132 }
00133
<a name="l00135"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z649_1">00135</a> <font class="keywordtype">void</font> CParticleSystem::reactivateSound()
00136 {
00137 <font class="keywordflow">for</font> (uint k = 0; k < this-><a class="code" href="classNL3D_1_1CParticleSystem.html#z639_5">getNbProcess</a>(); ++k)
00138 {
00139 CPSLocated *psl = dynamic_cast<NL3D::CPSLocated *>(this-><a class="code" href="classNL3D_1_1CParticleSystem.html#z639_6">getProcess</a>(k));
00140 <font class="keywordflow">if</font> (psl)
00141 {
00142 <font class="keywordflow">for</font> (uint <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = 0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> < psl->getNbBoundObjects(); ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
00143 {
00144 <font class="keywordflow">if</font> (psl->getBoundObject(l)->getType() == NL3D::PSSound)
00145 {
00146 static_cast<CPSSound *>(psl->getBoundObject(<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>))->reactivateSound();
00147 }
00148 }
00149 }
00150 }
00151 }
00152
00153
<a name="l00155"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z646_4">00155</a> <font class="keywordtype">void</font> CParticleSystem::enableLoadBalancing(<font class="keywordtype">bool</font> enabled <font class="comment">/*=true*/</font>)
00156 {
00157 <font class="keywordflow">if</font> (enabled)
00158 {
00159 <a class="code" href="classNL3D_1_1CParticleSystem.html#z646_2">notifyMaxNumFacesChanged</a>();
00160 }
00161 <a class="code" href="classNL3D_1_1CParticleSystem.html#o50">_EnableLoadBalancing</a> = enabled;
00162 }
00163
<a name="l00165"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z646_2">00165</a> <font class="keywordtype">void</font> CParticleSystem::notifyMaxNumFacesChanged(<font class="keywordtype">void</font>)
00166 {
00167 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CParticleSystem.html#o50">_EnableLoadBalancing</a>) <font class="keywordflow">return</font>;
00168 <a class="code" href="classNL3D_1_1CParticleSystem.html#o29">_MaxNumFacesWanted</a> = 0;
00169 <font class="keywordflow">for</font> (TProcessVect::iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(); it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(); ++it)
00170 {
00171 <a class="code" href="classNL3D_1_1CParticleSystem.html#o29">_MaxNumFacesWanted</a> += (*it)->querryMaxWantedNumFaces();
00172 }
00173 }
00174
00175
<a name="l00177"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z646_0">00177</a> <font class="keywordtype">float</font> CParticleSystem::getWantedNumTris(<font class="keywordtype">float</font> dist)
00178 {
00179 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CParticleSystem.html#o50">_EnableLoadBalancing</a>) <font class="keywordflow">return</font> 0; <font class="comment">// no contribution to the load balancing</font>
00180 <font class="keywordflow">if</font> (dist > <a class="code" href="classNL3D_1_1CParticleSystem.html#o24">_MaxViewDist</a>) <font class="keywordflow">return</font> 0;
00181 <font class="keywordtype">float</font> retValue = ((1.f - dist * <a class="code" href="classNL3D_1_1CParticleSystem.html#o25">_InvMaxViewDist</a>) * <a class="code" href="classNL3D_1_1CParticleSystem.html#o29">_MaxNumFacesWanted</a>);
00183 <font class="keywordflow">return</font> retValue;
00184 }
00185
00186
<a name="l00188"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z646_1">00188</a> <font class="keywordtype">void</font> CParticleSystem::setNumTris(uint numFaces)
00189 {
00190 <font class="keywordflow">if</font> (_EnableLoadBalancing)
00191 {
00192 <font class="keywordtype">float</font> modelDist = (<a class="code" href="classNL3D_1_1CParticleSystem.html#o7">_SysMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>() - <a class="code" href="classNL3D_1_1CParticleSystem.html#o6">_InvertedViewMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>()).norm();
00193 <font class="comment">/*uint numFaceWanted = (uint) getWantedNumTris(modelDist);*/</font>
00194
00195 <font class="keyword">const</font> <font class="keywordtype">float</font> epsilon = 10E-5f;
00196
00197
00198 uint wantedNumTri = (uint) <a class="code" href="classNL3D_1_1CParticleSystem.html#z646_0">getWantedNumTris</a>(modelDist);
00199 <font class="keywordflow">if</font> (numFaces >= wantedNumTri || wantedNumTri == 0 || <a class="code" href="classNL3D_1_1CParticleSystem.html#o29">_MaxNumFacesWanted</a> == 0 || modelDist < epsilon)
00200 {
00201 <a class="code" href="classNL3D_1_1CParticleSystem.html#o26">_InvCurrentViewDist</a> = <a class="code" href="classNL3D_1_1CParticleSystem.html#o25">_InvMaxViewDist</a>;
00202 }
00203 <font class="keywordflow">else</font>
00204 {
00205
00206 <a class="code" href="classNL3D_1_1CParticleSystem.html#o26">_InvCurrentViewDist</a> = (<a class="code" href="classNL3D_1_1CParticleSystem.html#o29">_MaxNumFacesWanted</a> - numFaces) / ( <a class="code" href="classNL3D_1_1CParticleSystem.html#o29">_MaxNumFacesWanted</a> * modelDist);
00207 }
00208 }
00209 <font class="keywordflow">else</font>
00210 {
00211 <font class="comment">// always take full detail when there's no load balancing</font>
00212 <a class="code" href="classNL3D_1_1CParticleSystem.html#o26">_InvCurrentViewDist</a> = <a class="code" href="classNL3D_1_1CParticleSystem.html#o25">_InvMaxViewDist</a>;
00213 }
00214 }
00215
00216
<a name="l00219"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z633_1">00219</a> CParticleSystem::~CParticleSystem()
00220 {
00221 <font class="keywordflow">for</font> (TProcessVect::iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(); it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(); ++it)
00222 {
00223 <font class="keyword">delete</font> *it;
00224 }
00225 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#o38">_ColorAttenuationScheme</a>;
00226 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>;
00227 }
00228
<a name="l00230"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z637_4">00230</a> <font class="keywordtype">void</font> CParticleSystem::setViewMat(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> &m)
00231 {
00232 <a class="code" href="classNL3D_1_1CParticleSystem.html#o5">_ViewMat</a> = m;
00233 <a class="code" href="classNL3D_1_1CParticleSystem.html#o6">_InvertedViewMat</a> = m.<a class="code" href="classNLMISC_1_1CMatrix.html#z293_7">inverted</a>();
00234 }
00235
<a name="l00237"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z648_11">00237</a> <font class="keywordtype">bool</font> CParticleSystem::hasEmitters(<font class="keywordtype">void</font>)<font class="keyword"> const</font>
00238 <font class="keyword"></font>{
00239 <font class="keywordflow">for</font> (TProcessVect::const_iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(); it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(); ++it)
00240 {
00241 <font class="keywordflow">if</font> ((*it)->hasEmitters()) <font class="keywordflow">return</font> <font class="keyword">true</font>;
00242 }
00243 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00244 }
00245
<a name="l00247"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z648_12">00247</a> <font class="keywordtype">bool</font> CParticleSystem::hasParticles(<font class="keywordtype">void</font>)<font class="keyword"> const</font>
00248 <font class="keyword"></font>{
00249 <font class="keywordflow">for</font> (TProcessVect::const_iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(); it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(); ++it)
00250 {
00251 <font class="keywordflow">if</font> ((*it)->hasParticles()) <font class="keywordflow">return</font> <font class="keyword">true</font>;
00252 }
00253 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00254 }
00255
<a name="l00257"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#c0">00257</a> <font class="keywordtype">void</font> CParticleSystem::stepLocated(<a class="code" href="namespaceNL3D.html#a484">TPSProcessPass</a> pass, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> et, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> realEt)
00258 {
00259 <font class="keywordflow">for</font> (TProcessVect::iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(); it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(); ++it)
00260 {
00261 (*it)->step(pass, et, realEt);
00262 }
00263 }
00264
00265
<a name="l00267"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#c1">00267</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CParticleSystem::updateLODRatio()
00268 {
00269 <font class="comment">// temp</font>
00270 CVector sysPos = <a class="code" href="classNL3D_1_1CParticleSystem.html#o7">_SysMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>();
00271 CVector obsPos = <a class="code" href="classNL3D_1_1CParticleSystem.html#o6">_InvertedViewMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>();
00272 <font class="keyword">const</font> CVector d = <a class="code" href="classNL3D_1_1CParticleSystem.html#o7">_SysMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>() - <a class="code" href="classNL3D_1_1CParticleSystem.html#o6">_InvertedViewMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>();
00273 <a class="code" href="classNL3D_1_1CParticleSystem.html#o23">_OneMinusCurrentLODRatio</a> = 1.f - (d.norm() * <a class="code" href="classNL3D_1_1CParticleSystem.html#o26">_InvCurrentViewDist</a>);
00274 <a class="code" href="namespaceNLMISC.html#a215">NLMISC::clamp</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#o23">_OneMinusCurrentLODRatio</a>, 0.f, 1.f);
00275 }
00276
<a name="l00278"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#c2">00278</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CParticleSystem::updateColor()
00279 {
00280 <font class="keywordflow">if</font> (_ColorAttenuationScheme)
00281 {
00282 <font class="keywordtype">float</font> ratio = 1.00f - <a class="code" href="classNL3D_1_1CParticleSystem.html#o23">_OneMinusCurrentLODRatio</a>;
00283 <a class="code" href="classNL3D_1_1CParticleSystem.html#o39">_GlobalColor</a> = <a class="code" href="classNL3D_1_1CParticleSystem.html#o38">_ColorAttenuationScheme</a>->get(ratio > 0.f ? ratio : 0.f);
00284 }
00285 }
00286
00287
00288 <font class="comment">/*</font>
00289 <font class="comment">static void displaySysPos(IDriver *drv, const CVector &pos, CRGBA col)</font>
00290 <font class="comment">{</font>
00291 <font class="comment"> if (!drv) return; </font>
00292 <font class="comment"> drv->setupModelMatrix(CMatrix::Identity);</font>
00293 <font class="comment"> CPSUtil::displayArrow(drv, pos, CVector::K, 1.f, CRGBA::White, col);</font>
00294 <font class="comment">}</font>
00295 <font class="comment">*/</font>
00296
<a name="l00298"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z638_0">00298</a> <font class="keywordtype">void</font> CParticleSystem::step(TPass pass, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00299 {
00300 <font class="keywordflow">switch</font> (pass)
00301 {
00302 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#s18s1">SolidRender</a>:
00304 <font class="keywordflow">if</font> (_Sharing)
00305 {
00306 <a class="code" href="classNL3D_1_1CParticleSystem.html#c1">updateLODRatio</a>();
00307 }
00308 <font class="comment">// update time</font>
00309 ++<a class="code" href="classNL3D_1_1CParticleSystem.html#o12">_Date</a>;
00310 <font class="comment">// update global color</font>
00311 <a class="code" href="classNL3D_1_1CParticleSystem.html#c2">updateColor</a>();
00312 <a class="code" href="classNL3D_1_1CParticleSystem.html#c0">stepLocated</a>(<a class="code" href="namespaceNL3D.html#a484a169">PSSolidRender</a>, ellapsedTime, ellapsedTime);
00313
00314 <font class="keywordflow">break</font>;
00315 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#s18s2">BlendRender</a>:
00317 <font class="keywordflow">if</font> (_Sharing)
00318 {
00319 <a class="code" href="classNL3D_1_1CParticleSystem.html#c1">updateLODRatio</a>();
00320 }
00321 <font class="comment">// update time</font>
00322 ++<a class="code" href="classNL3D_1_1CParticleSystem.html#o12">_Date</a>;
00323 <font class="comment">// update global color</font>
00324 <a class="code" href="classNL3D_1_1CParticleSystem.html#c2">updateColor</a>();
00325 <a class="code" href="classNL3D_1_1CParticleSystem.html#c0">stepLocated</a>(<a class="code" href="namespaceNL3D.html#a484a170">PSBlendRender</a>, ellapsedTime, ellapsedTime);
00326 <font class="keywordflow">break</font>;
00327 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#s18s3">ToolRender</a>:
00328 <a class="code" href="classNL3D_1_1CParticleSystem.html#c0">stepLocated</a>(<a class="code" href="namespaceNL3D.html#a484a171">PSToolRender</a>, ellapsedTime, ellapsedTime);
00329 <font class="keywordflow">break</font>;
00330 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#s18s0">Anim</a>:
00331 {
00332 <font class="comment">// update user param from global value if needed, unless this behaviour is bypassed has indicated by a flag in _BypassGlobalUserParam</font>
00333 <font class="keywordflow">if</font> (_UserParamGlobalValue)
00334 {
00335 <a class="code" href="debug_8h.html#a16">nlctassert</a>(<a class="code" href="namespaceNL3D.html#a165">MaxPSUserParam</a> < 8); <font class="comment">// there should be less than 8 parameters because of mask stored in a byte </font>
00336 uint8 bypassMask = 1;
00337 <font class="keywordflow">for</font>(uint k = 0; k < <a class="code" href="namespaceNL3D.html#a165">MaxPSUserParam</a>; ++k)
00338 {
00339 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>[k] && !(<a class="code" href="classNL3D_1_1CParticleSystem.html#o33">_BypassGlobalUserParam</a> & bypassMask)) <font class="comment">// if there is a global value for this param and if the update is not bypassed</font>
00340 {
00341 <a class="code" href="classNL3D_1_1CParticleSystem.html#o31">_UserParam</a>[k] = <a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>[k]->second;
00342 }
00343 bypassMask <<= 1;
00344 }
00345 }
00346 <font class="comment">//</font>
00347 <a class="code" href="classNL3D_1_1CParticleSystem.html#o41">_BBoxTouched</a> = <font class="keyword">true</font>;
00348 <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> et = ellapsedTime;
00349 uint nbPass = 1;
00350 <font class="keywordflow">if</font> (_AccurateIntegration)
00351 {
00352 <font class="keywordflow">if</font> (et > <a class="code" href="classNL3D_1_1CParticleSystem.html#o19">_TimeThreshold</a>)
00353 {
00354 nbPass = (uint32) ceilf(et / <a class="code" href="classNL3D_1_1CParticleSystem.html#o19">_TimeThreshold</a>);
00355 <font class="keywordflow">if</font> (nbPass > <a class="code" href="classNL3D_1_1CParticleSystem.html#o21">_MaxNbIntegrations</a>)
00356 {
00357 nbPass = <a class="code" href="classNL3D_1_1CParticleSystem.html#o21">_MaxNbIntegrations</a>;
00358 <font class="keywordflow">if</font> (_CanSlowDown)
00359 {
00360 et = <a class="code" href="classNL3D_1_1CParticleSystem.html#o19">_TimeThreshold</a>;
00361 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#o19">_TimeThreshold</a> != 0);
00362 <a class="code" href="classNL3D_1_1CParticleSystem.html#o51">_InverseEllapsedTime</a> = 1.f / (<a class="code" href="classNL3D_1_1CParticleSystem.html#o19">_TimeThreshold</a> * nbPass);
00363 }
00364 <font class="keywordflow">else</font>
00365 {
00366 et = ellapsedTime / nbPass;
00367 <a class="code" href="classNL3D_1_1CParticleSystem.html#o51">_InverseEllapsedTime</a> = ellapsedTime != 0 ? 1.f / ellapsedTime : 0.f;
00368 }
00369 }
00370 <font class="keywordflow">else</font>
00371 {
00372 et = ellapsedTime / nbPass;
00373 <a class="code" href="classNL3D_1_1CParticleSystem.html#o51">_InverseEllapsedTime</a> = ellapsedTime != 0 ? 1.f / ellapsedTime : 0.f;
00374 }
00375 }
00376 <font class="keywordflow">else</font>
00377 {
00378 <a class="code" href="classNL3D_1_1CParticleSystem.html#o51">_InverseEllapsedTime</a> = ellapsedTime != 0 ? 1.f / ellapsedTime : 0.f;
00379 }
00380 }
00381 <font class="keywordflow">else</font>
00382 {
00383 <a class="code" href="classNL3D_1_1CParticleSystem.html#o51">_InverseEllapsedTime</a> = ellapsedTime != 0 ? 1.f / ellapsedTime : 0.f;
00384 }
00385 <a class="code" href="classNL3D_1_1CParticleSystem.html#c1">updateLODRatio</a>();
00386
00387 <font class="comment">// set start position. Used by emitters that emit from Local basis to world</font>
00388 <a class="code" href="classNL3D_1_1CParticleSystem.html#o10">_CurrentDeltaPos</a> = -<a class="code" href="classNL3D_1_1CParticleSystem.html#o11">_DeltaPos</a>;
00389 <font class="comment">//displaySysPos(_Driver, _CurrentDeltaPos + _OldSysMat.getPos(), CRGBA::Red);</font>
00390 <font class="comment">// process passes</font>
00391 <font class="keywordtype">float</font> realEt = <a class="code" href="classNL3D_1_1CParticleSystem.html#o48">_KeepEllapsedTimeForLifeUpdate</a> ? (ellapsedTime / nbPass)
00392 : et;
00393 <font class="keywordflow">do</font>
00394 {
00395 <font class="comment">// position of the system at the end of the integration</font>
00396 <a class="code" href="classNL3D_1_1CParticleSystem.html#o10">_CurrentDeltaPos</a> += <a class="code" href="classNL3D_1_1CParticleSystem.html#o11">_DeltaPos</a> * (et * <a class="code" href="classNL3D_1_1CParticleSystem.html#o51">_InverseEllapsedTime</a>);
00397 <font class="comment">//displaySysPos(_Driver, _CurrentDeltaPos + _OldSysMat.getPos(), CRGBA::Blue);</font>
00398 <font class="comment">// the order of the following is important...</font>
00399 <a class="code" href="classNL3D_1_1CParticleSystem.html#c0">stepLocated</a>(<a class="code" href="namespaceNL3D.html#a484a167">PSCollision</a>, et, realEt);
00400 <font class="keywordflow">for</font> (TProcessVect::iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(); it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(); ++it)
00401 {
00402 (*it)->updateLife(realEt);
00403 (*it)->step(<a class="code" href="namespaceNL3D.html#a484a168">PSMotion</a>, et, realEt);
00404 }
00405 <a class="code" href="classNL3D_1_1CParticleSystem.html#o20">_SystemDate</a> += realEt;
00406 <a class="code" href="classNL3D_1_1CParticleSystem.html#c0">stepLocated</a>(<a class="code" href="namespaceNL3D.html#a484a166">PSEmit</a>, et, realEt);
00407 }
00408 <font class="keywordflow">while</font> (--nbPass);
00409
00410 <font class="comment">// perform parametric motion if present</font>
00411 <font class="keywordflow">for</font> (TProcessVect::iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(); it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(); ++it)
00412 {
00413 <font class="keywordflow">if</font> ((*it)->isParametricMotionEnabled()) (*it)->performParametricMotion(<a class="code" href="classNL3D_1_1CParticleSystem.html#o20">_SystemDate</a>, ellapsedTime, realEt);
00414 }
00415
00416 }
00417 }
00418 }
00419
00420
00421
<a name="l00423"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z633_2">00423</a> <font class="keywordtype">void</font> CParticleSystem::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00424 {
00425 sint version = f.serialVersion(12);
00426 <font class="comment">// version 12: global userParams</font>
00427 <font class="comment">// version 11: enable load balancing flag </font>
00428 <font class="comment">// version 9: Sharing flag added</font>
00429 <font class="comment">// Auto-lod parameters</font>
00430 <font class="comment">// New integration flag</font>
00431 <font class="comment">// Global color attenuation</font>
00432 <font class="comment">// version 8: Replaced the attribute '_PerformMotionWhenOutOfFrustum' by a _AnimType field which allow more precise control</font>
00433
00434 <font class="comment">//f.serial(_ViewMat);</font>
00435 f.serial(_SysMat);
00436 f.serial(_Date);
00437 <font class="keywordflow">if</font> (f.isReading())
00438 {
00439 <font class="keyword">delete</font> _ColorAttenuationScheme;
00440 <font class="comment">// delete previous multimap</font>
00441 _LBMap.clear();
00442 <font class="comment">// delete previously attached process</font>
00443 <font class="keywordflow">for</font> (TProcessVect::iterator it = _ProcessVect.begin(); it != _ProcessVect.end(); ++it)
00444 {
00445 <font class="keyword">delete</font> (*it);
00446 }
00447
00448 _ProcessVect.clear();
00449
00450 f.serialContPolyPtr(_ProcessVect);
00451
00452 _InvSysMat = _SysMat.inverted();
00453 _FontGenerator = NULL;
00454 _FontManager = NULL;
00455 <font class="keyword">delete</font> _UserParamGlobalValue;
00456 _UserParamGlobalValue = NULL;
00457 _BypassGlobalUserParam = 0;
00458 }
00459 <font class="keywordflow">else</font>
00460 {
00461 f.serialContPolyPtr(_ProcessVect);
00462 }
00463
00464 <font class="keywordflow">if</font> (version > 1) <font class="comment">// name of the system</font>
00465 {
00466 f.serial(_Name);
00467 }
00468
00469 <font class="keywordflow">if</font> (version > 2) <font class="comment">// infos about integration, and LOD</font>
00470 {
00471 f.serial(_AccurateIntegration);
00472 <font class="keywordflow">if</font> (_AccurateIntegration) f.serial(_CanSlowDown, _TimeThreshold, _MaxNbIntegrations);
00473 f.serial(_InvMaxViewDist, _LODRatio);
00474 _MaxViewDist = 1.f / _InvMaxViewDist;
00475 _InvCurrentViewDist = _InvMaxViewDist;
00476 }
00477
00478 <font class="keywordflow">if</font> (version > 3) <font class="comment">// tell wether the system must compute his bbox, hold a precomputed bbox</font>
00479 {
00480 f.serial(_ComputeBBox);
00481 <font class="keywordflow">if</font> (!_ComputeBBox)
00482 {
00483 f.serial(_PreComputedBBox);
00484 }
00485 }
00486
00487 <font class="keywordflow">if</font> (version > 4) <font class="comment">// lifetime informations</font>
00488 {
00489 f.serial(_DestroyModelWhenOutOfRange);
00490 f.serialEnum(_DieCondition);
00491 <font class="keywordflow">if</font> (_DieCondition != none)
00492 {
00493 f.serial(_DelayBeforeDieTest);
00494 }
00495 }
00496
00497 <font class="keywordflow">if</font> (version > 5)
00498 {
00499 f.serial(_DestroyWhenOutOfFrustum);
00500 }
00501
00502 <font class="keywordflow">if</font> (version > 6 && version < 8)
00503 {
00504 <font class="keywordtype">bool</font> performMotionWOOF;
00505 <font class="keywordflow">if</font> (f.isReading())
00506 {
00507 f.serial(performMotionWOOF);
00508 performMotionWhenOutOfFrustum(performMotionWOOF);
00509 }
00510 <font class="keywordflow">else</font>
00511 {
00512 performMotionWOOF = doesPerformMotionWhenOutOfFrustum();
00513 f.serial(performMotionWOOF);
00514 }
00515 }
00516
00517 <font class="keywordflow">if</font> (version > 7)
00518 {
00519 f.serialEnum(_AnimType);
00520 f.serialEnum(_PresetBehaviour);
00521 }
00522
00523 <font class="keywordflow">if</font> (version > 8)
00524 {
00525 f.serial(_Sharing);
00526 f.serial(_AutoLOD);
00527 <font class="keywordflow">if</font> (_AutoLOD)
00528 {
00529 f.serial(_AutoLODStartDistPercent, _AutoLODDegradationExponent);
00530 f.serial(_AutoLODSkipParticles);
00531 }
00532 f.serial(_KeepEllapsedTimeForLifeUpdate);
00533 f.serialPolyPtr(_ColorAttenuationScheme);
00534 }
00535
00536 <font class="keywordflow">if</font> (version >= 11)
00537 {
00538 f.serial(_EnableLoadBalancing);
00539 }
00540
00541 <font class="keywordflow">if</font> (version >= 12)
00542 {
00543 <font class="comment">// serial infos about global user params</font>
00544 <a class="code" href="debug_8h.html#a16">nlctassert</a>(<a class="code" href="namespaceNL3D.html#a165">MaxPSUserParam</a> < 8); <font class="comment">// In this version mask of used global user params are stored in a byte.. </font>
00545 <font class="keywordflow">if</font> (f.isReading())
00546 {
00547 uint8 mask;
00548 f.serial(mask);
00549 <font class="keywordflow">if</font> (mask)
00550 {
00551 std::string globalValueName;
00552 uint8 testMask = 1;
00553 <font class="keywordflow">for</font>(uint k = 0; k < <a class="code" href="namespaceNL3D.html#a165">MaxPSUserParam</a>; ++k)
00554 {
00555 <font class="keywordflow">if</font> (mask & testMask)
00556 {
00557 f.serial(globalValueName);
00558 bindGlobalValueToUserParam(globalValueName.c_str(), k);
00559 }
00560 testMask <<= 1;
00561 }
00562 }
00563 }
00564 <font class="keywordflow">else</font>
00565 {
00566 uint8 mask = 0;
00567 <font class="keywordflow">if</font> (_UserParamGlobalValue)
00568 {
00569 <font class="keywordflow">for</font>(uint k = 0; k < <a class="code" href="namespaceNL3D.html#a165">MaxPSUserParam</a>; ++k)
00570 {
00571 <font class="keywordflow">if</font> (_UserParamGlobalValue[k]) mask |= (1 << k);
00572 }
00573 }
00574 f.serial(mask);
00575 <font class="keywordflow">if</font> (_UserParamGlobalValue)
00576 {
00577 <font class="keywordflow">for</font>(uint k = 0; k < <a class="code" href="namespaceNL3D.html#a165">MaxPSUserParam</a>; ++k)
00578 {
00579 <font class="keywordflow">if</font> (_UserParamGlobalValue[k])
00580 {
00581 std::string valueName = _UserParamGlobalValue[k]->first;
00582 f.serial(valueName);
00583 }
00584 }
00585 }
00586 }
00587 }
00588
00589 <font class="keywordflow">if</font> (f.isReading())
00590 {
00591 notifyMaxNumFacesChanged();
00592 }
00593 }
00594
00595
<a name="l00597"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z639_0">00597</a> <font class="keywordtype">void</font> CParticleSystem::attach(CParticleSystemProcess *ptr)
00598 {
00599 <a class="code" href="debug_8h.html#a6">nlassert</a>(std::find(<a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(), <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(), ptr) == <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end() );
00600 <font class="comment">//nlassert(ptr->getOwner() == NULL); // deja attache a un autre systeme</font>
00601 <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.push_back(ptr);
00602 ptr->setOwner(<font class="keyword">this</font>);
00603 <a class="code" href="classNL3D_1_1CParticleSystem.html#z646_2">notifyMaxNumFacesChanged</a>();
00604 }
00605
<a name="l00607"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z639_4">00607</a> <font class="keywordtype">void</font> CParticleSystem::remove(CParticleSystemProcess *ptr)
00608 {
00609 TProcessVect::iterator it = std::find(<a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(), <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(), ptr);
00610 <a class="code" href="debug_8h.html#a6">nlassert</a>(it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end() );
00611 <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.erase(it);
00612 <font class="keyword">delete</font> ptr;
00613 }
00614
<a name="l00616"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z647_0">00616</a> <font class="keywordtype">void</font> CParticleSystem::computeBBox(<a class="code" href="classNLMISC_1_1CAABBox.html">NLMISC::CAABBox</a> &aabbox)
00617 {
00618 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CParticleSystem.html#o40">_ComputeBBox</a> || !<a class="code" href="classNL3D_1_1CParticleSystem.html#o41">_BBoxTouched</a>)
00619 {
00620 aabbox = <a class="code" href="classNL3D_1_1CParticleSystem.html#o0">_PreComputedBBox</a>;
00621 <font class="keywordflow">return</font>;
00622 }
00623
00624 <font class="keywordtype">bool</font> foundOne = <font class="keyword">false</font>;
00625 <a class="code" href="classNLMISC_1_1CAABBox.html">NLMISC::CAABBox</a> tmpBox;
00626 <font class="keywordflow">for</font> (TProcessVect::const_iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(); it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(); ++it)
00627 {
00628 <font class="keywordflow">if</font> ((*it)->computeBBox(tmpBox))
00629 {
00630 <font class="keywordflow">if</font> (!(*it)->isInSystemBasis())
00631 {
00632 <font class="comment">// rotate the aabbox so that it is in the correct basis</font>
00633 tmpBox = <a class="code" href="classNLMISC_1_1CAABBox.html#z266_3">NLMISC::CAABBox::transformAABBox</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#o9">_InvSysMat</a>, tmpBox);
00634 }
00635 <font class="keywordflow">if</font> (foundOne)
00636 {
00637 aabbox = <a class="code" href="classNLMISC_1_1CAABBox.html#z266_2">NLMISC::CAABBox::computeAABBoxUnion</a>(aabbox, tmpBox);
00638 }
00639 <font class="keywordflow">else</font>
00640 {
00641 aabbox = tmpBox;
00642 foundOne = <font class="keyword">true</font>;
00643 }
00644 }
00645 }
00646
00647 <font class="keywordflow">if</font> (!foundOne)
00648 {
00649 aabbox.<a class="code" href="classNLMISC_1_1CAABBox.html#z263_0">setCenter</a>(<a class="code" href="classNLMISC_1_1CVector.html#p0">NLMISC::CVector::Null</a>);
00650 aabbox.<a class="code" href="classNLMISC_1_1CAABBox.html#z263_1">setHalfSize</a>(<a class="code" href="classNLMISC_1_1CVector.html#p0">NLMISC::CVector::Null</a>);
00651 }
00652
00653 <a class="code" href="classNL3D_1_1CParticleSystem.html#o41">_BBoxTouched</a> = <font class="keyword">false</font>;
00654 <a class="code" href="classNL3D_1_1CParticleSystem.html#o0">_PreComputedBBox</a> = aabbox;
00655 }
00656
<a name="l00658"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z637_0">00658</a> <font class="keywordtype">void</font> CParticleSystem::setSysMat(<font class="keyword">const</font> CMatrix &m)
00659 {
00660 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CParticleSystem.html#o20">_SystemDate</a> != 0.f)
00661 {
00662 <a class="code" href="classNL3D_1_1CParticleSystem.html#o8">_OldSysMat</a> = <a class="code" href="classNL3D_1_1CParticleSystem.html#o7">_SysMat</a>; <font class="comment">// _sysMat is relevant if at least one call to setSysMat has been performed before</font>
00663 <a class="code" href="classNL3D_1_1CParticleSystem.html#o11">_DeltaPos</a> = m.getPos() - <a class="code" href="classNL3D_1_1CParticleSystem.html#o8">_OldSysMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>();
00664 }
00665 <font class="keywordflow">else</font>
00666 {
00667 <a class="code" href="classNL3D_1_1CParticleSystem.html#o11">_DeltaPos</a> = <a class="code" href="classNLMISC_1_1CVector.html#p0">NLMISC::CVector::Null</a>;
00668 <a class="code" href="classNL3D_1_1CParticleSystem.html#o8">_OldSysMat</a> = m;
00669 }
00670 <a class="code" href="classNL3D_1_1CParticleSystem.html#o7">_SysMat</a> = m;
00671 <a class="code" href="classNL3D_1_1CParticleSystem.html#o9">_InvSysMat</a> = <a class="code" href="classNL3D_1_1CParticleSystem.html#o7">_SysMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z293_7">inverted</a>();
00672 }
00673
<a name="l00675"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z643_0">00675</a> <font class="keywordtype">bool</font> CParticleSystem::hasOpaqueObjects(<font class="keywordtype">void</font>)<font class="keyword"> const</font>
00676 <font class="keyword"></font>{
00678 <font class="keywordflow">for</font> (TProcessVect::const_iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(); it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(); ++it)
00679 {
00680 <font class="keywordflow">if</font> (dynamic_cast<CPSLocated *>(*it))
00681 {
00682 <font class="keywordflow">for</font> (uint k = 0; k < ((CPSLocated *) *it)->getNbBoundObjects(); ++k)
00683 {
00684 CPSLocatedBindable *lb = ((CPSLocated *) *it)->getBoundObject(k);
00685 <font class="keywordflow">if</font> (lb->getType() == <a class="code" href="namespaceNL3D.html#a203">PSParticle</a>)
00686 {
00687 <font class="keywordflow">if</font> (((CPSParticle *) lb)->hasOpaqueFaces()) <font class="keywordflow">return</font> <font class="keyword">true</font>;
00688 }
00689 }
00690 }
00691 }
00692 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00693 }
00694
<a name="l00696"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z643_1">00696</a> <font class="keywordtype">bool</font> CParticleSystem::hasTransparentObjects(<font class="keywordtype">void</font>)<font class="keyword"> const</font>
00697 <font class="keyword"></font>{
00699 <font class="keywordflow">for</font> (TProcessVect::const_iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(); it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(); ++it)
00700 {
00701 <font class="keywordflow">if</font> (dynamic_cast<CPSLocated *>(*it))
00702 {
00703 <font class="keywordflow">for</font> (uint k = 0; k < ((CPSLocated *) *it)->getNbBoundObjects(); ++k)
00704 {
00705 CPSLocatedBindable *lb = ((CPSLocated *) *it)->getBoundObject(k);
00706 <font class="keywordflow">if</font> (lb->getType() == <a class="code" href="namespaceNL3D.html#a203">PSParticle</a>)
00707 {
00708 <font class="keywordflow">if</font> (((CPSParticle *) lb)->hasTransparentFaces()) <font class="keywordflow">return</font> <font class="keyword">true</font>;
00709 }
00710 }
00711 }
00712 }
00713 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00714 }
00715
<a name="l00717"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z645_4">00717</a> <font class="keywordtype">void</font> CParticleSystem::getLODVect(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>, <font class="keywordtype">float</font> &<a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a>, <font class="keywordtype">bool</font> systemBasis)
00718 {
00719 <font class="keywordflow">if</font> (!systemBasis)
00720 {
00721 v = <a class="code" href="classNL3D_1_1CParticleSystem.html#o26">_InvCurrentViewDist</a> * <a class="code" href="classNL3D_1_1CParticleSystem.html#o6">_InvertedViewMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_8">getJ</a>();
00722 <a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> = - <a class="code" href="classNL3D_1_1CParticleSystem.html#o6">_InvertedViewMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>() * v;
00723 }
00724 <font class="keywordflow">else</font>
00725 {
00726 <font class="keyword">const</font> CVector tv = <a class="code" href="classNL3D_1_1CParticleSystem.html#o9">_InvSysMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z294_0">mulVector</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#o6">_InvertedViewMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_8">getJ</a>());
00727 <font class="keyword">const</font> CVector org = <a class="code" href="classNL3D_1_1CParticleSystem.html#o9">_InvSysMat</a> * <a class="code" href="classNL3D_1_1CParticleSystem.html#o6">_InvertedViewMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>();
00728 v = <a class="code" href="classNL3D_1_1CParticleSystem.html#o26">_InvCurrentViewDist</a> * tv;
00729 <a class="code" href="driver__opengl__extension__def_8h.html#a378">offset</a> = - org * v;
00730 }
00731 }
00732
<a name="l00734"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z645_5">00734</a> <a class="code" href="namespaceNL3D.html#a485">TPSLod</a> CParticleSystem::getLOD(<font class="keywordtype">void</font>)<font class="keyword"> const</font>
00735 <font class="keyword"></font>{
00736 <font class="keyword">const</font> <font class="keywordtype">float</font> dist = fabsf(<a class="code" href="classNL3D_1_1CParticleSystem.html#o26">_InvCurrentViewDist</a> * (<a class="code" href="classNL3D_1_1CParticleSystem.html#o7">_SysMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>() - <a class="code" href="classNL3D_1_1CParticleSystem.html#o6">_InvertedViewMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_4">getPos</a>()) * <a class="code" href="classNL3D_1_1CParticleSystem.html#o6">_InvertedViewMat</a>.<a class="code" href="classNLMISC_1_1CMatrix.html#z291_8">getJ</a>());
00737 <font class="keywordflow">return</font> dist > <a class="code" href="classNL3D_1_1CParticleSystem.html#o22">_LODRatio</a> ? <a class="code" href="namespaceNL3D.html#a485a210">PSLod2</a> : <a class="code" href="namespaceNL3D.html#a485a209">PSLod1</a>;
00738 }
00739
00740
<a name="l00742"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z650_0">00742</a> <font class="keywordtype">void</font> CParticleSystem::registerLocatedBindableExternID(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, CPSLocatedBindable *lb)
00743 {
00744 <a class="code" href="debug_8h.html#a6">nlassert</a>(lb);
00745 <a class="code" href="debug_8h.html#a6">nlassert</a>(lb->getOwner() && lb->getOwner()->getOwner() == <font class="keyword">this</font>); <font class="comment">// the located bindable must belong to that system</font>
00746 <font class="preprocessor"> #ifdef NL_DEBUG </font>
00747 <font class="preprocessor"></font> <font class="comment">// check that this lb hasn't been inserted yet</font>
00748 TLBMap::iterator lbd = <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.lower_bound(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>), ubd = <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.upper_bound(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>);
00749 <a class="code" href="debug_8h.html#a6">nlassert</a>(std::find(lbd, ubd, TLBMap::value_type (<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, lb)) == ubd);
00750 <a class="code" href="debug_8h.html#a6">nlassert</a>(std::find(lbd, ubd, TLBMap::value_type (<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, lb)) == ubd );
00751
00752 <font class="preprocessor"> #endif</font>
00753 <font class="preprocessor"></font> <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.insert(TLBMap::value_type (<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, lb) );
00754 }
00755
<a name="l00757"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z650_1">00757</a> <font class="keywordtype">void</font> CParticleSystem::unregisterLocatedBindableExternID(CPSLocatedBindable *lb)
00758 {
00759 <a class="code" href="debug_8h.html#a6">nlassert</a>(lb);
00760 <a class="code" href="debug_8h.html#a6">nlassert</a>(lb->getOwner() && lb->getOwner()->getOwner() == <font class="keyword">this</font>); <font class="comment">// the located bindable must belong to that system</font>
00761 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a> = lb->getExternID();
00762 <font class="keywordflow">if</font> (!<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>) <font class="keywordflow">return</font>;
00763 TLBMap::iterator lbd = <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.lower_bound(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>), ubd = <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.upper_bound(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>);
00764 TLBMap::iterator el = std::find(lbd, ubd, TLBMap::value_type (<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, lb));
00765 <a class="code" href="debug_8h.html#a6">nlassert</a>(el != ubd);
00766 <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.erase(el);
00767 }
00768
<a name="l00770"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z651_0">00770</a> uint CParticleSystem::getNumLocatedBindableByExternID(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>)<font class="keyword"> const</font>
00771 <font class="keyword"></font>{
00772 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.count(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>);
00773 }
00774
<a name="l00776"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z651_1">00776</a> CPSLocatedBindable *CParticleSystem::getLocatedBindableByExternID(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00777 {
00778 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> >= <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.count(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>))
00779 {
00780 <font class="keywordflow">return</font> NULL;
00781 }
00782 TLBMap::const_iterator el = <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.lower_bound(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>);
00783 uint left = <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>;
00784 <font class="keywordflow">while</font> (left--) ++el;
00785 <font class="keywordflow">return</font> el->second;
00786
00787 }
00788
<a name="l00790"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z651_2">00790</a> <font class="keyword">const</font> CPSLocatedBindable *CParticleSystem::getLocatedBindableByExternID(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>, uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font>
00791 <font class="keyword"></font>{
00792 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> >= <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.count(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>))
00793 {
00794 <font class="keywordflow">return</font> NULL;
00795 }
00796 TLBMap::const_iterator el = <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.lower_bound(<a class="code" href="driver__opengl__extension__def_8h.html#a356">id</a>);
00797 uint left = <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>;
00798 <font class="keywordflow">while</font> (left--) ++el;
00799 <font class="keywordflow">return</font> el->second;
00800 }
00801
<a name="l00803"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z633_3">00803</a> <font class="keywordtype">void</font> CParticleSystem::merge(CParticleSystemShape *pss)
00804 {
00805 <a class="code" href="debug_8h.html#a6">nlassert</a>(pss);
00806 <a class="code" href="classNL3D_1_1CParticleSystem.html#z633_0">CParticleSystem</a> *duplicate = pss->instanciatePS(*this->_Scene); <font class="comment">// duplicate the p.s. to merge</font>
00807 <font class="comment">// now we transfer the located of the duplicated ps to this object...</font>
00808 <font class="keywordflow">for</font> (TProcessVect::iterator it = duplicate->_ProcessVect.begin(); it != duplicate->_ProcessVect.end(); ++it)
00809 {
00810 <a class="code" href="classNL3D_1_1CParticleSystem.html#z639_0">attach</a>(*it);
00811 }
00812 duplicate->_ProcessVect.clear();
00813 <font class="keyword">delete</font> duplicate;
00814 }
00815
<a name="l00817"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z648_17">00817</a> <font class="keywordtype">void</font> CParticleSystem::activatePresetBehaviour(TPresetBehaviour behaviour)
00818 {
00819
00820 <font class="keywordflow">switch</font>(behaviour)
00821 {
00822 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_2s11">EnvironmentFX</a>:
00823 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_3">setDestroyModelWhenOutOfRange</a>(<font class="keyword">false</font>);
00824 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_5">setDestroyCondition</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#z648_0s4">none</a>);
00825 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_9">destroyWhenOutOfFrustum</a>(<font class="keyword">false</font>);
00826 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_15">setAnimType</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#z648_1s7">AnimVisible</a>);
00827 <font class="keywordflow">break</font>;
00828 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_2s12">RunningEnvironmentFX</a>:
00829 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_3">setDestroyModelWhenOutOfRange</a>(<font class="keyword">false</font>);
00830 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_5">setDestroyCondition</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#z648_0s4">none</a>);
00831 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_9">destroyWhenOutOfFrustum</a>(<font class="keyword">false</font>);
00832 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_15">setAnimType</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#z648_1s8">AnimInCluster</a>);
00833 <font class="keywordflow">break</font>;
00834 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_2s13">SpellFX</a>:
00835 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_3">setDestroyModelWhenOutOfRange</a>(<font class="keyword">true</font>);
00836 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_5">setDestroyCondition</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#z648_0s5">noMoreParticles</a>);
00837 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_9">destroyWhenOutOfFrustum</a>(<font class="keyword">false</font>);
00838 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_15">setAnimType</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#z648_1s9">AnimAlways</a>);
00839 <font class="keywordflow">break</font>;
00840 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_2s14">LoopingSpellFX</a>:
00841 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_3">setDestroyModelWhenOutOfRange</a>(<font class="keyword">true</font>);
00842 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_5">setDestroyCondition</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#z648_0s5">noMoreParticles</a>);
00843 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_9">destroyWhenOutOfFrustum</a>(<font class="keyword">false</font>);
00844 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_15">setAnimType</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#z648_1s8">AnimInCluster</a>);
00845 <font class="keywordflow">break</font>;
00846 <font class="keywordflow">case</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_2s15">MinorFX</a>:
00847 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_3">setDestroyModelWhenOutOfRange</a>(<font class="keyword">true</font>);
00848 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_5">setDestroyCondition</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#z648_0s5">noMoreParticles</a>);
00849 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_9">destroyWhenOutOfFrustum</a>(<font class="keyword">true</font>);
00850 <a class="code" href="classNL3D_1_1CParticleSystem.html#z648_15">setAnimType</a>(<a class="code" href="classNL3D_1_1CParticleSystem.html#z648_1s7">AnimVisible</a>);
00851 <font class="keywordflow">break</font>;
00852 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
00853 }
00854 <a class="code" href="classNL3D_1_1CParticleSystem.html#o34">_PresetBehaviour</a> = behaviour;
00855 }
00856
00857
<a name="l00859"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z639_1">00859</a> CParticleSystemProcess *CParticleSystem::detach(uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00860 {
00861 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> < <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.size());
00862 CParticleSystemProcess *proc = <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>];
00863 <font class="comment">// release references other process may have to this system</font>
00864 <font class="keywordflow">for</font>(TProcessVect::iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(); it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(); ++it)
00865 {
00866 (*it)->releaseRefTo(proc);
00867 }
00868 <font class="comment">// erase from the vector</font>
00869 <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.erase(<a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin() + <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00870 proc->setOwner(NULL);
00871 <font class="comment">// not part of this system any more </font>
00872 <font class="keywordflow">return</font> proc;
00873 }
00874
<a name="l00876"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z639_2">00876</a> <font class="keywordtype">bool</font> CParticleSystem::isProcess(CParticleSystemProcess *process)<font class="keyword"> const</font>
00877 <font class="keyword"></font>{
00878 <font class="keywordflow">for</font>(TProcessVect::const_iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.begin(); it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.end(); ++it)
00879 {
00880 <font class="keywordflow">if</font> (*it == process) <font class="keywordflow">return</font> <font class="keyword">true</font>;
00881 }
00882 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00883 }
00884
<a name="l00886"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z639_3">00886</a> uint CParticleSystem::getIndexOf(<font class="keyword">const</font> CParticleSystemProcess *process)<font class="keyword"> const</font>
00887 <font class="keyword"></font>{
00888 <font class="keywordflow">for</font>(uint k = 0; k < <a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>.size(); ++k)
00889 {
00890 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CParticleSystem.html#o2">_ProcessVect</a>[k] == process) <font class="keywordflow">return</font> k;
00891 }
00892 <a class="code" href="debug_8h.html#a6">nlassert</a>(0); <font class="comment">// not a process of this system</font>
00893 <font class="keywordflow">return</font> 0; <font class="comment">// for warning</font>
00894 }
00895
<a name="l00897"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z651_3">00897</a> uint CParticleSystem::getNumID()<font class="keyword"> const</font>
00898 <font class="keyword"></font>{
00899 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.size();
00900 }
00901
<a name="l00903"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z651_4">00903</a> uint32 CParticleSystem::getID(uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font>
00904 <font class="keyword"></font>{
00905 TLBMap::const_iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.begin();
00906 <font class="keywordflow">for</font>(uint k = 0; k < <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>; ++k)
00907 {
00908 <font class="keywordflow">if</font> (it == <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.end()) <font class="keywordflow">return</font> 0;
00909 ++it;
00910 }
00911 <font class="keywordflow">return</font> it->first;
00912 }
00913
<a name="l00915"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z651_5">00915</a> <font class="keywordtype">void</font> CParticleSystem::getIDs(std::vector<uint32> &dest)<font class="keyword"> const</font>
00916 <font class="keyword"></font>{
00917 dest.resize(<a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.size());
00918 uint k = 0;
00919 <font class="keywordflow">for</font>(TLBMap::const_iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.begin(); it != <a class="code" href="classNL3D_1_1CParticleSystem.html#o35">_LBMap</a>.end(); ++it)
00920 {
00921 dest[k] = it->first;
00922 ++k;
00923 }
00924 }
00925
<a name="l00927"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#a2">00927</a> <font class="keywordtype">void</font> CParticleSystem::interpolatePosDelta(<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &dest,<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> deltaT)
00928 {
00929 dest = <a class="code" href="classNL3D_1_1CParticleSystem.html#o10">_CurrentDeltaPos</a> - (deltaT * <a class="code" href="classNL3D_1_1CParticleSystem.html#o51">_InverseEllapsedTime</a>) * <a class="code" href="classNL3D_1_1CParticleSystem.html#o11">_DeltaPos</a>;
00930 }
00931
<a name="l00933"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z641_2">00933</a> <font class="keywordtype">void</font> CParticleSystem::bindGlobalValueToUserParam(<font class="keyword">const</font> std::string &globalValueName, uint userParamIndex)
00934 {
00935 <a class="code" href="debug_8h.html#a6">nlassert</a>(userParamIndex < <a class="code" href="namespaceNL3D.html#a165">MaxPSUserParam</a>);
00936 <font class="keywordflow">if</font> (globalValueName.empty()) <font class="comment">// disable a user param global value</font>
00937 {
00938 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>) <font class="keywordflow">return</font>;
00939 <a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>[userParamIndex] = NULL;
00940 <font class="keywordflow">for</font>(uint k = 0; k < <a class="code" href="namespaceNL3D.html#a165">MaxPSUserParam</a>; ++k)
00941 {
00942 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>[k] != NULL) <font class="keywordflow">return</font>;
00943 }
00944 <font class="comment">// no more entry used</font>
00945 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>;
00946 <a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a> = NULL;
00947 }
00948 <font class="keywordflow">else</font> <font class="comment">// enable a user param global value</font>
00949 {
00950 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>)
00951 {
00952 <font class="comment">// no table has been allocated yet, so create one</font>
00953 <a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a> = <font class="keyword">new</font> <font class="keyword">const</font> TGlobalValuesMap::value_type *[<a class="code" href="namespaceNL3D.html#a165">MaxPSUserParam</a>];
00954 std::fill(<a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>, <a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a> + <a class="code" href="namespaceNL3D.html#a165">MaxPSUserParam</a>, (TGlobalValuesMap::value_type *) NULL);
00955 }
00956 <font class="comment">// has the global value be created yet ?</font>
00957 TGlobalValuesMap::const_iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#r0">_GlobalValuesMap</a>.find(globalValueName);
00958 <font class="keywordflow">if</font> (it != <a class="code" href="classNL3D_1_1CParticleSystem.html#r0">_GlobalValuesMap</a>.end())
00959 {
00960 <font class="comment">// yes, make a reference on it</font>
00961 <a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>[userParamIndex] = &(*it);
00962 }
00963 <font class="keywordflow">else</font>
00964 {
00965 <font class="comment">// create a new entry</font>
00966 std::pair<TGlobalValuesMap::iterator, bool> itPair = <a class="code" href="classNL3D_1_1CParticleSystem.html#r0">_GlobalValuesMap</a>.insert(TGlobalValuesMap::value_type(globalValueName, 0.f));
00967 <a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>[userParamIndex] = &(*(itPair.first));
00968 }
00969 }
00970 }
00971
<a name="l00973"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z641_4">00973</a> <font class="keywordtype">void</font> CParticleSystem::setGlobalValue(<font class="keyword">const</font> std::string &name, <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>)
00974 {
00975 <a class="code" href="debug_8h.html#a6">nlassert</a>(!name.empty());
00976 <a class="code" href="namespaceNLMISC.html#a215">NLMISC::clamp</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>, 0.f, 1.f);
00977 <a class="code" href="classNL3D_1_1CParticleSystem.html#r0">_GlobalValuesMap</a>[name] = <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>;
00978 }
00979
<a name="l00981"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z641_5">00981</a> <font class="keywordtype">float</font> CParticleSystem::getGlobalValue(<font class="keyword">const</font> std::string &name)
00982 {
00983 TGlobalValuesMap::const_iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#r0">_GlobalValuesMap</a>.find(name);
00984 <font class="keywordflow">if</font> (it != <a class="code" href="classNL3D_1_1CParticleSystem.html#r0">_GlobalValuesMap</a>.end()) <font class="keywordflow">return</font> it->second;
00985 <font class="keywordflow">return</font> 0.f; <font class="comment">// not a known value</font>
00986 }
00987
<a name="l00989"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z641_3">00989</a> std::string CParticleSystem::getGlobalValueName(uint userParamIndex)<font class="keyword"> const</font>
00990 <font class="keyword"></font>{
00991 <a class="code" href="debug_8h.html#a6">nlassert</a>(userParamIndex < <a class="code" href="namespaceNL3D.html#a165">MaxPSUserParam</a>);
00992 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>) <font class="keywordflow">return</font> <font class="stringliteral">""</font>;
00993 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>[userParamIndex]) <font class="keywordflow">return</font> <font class="stringliteral">""</font>;
00994 <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CParticleSystem.html#o32">_UserParamGlobalValue</a>[userParamIndex]->first;
00995 }
00996
<a name="l00998"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z641_6">00998</a> <font class="keywordtype">void</font> CParticleSystem::setGlobalVectorValue(<font class="keyword">const</font> std::string &name, <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>)
00999 {
01000 <a class="code" href="debug_8h.html#a6">nlassert</a>(!name.empty());
01001 <a class="code" href="classNL3D_1_1CParticleSystem.html#r1">_GlobalVectorValuesMap</a>[name] = value;
01002 }
01003
01004
<a name="l01006"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z641_7">01006</a> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> CParticleSystem::getGlobalVectorValue(<font class="keyword">const</font> std::string &name)
01007 {
01008 <a class="code" href="debug_8h.html#a6">nlassert</a>(!name.empty());
01009 TGlobalVectorValuesMap::const_iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#r1">_GlobalVectorValuesMap</a>.find(name);
01010 <font class="keywordflow">if</font> (it != <a class="code" href="classNL3D_1_1CParticleSystem.html#r1">_GlobalVectorValuesMap</a>.end()) <font class="keywordflow">return</font> it->second;
01011 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CVector.html#p0">NLMISC::CVector::Null</a>; <font class="comment">// not a known value </font>
01012 }
01013
<a name="l01015"></a><a class="code" href="classNL3D_1_1CParticleSystem.html#z641_8">01015</a> CParticleSystem::CGlobalVectorValueHandle CParticleSystem::getGlobalVectorValueHandle(<font class="keyword">const</font> std::string &name)
01016 {
01017 <a class="code" href="debug_8h.html#a6">nlassert</a>(!name.empty());
01018 TGlobalVectorValuesMap::iterator it = <a class="code" href="classNL3D_1_1CParticleSystem.html#r1">_GlobalVectorValuesMap</a>.find(name);
01019 <font class="keywordflow">if</font> (it == <a class="code" href="classNL3D_1_1CParticleSystem.html#r1">_GlobalVectorValuesMap</a>.end())
01020 {
01021 it = <a class="code" href="classNL3D_1_1CParticleSystem.html#r1">_GlobalVectorValuesMap</a>.insert(TGlobalVectorValuesMap::value_type(name, <a class="code" href="classNLMISC_1_1CVector.html#p0">NLMISC::CVector::Null</a>)).first;
01022 }
01023 CGlobalVectorValueHandle handle;
01024 handle._Value = &it->second;
01025 handle._Name = &it->first;
01026 <font class="keywordflow">return</font> handle;
01027 }
01028
01029
01030
01031 } <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>
|