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
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
|
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>nevrax.org : docs</TITLE>
<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF='/'><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF='/'><b>nevrax.com</B></FONT></A> </TD>
</TR>
</TABLE>
<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>
<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!------ Begin Box ------>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
<TABLE cellspacing=0 cellpadding=1 border=0>
<tr><td ALIGN=middle><a class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
</TABLE>
</TD></TR></TABLE></TD></TR></TABLE>
<!------ End Box ------>
</TD>
<TD WIDTH=15><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD ALIGN=left valign=top><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!-- title -->
<TABLE background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
<!-- block -->
<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
<TD><B>Documentation</B></TD>
<TD ALIGN=RIGHT> </td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>ps_emitter.cpp</h1><a href="ps__emitter_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 <stdlib.h></font>
00029 <font class="preprocessor">#include "<a class="code" href="ps__emitter_8h.html">3d/ps_emitter.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="material_8h.html">3d/material.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="line_8h.html">nel/misc/line.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="dru_8h.html">3d/dru.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="particle__system_8h.html">3d/particle_system.h</a>"</font>
00034
00035 <font class="keyword">namespace </font>NL3D {
00036
00037
00038
00039 <font class="comment">// number of emitter to be processed at once</font>
00040 <font class="keyword">const</font> uint <a class="code" href="namespaceNL3D.html#a189">emitterBuffSize</a> = 512;
00041
00043 <font class="comment">// CPSEmitter implementation //</font>
<a name="l00045"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#z716_0">00045</a> <font class="comment">CPSEmitter::CPSEmitter() : _EmittedType(NULL),</font>
00046 _SpeedInheritanceFactor(0.f),
00047 _EmissionType(regular),
00048 _Period(0.02f),
00049 _PeriodScheme(NULL),
00050 _GenNb(1),
00051 _GenNbScheme(NULL),
00052 _EmitDelay(0),
00053 _MaxEmissionCount(0),
00054 _SpeedBasisEmission(<font class="keyword">false</font>),
00055 _EmitDirBasis(<font class="keyword">true</font>),
00056 _ConsistentEmission(<font class="keyword">true</font>)
00057 {
00058 }
00059
00060
<a name="l00062"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#z716_1">00062</a> CPSEmitter::~CPSEmitter()
00063 {
00064 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a>;
00065 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>;
00066 <font class="comment">// if a located is emitted, unregister us as an observer</font>
00067 <font class="keywordflow">if</font> (_EmittedType)
00068 {
00069 <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>->unregisterDtorObserver(<font class="keyword">this</font>);
00070 }
00071 }
00072
<a name="l00074"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a31">00074</a> <font class="keywordtype">void</font> CPSEmitter::releaseRefTo(<font class="keyword">const</font> CParticleSystemProcess *other)
00075 {
00076 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a> == other)
00077 {
00078 <a class="code" href="classNL3D_1_1CPSEmitter.html#a5">setEmittedType</a>(NULL);
00079 }
00080 }
00081
<a name="l00082"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a32">00082</a> <font class="keywordtype">void</font> CPSEmitter::releaseAllRef()
00083 {
00084 <a class="code" href="classNL3D_1_1CPSEmitter.html#a5">setEmittedType</a>(NULL);
00085 }
00086
00087
<a name="l00089"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#b0">00089</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CPSEmitter::processEmit(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, sint nbToGenerate)
00090 {
00091 <font class="keyword">static</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> speed, pos;
00092
00093 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSEmitter.html#n11">_SpeedBasisEmission</a>)
00094 {
00095 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n3">_SpeedInheritanceFactor</a> == 0.f)
00096 {
00097 <font class="keywordflow">if</font> (_EmitDirBasis)
00098 {
00099 <font class="keywordflow">while</font> (nbToGenerate > 0)
00100 {
00101 nbToGenerate --;
00102 <a class="code" href="classNL3D_1_1CPSEmitter.html#b4">emit</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, pos, speed);
00103 <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>->newElement(pos, speed, this->_Owner, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00104 }
00105 }
00106 <font class="keywordflow">else</font>
00107 {
00108 <font class="keywordflow">while</font> (nbToGenerate > 0)
00109 {
00110 nbToGenerate --;
00111 <a class="code" href="classNL3D_1_1CPSEmitter.html#b4">emit</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, pos, speed);
00112 <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>->newElement(pos, speed, this->_Owner, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">false</font>);
00113 }
00114 }
00115 }
00116 <font class="keywordflow">else</font>
00117 {
00118 <font class="keywordflow">while</font> (nbToGenerate --)
00119 {
00120 <a class="code" href="classNL3D_1_1CPSEmitter.html#b4">emit</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, pos, speed);
00121 <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>->newElement(pos, speed + <a class="code" href="classNL3D_1_1CPSEmitter.html#n3">_SpeedInheritanceFactor</a> * <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSpeed()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], this-><a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
00122 }
00123 }
00124 }
00125 <font class="keywordflow">else</font>
00126 {
00127 <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> m;
00128 CPSUtil::buildSchmidtBasis(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSpeed()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], m);
00129 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n3">_SpeedInheritanceFactor</a> == 0.f)
00130 {
00131 <font class="keywordflow">while</font> (nbToGenerate > 0)
00132 {
00133 nbToGenerate --;
00134 <a class="code" href="classNL3D_1_1CPSEmitter.html#b4">emit</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, pos, speed);
00135 <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>->newElement(pos, m * speed, this->_Owner, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00136 }
00137 }
00138 <font class="keywordflow">else</font>
00139 {
00140 <font class="keywordflow">while</font> (nbToGenerate --)
00141 {
00142 <a class="code" href="classNL3D_1_1CPSEmitter.html#b4">emit</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, pos, speed);
00143 <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>->newElement(pos, m * speed + <a class="code" href="classNL3D_1_1CPSEmitter.html#n3">_SpeedInheritanceFactor</a> * <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSpeed()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], this-><a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00144 }
00145 }
00146 }
00147 }
00148
00152 <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNL3D.html#a419">CompensateEmission</a>(CPSLocated *emittedType, uint emittedIndex, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> deltaT, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime, <font class="keywordtype">float</font> realEllapsedTimeRatio)
00153 {
00154 <font class="comment">// now, update emitted element life time </font>
00155 <font class="keywordflow">if</font> (emittedType->getLastForever())
00156 {
00157 emittedType->getTime()[emittedIndex] += realEllapsedTimeRatio * deltaT;
00158
00159 <font class="keywordflow">if</font> (emittedType->isParametricMotionEnabled())
00160 {
00161 emittedType->getParametricInfos()[emittedIndex].Date -= realEllapsedTimeRatio * deltaT;
00162 }
00163 <font class="keywordflow">else</font>
00164 {
00165 <font class="keywordflow">if</font> (!emittedType->hasCollisionInfos())
00166 {
00167 <font class="comment">// no collision case</font>
00168 emittedType->getPos()[emittedIndex] += deltaT * emittedType->getSpeed()[emittedIndex];
00169 }
00170 <font class="keywordflow">else</font> <font class="comment">// if there are collisions, we delay the step to the next iteration to ensure correct collisions</font>
00171 {
00172 emittedType->getCollisionInfo()[emittedIndex].TimeSliceRatio = deltaT / ellapsedTime;
00173 }
00174 }
00175 }
00176 <font class="keywordflow">else</font>
00177 {
00178 <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> &destTime = emittedType->getTime()[emittedIndex];
00179 <font class="keywordflow">if</font> (emittedType->getLifeScheme() != NULL)
00180 {
00181 destTime = realEllapsedTimeRatio * deltaT * emittedType->getTimeIncrement()[emittedIndex];
00182 }
00183 <font class="keywordflow">else</font>
00184 {
00185 <font class="keywordflow">if</font> (emittedType->getInitialLife() != 0.f)
00186 {
00187 destTime = realEllapsedTimeRatio * deltaT / emittedType->getInitialLife();
00188 }
00189 }
00190 <font class="keywordflow">if</font> (destTime >= 1.f)
00191 {
00192 emittedType->deleteElement(emittedIndex);
00193 }
00194 <font class="keywordflow">else</font>
00195 {
00196 <font class="keywordflow">if</font> (emittedType->isParametricMotionEnabled())
00197 {
00198 emittedType->getParametricInfos()[emittedIndex].Date -= realEllapsedTimeRatio * deltaT;
00199 }
00200 <font class="keywordflow">else</font>
00201 {
00202 <font class="keywordflow">if</font> (!emittedType->hasCollisionInfos())
00203 {
00204 <font class="comment">// no collision case</font>
00205 emittedType->getPos()[emittedIndex] += deltaT * emittedType->getSpeed()[emittedIndex];
00206 }
00207 <font class="keywordflow">else</font> <font class="comment">// if there are collisions, we delay the step to the next iteration to ensure correct collisions</font>
00208 {
00209 emittedType->getCollisionInfo()[emittedIndex].TimeSliceRatio = deltaT / ellapsedTime;
00210 }
00211 }
00212 }
00213 }
00214 }
00215
<a name="l00217"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#b1">00217</a> <font class="keyword">inline</font> <font class="keywordtype">void</font> CPSEmitter::processEmitConsistent(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &emitterPos,
00218 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>,
00219 sint nbToGenerate,
00220 <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> deltaT,
00221 <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime,
00222 <font class="keywordtype">float</font> realEllapsedTimeRatio
00223 )
00224 {
00225 <font class="keyword">static</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> speed, pos;
00226 sint emittedIndex;
00227 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSEmitter.html#n11">_SpeedBasisEmission</a>)
00228 {
00229 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n3">_SpeedInheritanceFactor</a> == 0.f)
00230 {
00231 <font class="keywordflow">if</font> (_EmitDirBasis)
00232 {
00233 <font class="keywordflow">while</font> (nbToGenerate > 0)
00234 {
00235 nbToGenerate --;
00236 <a class="code" href="classNL3D_1_1CPSEmitter.html#b4">emit</a>(emitterPos, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, pos, speed);
00237 emittedIndex = <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>->newElement(pos, speed, this->_Owner, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">true</font>, deltaT);
00238 <font class="keywordflow">if</font> (emittedIndex != - 1) <a class="code" href="namespaceNL3D.html#a419">CompensateEmission</a>(<a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>, emittedIndex, deltaT, ellapsedTime, realEllapsedTimeRatio);
00239 <font class="keywordflow">else</font> <font class="keywordflow">break</font>;
00240 }
00241 }
00242 <font class="keywordflow">else</font>
00243 {
00244 <font class="keywordflow">while</font> (nbToGenerate > 0)
00245 {
00246 nbToGenerate --;
00247 <a class="code" href="classNL3D_1_1CPSEmitter.html#b4">emit</a>(emitterPos, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, pos, speed);
00248 emittedIndex = <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>->newElement(pos, speed, this->_Owner, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">false</font>, deltaT);
00249 <font class="keywordflow">if</font> (emittedIndex != - 1) <a class="code" href="namespaceNL3D.html#a419">CompensateEmission</a>(<a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>, emittedIndex, deltaT, ellapsedTime, realEllapsedTimeRatio);
00250 <font class="keywordflow">else</font> <font class="keywordflow">break</font>;
00251 }
00252 }
00253 }
00254 <font class="keywordflow">else</font>
00255 {
00256 <font class="keywordflow">while</font> (nbToGenerate --)
00257 {
00258 <a class="code" href="classNL3D_1_1CPSEmitter.html#b4">emit</a>(emitterPos, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, pos, speed);
00259 emittedIndex = <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>->newElement(pos, speed + <a class="code" href="classNL3D_1_1CPSEmitter.html#n3">_SpeedInheritanceFactor</a> * <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSpeed()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], this-><a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">true</font>, deltaT);
00260 <font class="keywordflow">if</font> (emittedIndex != - 1) <a class="code" href="namespaceNL3D.html#a419">CompensateEmission</a>(<a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>, emittedIndex, deltaT, ellapsedTime, realEllapsedTimeRatio);
00261 <font class="keywordflow">else</font> <font class="keywordflow">break</font>;
00262 }
00263 }
00264 }
00265 <font class="keywordflow">else</font>
00266 {
00267 <a class="code" href="classNLMISC_1_1CMatrix.html">NLMISC::CMatrix</a> m;
00268 CPSUtil::buildSchmidtBasis(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSpeed()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], m);
00269 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n3">_SpeedInheritanceFactor</a> == 0.f)
00270 {
00271 <font class="keywordflow">while</font> (nbToGenerate > 0)
00272 {
00273 nbToGenerate --;
00274 <a class="code" href="classNL3D_1_1CPSEmitter.html#b4">emit</a>(emitterPos, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, pos, speed);
00275 emittedIndex = <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>->newElement(pos, m * speed, this->_Owner, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">true</font>, deltaT);
00276 <font class="keywordflow">if</font> (emittedIndex != - 1) <a class="code" href="namespaceNL3D.html#a419">CompensateEmission</a>(<a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>, emittedIndex, deltaT, ellapsedTime, realEllapsedTimeRatio);
00277 <font class="keywordflow">else</font> <font class="keywordflow">break</font>;
00278 }
00279 }
00280 <font class="keywordflow">else</font>
00281 {
00282 <font class="keywordflow">while</font> (nbToGenerate --)
00283 {
00284 <a class="code" href="classNL3D_1_1CPSEmitter.html#b4">emit</a>(emitterPos, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, pos, speed);
00285 emittedIndex = <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>->newElement(pos, m * speed + <a class="code" href="classNL3D_1_1CPSEmitter.html#n3">_SpeedInheritanceFactor</a> * <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSpeed()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], this-><a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">true</font>, deltaT);
00286 <font class="keywordflow">if</font> (emittedIndex != - 1) <a class="code" href="namespaceNL3D.html#a419">CompensateEmission</a>(<a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>, emittedIndex, deltaT, ellapsedTime, realEllapsedTimeRatio);
00287 <font class="keywordflow">else</font> <font class="keywordflow">break</font>;
00288 }
00289 }
00290 }
00291 }
00292
00293
<a name="l00295"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a9">00295</a> <font class="keywordtype">void</font> CPSEmitter::setEmissionType(TEmissionType freqType)
00296 {
00297 <a class="code" href="classNL3D_1_1CPSEmitter.html#n4">_EmissionType</a> = freqType;
00298 }
00299
<a name="l00301"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a5">00301</a> <font class="keywordtype">void</font> CPSEmitter::setEmittedType(CPSLocated *et)
00302 {
00303 <font class="keywordflow">if</font> (_EmittedType)
00304 {
00305 <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>->unregisterDtorObserver(<font class="keyword">this</font>);
00306 }
00307 <font class="keywordflow">if</font> (et)
00308 {
00309 et->registerDtorObserver(<font class="keyword">this</font>);
00310 }
00311
00312 <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a> = et;
00313 }
00314
<a name="l00316"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a6">00316</a> <font class="keywordtype">void</font> CPSEmitter::notifyTargetRemoved(CPSLocated *ptr)
00317 {
00318 <a class="code" href="debug_8h.html#a6">nlassert</a>(ptr == <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a> && <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>);
00319 <a class="code" href="classNL3D_1_1CPSEmitter.html#a5">setEmittedType</a>(NULL);
00320 }
00321
<a name="l00323"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a11">00323</a> <font class="keywordtype">void</font> CPSEmitter::setPeriod(<font class="keywordtype">float</font> period)
00324 {
00325 <font class="keywordflow">if</font> (_PeriodScheme)
00326 {
00327 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a>;
00328 <a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a> = NULL;
00329 }
00330 <a class="code" href="classNL3D_1_1CPSEmitter.html#n5">_Period</a> = period;
00331 }
00332
<a name="l00334"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a14">00334</a> <font class="keywordtype">void</font> CPSEmitter::setPeriodScheme(CPSAttribMaker<float> *scheme)
00335 {
00336 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a>;
00337 <a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a> = scheme;
00338 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> && scheme->hasMemory()) scheme->resize(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getMaxSize(), <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize());
00339 }
00340
<a name="l00342"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a21">00342</a> <font class="keywordtype">void</font> CPSEmitter::setGenNb(uint32 genNb)
00343 {
00344 <font class="keywordflow">if</font> (_GenNbScheme)
00345 {
00346 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>;
00347 <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> = NULL;
00348 }
00349 <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a> = genNb;
00350 }
00351
<a name="l00353"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a24">00353</a> <font class="keywordtype">void</font> CPSEmitter::setGenNbScheme(CPSAttribMaker<uint32> *scheme)
00354 {
00355 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>;
00356 <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> = scheme;
00357 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> && scheme->hasMemory()) scheme->resize(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getMaxSize(), <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize());
00358 }
00359
<a name="l00361"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a4">00361</a> <font class="keywordtype">void</font> CPSEmitter::showTool(<font class="keywordtype">void</font>)
00362 {
00363 uint32 size = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize();
00364 <font class="keywordflow">if</font> (!size) <font class="keywordflow">return</font>;
00365 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();
00366
00367 <font class="keyword">const</font> CVector I = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a22">computeI</a>();
00368 <font class="keyword">const</font> CVector K = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a24">computeK</a>();
00369
00370 <font class="comment">// ugly slow code, but not for runtime</font>
00371 <font class="keywordflow">for</font> (uint k = 0; k < size; ++k)
00372 {
00373 <font class="comment">// center of the current particle</font>
00374 <font class="keyword">const</font> CVector p = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos()[k];
00375 <font class="keyword">const</font> <font class="keywordtype">float</font> sSize =0.1f;
00376 std::vector<NLMISC::CLine> lines;
00377 <a class="code" href="classNLMISC_1_1CLine.html">NLMISC::CLine</a> <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>;
00378 l.<a class="code" href="classNLMISC_1_1CLine.html#m0">V0</a> = p - sSize * I; l.<a class="code" href="classNLMISC_1_1CLine.html#m1">V1</a> = p + sSize * I; lines.push_back(l);
00379 l.<a class="code" href="classNLMISC_1_1CLine.html#m0">V0</a> = p - sSize * K; l.<a class="code" href="classNLMISC_1_1CLine.html#m1">V1</a> = p + sSize * K; lines.push_back(l);
00380 l.<a class="code" href="classNLMISC_1_1CLine.html#m0">V0</a> = p - sSize * (I + K); l.<a class="code" href="classNLMISC_1_1CLine.html#m1">V1</a> = p + sSize * (I + K); lines.push_back(l);
00381 l.<a class="code" href="classNLMISC_1_1CLine.html#m0">V0</a> = p - sSize * (I - K); l.<a class="code" href="classNLMISC_1_1CLine.html#m1">V1</a> = p + sSize * (I - K); lines.push_back(l);
00382
00383 CMaterial mat;
00384 mat.setBlendFunc(CMaterial::one, CMaterial::one);
00385 mat.setZWrite(<font class="keyword">false</font>);
00386 mat.setLighting(<font class="keyword">false</font>);
00387 mat.setBlend(<font class="keyword">true</font>);
00388 mat.setZFunc(CMaterial::less);
00389
00390
00391 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#l0">CPSLocated</a> *loc;
00392 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>;
00393 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#z720_0">CPSLocatedBindable</a> *lb;
00394 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner()->getCurrentEditedElement(loc, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, lb);
00395
00396 mat.setColor((lb == NULL || <font class="keyword">this</font> == lb) && loc == <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> && <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> == k ? CRGBA::Red : CRGBA(127, 127, 127));
00397
00398
00399 CDRU::drawLinesUnlit(lines, mat, *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>() );
00400 }
00401 }
00402
<a name="l00404"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a28">00404</a> <font class="keywordtype">void</font> CPSEmitter::singleEmit(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, uint quantity)
00405 {
00406 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
00407 <font class="keyword">const</font> uint32 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>,0) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00408 <a class="code" href="classNL3D_1_1CPSEmitter.html#b0">processEmit</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, quantity * nbToGenerate);
00409 }
00410
00411
<a name="l00413"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#b2">00413</a> <font class="keywordtype">void</font> CPSEmitter::processRegularEmission(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00414 {
00415 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
00416 <font class="keyword">const</font> uint size = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize();
00417 uint leftToDo = size, toProcess;
00418 <font class="keywordtype">float</font> emitPeriod[<a class="code" href="namespaceNL3D.html#a189">emitterBuffSize</a>];
00419 <font class="keywordtype">float</font> *currEmitPeriod;
00420 uint currEmitPeriodPtrInc = <a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a> ? 1 : 0;
00421 sint32 nbToGenerate;
00422
00423 TPSAttribTime::iterator phaseIt = <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin(), endPhaseIt;
00424 TPSAttribUInt8::iterator numEmitIt = <a class="code" href="classNL3D_1_1CPSEmitter.html#n2">_NumEmission</a>.begin();
00425
00426 <font class="comment">// we don't use an iterator here</font>
00427 <font class="comment">// because it could be invalidated if size change (a located could generate itself) </font>
00428 <font class="keywordflow">do</font>
00429 {
00430 toProcess = leftToDo < <a class="code" href="namespaceNL3D.html#a189">emitterBuffSize</a> ? leftToDo : <a class="code" href="namespaceNL3D.html#a189">emitterBuffSize</a>;
00431
00432
00433 <font class="keywordflow">if</font> (_PeriodScheme)
00434 {
00435 currEmitPeriod = (<font class="keywordtype">float</font> *) (<a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a>->make(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, size - leftToDo, emitPeriod, <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>));
00436 }
00437 <font class="keywordflow">else</font>
00438 {
00439 currEmitPeriod = &<a class="code" href="classNL3D_1_1CPSEmitter.html#n5">_Period</a>;
00440 }
00441
00442 endPhaseIt = phaseIt + toProcess;
00443
00444 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a> == 0) <font class="comment">// no emission count limit</font>
00445 {
00447 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a> == 0.f) <font class="comment">// no emission delay</font>
00448 {
00449 <font class="keywordflow">do</font>
00450 {
00451 *phaseIt += ellapsedTime;
00452 <font class="keywordflow">if</font> ( *phaseIt >= *currEmitPeriod) <font class="comment">// phase is greater than period -> must emit</font>
00453 {
00454 <font class="keywordflow">if</font> (*currEmitPeriod != 0)
00455 {
00456 *phaseIt -= ::floorf(*phaseIt / *currEmitPeriod) * *currEmitPeriod;
00457 }
00458 <font class="keyword">const</font> uint32 k = phaseIt - (<a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin());
00459 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, k) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00460 <a class="code" href="classNL3D_1_1CPSEmitter.html#b0">processEmit</a>(k, nbToGenerate);
00461 }
00462
00463 ++phaseIt;
00464 currEmitPeriod += currEmitPeriodPtrInc;
00465 }
00466 <font class="keywordflow">while</font> (phaseIt != endPhaseIt);
00467 }
00468 <font class="keywordflow">else</font> <font class="comment">// thhere's an emission delay</font>
00469 {
00470 <font class="keywordflow">do</font>
00471 {
00472 *phaseIt += ellapsedTime;
00473 <font class="keywordflow">if</font> ( *phaseIt >= *currEmitPeriod + <a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a>) <font class="comment">// phase is greater than period -> must emit</font>
00474 {
00475 <font class="keywordflow">if</font> (*currEmitPeriod != 0)
00476 {
00477 *phaseIt -= ::floorf((*phaseIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a>) / *currEmitPeriod) * *currEmitPeriod;
00478 }
00479 <font class="keyword">const</font> uint32 k = phaseIt - (<a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin());
00480 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, k) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00481 <a class="code" href="classNL3D_1_1CPSEmitter.html#b0">processEmit</a>(k, nbToGenerate);
00482 }
00483
00484 ++phaseIt;
00485 currEmitPeriod += currEmitPeriodPtrInc;
00486 }
00487 <font class="keywordflow">while</font> (phaseIt != endPhaseIt);
00488 }
00489 }
00490 <font class="keywordflow">else</font> <font class="comment">// there's an emission count limit</font>
00491 {
00493 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a> == 0.f) <font class="comment">// no emission delay</font>
00494 {
00495 <font class="keywordflow">do</font>
00496 {
00497 <font class="keywordflow">if</font> (*numEmitIt < <a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a>)
00498 {
00499 *phaseIt += ellapsedTime;
00500 <font class="keywordflow">if</font> ( *phaseIt >= *currEmitPeriod) <font class="comment">// phase is greater than period -> must emit</font>
00501 {
00502 <font class="keywordflow">if</font> (*currEmitPeriod != 0)
00503 {
00504 *phaseIt -= ::floorf(*phaseIt / *currEmitPeriod) * *currEmitPeriod;
00505 }
00506 <font class="keyword">const</font> uint32 k = phaseIt - (<a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin());
00507 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, k) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00508 <a class="code" href="classNL3D_1_1CPSEmitter.html#b0">processEmit</a>(k, nbToGenerate);
00509 ++*numEmitIt;
00510 }
00511 }
00512 ++phaseIt;
00513 currEmitPeriod += currEmitPeriodPtrInc;
00514 ++ numEmitIt;
00515 }
00516 <font class="keywordflow">while</font> (phaseIt != endPhaseIt);
00517 }
00518 <font class="keywordflow">else</font> <font class="comment">// there's an emission delay</font>
00519 {
00520 <font class="keywordflow">do</font>
00521 {
00522 <font class="keywordflow">if</font> (*numEmitIt < <a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a>)
00523 {
00524 *phaseIt += ellapsedTime;
00525 <font class="keywordflow">if</font> ( *phaseIt >= *currEmitPeriod + <a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a>) <font class="comment">// phase is greater than period -> must emit</font>
00526 {
00527 <font class="keywordflow">if</font> (*currEmitPeriod != 0)
00528 {
00529 *phaseIt -= ::floorf((*phaseIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a>) / *currEmitPeriod) * *currEmitPeriod;
00530 }
00531 <font class="keyword">const</font> uint32 k = phaseIt - (<a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin());
00532 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, k) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00533 <a class="code" href="classNL3D_1_1CPSEmitter.html#b0">processEmit</a>(k, nbToGenerate);
00534 ++*numEmitIt;
00535 }
00536 }
00537 ++phaseIt;
00538 currEmitPeriod += currEmitPeriodPtrInc;
00539 ++numEmitIt;
00540 }
00541 <font class="keywordflow">while</font> (phaseIt != endPhaseIt);
00542 }
00543 }
00544
00545 leftToDo -= toProcess;
00546 }
00547 <font class="keywordflow">while</font> (leftToDo);
00548 }
00549
00551 <font class="comment">// depending on wether its motion is parametric or incremental. This is used to create emittees at the right position</font>
00552
00553 <font class="keyword">static</font> <font class="keyword">inline</font> uint <a class="code" href="namespaceNL3D.html#a420">GenEmitterPositions</a>(CPSLocated *emitter,
00554 CPSLocated *emittee,
00555 uint emitterIndex,
00556 uint numStep,
00557 <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> deltaT, <font class="comment">/* fraction of time needed to reach the first emission */</font>
00558 <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> step,
00559 std::vector<NLMISC::CVector> &dest
00560 )
00561 {
00562 <font class="keyword">const</font> uint toProcess = std::max(1U, std::min(numStep, (uint) emittee->getMaxSize()));
00563 dest.resize(toProcess);
00564
00565
00566 <font class="keywordflow">if</font> (!emitter->isParametricMotionEnabled()) <font class="comment">// standard case : take current pos and integrate</font>
00567 {
00568 <font class="keywordflow">if</font> (toProcess == 1) <font class="comment">// only one emission -> takes current pos</font>
00569 {
00570 dest[0] = emitter->getPos()[emitterIndex] - deltaT * emitter->getSpeed()[emitterIndex];
00571 }
00572 <font class="keywordflow">else</font>
00573 {
00574 std::vector<NLMISC::CVector>::iterator outIt = dest.end();
00575 std::vector<NLMISC::CVector>::iterator endIt = dest.begin();
00576 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> pos = emitter->getPos()[emitterIndex] - deltaT * emitter->getSpeed()[emitterIndex];
00577 <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> speed = step * emitter->getSpeed()[emitterIndex];
00578 <font class="keywordflow">do</font>
00579 {
00580 -- outIt;
00581 *outIt = pos;
00582 pos -= speed;
00583 }
00584 <font class="keywordflow">while</font> (outIt != endIt);
00585 }
00586 }
00587 <font class="keywordflow">else</font> <font class="comment">// compute parametric trajectory</font>
00588 {
00589 emitter->integrateSingle(emitter->getOwner()->getSystemDate() - deltaT - step * toProcess,
00590 step,
00591 toProcess,
00592 emitterIndex,
00593 &dest[0]
00594 );
00595 }
00596
00597 <font class="keywordflow">return</font> toProcess;
00598 }
00599
<a name="l00601"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#b3">00601</a> <font class="keywordtype">void</font> CPSEmitter::processRegularEmissionConsistent(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime, <font class="keywordtype">float</font> realEllapsedTimeRatio)
00602 {
00604
00605 <font class="keyword">static</font> std::vector<NLMISC::CVector> emitterPositions;
00606 <font class="comment">// Positions for the emitter. They are computed by using a parametric trajectory or by using integration</font>
00607
00608 <font class="keyword">const</font> uint size = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize();
00609 uint leftToDo = size, toProcess;
00610 <font class="keywordtype">float</font> emitPeriod[<a class="code" href="namespaceNL3D.html#a189">emitterBuffSize</a>];
00611 <font class="keywordtype">float</font> *currEmitPeriod;
00612 uint currEmitPeriodPtrInc = <a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a> ? 1 : 0;
00613 sint32 nbToGenerate;
00614
00615
00616 TPSAttribTime::iterator phaseIt = <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin(), endPhaseIt;
00617 TPSAttribUInt8::iterator numEmitIt = <a class="code" href="classNL3D_1_1CPSEmitter.html#n2">_NumEmission</a>.begin();
00618
00619 <font class="comment">// we don't use an iterator here</font>
00620 <font class="comment">// because it could be invalidated if size change (a located could generate itself) </font>
00621 <font class="keywordflow">do</font>
00622 {
00623 toProcess = leftToDo < <a class="code" href="namespaceNL3D.html#a189">emitterBuffSize</a> ? leftToDo : <a class="code" href="namespaceNL3D.html#a189">emitterBuffSize</a>;
00624
00625
00626 <font class="keywordflow">if</font> (_PeriodScheme)
00627 {
00628 currEmitPeriod = (<font class="keywordtype">float</font> *) (<a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a>->make(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, size - leftToDo, emitPeriod, <font class="keyword">sizeof</font>(<font class="keywordtype">float</font>), toProcess, <font class="keyword">true</font>));
00629 }
00630 <font class="keywordflow">else</font>
00631 {
00632 currEmitPeriod = &<a class="code" href="classNL3D_1_1CPSEmitter.html#n5">_Period</a>;
00633 }
00634
00635 endPhaseIt = phaseIt + toProcess;
00636
00637 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a> == 0) <font class="comment">// no emission count limit</font>
00638 {
00640 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a> == 0.f) <font class="comment">// no emission delay</font>
00641 {
00642 <font class="keywordflow">do</font>
00643 {
00644 *phaseIt += ellapsedTime;
00645 <font class="keywordflow">if</font> ( *phaseIt >= *currEmitPeriod) <font class="comment">// phase is greater than period -> must emit</font>
00646 {
00647 <font class="keywordflow">if</font> (*currEmitPeriod != 0)
00648 {
00651 *phaseIt = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(*phaseIt, *currEmitPeriod + ellapsedTime);
00652 <font class="comment">//</font>
00654 <font class="comment"> uint numEmissions = (uint) ::floorf(*phaseIt / *currEmitPeriod);</font>
00655 *phaseIt -= *currEmitPeriod * numEmissions;
00656 <font class="keywordtype">float</font> deltaT = std::max(0.f, *phaseIt);
00657 <font class="comment">//nlassert(deltaT >= 0.f);</font>
00658 uint emitterIndex = phaseIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin();
00659
00661 numEmissions = <a class="code" href="namespaceNL3D.html#a420">GenEmitterPositions</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>,
00662 <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>,
00663 emitterIndex,
00664 numEmissions,
00665 deltaT,
00666 *currEmitPeriod,
00667 emitterPositions
00668 );
00669
00671 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, emitterIndex) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00672 uint k = numEmissions;
00673 <font class="keywordflow">do</font>
00674 {
00675 --k;
00676 <a class="code" href="classNL3D_1_1CPSEmitter.html#b1">processEmitConsistent</a>(emitterPositions[k],
00677 emitterIndex,
00678 nbToGenerate,
00679 deltaT,
00680 ellapsedTime,
00681 realEllapsedTimeRatio);
00682 deltaT += *currEmitPeriod;
00683 }
00684 <font class="keywordflow">while</font> (k);
00685 }
00686 <font class="keywordflow">else</font>
00687 {
00688 <font class="keyword">const</font> uint32 emitterIndex = phaseIt - (<a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin());
00689 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, emitterIndex) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00690 <a class="code" href="classNL3D_1_1CPSEmitter.html#b0">processEmit</a>(emitterIndex, nbToGenerate);
00691 }
00692 }
00693
00694 ++phaseIt;
00695 currEmitPeriod += currEmitPeriodPtrInc;
00696 }
00697 <font class="keywordflow">while</font> (phaseIt != endPhaseIt);
00698 }
00699 <font class="keywordflow">else</font> <font class="comment">// thhere's an emission delay</font>
00700 {
00701 <font class="keywordflow">do</font>
00702 {
00703 *phaseIt += ellapsedTime;
00704 <font class="keywordflow">if</font> ( *phaseIt >= *currEmitPeriod + <a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a>) <font class="comment">// phase is greater than period -> must emit</font>
00705 {
00706 <font class="keywordflow">if</font> (*currEmitPeriod != 0)
00707 {
00710 *phaseIt = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(*phaseIt, *currEmitPeriod + ellapsedTime + <a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a>);
00711 <font class="comment">//</font>
00712 uint numEmissions = (uint) ::floorf((*phaseIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a>) / *currEmitPeriod);
00713 *phaseIt -= *currEmitPeriod * numEmissions;
00714 <font class="keywordtype">float</font> deltaT = std::max(*phaseIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a>, 0.f);
00715 <font class="comment">//nlassert(deltaT >= 0.f);</font>
00716
00717 uint emitterIndex = phaseIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin();
00719 numEmissions = <a class="code" href="namespaceNL3D.html#a420">GenEmitterPositions</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>,
00720 <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>,
00721 emitterIndex,
00722 numEmissions,
00723 deltaT,
00724 *currEmitPeriod,
00725 emitterPositions
00726 );
00728 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, emitterIndex) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00729 uint k = numEmissions;
00730 <font class="keywordflow">do</font>
00731 {
00732 --k;
00733 <a class="code" href="classNL3D_1_1CPSEmitter.html#b1">processEmitConsistent</a>(emitterPositions[k],
00734 emitterIndex,
00735 nbToGenerate,
00736 deltaT,
00737 ellapsedTime,
00738 realEllapsedTimeRatio);
00739 deltaT += *currEmitPeriod;
00740 }
00741 <font class="keywordflow">while</font> (k);
00742 }
00743 <font class="keywordflow">else</font>
00744 {
00745 <font class="keyword">const</font> uint32 emitterIndex = phaseIt - (<a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin());
00746 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, emitterIndex) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00747 <a class="code" href="classNL3D_1_1CPSEmitter.html#b0">processEmit</a>(emitterIndex, nbToGenerate);
00748 }
00749 }
00750
00751 ++phaseIt;
00752 currEmitPeriod += currEmitPeriodPtrInc;
00753 }
00754 <font class="keywordflow">while</font> (phaseIt != endPhaseIt);
00755 }
00756 }
00757 <font class="keywordflow">else</font> <font class="comment">// there's an emission count limit</font>
00758 {
00760 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a> == 0.f) <font class="comment">// no emission delay</font>
00761 {
00762 <font class="keywordflow">do</font>
00763 {
00764 <font class="keywordflow">if</font> (*numEmitIt < <a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a>)
00765 {
00766 *phaseIt += ellapsedTime;
00767 <font class="keywordflow">if</font> ( *phaseIt >= *currEmitPeriod) <font class="comment">// phase is greater than period -> must emit</font>
00768 {
00769 <font class="keywordflow">if</font> (*currEmitPeriod != 0)
00770 {
00773 *phaseIt = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(*phaseIt, *currEmitPeriod + ellapsedTime);
00774 <font class="comment">//</font>
00775 uint numEmissions = (uint) ::floorf(*phaseIt / *currEmitPeriod);
00776 *numEmitIt += numEmissions;
00777 *phaseIt -= *currEmitPeriod * numEmissions;
00778 <font class="keywordtype">float</font> deltaT = std::max(*phaseIt, 0.f);
00779 <font class="comment">//nlassert(deltaT >= 0.f);</font>
00780 uint emitterIndex = phaseIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin();
00781 <font class="keywordflow">if</font> (*numEmitIt > <a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a>) <font class="comment">// make sure we don't go over the emission limit</font>
00782 {
00783 numEmissions -= *numEmitIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a>;
00784 *numEmitIt = <a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a>;
00785 }
00787 numEmissions = <a class="code" href="namespaceNL3D.html#a420">GenEmitterPositions</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>,
00788 <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>,
00789 emitterIndex,
00790 numEmissions,
00791 deltaT,
00792 *currEmitPeriod,
00793 emitterPositions
00794 );
00795 uint k = numEmissions;
00797 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, emitterIndex) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00798 <font class="keywordflow">do</font>
00799 {
00800 --k;
00801 <a class="code" href="classNL3D_1_1CPSEmitter.html#b1">processEmitConsistent</a>(emitterPositions[k],
00802 emitterIndex,
00803 nbToGenerate,
00804 deltaT,
00805 ellapsedTime,
00806 realEllapsedTimeRatio);
00807 deltaT += *currEmitPeriod;
00808 }
00809 <font class="keywordflow">while</font> (k);
00810 }
00811 <font class="keywordflow">else</font>
00812 {
00813 <font class="keyword">const</font> uint32 emitterIndex = phaseIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin();
00814 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, emitterIndex) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00815 <a class="code" href="classNL3D_1_1CPSEmitter.html#b0">processEmit</a>(emitterIndex, nbToGenerate);
00816 ++*numEmitIt;
00817 }
00818 }
00819 }
00820 ++phaseIt;
00821 currEmitPeriod += currEmitPeriodPtrInc;
00822 ++ numEmitIt;
00823 }
00824 <font class="keywordflow">while</font> (phaseIt != endPhaseIt);
00825 }
00826 <font class="keywordflow">else</font> <font class="comment">// there's an emission delay</font>
00827 {
00828 <font class="keywordflow">do</font>
00829 {
00830 <font class="keywordflow">if</font> (*numEmitIt < <a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a>)
00831 {
00832 *phaseIt += ellapsedTime;
00833 <font class="keywordflow">if</font> ( *phaseIt >= *currEmitPeriod + <a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a>) <font class="comment">// phase is greater than period -> must emit</font>
00834 {
00835 <font class="keywordflow">if</font> (*currEmitPeriod != 0)
00836 {
00839 *phaseIt = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(*phaseIt, *currEmitPeriod + ellapsedTime + <a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a>);
00840 <font class="comment">//</font>
00841 uint numEmissions = (uint) ::floorf((*phaseIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a>) / *currEmitPeriod);
00842 *numEmitIt += numEmissions;
00843 *phaseIt -= *currEmitPeriod * numEmissions;
00844 <font class="keywordtype">float</font> deltaT = std::max(*phaseIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n9">_EmitDelay</a>, 0.f);
00845 <font class="comment">//nlassert(deltaT >= 0.f);</font>
00846 uint emitterIndex = phaseIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin();
00847 <font class="keywordflow">if</font> (*numEmitIt > <a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a>) <font class="comment">// make sure we don't go over the emission limit</font>
00848 {
00849 numEmissions -= *numEmitIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a>;
00850 *numEmitIt = <a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a>;
00851 }
00853 numEmissions = <a class="code" href="namespaceNL3D.html#a420">GenEmitterPositions</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>,
00854 <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>,
00855 emitterIndex,
00856 numEmissions,
00857 deltaT,
00858 *currEmitPeriod,
00859 emitterPositions
00860 );
00861 uint k = numEmissions;
00863 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, emitterIndex) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00864 <font class="keywordflow">do</font>
00865 {
00866 --k;
00867 <a class="code" href="classNL3D_1_1CPSEmitter.html#b1">processEmitConsistent</a>(emitterPositions[k],
00868 emitterIndex,
00869 nbToGenerate,
00870 deltaT,
00871 ellapsedTime,
00872 realEllapsedTimeRatio);
00873 deltaT += *currEmitPeriod;
00874 }
00875 <font class="keywordflow">while</font> (k);
00876 }
00877 <font class="keywordflow">else</font>
00878 {
00879 <font class="keyword">const</font> uint32 emitterIndex = phaseIt - (<a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin());
00880 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, emitterIndex) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00881 <a class="code" href="classNL3D_1_1CPSEmitter.html#b0">processEmit</a>(emitterIndex, nbToGenerate);
00882 ++*numEmitIt;
00883 }
00884 }
00885 }
00886 ++phaseIt;
00887 currEmitPeriod += currEmitPeriodPtrInc;
00888 ++numEmitIt;
00889 }
00890 <font class="keywordflow">while</font> (phaseIt != endPhaseIt);
00891 }
00892 }
00893
00894 leftToDo -= toProcess;
00895 }
00896 <font class="keywordflow">while</font> (leftToDo);
00897 }
00898
<a name="l00900"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a3">00900</a> <font class="keywordtype">void</font> CPSEmitter::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> realEllapsedTime)
00901 {
00902 <font class="keywordflow">if</font> (pass == <a class="code" href="namespaceNL3D.html#a484a171">PSToolRender</a>)
00903 {
00904 <a class="code" href="classNL3D_1_1CPSEmitter.html#a4">showTool</a>();
00905 <font class="keywordflow">return</font>;
00906 }
00907 <font class="keywordflow">if</font> (pass != <a class="code" href="namespaceNL3D.html#a484a166">PSEmit</a> || !<a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>) <font class="keywordflow">return</font>;
00908 <font class="keyword">const</font> uint32 size = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize();
00909 <font class="keywordflow">if</font> (!size) <font class="keywordflow">return</font>;
00910
00911 <font class="keywordflow">if</font> (ellapsedTime == 0.f) <font class="keywordflow">return</font>; <font class="comment">// do nothing when paused</font>
00912
00913 <font class="comment">// our behaviour depend of the frequency</font>
00914 <font class="keywordflow">switch</font> (_EmissionType)
00915 {
00916 <font class="keywordflow">case</font> CPSEmitter::once :
00917 {
00918 TPSAttribTime::iterator timeIt = <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin()
00919 , timeEndIt = <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.end();
00920
00921 <font class="keywordflow">while</font> (timeIt != timeEndIt)
00922 {
00923 <font class="keywordflow">if</font> (*timeIt == 0.f)
00924 {
00925 <font class="keyword">const</font> uint32 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, timeIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin()) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00926 <a class="code" href="classNL3D_1_1CPSEmitter.html#b0">processEmit</a>(timeIt - <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.begin(), nbToGenerate);
00927 *timeIt = 1.f;
00928 }
00929 ++timeIt;
00930 }
00931 }
00932 <font class="keywordflow">break</font>;
00933 <font class="keywordflow">case</font> (CPSEmitter::regular):
00934 {
00935 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSEmitter.html#n13">_ConsistentEmission</a>)
00936 {
00937 <a class="code" href="classNL3D_1_1CPSEmitter.html#b2">processRegularEmission</a>(ellapsedTime);
00938 }
00939 <font class="keywordflow">else</font>
00940 {
00941 <a class="code" href="classNL3D_1_1CPSEmitter.html#b3">processRegularEmissionConsistent</a>(ellapsedTime, realEllapsedTime / ellapsedTime);
00942 }
00943 }
00944 <font class="keywordflow">break</font>;
00945 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
00946 }
00947 }
00948
<a name="l00950"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#b5">00950</a> <font class="keywordtype">void</font> CPSEmitter::newElement(CPSLocated *emitterLocated, uint32 emitterIndex)
00951 {
00952 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.getSize() != <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.getMaxSize());
00953
00954 <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.insert(0.f);
00955 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a> != 0)
00956 {
00957 <a class="code" href="classNL3D_1_1CPSEmitter.html#n2">_NumEmission</a>.insert(0);
00958 }
00959 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a> && <a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a>->hasMemory()) <a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a>->newElement(emitterLocated, emitterIndex);
00960 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> && <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->hasMemory()) <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->newElement(emitterLocated, emitterIndex);
00961
00962 }
00963
<a name="l00965"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#b6">00965</a> <font class="keywordtype">void</font> CPSEmitter::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00966 {
00967
00968 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n4">_EmissionType</a> == CPSEmitter::onDeath && <a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>)
00969 {
00970 <font class="keyword">const</font> uint32 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
00971 <a class="code" href="classNL3D_1_1CPSEmitter.html#b0">processEmit</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, nbToGenerate);
00972 }
00973
00974 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a> && <a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a>->hasMemory()) <a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a>->deleteElement(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00975 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> && <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->hasMemory()) <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->deleteElement(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00976 <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00977 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a> != 0)
00978 {
00979 <a class="code" href="classNL3D_1_1CPSEmitter.html#n2">_NumEmission</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00980 }
00981 }
00982
<a name="l00984"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#b7">00984</a> <font class="keywordtype">void</font> CPSEmitter::resize(uint32 size)
00985 {
00986 <a class="code" href="debug_8h.html#a6">nlassert</a>(size < (1 << 16));
00987 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a> && <a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a>->hasMemory()) <a class="code" href="classNL3D_1_1CPSEmitter.html#n6">_PeriodScheme</a>->resize(size, <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize());
00988 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> && <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->hasMemory()) <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->resize(size, <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize());
00989 <a class="code" href="classNL3D_1_1CPSEmitter.html#n1">_Phase</a>.resize(size);
00990 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a> != 0)
00991 {
00992 <a class="code" href="classNL3D_1_1CPSEmitter.html#n2">_NumEmission</a>.resize(size);
00993 }
00994 }
00995
<a name="l00997"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#b8">00997</a> <font class="keywordtype">void</font> CPSEmitter::bounceOccured(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00998 {
00999 <font class="comment">// TODO : avoid duplication with deleteElement</font>
01000 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n4">_EmissionType</a> == CPSEmitter::onBounce)
01001 {
01002 <font class="keyword">const</font> uint32 nbToGenerate = <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a> ? <a class="code" href="classNL3D_1_1CPSEmitter.html#n8">_GenNbScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>) : <a class="code" href="classNL3D_1_1CPSEmitter.html#n7">_GenNb</a>;
01003 <a class="code" href="classNL3D_1_1CPSEmitter.html#b0">processEmit</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, nbToGenerate);
01004 }
01005 }
01006
<a name="l01008"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a27">01008</a> <font class="keywordtype">void</font> CPSEmitter::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream)
01009 {
01010
01012 sint ver = f.serialVersion(4);
01013 CPSLocatedBindable::serial(f);
01014
01015 f.serialPolyPtr(_EmittedType);
01016 f.serial(_Phase);
01017 f.serial(_SpeedInheritanceFactor);
01018 f.serial(_SpeedBasisEmission);
01019
01020 f.serialEnum(_EmissionType);
01021
01022 <font class="comment">// this is for use with serial</font>
01023 <font class="keywordtype">bool</font> trueB = <font class="keyword">true</font>, falseB = <font class="keyword">false</font>;
01024
01025 <font class="keywordflow">if</font> (!f.isReading())
01026 {
01027 <font class="keywordflow">switch</font> (_EmissionType)
01028 {
01029 <font class="keywordflow">case</font> CPSEmitter::regular:
01030 <font class="keywordflow">if</font> (_PeriodScheme)
01031 {
01032 f.serial(trueB);
01033 f.serialPolyPtr(_PeriodScheme);
01034 }
01035 <font class="keywordflow">else</font>
01036 {
01037 f.serial(falseB);
01038 f.serial(_Period);
01039 }
01040 <font class="keywordflow">if</font> (ver >= 3)
01041 {
01042 f.serial(_EmitDelay, _MaxEmissionCount);
01043 }
01044 <font class="keywordflow">break</font>;
01045 <font class="keywordflow">default</font>:
01046 <font class="keywordflow">break</font>;
01047 }
01048 <font class="keywordflow">if</font> (_GenNbScheme)
01049 {
01050 f.serial(trueB);
01051 f.serialPolyPtr(_GenNbScheme);
01052 }
01053 <font class="keywordflow">else</font>
01054 {
01055 f.serial(falseB);
01056 f.serial(_GenNb);
01057 }
01058 }
01059 <font class="keywordflow">else</font>
01060 {
01061 <font class="keywordtype">bool</font> useScheme;
01062 <font class="keywordflow">switch</font> (_EmissionType)
01063 {
01064 <font class="keywordflow">case</font> CPSEmitter::regular:
01065 {
01066 f.serial(useScheme);
01067 <font class="keywordflow">if</font> (useScheme)
01068 {
01069 <font class="keyword">delete</font> _PeriodScheme;
01070 f.serialPolyPtr(_PeriodScheme);
01071 }
01072 <font class="keywordflow">else</font>
01073 {
01074 f.serial(_Period);
01075 }
01076 <font class="keywordflow">if</font> (ver >= 3)
01077 {
01078 f.serial(_EmitDelay, _MaxEmissionCount);
01079 updateMaxCountVect();
01080 }
01081 }
01082 <font class="keywordflow">break</font>;
01083 <font class="keywordflow">default</font>:
01084 <font class="keywordflow">break</font>;
01085 }
01086
01087 f.serial(useScheme);
01088 <font class="keywordflow">if</font> (useScheme)
01089 {
01090 <font class="keyword">delete</font> _GenNbScheme;
01091 f.serialPolyPtr(_GenNbScheme);
01092 }
01093 <font class="keywordflow">else</font>
01094 {
01095 f.serial(_GenNb);
01096 }
01097 }
01098 <font class="keywordflow">if</font> (ver > 1)
01099 {
01100 f.serial(_EmitDirBasis);
01101 }
01102 <font class="keywordflow">if</font> (ver >= 4)
01103 {
01104 f.serial(_ConsistentEmission);
01105 }
01106 }
01107
<a name="l01109"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#b9">01109</a> <font class="keywordtype">void</font> CPSEmitter::updateMaxCountVect()
01110 {
01111 <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a>)
01112 {
01113 <a class="code" href="classNL3D_1_1CPSEmitter.html#n2">_NumEmission</a>.resize(0);
01114 }
01115 <font class="keywordflow">else</font>
01116 {
01117 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
01118 <a class="code" href="classNL3D_1_1CPSEmitter.html#n2">_NumEmission</a>.resize(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getMaxSize());
01119 <font class="keywordflow">while</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n2">_NumEmission</a>.getSize() != 0)
01120 {
01121 <a class="code" href="classNL3D_1_1CPSEmitter.html#n2">_NumEmission</a>.remove(0);
01122 }
01123 <font class="keywordflow">while</font> (<a class="code" href="classNL3D_1_1CPSEmitter.html#n2">_NumEmission</a>.getSize() != <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize())
01124 {
01125 <a class="code" href="classNL3D_1_1CPSEmitter.html#n2">_NumEmission</a>.insert(0);
01126 }
01127 }
01128 }
01129
<a name="l01131"></a><a class="code" href="classNL3D_1_1CPSEmitter.html#a19">01131</a> <font class="keywordtype">void</font> CPSEmitter::setMaxEmissionCount(uint8 count)
01132 {
01133 <font class="keywordflow">if</font> (count == <a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a>) <font class="keywordflow">return</font>;
01134 <a class="code" href="classNL3D_1_1CPSEmitter.html#n10">_MaxEmissionCount</a> = count;
01135 <a class="code" href="classNL3D_1_1CPSEmitter.html#b9">updateMaxCountVect</a>();
01136 }
01137
01138
01139
01141 <font class="comment">// implementation of CPSModulatedEmitter //</font>
01143 <font class="comment"></font>
<a name="l01144"></a><a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#a8">01144</a> <font class="keywordtype">void</font> CPSModulatedEmitter::serialEmitteeSpeedScheme(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream)
01145 {
01146 <font class="keywordtype">bool</font> useScheme;
01147 <font class="keywordflow">if</font> (!f.isReading())
01148 {
01149 useScheme = useEmitteeSpeedScheme();
01150 }
01151 f.serial(useScheme);
01152 <font class="keywordflow">if</font> (useScheme)
01153 {
01154 f.serialPolyPtr(_EmitteeSpeedScheme);
01155 }
01156 <font class="keywordflow">else</font>
01157 {
01158 f.serial(_EmitteeSpeed);
01159 }
01160 }
01161
01162
01163
01165 <font class="comment">// implementation of CPSEmitterOmni //</font>
01167 <font class="comment"></font>
<a name="l01169"></a><a class="code" href="classNL3D_1_1CPSEmitterOmni.html#a3">01169</a> <font class="comment">void CPSEmitterOmni::emit(const NLMISC::CVector &srcPos, uint32 index, CVector &pos, CVector &speed)</font>
01170 {
01171 <font class="comment">// TODO : verifier que ca marche si une particule s'emet elle-mem</font>
01172 <a class="code" href="debug_8h.html#a6">nlassert</a>(_EmittedType);
01173
01174 CVector <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>( ((rand() % 1000) - 500) / 500.0f
01175 , ((rand() % 1000) - 500) / 500.0f
01176 , ((rand() % 1000) - 500) / 500.0f);
01177 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>.normalize();
01178 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> *= _EmitteeSpeedScheme ? _EmitteeSpeedScheme->get(_Owner, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>) : _EmitteeSpeed;
01179
01180 pos = srcPos;
01181 speed = <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>;
01182 }
01183
<a name="l01185"></a><a class="code" href="classNL3D_1_1CPSEmitterOmni.html#a1">01185</a> <font class="keywordtype">void</font> CPSEmitterOmni::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream)
01186 {
01187 f.serialVersion(1);
01188 CPSEmitter::serial(f);
01189 CPSModulatedEmitter::serialEmitteeSpeedScheme(f);
01190 }
01191
<a name="l01193"></a><a class="code" href="classNL3D_1_1CPSEmitterOmni.html#b1">01193</a> <font class="keywordtype">void</font> CPSEmitterOmni::newElement(CPSLocated *emitter, uint32 emitterIndex)
01194 {
01195 CPSEmitter::newElement(emitter, emitterIndex);
01196 <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#b1">newEmitteeSpeedElement</a>(emitter, emitterIndex);
01197 }
01198
<a name="l01200"></a><a class="code" href="classNL3D_1_1CPSEmitterOmni.html#b2">01200</a> <font class="keywordtype">void</font> CPSEmitterOmni::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
01201 {
01202 CPSEmitter::deleteElement(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01203 <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#b2">deleteEmitteeSpeedElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01204 }
01205
<a name="l01207"></a><a class="code" href="classNL3D_1_1CPSEmitterOmni.html#b3">01207</a> <font class="keywordtype">void</font> CPSEmitterOmni::resize(uint32 capacity)
01208 {
01209 <a class="code" href="debug_8h.html#a6">nlassert</a>(capacity < (1 << 16));
01210 CPSEmitter::resize(capacity);
01211 <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#b3">resizeEmitteeSpeed</a>(capacity);
01212 }
01213
<a name="l01215"></a><a class="code" href="classNL3D_1_1CPSEmitterDirectionnal.html#a3">01215</a> <font class="keywordtype">void</font> CPSEmitterDirectionnal::emit(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &srcPos, uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, CVector &pos, CVector &speed)
01216 {
01217 <font class="comment">// TODO : verifier que ca marche si une particule s'emet elle-mem</font>
01218 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>);
01219
01220
01221 speed = (<a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#n1">_EmitteeSpeedScheme</a> ? <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#n1">_EmitteeSpeedScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>) : <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#n0">_EmitteeSpeed</a>) * <a class="code" href="classNL3D_1_1CPSEmitterDirectionnal.html#n0">_Dir</a>;
01222 pos = srcPos;
01223 }
01224
<a name="l01226"></a><a class="code" href="classNL3D_1_1CPSEmitterDirectionnal.html#b1">01226</a> <font class="keywordtype">void</font> CPSEmitterDirectionnal::newElement(CPSLocated *emitter, uint32 emitterIndex)
01227 {
01228 CPSEmitter::newElement(emitter, emitterIndex);
01229 <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#b1">newEmitteeSpeedElement</a>(emitter, emitterIndex);
01230 }
01231
<a name="l01233"></a><a class="code" href="classNL3D_1_1CPSEmitterDirectionnal.html#b2">01233</a> <font class="keywordtype">void</font> CPSEmitterDirectionnal::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
01234 {
01235 CPSEmitter::deleteElement(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01236 <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#b2">deleteEmitteeSpeedElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01237 }
01238
<a name="l01240"></a><a class="code" href="classNL3D_1_1CPSEmitterDirectionnal.html#b3">01240</a> <font class="keywordtype">void</font> CPSEmitterDirectionnal::resize(uint32 capacity)
01241 {
01242 <a class="code" href="debug_8h.html#a6">nlassert</a>(capacity < (1 << 16));
01243 CPSEmitter::resize(capacity);
01244 <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#b3">resizeEmitteeSpeed</a>(capacity);
01245 }
01246
<a name="l01248"></a><a class="code" href="classNL3D_1_1CPSEmitterDirectionnal.html#a1">01248</a> <font class="keywordtype">void</font> CPSEmitterDirectionnal::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream)
01249 {
01250 f.serialVersion(1);
01251 CPSEmitter::serial(f);
01252 CPSModulatedEmitter::serialEmitteeSpeedScheme(f);
01253 f.serial(_Dir);
01254 }
01255
01257 <font class="comment">// implementation of CPSEmitterRectangle //</font>
01259 <font class="comment"></font>
<a name="l01261"></a><a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#a1">01261</a> <font class="comment">void CPSEmitterRectangle::serial(NLMISC::IStream &f) throw(NLMISC::EStream)</font>
01262 {
01263 f.serialVersion(1);
01264 CPSEmitter::serial(f);
01265 CPSModulatedEmitter::serialEmitteeSpeedScheme(f);
01266 f.serial(_Basis);
01267 f.serial(_Width);
01268 f.serial(_Height);
01269 f.serial(_Dir);
01270
01271 }
01272
<a name="l01274"></a><a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#a3">01274</a> <font class="keywordtype">void</font> CPSEmitterRectangle::emit(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &srcPos, uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, CVector &pos, CVector &speed)
01275 {
01276 CVector N = <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].X ^ <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].Y;
01277 pos = srcPos + ((rand() % 32000) * (1.f / 16000) - 1.f) * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n1">_Width</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].X
01278 + ((rand() % 32000) * (1.f / 16000) - 1.f) * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n2">_Height</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].Y;
01279 speed = (<a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#n1">_EmitteeSpeedScheme</a> ? <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#n1">_EmitteeSpeedScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>) : <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#n0">_EmitteeSpeed</a>)
01280 * (<a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n3">_Dir</a>.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].X+ <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n3">_Dir</a>.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].Y + <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n3">_Dir</a>.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> * N);
01281 }
01282
<a name="l01284"></a><a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#a9">01284</a> <font class="keywordtype">void</font> CPSEmitterRectangle::setMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">const</font> CMatrix &m)
01285 {
01286 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = m.getPos();
01287
01288
01289 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].X = m.getI();
01290 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].Y = m.getJ();
01291 }
01292
<a name="l01294"></a><a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#a10">01294</a> CMatrix CPSEmitterRectangle::getMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font>
01295 <font class="keyword"></font>{
01296 CMatrix m;
01297 m.setPos(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>]);
01298 m.setRot(<a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].X, <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].Y, <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].X ^ <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].Y, <font class="keyword">true</font>);
01299 <font class="keywordflow">return</font> m;
01300 }
01301
<a name="l01303"></a><a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#a11">01303</a> <font class="keywordtype">void</font> CPSEmitterRectangle::setScale(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keywordtype">float</font> scale)
01304 {
01305 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n1">_Width</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = scale;
01306 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n2">_Height</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = scale;
01307 }
01308
<a name="l01310"></a><a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#a12">01310</a> <font class="keywordtype">void</font> CPSEmitterRectangle::setScale(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>)
01311 {
01312 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n1">_Width</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>.x;
01313 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n2">_Height</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>.y;
01314 }
01315
<a name="l01317"></a><a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#a13">01317</a> CVector CPSEmitterRectangle::getScale(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font>
01318 <font class="keyword"></font>{
01319 <font class="keywordflow">return</font> CVector(<a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n1">_Width</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n2">_Height</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], 1.f);
01320 }
01321
<a name="l01323"></a><a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#b1">01323</a> <font class="keywordtype">void</font> CPSEmitterRectangle::newElement(CPSLocated *emitterLocated, uint32 emitterIndex)
01324 {
01325 CPSEmitter::newElement(emitterLocated, emitterIndex);
01326 <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#b1">newEmitteeSpeedElement</a>(emitterLocated, emitterIndex);
01327 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>.insert(CPlaneBasis(CVector::K));
01328 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n1">_Width</a>.insert(1.f);
01329 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n2">_Height</a>.insert(1.f);
01330 }
01331
<a name="l01333"></a><a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#b2">01333</a> <font class="keywordtype">void</font> CPSEmitterRectangle::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
01334 {
01335 CPSEmitter::deleteElement(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01336 <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#b2">deleteEmitteeSpeedElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01337 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01338 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n1">_Width</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01339 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n2">_Height</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01340 }
01341
<a name="l01343"></a><a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#b3">01343</a> <font class="keywordtype">void</font> CPSEmitterRectangle::resize(uint32 size)
01344 {
01345 <a class="code" href="debug_8h.html#a6">nlassert</a>(size < (1 << 16));
01346 CPSEmitter::resize(size);
01347 <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#b3">resizeEmitteeSpeed</a>(size);
01348 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>.resize(size);
01349 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n1">_Width</a>.resize(size);
01350 <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n2">_Height</a>.resize(size);
01351 }
01352
<a name="l01354"></a><a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#a6">01354</a> <font class="keywordtype">void</font> CPSEmitterRectangle::showTool(<font class="keywordtype">void</font>)
01355 {
01356 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
01357 <font class="keyword">const</font> uint size = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getSize();
01358 <font class="keywordflow">if</font> (!size) <font class="keywordflow">return</font>;
01359 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();
01360 CMatrix mat;
01361
01362 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#l0">CPSLocated</a> *loc;
01363 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>;
01364 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#z720_0">CPSLocatedBindable</a> *lb;
01365 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner()->getCurrentEditedElement(loc, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, lb);
01366
01367 <font class="keywordflow">for</font> (uint k = 0; k < size; ++k)
01368 {
01369 <font class="keyword">const</font> CVector &I = <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[k].X;
01370 <font class="keyword">const</font> CVector &J = <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n0">_Basis</a>[k].Y;
01371 mat.setRot(I, J , I ^J);
01372 mat.setPos(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos()[k]);
01373 CPSUtil::displayBasis(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>() ,<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a17">getLocatedMat</a>(), mat, 1.f, *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a11">getFontGenerator</a>(), *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a13">getFontManager</a>());
01374 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();
01375
01376 <font class="keyword">const</font> CRGBA col = ((lb == NULL || <font class="keyword">this</font> == lb) && loc == <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> && <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> == k ? CRGBA::Red : CRGBA(127, 127, 127));
01377
01378
01379
01380 <font class="keyword">const</font> CVector &pos = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos()[k];
01381 CPSUtil::display3DQuad(*<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>(), pos + I * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n1">_Width</a>[k] + J * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n2">_Height</a>[k]
01382 , pos + I * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n1">_Width</a>[k] - J * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n2">_Height</a>[k]
01383 , pos - I * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n1">_Width</a>[k] - J * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n2">_Height</a>[k]
01384 , pos - I * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n1">_Width</a>[k] + J * <a class="code" href="classNL3D_1_1CPSEmitterRectangle.html#n2">_Height</a>[k], col);
01385 }
01386 }
01387
01388
01389
01391 <font class="comment">// CPSEmitterconic implementation //</font>
01393 <font class="comment"></font>
<a name="l01395"></a><a class="code" href="classNL3D_1_1CPSEmitterConic.html#a1">01395</a> <font class="comment">void CPSEmitterConic::serial(NLMISC::IStream &f) throw(NLMISC::EStream)</font>
01396 {
01397 f.serialVersion(1);
01398 CPSEmitterDirectionnal::serial(f);
01399 f.serial(_Radius);
01400 }
01401
<a name="l01403"></a><a class="code" href="classNL3D_1_1CPSEmitterConic.html#a6">01403</a> <font class="keywordtype">void</font> CPSEmitterConic::setDir(<font class="keyword">const</font> CVector &<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>)
01404 {
01405 CPSEmitterDirectionnal::setDir(<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>);
01406
01407 }
01408
<a name="l01410"></a><a class="code" href="classNL3D_1_1CPSEmitterConic.html#a3">01410</a> <font class="keywordtype">void</font> CPSEmitterConic::emit(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &srcPos, uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, CVector &pos, CVector &speed)
01411 {
01412 <font class="comment">// TODO : optimize that</font>
01413 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>);
01414
01415 <font class="comment">// we choose a custom direction like with omnidirectionnal emitter</font>
01416 <font class="comment">// then we force the direction vect to have the unit size</font>
01417
01418 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">double</font> divRand = (2.0 / RAND_MAX);
01419
01420 CVector dir((<font class="keywordtype">float</font>) (rand() * divRand - 1)
01421 , (<font class="keywordtype">float</font>) (rand() * divRand - 1)
01422 , (<font class="keywordtype">float</font>) (rand() * divRand - 1) );
01423
01424 <font class="keyword">const</font> <font class="keywordtype">float</font> n =dir.norm();
01425
01426 dir *= <a class="code" href="classNL3D_1_1CPSEmitterConic.html#n0">_Radius</a> / n;
01427
01428 dir -= (<a class="code" href="classNL3D_1_1CPSEmitterDirectionnal.html#n0">_Dir</a> * dir) * <a class="code" href="classNL3D_1_1CPSEmitterDirectionnal.html#n0">_Dir</a>;
01429 dir += <a class="code" href="classNL3D_1_1CPSEmitterDirectionnal.html#n0">_Dir</a>;
01430 dir.<a class="code" href="classNLMISC_1_1CVector.html#z331_4">normalize</a>();
01431
01432
01433 speed = (<a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#n1">_EmitteeSpeedScheme</a> ? <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#n1">_EmitteeSpeedScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>) : <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#n0">_EmitteeSpeed</a>)
01434 * dir;
01435 pos = srcPos;
01436 }
01437
01439 <font class="comment">// CPSSphericalEmitter implementation //</font>
01441 <font class="comment"></font>
<a name="l01443"></a><a class="code" href="classNL3D_1_1CPSSphericalEmitter.html#a3">01443</a> <font class="comment">void CPSSphericalEmitter::emit(const NLMISC::CVector &srcPos, uint32 index, CVector &pos, CVector &speed)</font>
01444 {
01445 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">double</font> divRand = (2.0 / RAND_MAX);
01446 CVector dir((<font class="keywordtype">float</font>) (rand() * divRand - 1), (<font class="keywordtype">float</font>) (rand() * divRand - 1) , (<font class="keywordtype">float</font>) (rand() * divRand - 1) );
01447 dir.normalize();
01448 pos = srcPos + _Radius[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] * dir;
01449 speed = (_EmitteeSpeedScheme ? _EmitteeSpeedScheme->get(_Owner, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>) : _EmitteeSpeed) * dir;
01450 }
01451
01452
<a name="l01454"></a><a class="code" href="classNL3D_1_1CPSSphericalEmitter.html#a4">01454</a> <font class="keywordtype">void</font> CPSSphericalEmitter::showTool(<font class="keywordtype">void</font>)
01455 {
01456 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#l0">CPSLocated</a> *loc;
01457 uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>;
01458 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#z720_0">CPSLocatedBindable</a> *lb;
01459 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getOwner()->getCurrentEditedElement(loc, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, lb);
01460
01461
01462 TPSAttribFloat::const_iterator radiusIt = <a class="code" href="classNL3D_1_1CPSSphericalEmitter.html#n0">_Radius</a>.begin();
01463 TPSAttribVector::const_iterator posIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos().begin(), endPosIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos().end();
01464 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();
01465 <font class="keywordflow">for</font> (uint k = 0; posIt != endPosIt; ++posIt, ++radiusIt, ++k)
01466 {
01467 <font class="keyword">const</font> CRGBA col = ((lb == NULL || <font class="keyword">this</font> == lb) && loc == <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> && <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> == k ? CRGBA::Red : CRGBA(127, 127, 127));
01468 CPSUtil::displaySphere(*<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>(), *radiusIt, *posIt, 5, col);
01469 }
01470 }
01471
01472
<a name="l01474"></a><a class="code" href="classNL3D_1_1CPSSphericalEmitter.html#a7">01474</a> <font class="keywordtype">void</font> CPSSphericalEmitter::setMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">const</font> CMatrix &m)
01475 {
01476 <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_1CPSSphericalEmitter.html#n0">_Radius</a>.getSize());
01477 <font class="comment">// compute new pos</font>
01478 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = m.getPos();
01479
01480 }
01481
<a name="l01483"></a><a class="code" href="classNL3D_1_1CPSSphericalEmitter.html#a8">01483</a> CMatrix CPSSphericalEmitter::getMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font>
01484 <font class="keyword"></font>{
01485 <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_1CPSSphericalEmitter.html#n0">_Radius</a>.getSize());
01486 CMatrix m;
01487 m.identity();
01488 m.translate(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>->getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>]);
01489 <font class="keywordflow">return</font> m;
01490 }
01491
<a name="l01493"></a><a class="code" href="classNL3D_1_1CPSSphericalEmitter.html#a1">01493</a> <font class="keywordtype">void</font> CPSSphericalEmitter::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &f) <font class="keywordflow">throw</font>(NLMISC::EStream)
01494 {
01495 f.serialVersion(1);
01496 CPSEmitter::serial(f);
01497 CPSModulatedEmitter::serialEmitteeSpeedScheme(f);
01498 f.serial(_Radius);
01499 }
01500
<a name="l01502"></a><a class="code" href="classNL3D_1_1CPSSphericalEmitter.html#b1">01502</a> <font class="keywordtype">void</font> CPSSphericalEmitter::newElement(CPSLocated *emitterLocated, uint32 emitterIndex)
01503 {
01504 CPSEmitter::newElement(emitterLocated, emitterIndex);
01505 <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#b1">newEmitteeSpeedElement</a>(emitterLocated, emitterIndex);
01506 <a class="code" href="classNL3D_1_1CPSSphericalEmitter.html#n0">_Radius</a>.insert(1.f);
01507 }
01508
<a name="l01510"></a><a class="code" href="classNL3D_1_1CPSSphericalEmitter.html#b2">01510</a> <font class="keywordtype">void</font> CPSSphericalEmitter::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
01511 {
01512 CPSEmitter::deleteElement(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01513 <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#b2">deleteEmitteeSpeedElement</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01514 <a class="code" href="classNL3D_1_1CPSSphericalEmitter.html#n0">_Radius</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01515 }
01516
<a name="l01518"></a><a class="code" href="classNL3D_1_1CPSSphericalEmitter.html#b3">01518</a> <font class="keywordtype">void</font> CPSSphericalEmitter::resize(uint32 size)
01519 {
01520 <a class="code" href="debug_8h.html#a6">nlassert</a>(size < (1 << 16));
01521 CPSEmitter::resize(size);
01522 <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#b3">resizeEmitteeSpeed</a>(size);
01523 <a class="code" href="classNL3D_1_1CPSSphericalEmitter.html#n0">_Radius</a>.resize(size);
01524 }
01525
01527 <font class="comment">// CPSRadialEmitter implementation //</font>
01529 <font class="comment"></font>
<a name="l01531"></a><a class="code" href="classNL3D_1_1CPSRadialEmitter.html#a1">01531</a> <font class="comment">void CPSRadialEmitter::serial(NLMISC::IStream &f) throw(NLMISC::EStream)</font>
01532 {
01533 f.serialVersion(1);
01534 CPSEmitterDirectionnal::serial(f);
01535 }
01536
<a name="l01538"></a><a class="code" href="classNL3D_1_1CPSRadialEmitter.html#a3">01538</a> <font class="keywordtype">void</font> CPSRadialEmitter::emit(<font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &srcPos, uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &pos, <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &speed)
01539 {
01540 <font class="comment">// TODO : verifier que ca marche si une particule s'emet elle-mem</font>
01541 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSEmitter.html#n0">_EmittedType</a>);
01542
01543 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">double</font> divRand = (2.0 / RAND_MAX);
01544 CVector dir((<font class="keywordtype">float</font>) (rand() * divRand - 1)
01545 , (<font class="keywordtype">float</font>) (rand() * divRand - 1)
01546 , (<font class="keywordtype">float</font>) (rand() * divRand - 1) );
01547 dir -= (dir * <a class="code" href="classNL3D_1_1CPSEmitterDirectionnal.html#n0">_Dir</a>) * <a class="code" href="classNL3D_1_1CPSEmitterDirectionnal.html#n0">_Dir</a>; <font class="comment">//keep tangential direction</font>
01548 dir.<a class="code" href="classNLMISC_1_1CVector.html#z331_4">normalize</a>();
01549
01550 speed = (<a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#n1">_EmitteeSpeedScheme</a> ? <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#n1">_EmitteeSpeedScheme</a>->get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>) : <a class="code" href="classNL3D_1_1CPSModulatedEmitter.html#n0">_EmitteeSpeed</a>) * dir;
01551 pos = srcPos;
01552 }
01553
01554
01555
01556 } <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>
|