aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/ps__force_8cpp-source.html
blob: 15f8b09bced87c6a18751c43bb434e68fe32f90f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
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
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
	<TITLE>nevrax.org : docs</TITLE>
	<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
	<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">

<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0>
 <TR>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=140 BGCOLOR=#dddddd><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
        <TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
        <TD><IMG  width=6 height=14  SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
 </TR>
</TABLE> 

<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 WIDTH=100%>
 <TR><TD  BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG  SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>

<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0  BORDER=0 height=100%>
 <TR>
	<TD WIDTH=16><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
	<TD WIDTH=140   BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

		<!------ Begin Box ------>
		<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0  cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
		<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td  colspan=2 bgcolor=#FFFFFF>
		<TABLE cellspacing=0 cellpadding=1 border=0>
			<tr><td ALIGN=middle><a  class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15  hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a  class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11  hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a  class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16  hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a  class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17  hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a  class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16  hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a  class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
			<tr><td ALIGN=middle><a  class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img  width=18 height=12   hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a  class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
		</TABLE>
		</TD></TR></TABLE></TD></TR></TABLE>
		<!------ End Box  ------>

	</TD>
	<TD WIDTH=15><IMG  SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
	<TD ALIGN=left valign=top><IMG  SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">

<!-- title -->
<TABLE  background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG  SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
&nbsp;

<!-- block -->
<TABLE  bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
	<TD><B>Documentation</B></TD>
	<TD ALIGN=RIGHT>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>ps_force.cpp</h1><a href="ps__force_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025 
00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font>
00027 
00028 <font class="preprocessor">#include "<a class="code" href="ps__force_8h.html">3d/ps_force.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="driver_8h.html">3d/driver.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="3d_2primitive__block_8h.html">3d/primitive_block.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="material_8h.html">3d/material.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="vertex__buffer_8h.html">3d/vertex_buffer.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="computed__string_8h.html">3d/computed_string.h</a>"</font>
00034 <font class="preprocessor">#include "<a class="code" href="font__manager_8h.html">3d/font_manager.h</a>"</font>
00035 <font class="preprocessor">#include "<a class="code" href="particle__system_8h.html">3d/particle_system.h</a>"</font>
00036 <font class="preprocessor">#include "<a class="code" href="common_8h.html">nel/misc/common.h</a>"</font>
00037 <font class="preprocessor">#include "<a class="code" href="ps__util_8h.html">3d/ps_util.h</a>"</font>
00038 <font class="preprocessor">#include "<a class="code" href="ps__misc_8h.html">3d/ps_misc.h</a>"</font>
00039 
00040 <font class="keyword">namespace </font>NL3D {
00041 
00042 
00043 <font class="comment">/*</font>
00044 <font class="comment"> * Constructor</font>
00045 <font class="comment"> */</font>
<a name="l00046"></a><a class="code" href="classNL3D_1_1CPSForce.html#a0">00046</a> CPSForce::CPSForce()
00047 {
00048 }
00049 
00050 
00051 
<a name="l00052"></a><a class="code" href="classNL3D_1_1CPSForce.html#a7">00052</a> <font class="keywordtype">void</font> CPSForce::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00053 {
00054         
00055                 f.serialVersion(1);     
00056                 CPSTargetLocatedBindable::serial(f);    
00057                 CPSLocatedBindable::serial(f);
00058         
00059 }
00060 
00061 
<a name="l00062"></a><a class="code" href="classNL3D_1_1CPSForce.html#b0">00062</a> <font class="keywordtype">void</font> CPSForce::registerToTargets(<font class="keywordtype">void</font>)
00063 {
00064         <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00065         {
00066                 <font class="keywordflow">if</font> (this-&gt;<a class="code" href="classNL3D_1_1CPSForce.html#a8">isIntegrable</a>())
00067                 {                                               
00068                         (*it)-&gt;registerIntegrableForce(<font class="keyword">this</font>);
00069                 }
00070                 <font class="keywordflow">else</font>
00071                 {
00072                         (*it)-&gt;addNonIntegrableForceRef();
00073                 }
00074         }
00075 }
00076 
00077 
<a name="l00078"></a><a class="code" href="classNL3D_1_1CPSForce.html#a4">00078</a> <font class="keywordtype">void</font> CPSForce::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)
00079 {
00080         <font class="keywordflow">switch</font>(pass)
00081         {
00082                 <font class="keywordflow">case</font> <a class="code" href="namespaceNL3D.html#a484a168">PSMotion</a>:
00083                         <a class="code" href="classNL3D_1_1CPSForce.html#a5">performDynamic</a>(ellapsedTime);
00084                         <font class="keywordflow">break</font>;
00085                 <font class="keywordflow">case</font> <a class="code" href="namespaceNL3D.html#a484a171">PSToolRender</a>:
00086                         <a class="code" href="classNL3D_1_1CPSForce.html#a6">show</a>(ellapsedTime);
00087                         <font class="keywordflow">break</font>;
00088                 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
00089         }
00090 }
00091 
00092 
00093 
<a name="l00094"></a><a class="code" href="classNL3D_1_1CPSForce.html#a9">00094</a> <font class="keywordtype">void</font>    CPSForce::attachTarget(CPSLocated *ptr)
00095 {
00096         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);       
00097         CPSTargetLocatedBindable::attachTarget(ptr);
00098         <font class="comment">// check wether we are integrable, and if so, add us to the list</font>
00099         <font class="keywordflow">if</font> (this-&gt;<a class="code" href="classNL3D_1_1CPSForce.html#a8">isIntegrable</a>())
00100         {
00101                 ptr-&gt;registerIntegrableForce(<font class="keyword">this</font>);
00102         }
00103         <font class="keywordflow">else</font>
00104         {
00105                 ptr-&gt;addNonIntegrableForceRef();
00106         }
00107 }
00108 
<a name="l00109"></a><a class="code" href="classNL3D_1_1CPSForce.html#a10">00109</a> <font class="keywordtype">void</font>    CPSForce::releaseTargetRsc(CPSLocated *target)
00110 {
00111         <font class="keywordflow">if</font> (this-&gt;<a class="code" href="classNL3D_1_1CPSForce.html#a8">isIntegrable</a>())
00112         {
00113                 target-&gt;unregisterIntegrableForce(<font class="keyword">this</font>);
00114         }
00115         <font class="keywordflow">else</font>
00116         {
00117                 target-&gt;releaseNonIntegrableForceRef();
00118         }       
00119 }
00120 
00121 
00122 
<a name="l00123"></a><a class="code" href="classNL3D_1_1CPSForce.html#b3">00123</a> <font class="keywordtype">void</font>    CPSForce::basisChanged(<font class="keywordtype">bool</font> systemBasis)
00124 {
00125         <font class="keywordflow">if</font> (!this-&gt;<a class="code" href="classNL3D_1_1CPSForce.html#a8">isIntegrable</a>()) <font class="keywordflow">return</font>;
00126         <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00127         {       
00128                 (*it)-&gt;integrableForceBasisChanged(systemBasis);
00129         }               
00130 }
00131 
00132 
<a name="l00133"></a><a class="code" href="classNL3D_1_1CPSForce.html#b1">00133</a> <font class="keywordtype">void</font>    CPSForce::cancelIntegrable(<font class="keywordtype">void</font>)
00134 {
00135         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
00136         <font class="keywordtype">bool</font> useSystemBasis = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;isInSystemBasis();
00137         <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00138         {
00139                 <font class="keywordflow">if</font> ((*it)-&gt;isInSystemBasis() == useSystemBasis)
00140                 {
00141                         (*it)-&gt;unregisterIntegrableForce(<font class="keyword">this</font>);
00142                         (*it)-&gt;addNonIntegrableForceRef();
00143                 }
00144         }
00145 }
00146 
00147 
<a name="l00148"></a><a class="code" href="classNL3D_1_1CPSForce.html#b2">00148</a> <font class="keywordtype">void</font>    CPSForce::renewIntegrable(<font class="keywordtype">void</font>)
00149 {
00150         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
00151         <font class="keywordtype">bool</font> useSystemBasis = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;isInSystemBasis();
00152         <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00153         {
00154                 <font class="keywordflow">if</font> ((*it)-&gt;isInSystemBasis() == useSystemBasis)
00155                 {
00156                         (*it)-&gt;registerIntegrableForce(<font class="keyword">this</font>);
00157                         (*it)-&gt;releaseNonIntegrableForceRef();
00158                 }
00159         }
00160 }
00161 
00162 
00163 
00165 <font class="comment">//  CPSForceIntensity implementation //</font>
00167 <font class="comment"></font>
<a name="l00168"></a><a class="code" href="classNL3D_1_1CPSForceIntensity.html#a3">00168</a> <font class="keywordtype">void</font> CPSForceIntensity::setIntensity(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>)
00169 {
00170         <font class="keywordflow">if</font> (_IntensityScheme)
00171         {
00172                 <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a>;
00173                 <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a> = NULL;
00174         }
00175         <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>;
00176         
00177 }
00178 
<a name="l00179"></a><a class="code" href="classNL3D_1_1CPSForceIntensity.html#a1">00179</a> CPSForceIntensity::~CPSForceIntensity()
00180 {
00181         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a>;
00182 }
00183 
<a name="l00184"></a><a class="code" href="classNL3D_1_1CPSForceIntensity.html#a4">00184</a> <font class="keywordtype">void</font> CPSForceIntensity::setIntensityScheme(CPSAttribMaker&lt;float&gt; *scheme)
00185 {
00186         <a class="code" href="debug_8h.html#a6">nlassert</a>(scheme);
00187         <font class="keyword">delete</font> <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a>;
00188         <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a> = scheme;
00189         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSForceIntensity.html#b0">getForceIntensityOwner</a>() &amp;&amp; scheme-&gt;hasMemory()) scheme-&gt;resize(<a class="code" href="classNL3D_1_1CPSForceIntensity.html#b0">getForceIntensityOwner</a>()-&gt;getMaxSize(), <a class="code" href="classNL3D_1_1CPSForceIntensity.html#b0">getForceIntensityOwner</a>()-&gt;getSize());
00190 }
00191 
<a name="l00192"></a><a class="code" href="classNL3D_1_1CPSForceIntensity.html#a8">00192</a> <font class="keywordtype">void</font> CPSForceIntensity::serialForceIntensity(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00193 {       
00194         f.serialVersion(1);
00195         <font class="keywordflow">if</font> (!f.isReading())
00196         {
00197                 <font class="keywordflow">if</font> (_IntensityScheme)
00198                 {
00199                         <font class="keywordtype">bool</font> bFalse = <font class="keyword">false</font>;
00200                         f.serial(bFalse);
00201                         f.serialPolyPtr(_IntensityScheme);
00202                 }
00203                 <font class="keywordflow">else</font>
00204                 {
00205                         <font class="keywordtype">bool</font> bTrue = <font class="keyword">true</font>;
00206                         f.serial(bTrue);
00207                         f.serial(_K);
00208                 }
00209         }
00210         <font class="keywordflow">else</font>
00211         {
00212                 <font class="keywordtype">bool</font> constantIntensity;
00213                 f.serial(constantIntensity);
00214                 <font class="keywordflow">if</font> (constantIntensity)
00215                 {
00216                         f.serial(_K);
00217                 }
00218                 <font class="keywordflow">else</font>
00219                 {
00220                         f.serialPolyPtr(_IntensityScheme);
00221                 }
00222         }       
00223 }
00224 
00225 
00227 <font class="comment">// CPSForceIntensityHelper            //</font>
00229 <font class="comment"></font>
00230 
<a name="l00231"></a><a class="code" href="classNL3D_1_1CPSForceIntensityHelper.html#a0">00231</a> <font class="keywordtype">void</font> CPSForceIntensityHelper::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00232 {
00233         f.serialVersion(1);
00234         CPSForce::serial(f);
00235         serialForceIntensity(f);
00236         <font class="keywordflow">if</font> (f.isReading())
00237         {
00238                 registerToTargets();
00239         }
00240 }
00241 
00242 
00243 
00245 <font class="comment">// CPSDirectionalForce implementation //</font>
00247 <font class="comment"></font>
00248 
<a name="l00249"></a><a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#a0">00249</a> <font class="keywordtype">void</font> CPSDirectionnalForce::performDynamic(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00250 {
00251         <font class="comment">// perform the operation on each target</font>
00252         CVector toAdd;
00253         <font class="keywordflow">for</font> (uint32 k = 0; k &lt; <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize(); ++k)
00254         {       
00255                 CVector toAddLocal;
00256                 CVector dir;
00257                 
00258                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#n1">_GlobalValueHandle</a>.isValid()) <font class="comment">// is direction a global variable ?</font>
00259                 {               
00260                         dir = <a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#n1">_GlobalValueHandle</a>.get(); <font class="comment">// takes direction from global variable instead                 </font>
00261                 }
00262                 <font class="keywordflow">else</font>
00263                 {
00264                         dir = <a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#n0">_Dir</a>;
00265                 }
00266                 
00267                 toAddLocal = ellapsedTime * (<a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a> ? <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a>-&gt;get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, k) : <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> ) * dir;                  
00268                 <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00269                 {
00270 
00271                         toAdd = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner).mulVector(toAddLocal); <font class="comment">// express this in the target basis</font>
00272                         TPSAttribVector::iterator it2 = (*it)-&gt;getSpeed().begin(), it2end = (*it)-&gt;getSpeed().end();
00273                         <font class="comment">// 1st case : non-constant mass</font>
00274                         <font class="keywordflow">if</font> ((*it)-&gt;getMassScheme())
00275                         {
00276                                 TPSAttribFloat::const_iterator invMassIt = (*it)-&gt;getInvMass().begin();                 
00277                                 <font class="keywordflow">for</font> (; it2 != it2end; ++it2, ++invMassIt)
00278                                 {
00279                                         (*it2) += *invMassIt * toAdd;                           
00280                                         
00281                                 }
00282                         }
00283                         <font class="keywordflow">else</font>
00284                         {
00285                                 <font class="comment">// the mass is constant</font>
00286                                 toAdd /= (*it)-&gt;getInitialMass();
00287                                 <font class="keywordflow">for</font> (; it2 != it2end; ++it2)
00288                                 {
00289                                         (*it2) += toAdd;                                                                        
00290                                 }
00291                         }
00292                 }
00293         }
00294 }
00295 
00296 
<a name="l00297"></a><a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#a1">00297</a> <font class="keywordtype">void</font> CPSDirectionnalForce::show(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00298 {
00299         <a class="code" href="classNL3D_1_1CPSForce.html#l0">CPSLocated</a> *loc;
00300         uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>;
00301         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#z720_0">CPSLocatedBindable</a> *lb;
00302         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getOwner()-&gt;getCurrentEditedElement(loc, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, lb);
00303 
00304         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();
00305 
00306         CVector dir;            
00307         <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#n1">_GlobalValueHandle</a>.isValid()) <font class="comment">// is direction a global variable ?</font>
00308         {               
00309                 dir = <a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#n1">_GlobalValueHandle</a>.get(); <font class="comment">// takes direction from global variable instead                 </font>
00310         }
00311         <font class="keywordflow">else</font>
00312         {
00313                 dir = <a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#n0">_Dir</a>;
00314         }
00315         
00316         <font class="comment">// for each element, see if it is the selected element, and if yes, display in red</font>
00317         <font class="keywordflow">for</font> (uint k = 0; k &lt; <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize(); ++k)
00318         {
00319                 <font class="keyword">const</font> CRGBA col = (((lb == NULL || <font class="keyword">this</font> == lb) &amp;&amp; loc == <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> &amp;&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> == k)  ? CRGBA::Red : CRGBA(127, 127, 127));
00320                 CPSUtil::displayArrow(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>(), <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[k], dir, 1.f, col, CRGBA(80, 80, 0));
00321         }
00322 }
00323 
<a name="l00324"></a><a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#a3">00324</a> <font class="keywordtype">void</font> CPSDirectionnalForce::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00325 {
00326         <font class="comment">// Version 2 : added link to a global vector value</font>
00327         <font class="comment">//</font>
00328         sint ver = f.serialVersion(2);          
00329         CPSForceIntensityHelper::serial(f);     
00330         <font class="keywordflow">if</font> (ver == 1)
00331         {       
00332                 f.serial(_Dir);
00333                 _GlobalValueHandle.reset();
00334         }
00335         <font class="keywordflow">else</font>
00336         {
00337                 <font class="keywordtype">bool</font> useHandle = _GlobalValueHandle.isValid();
00338                 f.serial(useHandle);
00339                 <font class="keywordflow">if</font> (useHandle)
00340                 {
00341                         <font class="comment">// a global value is used</font>
00342                         <font class="keywordflow">if</font> (f.isReading())
00343                         {
00344                                 std::string handleName;
00345                                 f.serial(handleName);
00346                                 <font class="comment">// retrieve a handle to the global value from the particle system</font>
00347                                 _GlobalValueHandle = CParticleSystem::getGlobalVectorValueHandle(handleName);
00348                         }
00349                         <font class="keywordflow">else</font>
00350                         {
00351                                 std::string handleName = _GlobalValueHandle.getName();
00352                                 f.serial(handleName);
00353                         }
00354                 }
00355                 <font class="keywordflow">else</font>
00356                 {
00357                         f.serial(_Dir);
00358                 }
00359         }
00360 }
00361 
<a name="l00362"></a><a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#z719_3">00362</a> <font class="keywordtype">void</font> CPSDirectionnalForce::enableGlobalVectorValue(<font class="keyword">const</font> std::string &amp;name)
00363 {
00364         <font class="keywordflow">if</font> (name.empty())
00365         {
00366                 <a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#n1">_GlobalValueHandle</a>.reset();
00367                 <font class="keywordflow">return</font>;
00368         }
00369         <a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#n1">_GlobalValueHandle</a> = CParticleSystem::getGlobalVectorValueHandle(name);
00370 }
00371 
<a name="l00372"></a><a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#z719_4">00372</a> std::string CPSDirectionnalForce::getGlobalVectorValueName()<font class="keyword"> const</font>
00373 <font class="keyword"></font>{
00374         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#n1">_GlobalValueHandle</a>.isValid() ? <a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#n1">_GlobalValueHandle</a>.getName() : <font class="stringliteral">""</font>;
00375 }
00376 
00378 <font class="comment">// gravity implementation //</font>
00380 <font class="comment"></font>
00381 
<a name="l00382"></a><a class="code" href="classNL3D_1_1CPSGravity.html#a0">00382</a> <font class="keywordtype">void</font> CPSGravity::performDynamic(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00383 {       
00384         
00385         <font class="comment">// perform the operation on each target</font>
00386         CVector toAdd;
00387         <font class="keywordflow">for</font> (uint32 k = 0; k &lt; <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize(); ++k)
00388         {       
00389                 CVector toAddLocal = ellapsedTime * CVector(0, 0, <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a> ? - <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a>-&gt;get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, k) : - <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>);
00390                 <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00391                 {
00392                         toAdd = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner).mulVector(toAddLocal); <font class="comment">// express this in the target basis</font>
00393                         TPSAttribVector::iterator it2 = (*it)-&gt;getSpeed().begin(), it2end = (*it)-&gt;getSpeed().end();
00394                         
00395                         <font class="keywordflow">if</font> (toAdd.x &amp;&amp; toAdd.y)
00396                         {
00397                                 <font class="keywordflow">for</font> (; it2 != it2end; ++it2)
00398                                 {
00399                                         (*it2) += toAdd;                                
00400                                         
00401                                 }
00402                         }
00403                         <font class="keywordflow">else</font> <font class="comment">// only the z component is not null, which should be the majority of cases ...</font>
00404                         {
00405                                 <font class="keywordflow">for</font> (; it2 != it2end; ++it2)
00406                                 {
00407                                         it2-&gt;z += toAdd.z;                              
00408                                         
00409                                 }
00410                         }
00411                 }
00412         }
00413 }
00414 
<a name="l00415"></a><a class="code" href="classNL3D_1_1CPSGravity.html#a1">00415</a> <font class="keywordtype">void</font> CPSGravity::show(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime) 
00416 {       
00417         CVector I = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a22">computeI</a>();
00418         CVector K = CVector(0,0,1);         
00419 
00420         <font class="comment">// this is not designed for efficiency (target : edition code)</font>
00421         CPrimitiveBlock  pb;
00422         CVertexBuffer vb;
00423         CMaterial material;
00424         IDriver *driver = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>();
00425         <font class="keyword">const</font> <font class="keywordtype">float</font> toolSize = 0.2f;
00426 
00427         vb.setVertexFormat(CVertexBuffer::PositionFlag);
00428         vb.setNumVertices(6);
00429         vb.setVertexCoord(0, -toolSize * I);
00430         vb.setVertexCoord(1, toolSize * I);
00431         vb.setVertexCoord(2, CVector(0, 0, 0));
00432         vb.setVertexCoord(3, -6.0f * toolSize * K);
00433         vb.setVertexCoord(4, -toolSize * I  - 5.0f * toolSize * K);
00434         vb.setVertexCoord(5, toolSize * I - 5.0f * toolSize * K);
00435 
00436         pb.reserveLine(4);
00437         pb.addLine(0, 1);
00438         pb.addLine(2, 3);
00439         pb.addLine(4, 3);
00440         pb.addLine(3, 5);       
00441         
00442         material.setColor(CRGBA(127, 127, 127));
00443         material.setLighting(<font class="keyword">false</font>);
00444         material.setBlendFunc(CMaterial::one, CMaterial::one);
00445         material.setZWrite(<font class="keyword">false</font>);
00446         material.setBlend(<font class="keyword">true</font>);
00447 
00448         
00449         CMatrix mat;
00450 
00451         <font class="keywordflow">for</font> (TPSAttribVector::const_iterator it = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().begin(); it != <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().end(); ++it)
00452         {
00453                 mat.identity();
00454                 mat.translate(*it);
00455                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;isInSystemBasis())
00456                 {
00457                         mat = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a15">getSysMat</a>() * mat;
00458                 }
00459                 
00460                 driver-&gt;setupModelMatrix(mat);
00461                 driver-&gt;activeVertexBuffer(vb);
00462                 driver-&gt;render(pb, material);
00463         
00464 
00465 
00466                 <font class="comment">// affiche un g a cote de la force</font>
00467 
00468                 CVector pos = *it + CVector(1.5f * toolSize, 0, -1.2f * toolSize);
00469 
00470                 <font class="keywordflow">if</font> (<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;isInSystemBasis())
00471                 {
00472                         pos = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a15">getSysMat</a>() * pos;
00473                 }
00474 
00475                 <font class="comment">// must have set this</font>
00476                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a11">getFontGenerator</a>() &amp;&amp; <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a11">getFontGenerator</a>());
00477                 
00478                 CPSUtil::print(driver, std::string(<font class="stringliteral">"G"</font>)
00479                                                         , *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a11">getFontGenerator</a>()
00480                                                         , *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a13">getFontManager</a>()
00481                                                         , pos
00482                                                         , 80.0f * toolSize );                                                           
00483         }
00484 
00485         
00486 }
00487 
<a name="l00488"></a><a class="code" href="classNL3D_1_1CPSGravity.html#a3">00488</a> <font class="keywordtype">void</font> CPSGravity::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00489 {
00490         f.serialVersion(1);     
00491         CPSForceIntensityHelper::serial(f);     
00492 }
00493 
00494 
<a name="l00495"></a><a class="code" href="classNL3D_1_1CPSGravity.html#a5">00495</a> <font class="keywordtype">bool</font>    CPSGravity::isIntegrable(<font class="keywordtype">void</font>)<font class="keyword"> const</font>
00496 <font class="keyword"></font>{
00497         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a> == NULL;
00498 }
00499 
<a name="l00500"></a><a class="code" href="classNL3D_1_1CPSGravity.html#a6">00500</a> <font class="keywordtype">void</font> CPSGravity::integrate(<font class="keywordtype">float</font> date, CPSLocated *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, uint32 startIndex, uint32 numObjects, <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *destPos, <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *destSpeed,
00501                                                         <font class="keywordtype">bool</font> accumulate,
00502                                                         uint posStride, uint speedStride
00503                                                         )
00504 {
00505 <font class="preprocessor">        #define NEXT_SPEED destSpeed = (NLMISC::CVector *) ((uint8 *) destSpeed + speedStride);</font>
00506 <font class="preprocessor"></font><font class="preprocessor">        #define NEXT_POS   destPos   = (NLMISC::CVector *) ((uint8 *) destPos   + posStride);</font>
00507 <font class="preprocessor"></font>
00508         <font class="keywordtype">float</font> deltaT;
00509 
00510         <font class="keywordflow">if</font> (!destPos &amp;&amp; !destSpeed) <font class="keywordflow">return</font>;
00511 
00512         CPSLocated::TPSAttribParametricInfo::const_iterator it = <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;_PInfo.begin() + startIndex,
00513                                                                                                                 endIt = <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;_PInfo.begin() + startIndex + numObjects;  
00514         <font class="keywordflow">if</font> (!accumulate) <font class="comment">// compute coords from initial condition, and applying this force</font>
00515         {
00516                 <font class="keywordflow">if</font> (destPos &amp;&amp; !destSpeed) <font class="comment">// fills dest pos only</font>
00517                 {
00518                         <font class="keywordflow">while</font> (it != endIt)
00519                         {
00520                                 deltaT = date - it-&gt;Date;                               
00521                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> = it-&gt;Pos.x + deltaT * it-&gt;Speed.x;                          
00522                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = it-&gt;Pos.y + deltaT * it-&gt;Speed.y;
00523                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> = it-&gt;Pos.z + deltaT * it-&gt;Speed.z - 0.5f * deltaT * deltaT * <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>;
00524                                 ++it;
00525                                 NEXT_POS;       
00526                         }
00527                 }
00528                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!destPos &amp;&amp; destSpeed) <font class="comment">// fills dest speed only</font>
00529                 {
00530                         <font class="keywordflow">while</font> (it != endIt)
00531                         {
00532                                 deltaT = date - it-&gt;Date;                               
00533                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> = it-&gt;Speed.x;                             
00534                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = it-&gt;Speed.y;
00535                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> = it-&gt;Speed.z - deltaT * <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>;
00536                                 ++it;
00537                                 NEXT_SPEED;     
00538                         }
00539                 }
00540                 <font class="keywordflow">else</font> <font class="comment">// fills both speed and pos</font>
00541                 {
00542                         <font class="keywordflow">while</font> (it != endIt)
00543                         {
00544                                 deltaT = date - it-&gt;Date;                               
00545                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> = it-&gt;Pos.x + deltaT * it-&gt;Speed.x;                          
00546                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = it-&gt;Pos.y + deltaT * it-&gt;Speed.y;
00547                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> = it-&gt;Pos.z + deltaT * it-&gt;Speed.z - 0.5f * deltaT * deltaT * <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>;
00548 
00549                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> = it-&gt;Speed.x;                             
00550                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = it-&gt;Speed.y;
00551                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> = it-&gt;Speed.z - deltaT * <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>;
00552 
00553                                 ++it;
00554                                 NEXT_POS;
00555                                 NEXT_SPEED;
00556                         }
00557                 }
00558         }
00559         <font class="keywordflow">else</font> <font class="comment">// accumulate datas</font>
00560         {
00561                 <font class="keywordflow">if</font> (destPos &amp;&amp; !destSpeed) <font class="comment">// fills dest pos only</font>
00562                 {
00563                         <font class="keywordflow">while</font> (it != endIt)
00564                         {
00565                                 deltaT = date - it-&gt;Date;                                                               
00566                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> -= 0.5f * deltaT * deltaT * <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>;                              
00567                                 ++it;
00568                                 NEXT_POS;       
00569                         }
00570                 }
00571                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!destPos &amp;&amp; destSpeed) <font class="comment">// fills dest speed only</font>
00572                 {
00573                         <font class="keywordflow">while</font> (it != endIt)
00574                         {
00575                                 deltaT = date - it-&gt;Date;                                                               
00576                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> -= deltaT * <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>;                            
00577                                 ++it;
00578                                 NEXT_SPEED;     
00579                         }
00580                 }
00581                 <font class="keywordflow">else</font> <font class="comment">// fills both speed and pos</font>
00582                 {
00583                         <font class="keywordflow">while</font> (it != endIt)
00584                         {
00585                                 deltaT = date - it-&gt;Date;                                                               
00586                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> -= 0.5f * deltaT * deltaT * <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>;
00587                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> -= deltaT * <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>;
00588                                 ++it;
00589                                 NEXT_POS;
00590                                 NEXT_SPEED;
00591                         }
00592                 }
00593         }
00594         
00595 }
00596 
00597 
00598 
<a name="l00599"></a><a class="code" href="classNL3D_1_1CPSGravity.html#a7">00599</a> <font class="keywordtype">void</font> CPSGravity::integrateSingle(<font class="keywordtype">float</font> startDate, <font class="keywordtype">float</font> deltaT, uint numStep,                                                            
00600                                                                  CPSLocated *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, uint32 indexInLocated,
00601                                                                  <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *destPos,
00602                                                                  <font class="keywordtype">bool</font> accumulate <font class="comment">/*= false*/</font>,
00603                                                                  uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a><font class="comment">/* = sizeof(NLMISC::CVector)*/</font>)
00604 {               
00605         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;isParametricMotionEnabled());
00606         <a class="code" href="debug_8h.html#a6">nlassert</a>(deltaT &gt; 0);
00607         <a class="code" href="debug_8h.html#a6">nlassert</a>(numStep &gt; 0);
00608 <font class="preprocessor">        #ifdef NL_DEBUG</font>
00609 <font class="preprocessor"></font>                <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *endPos = (<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) ( (uint8 *) destPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a> * numStep);
00610 <font class="preprocessor">        #endif</font>
00611 <font class="preprocessor"></font>        <font class="keyword">const</font> CPSLocated::CParametricInfo &amp;pi = <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;_PInfo[indexInLocated];
00612         <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;startPos   = pi.Pos;     
00613         <font class="keywordflow">if</font> (numStep != 0)
00614         {
00615                 <font class="keywordflow">if</font> (!accumulate)
00616                 {                               
00617                         destPos = <a class="code" href="namespaceNL3D.html#a436">FillBufUsingSubdiv</a>(startPos, pi.Date, startDate, deltaT, numStep, destPos, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>);
00618                         <font class="keywordflow">if</font> (numStep != 0)
00619                         {
00620                                 <font class="keywordtype">float</font> currDate = startDate - pi.Date;
00621                                 <a class="code" href="debug_8h.html#a6">nlassert</a>(currDate &gt;= 0);
00622                                 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;startSpeed = pi.Speed;                   
00623                                 <font class="keywordflow">do</font>
00624                                 {
00625 <font class="preprocessor">                                        #ifdef NL_DEBUG</font>
00626 <font class="preprocessor"></font>                                                <a class="code" href="debug_8h.html#a6">nlassert</a>(destPos &lt; endPos);
00627 <font class="preprocessor">                                        #endif</font>
00628 <font class="preprocessor"></font>                                        <font class="keywordtype">float</font> halfTimeSquare  = 0.5f * currDate * currDate;
00629                                         destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> = startPos.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> + currDate * startSpeed.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>;
00630                                         destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = startPos.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> + currDate * startSpeed.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>;
00631                                         destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> = startPos.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> + currDate * startSpeed.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> - <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * halfTimeSquare;
00632                                         currDate += deltaT;
00633                                         destPos = (<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) ( (uint8 *) destPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>);
00634                                 }
00635                                 <font class="keywordflow">while</font> (--numStep);
00636                         }
00637                 }
00638                 <font class="keywordflow">else</font>
00639                 {
00640                         uint numToSkip = <a class="code" href="namespaceNL3D.html#a435">ScaleFloatGE</a>(startDate, deltaT, pi.Date, numStep);             
00641                         <font class="keywordflow">if</font> (numToSkip &lt; numStep)
00642                         {
00643                                 numStep -= numToSkip;
00644                                 <font class="keywordtype">float</font> currDate = startDate + deltaT * numToSkip - pi.Date;
00645                                 <font class="keywordflow">do</font>
00646                                 {
00647 <font class="preprocessor">                                        #ifdef NL_DEBUG</font>
00648 <font class="preprocessor"></font>                                                <a class="code" href="debug_8h.html#a6">nlassert</a>(destPos &lt; endPos);
00649 <font class="preprocessor">                                        #endif</font>
00650 <font class="preprocessor"></font>                                        <font class="keywordtype">float</font> halfTimeSquare  = 0.5f * currDate * currDate;                             
00651                                         destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> -=  <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * halfTimeSquare;
00652                                         currDate += deltaT;
00653                                         destPos = (<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) ( (uint8 *) destPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>);
00654                                 }
00655                                 <font class="keywordflow">while</font> (--numStep);
00656                         }                               
00657                 }
00658         }
00659 }
00660 
00661 
<a name="l00662"></a><a class="code" href="classNL3D_1_1CPSGravity.html#b0">00662</a> <font class="keywordtype">void</font> CPSGravity::setIntensity(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>)
00663 {
00664         <font class="keywordflow">if</font> (_IntensityScheme)
00665         {
00666                 CPSForceIntensityHelper::setIntensity(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>);
00667                 <a class="code" href="classNL3D_1_1CPSForce.html#b2">renewIntegrable</a>(); <font class="comment">// integrable again</font>
00668         }
00669         <font class="keywordflow">else</font>
00670         {
00671                 CPSForceIntensityHelper::setIntensity(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>);
00672         }
00673 }
00674         
<a name="l00675"></a><a class="code" href="classNL3D_1_1CPSGravity.html#b1">00675</a> <font class="keywordtype">void</font> CPSGravity::setIntensityScheme(CPSAttribMaker&lt;float&gt; *scheme)
00676 {
00677         <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a>)
00678         {
00679                 <a class="code" href="classNL3D_1_1CPSForce.html#b1">cancelIntegrable</a>(); <font class="comment">// not integrable anymore</font>
00680         }                       
00681         CPSForceIntensityHelper::setIntensityScheme(scheme);    
00682 }
00683 
00684 
00686 <font class="comment">// CPSCentralGravity  implementation   //</font>
00688 <font class="comment"></font>
00689 
<a name="l00690"></a><a class="code" href="classNL3D_1_1CPSCentralGravity.html#a0">00690</a> <font class="keywordtype">void</font> CPSCentralGravity::performDynamic(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00691 {
00692         <font class="comment">// for each central gravity, and each target, we check if they are in the same basis</font>
00693         <font class="comment">// if not, we need to transform the central gravity attachment pos into the target basis</font>
00694         
00695 
00696         uint32 size = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize();
00697 
00698         <font class="comment">// a vector that goes from the gravity to the object</font>
00699         CVector centerToObj;
00700         <font class="keywordtype">float</font> dist;
00701         
00702         <font class="keywordflow">for</font> (uint32 k = 0; k &lt; size; ++k)
00703         {       
00704                 <font class="keyword">const</font> <font class="keywordtype">float</font> ellapsedTimexK = ellapsedTime  * (<a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a> ? <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a>-&gt;get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, k) : <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>);
00705 
00706                 <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00707                 {
00708                         <font class="keyword">const</font> CMatrix &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);
00709                         <font class="keyword">const</font> CVector center = m * (<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[k]);
00710                                                 
00711                         TPSAttribVector::iterator it2 = (*it)-&gt;getSpeed().begin(), it2End = (*it)-&gt;getSpeed().end();
00712                         TPSAttribFloat::const_iterator invMassIt = (*it)-&gt;getInvMass().begin();
00713                         TPSAttribVector::const_iterator posIt = (*it)-&gt;getPos().begin();
00714                         
00715                         <font class="keywordflow">for</font> (; it2 != it2End; ++it2, ++invMassIt, ++posIt)
00716                         {
00717                                 <font class="comment">// our equation does 1 / r attenuation, which is not realistic, but fast ...</font>
00718                                 centerToObj = center - *posIt;
00719         
00720                                 dist = centerToObj * centerToObj;
00721                                 <font class="keywordflow">if</font> (dist &gt; 10E-6f)
00722                                 {
00723                                         (*it2) += (*invMassIt) * ellapsedTimexK * (1.f / dist) *  centerToObj;                                                          
00724                                 }
00725                         }
00726                 }
00727         }
00728 
00729 }
00730 
<a name="l00731"></a><a class="code" href="classNL3D_1_1CPSCentralGravity.html#a1">00731</a> <font class="keywordtype">void</font> CPSCentralGravity::show(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00732 {
00733         CVector I = CVector::I;
00734         CVector J = CVector::J;
00735 
00736         <font class="keyword">const</font> CVector tab[] = { -I - J, I - J
00737                                                         ,-I + J, I + J
00738                                                         , I - J, I + J
00739                                                         , -I - J, -I + J
00740                                                         , I + J, -I - J
00741                                                         , I - J, J - I
00742                                                         };
00743         <font class="keyword">const</font> uint tabSize = <font class="keyword">sizeof</font>(tab) / (2 * <font class="keyword">sizeof</font>(CVector));
00744 
00745         <font class="keyword">const</font> <font class="keywordtype">float</font> sSize = 0.08f;
00746         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#b4">displayIcon2d</a>(tab, tabSize, sSize);
00747 }       
00748 
<a name="l00749"></a><a class="code" href="classNL3D_1_1CPSCentralGravity.html#a3">00749</a> <font class="keywordtype">void</font> CPSCentralGravity::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00750 {
00751         f.serialVersion(1);     
00752         CPSForceIntensityHelper::serial(f);     
00753 }
00754 
00755 
00757 <font class="comment">// CPSSpring  implementation   //</font>
00759 <font class="comment"></font>
00760 
00761 
<a name="l00762"></a><a class="code" href="classNL3D_1_1CPSSpring.html#a2">00762</a> <font class="keywordtype">void</font> CPSSpring::performDynamic(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00763 {
00764         <font class="comment">// for each spring, and each target, we check if they are in the same basis</font>
00765         <font class="comment">// if not, we need to transform the spring attachment pos into the target basis</font>
00766         
00767 
00768         uint32 size = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize();
00769 
00770         
00771         <font class="keywordflow">for</font> (uint32 k = 0; k &lt; size; ++k)
00772         {       
00773                 <font class="keyword">const</font> <font class="keywordtype">float</font> ellapsedTimexK = ellapsedTime  * (<a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a> ? <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a>-&gt;get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, k) : <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>);
00774 
00775                 <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00776                 {
00777                         <font class="keyword">const</font> CMatrix &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);
00778                         <font class="keyword">const</font> CVector center = m * (<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[k]);
00779                                                 
00780                         TPSAttribVector::iterator it2 = (*it)-&gt;getSpeed().begin(), it2End = (*it)-&gt;getSpeed().end();
00781                         TPSAttribFloat::const_iterator invMassIt = (*it)-&gt;getInvMass().begin();
00782                         TPSAttribVector::const_iterator posIt = (*it)-&gt;getPos().begin();
00783                         
00784                         <font class="keywordflow">for</font> (; it2 != it2End; ++it2, ++invMassIt, ++posIt)
00785                         {
00786                                 <font class="comment">// apply the spring equation</font>
00787                                 (*it2) += (*invMassIt) * ellapsedTimexK * (center - *posIt);                                                            
00788                         }
00789                 }
00790         }
00791 }
00792 
00793 
<a name="l00794"></a><a class="code" href="classNL3D_1_1CPSSpring.html#a1">00794</a> <font class="keywordtype">void</font> CPSSpring::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00795 {
00796         f.serialVersion(1);     
00797         CPSForceIntensityHelper::serial(f);     
00798 }
00799 
00800 
00801 
<a name="l00802"></a><a class="code" href="classNL3D_1_1CPSSpring.html#a3">00802</a> <font class="keywordtype">void</font> CPSSpring::show(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00803 {
00804         CVector I = CVector::I;
00805         CVector J = CVector::J;
00806         <font class="keyword">static</font> <font class="keyword">const</font> CVector tab[] = 
00807         { 
00808            -I + 2 * J,
00809            I + 2 * J,
00810            I + 2 * J, -I + J,
00811            -I + J, I + J,
00812            I + J, -I,
00813            -I, I,
00814            I, -I - J,
00815            -I - J, I - J,
00816            I - J,
00817            - I - 2 * J,
00818            - I - 2 * J,
00819            I - 2 * J
00820         };
00821         <font class="keyword">const</font> uint tabSize = <font class="keyword">sizeof</font>(tab) / (2 * <font class="keyword">sizeof</font>(CVector));
00822         <font class="keyword">const</font> <font class="keywordtype">float</font> sSize = 0.08f;
00823         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#b4">displayIcon2d</a>(tab, tabSize, sSize);
00824 }
00825 
00826 
00828 <font class="comment">//  CPSCylindricVortex implementation  //</font>
00830 <font class="comment"></font>
<a name="l00831"></a><a class="code" href="classNL3D_1_1CPSCylindricVortex.html#a0">00831</a> <font class="keywordtype">void</font> CPSCylindricVortex::performDynamic(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00832 {
00833         uint32 size = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize();
00834                 
00835         <font class="keywordflow">for</font> (uint32 k = 0; k &lt; size; ++k) <font class="comment">// for each vortex</font>
00836         {                                       
00837                 
00838                 <font class="keyword">const</font> <font class="keywordtype">float</font> invR = 1.f  / <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n1">_Radius</a>[k];
00839                 <font class="keyword">const</font> <font class="keywordtype">float</font> radius2 = <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n1">_Radius</a>[k] * <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n1">_Radius</a>[k];
00840 
00841                 <font class="comment">// intensity for this vortex</font>
00842                 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
00843                 <font class="keywordtype">float</font> intensity =  (<a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a> ? <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a>-&gt;get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, k) : <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>);
00844 
00845                 <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00846                 {
00847                         <font class="comment">// express the vortex position and plane normal in the located basis</font>
00848                         <font class="keyword">const</font> CMatrix &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);
00849                         <font class="keyword">const</font> CVector center = m * (<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[k]);
00850                         <font class="keyword">const</font> CVector n = m.mulVector(<a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n0">_Normal</a>[k]);
00851 
00852                         TPSAttribVector::iterator speedIt = (*it)-&gt;getSpeed().begin(), speedItEnd = (*it)-&gt;getSpeed().end();
00853                         TPSAttribFloat::const_iterator invMassIt = (*it)-&gt;getInvMass().begin();
00854                         TPSAttribVector::const_iterator posIt = (*it)-&gt;getPos().begin();
00855                         
00856 
00857                         <font class="comment">// projection of the current located pos on the vortex axis</font>
00858                         CVector p;
00859                         <font class="comment">// a vector that go from the vortex center to the point we're dealing with</font>
00860                         CVector v2p;
00861 
00862                         <font class="comment">// the square of the dist of the projected pos</font>
00863                         <font class="keywordtype">float</font> d2 , d;
00864 
00865                         CVector realTangentialSpeed;
00866                         CVector tangentialSpeed;
00867 
00868                         
00869                         CVector radialSpeed;
00870 
00871 
00872                         <font class="keywordflow">for</font> (; speedIt != speedItEnd; ++speedIt, ++invMassIt, ++posIt)
00873                         {
00874                                 v2p = *posIt - center;
00875                                 p = v2p - (v2p * n) * n;
00876 
00877                                 d2 = p * p;
00878 
00879                                 
00880 
00881                                 <font class="keywordflow">if</font> (d2 &lt; radius2) <font class="comment">// not out of range ?</font>
00882                                 {
00883                                         <font class="keywordflow">if</font> (d2 &gt; 10E-6)
00884                                         {
00885                                                 d = sqrtf(d2);
00886 
00887                                                 p *= 1.f / d;
00888                                                 <font class="comment">// compute the speed vect that we should have (normalized) </font>
00889                                                 realTangentialSpeed = n ^ p;
00890 
00891                                                 tangentialSpeed = (*speedIt * realTangentialSpeed) * realTangentialSpeed;
00892                                                 radialSpeed =  (p * *speedIt) * p;
00893                                                 
00894                                                 <font class="comment">// update radial speed;</font>
00895                                                 *speedIt -= <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n2">_RadialViscosity</a> * ellapsedTime * radialSpeed;
00896                                                 
00897                                                 <font class="comment">// update tangential speed                                      </font>
00898                                                 *speedIt -= <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n3">_TangentialViscosity</a> * intensity * ellapsedTime * (tangentialSpeed - (1.f - d * invR) * realTangentialSpeed);
00899                                         }
00900                                 }                               
00901                         }
00902                 }
00903         }
00904 }
00905 
00906 
<a name="l00907"></a><a class="code" href="classNL3D_1_1CPSCylindricVortex.html#a1">00907</a> <font class="keywordtype">void</font> CPSCylindricVortex::show(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00908 {
00909         
00910         <a class="code" href="classNL3D_1_1CPSForce.html#l0">CPSLocated</a> *loc;
00911         uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>;
00912         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#z720_0">CPSLocatedBindable</a> *lb;
00913         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getOwner()-&gt;getCurrentEditedElement(loc, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, lb);
00914 
00915 
00916         <font class="comment">// must have set this</font>
00917         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a11">getFontGenerator</a>() &amp;&amp; <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a11">getFontGenerator</a>());
00918         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();
00919         
00920         <font class="keywordflow">for</font> (uint k = 0; k &lt; <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize(); ++k)
00921         {
00922                 <font class="keyword">const</font> CRGBA col = ((lb == NULL || <font class="keyword">this</font> == lb) &amp;&amp; loc == <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> &amp;&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> == k  ? CRGBA::Red : CRGBA(127, 127, 127));
00923                 CMatrix m;
00924                 CPSUtil::buildSchmidtBasis(<a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n0">_Normal</a>[k], m);
00925                 CPSUtil::displayDisc(*<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>(), <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n1">_Radius</a>[k], <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[k], m, 32, col);
00926                 CPSUtil::displayArrow(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>(), <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[k], <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n0">_Normal</a>[k], 1.f, col, CRGBA(200, 0, 200));
00927                 <font class="comment">// display a V letter at the center</font>
00928                 CPSUtil::print(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>(), std::string(<font class="stringliteral">"v"</font>), *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a11">getFontGenerator</a>(), *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a13">getFontManager</a>(), <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[k], 80.f);
00929         }
00930 
00931 }
00932 
<a name="l00933"></a><a class="code" href="classNL3D_1_1CPSCylindricVortex.html#a10">00933</a> <font class="keywordtype">void</font> CPSCylindricVortex::setMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">const</font> CMatrix &amp;m)
00934 {
00935         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> &lt; <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n0">_Normal</a>.getSize());
00936         <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n0">_Normal</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = m.getK();
00937         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = m.getPos();   
00938 }
00939 
<a name="l00940"></a><a class="code" href="classNL3D_1_1CPSCylindricVortex.html#a11">00940</a> CMatrix CPSCylindricVortex::getMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font>
00941 <font class="keyword"></font>{
00942         CMatrix m;
00943         CPSUtil::buildSchmidtBasis(<a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n0">_Normal</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], m);
00944         m.setPos(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] ); 
00945         <font class="keywordflow">return</font> m;
00946 }
00947 
00948 
<a name="l00949"></a><a class="code" href="classNL3D_1_1CPSCylindricVortex.html#a17">00949</a> <font class="keywordtype">void</font> CPSCylindricVortex::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00950 {
00951         f.serialVersion(1);     
00952         CPSForceIntensityHelper::serial(f);     
00953         f.serial(_Normal);
00954         f.serial(_Radius);
00955         f.serial(_RadialViscosity);
00956         f.serial(_TangentialViscosity);
00957 }
00958 
<a name="l00959"></a><a class="code" href="classNL3D_1_1CPSCylindricVortex.html#b1">00959</a> <font class="keywordtype">void</font> CPSCylindricVortex::newElement(CPSLocated *emitterLocated, uint32 emitterIndex) 
00960 { 
00961         CPSForceIntensityHelper::newElement(emitterLocated, emitterIndex); 
00962         <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n0">_Normal</a>.insert(CVector::K);
00963         <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n1">_Radius</a>.insert(1.f); 
00964 }
<a name="l00965"></a><a class="code" href="classNL3D_1_1CPSCylindricVortex.html#b2">00965</a> <font class="keywordtype">void</font> CPSCylindricVortex::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>) 
00966 { 
00967         CPSForceIntensityHelper::deleteElement(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00968         <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n0">_Normal</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); 
00969         <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n1">_Radius</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00970 }
<a name="l00971"></a><a class="code" href="classNL3D_1_1CPSCylindricVortex.html#b3">00971</a> <font class="keywordtype">void</font> CPSCylindricVortex::resize(uint32 size) 
00972 { 
00973         <a class="code" href="debug_8h.html#a6">nlassert</a>(size &lt; (1 &lt;&lt; 16));
00974         CPSForceIntensityHelper::resize(size); 
00975         <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n0">_Normal</a>.resize(size);
00976         <a class="code" href="classNL3D_1_1CPSCylindricVortex.html#n1">_Radius</a>.resize(size);
00977 }
00978 
00979 
<a name="l00984"></a><a class="code" href="classNL3D_1_1CPSMagneticForce.html#a2">00984</a> <font class="keywordtype">void</font> CPSMagneticForce::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00985 {
00986         f.serialVersion(1);
00987         CPSDirectionnalForce::serial(f);
00988 }
00989 
<a name="l00990"></a><a class="code" href="classNL3D_1_1CPSMagneticForce.html#a1">00990</a> <font class="keywordtype">void</font> CPSMagneticForce::performDynamic(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00991 {       
00992         <font class="comment">// perform the operation on each target</font>
00993         <font class="keywordflow">for</font> (uint32 k = 0; k &lt; <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize(); ++k)
00994         {       
00995                 <font class="keywordtype">float</font> intensity = ellapsedTime * (<a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a> ? <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a>-&gt;get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, k) : <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>);
00996                 <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00997                 {
00998 
00999                         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> toAdd = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner).mulVector(<a class="code" href="classNL3D_1_1CPSDirectionnalForce.html#n0">_Dir</a>); <font class="comment">// express this in the target basis                 </font>
01000 
01001                         TPSAttribVector::iterator it2 = (*it)-&gt;getSpeed().begin(), it2end = (*it)-&gt;getSpeed().end();
01002 
01003                         <font class="comment">// 1st case : non-constant mass</font>
01004                         <font class="keywordflow">if</font> ((*it)-&gt;getMassScheme())
01005                         {
01006                                 TPSAttribFloat::const_iterator invMassIt = (*it)-&gt;getInvMass().begin();                 
01007                                 <font class="keywordflow">for</font> (; it2 != it2end; ++it2, ++invMassIt)
01008                                 {
01009                                         (*it2) += intensity * *invMassIt * (*it2 ^ toAdd);
01010                                         
01011                                 }
01012                         }
01013                         <font class="keywordflow">else</font>
01014                         {
01015                                 <font class="keywordtype">float</font> i = intensity / (*it)-&gt;getInitialMass();
01016                                 <font class="keywordflow">for</font> (; it2 != it2end; ++it2)
01017                                 {
01018                                         (*it2) += i * (*it2 ^ toAdd);
01019                                 }
01020                         }
01021                 }
01022         }
01023 }
01024 
01025 
01030 <font class="keyword">const</font> uint <a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a>    = 8192;        <font class="comment">// should be a power of 2</font>
01031 <font class="keyword">const</font> uint <a class="code" href="namespaceNL3D.html#a193">BFPredefinedNumInterp</a> = 256;     
01035 <font class="keyword">const</font> uint <a class="code" href="namespaceNL3D.html#a194">BFNumPrecomputedImpulsions</a> = 1024; 
01036 
<a name="l01037"></a><a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">01037</a> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> CPSBrownianForce::PrecomputedPos[<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a>]; <font class="comment">// after the sequence we must be back to the start position</font>
<a name="l01038"></a><a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">01038</a> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> CPSBrownianForce::PrecomputedSpeed[<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a>];
<a name="l01039"></a><a class="code" href="classNL3D_1_1CPSBrownianForce.html#q2">01039</a> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> CPSBrownianForce::PrecomputedImpulsions[<a class="code" href="namespaceNL3D.html#a194">BFNumPrecomputedImpulsions</a>];
01040 
<a name="l01042"></a><a class="code" href="classNL3D_1_1CPSBrownianForce.html#a0">01042</a> CPSBrownianForce::CPSBrownianForce(<font class="keywordtype">float</font> intensity <font class="comment">/* = 1.f*/</font>) : _ParametricFactor(1.f)
01043 {
01044         <a class="code" href="classNL3D_1_1CPSBrownianForce.html#a5">setIntensity</a>(intensity);
01045         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n3">_Name</a> = std::string(<font class="stringliteral">"BrownianForce"</font>);
01046 
01047 }
01048 
<a name="l01050"></a><a class="code" href="classNL3D_1_1CPSBrownianForce.html#a2">01050</a> <font class="keywordtype">bool</font>    CPSBrownianForce::isIntegrable(<font class="keywordtype">void</font>)<font class="keyword"> const</font>
01051 <font class="keyword"></font>{
01052         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a> == NULL;
01053 }
01054 
01055 
<a name="l01057"></a><a class="code" href="classNL3D_1_1CPSBrownianForce.html#a3">01057</a> <font class="keywordtype">void</font> CPSBrownianForce::integrate(<font class="keywordtype">float</font> date, CPSLocated *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>,
01058                                                                  uint32 startIndex,
01059                                                                  uint32 numObjects,
01060                                                                  <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *destPos,
01061                                                                  <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *destSpeed,
01062                                                                  <font class="keywordtype">bool</font> accumulate,
01063                                                                  uint posStride, uint speedStride
01064                                                             )
01065 {
01067         <font class="keywordtype">float</font> deltaT;
01068         <font class="keywordflow">if</font> (!destPos &amp;&amp; !destSpeed) <font class="keywordflow">return</font>;
01069         CPSLocated::TPSAttribParametricInfo::const_iterator it = <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;_PInfo.begin() + startIndex,
01070                                                                                                                 endIt = <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;_PInfo.begin() + startIndex + numObjects;
01071         <font class="keywordtype">float</font> lookUpFactor = <a class="code" href="classNL3D_1_1CPSBrownianForce.html#n0">_ParametricFactor</a> * <a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a>;
01072         <font class="keywordtype">float</font> speedFactor  = <a class="code" href="classNL3D_1_1CPSBrownianForce.html#n0">_ParametricFactor</a> * <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>;
01073         <font class="keywordflow">if</font> (!accumulate) <font class="comment">// compute coords from initial condition, and applying this force</font>
01074         {
01075                 <font class="keywordflow">if</font> (destPos &amp;&amp; !destSpeed) <font class="comment">// fills dest pos only</font>
01076                 {
01077                         <font class="keywordflow">while</font> (it != endIt)
01078                         {
01079                                 <font class="keywordtype">float</font> deltaT = date - it-&gt;Date;
01080                                 uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = (uint) (lookUpFactor * deltaT) &amp; (<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a> - 1);
01081                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#z332_0">set</a>(it-&gt;Pos.x + deltaT * it-&gt;Speed.x + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].x,
01082                                                          it-&gt;Pos.y + deltaT * it-&gt;Speed.y + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].y,
01083                                                          it-&gt;Pos.z + deltaT * it-&gt;Speed.z + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].z );
01084                                 ++it;
01085                                 NEXT_POS;       
01086                         }
01087                 }
01088                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!destPos &amp;&amp; destSpeed) <font class="comment">// fills dest speed only</font>
01089                 {
01090                         <font class="keywordflow">while</font> (it != endIt)
01091                         {
01092                                 deltaT = date - it-&gt;Date;
01093                                 uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = (uint) (lookUpFactor * deltaT) &amp; (<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a> - 1);
01094                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> = it-&gt;Speed.x  + speedFactor * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].x;                          
01095                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = it-&gt;Speed.y  + speedFactor * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].y;
01096                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> = it-&gt;Speed.z  + speedFactor * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].z;
01097                                 ++it;
01098                                 NEXT_SPEED;     
01099                         }
01100                 }
01101                 <font class="keywordflow">else</font> <font class="comment">// fills both speed and pos</font>
01102                 {
01103                         <font class="keywordflow">while</font> (it != endIt)
01104                         {
01105                                 deltaT = date - it-&gt;Date;
01106                                 uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = (uint) (lookUpFactor * deltaT) &amp; (<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a> - 1);
01107                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> = it-&gt;Pos.x + deltaT * it-&gt;Speed.x + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].x;                           
01108                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = it-&gt;Pos.y + deltaT * it-&gt;Speed.y + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].y;
01109                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> = it-&gt;Pos.z + deltaT * it-&gt;Speed.z + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].z;
01110 
01111                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> = it-&gt;Speed.x + speedFactor * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].x;                           
01112                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = it-&gt;Speed.y + speedFactor * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].y;
01113                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> = it-&gt;Speed.z + speedFactor * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].z;
01114 
01115                                 ++it;
01116                                 NEXT_POS;
01117                                 NEXT_SPEED;
01118                         }
01119                 }
01120         }
01121         <font class="keywordflow">else</font> <font class="comment">// accumulate datas</font>
01122         {
01123                 <font class="keywordflow">if</font> (destPos &amp;&amp; !destSpeed) <font class="comment">// fills dest pos only</font>
01124                 {
01125                         <font class="keywordflow">while</font> (it != endIt)
01126                         {
01127                                 deltaT = date - it-&gt;Date;
01128                                 uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = (uint) (lookUpFactor * deltaT) &amp; (<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a> - 1);
01129                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#z332_0">set</a>(destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].x,
01130                                                          destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].y,
01131                                                          destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].z);
01132                                 ++it;
01133                                 NEXT_POS;       
01134                         }
01135                 }
01136                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (!destPos &amp;&amp; destSpeed) <font class="comment">// fills dest speed only</font>
01137                 {
01138                         <font class="keywordflow">while</font> (it != endIt)
01139                         {
01140                                 deltaT = date - it-&gt;Date;
01141                                 uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = (uint) (lookUpFactor * deltaT) &amp; (<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a> - 1);
01142                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#z332_0">set</a>(destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> + speedFactor * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].x,
01143                                                            destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> + speedFactor * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].y,
01144                                                            destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> + speedFactor * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].z);
01145                                 ++it;
01146                                 NEXT_SPEED;     
01147                         }
01148                 }
01149                 <font class="keywordflow">else</font> <font class="comment">// fills both speed and pos</font>
01150                 {
01151                         <font class="keywordflow">while</font> (it != endIt)
01152                         {
01153                                 deltaT = date - it-&gt;Date;
01154                                 uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = (uint) (lookUpFactor * deltaT) &amp; (<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a> - 1);
01155                                 destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#z332_0">set</a>(destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].x,
01156                                                          destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].y,
01157                                                          destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].z);
01158                                 destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#z332_0">set</a>(destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> + speedFactor * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].x,
01159                                                            destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> + speedFactor * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].y,
01160                                                            destSpeed-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> + speedFactor * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].z);     
01161                                 ++it;
01162                                 NEXT_POS;
01163                                 NEXT_SPEED;
01164                         }
01165                 }
01166         }       
01167 }
01168 
01169 
<a name="l01171"></a><a class="code" href="classNL3D_1_1CPSBrownianForce.html#a4">01171</a> <font class="keywordtype">void</font> CPSBrownianForce::integrateSingle(<font class="keywordtype">float</font> startDate, <font class="keywordtype">float</font> deltaT, uint numStep,                                                              
01172                                                                  CPSLocated *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, uint32 indexInLocated,
01173                                                                  <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *destPos,
01174                                                                  <font class="keywordtype">bool</font> accumulate,
01175                                                                  uint <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>)
01176 {
01177         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;isParametricMotionEnabled());
01178         <a class="code" href="debug_8h.html#a6">nlassert</a>(deltaT &gt; 0);
01179         <a class="code" href="debug_8h.html#a6">nlassert</a>(numStep &gt; 0);
01180 <font class="preprocessor">        #ifdef NL_DEBUG</font>
01181 <font class="preprocessor"></font>                <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *endPos = (<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) ( (uint8 *) destPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a> * numStep);
01182 <font class="preprocessor">        #endif</font>
01183 <font class="preprocessor"></font>        <font class="keyword">const</font> CPSLocated::CParametricInfo &amp;pi = <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>-&gt;_PInfo[indexInLocated];
01184         <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;startPos   = pi.Pos;     
01185         <font class="keywordflow">if</font> (numStep != 0)
01186         {
01187                 <font class="keywordtype">float</font> lookUpFactor = <a class="code" href="classNL3D_1_1CPSBrownianForce.html#n0">_ParametricFactor</a> * <a class="code" href="namespaceNL3D.html#a193">BFPredefinedNumInterp</a>;
01188                 <font class="keywordflow">if</font> (!accumulate)
01189                 {                               
01191                         destPos = <a class="code" href="namespaceNL3D.html#a436">FillBufUsingSubdiv</a>(startPos, pi.Date, startDate, deltaT, numStep, destPos, <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>);
01192                         <font class="keywordflow">if</font> (numStep != 0)
01193                         {
01194                                 <font class="keywordtype">float</font> currDate = startDate - pi.Date;
01195                                 <a class="code" href="debug_8h.html#a6">nlassert</a>(currDate &gt;= 0);                                
01196                                 <font class="keyword">const</font> <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> &amp;startSpeed = pi.Speed;                   
01197                                 <font class="keywordflow">do</font>
01198                                 {
01199 <font class="preprocessor">                                        #ifdef NL_DEBUG</font>
01200 <font class="preprocessor"></font>                                                <a class="code" href="debug_8h.html#a6">nlassert</a>(destPos &lt; endPos);
01201 <font class="preprocessor">                                        #endif</font>
01202 <font class="preprocessor"></font>                                        uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = (uint) (lookUpFactor * currDate) &amp; (<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a> - 1);
01203                                         destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> = startPos.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> + currDate * startSpeed.<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].x;
01204                                         destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> = startPos.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> + currDate * startSpeed.<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].y;
01205                                         destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> = startPos.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> + currDate * startSpeed.<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> + <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].z;
01206                                         currDate += deltaT;
01207                                         destPos = (<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) ( (uint8 *) destPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>);
01208                                 }
01209                                 <font class="keywordflow">while</font> (--numStep);
01210                         }
01211                 }
01212                 <font class="keywordflow">else</font>
01213                 {
01214                         uint numToSkip = <a class="code" href="namespaceNL3D.html#a435">ScaleFloatGE</a>(startDate, deltaT, pi.Date, numStep);             
01215                         <font class="keywordflow">if</font> (numToSkip &lt; numStep)
01216                         {
01217                                 numStep -= numToSkip;                           
01218                                 <font class="keywordtype">float</font> currDate = startDate + deltaT * numToSkip - pi.Date;
01219                                 <font class="keywordflow">do</font>
01220                                 {
01221 <font class="preprocessor">                                        #ifdef NL_DEBUG</font>
01222 <font class="preprocessor"></font>                                                <a class="code" href="debug_8h.html#a6">nlassert</a>(destPos &lt; endPos);
01223 <font class="preprocessor">                                        #endif</font>
01224 <font class="preprocessor"></font>                                        uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = (uint) (lookUpFactor * currDate) &amp; (<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a> - 1);
01225                                         destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a> += <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].x;
01226                                         destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a> += <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].y;
01227                                         destPos-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m2">z</a> += <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a> * <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].z;
01228                                         currDate += deltaT;
01229                                         destPos = (<a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *) ( (uint8 *) destPos + <a class="code" href="driver__opengl__extension__def_8h.html#a374">stride</a>);
01230                                 }
01231                                 <font class="keywordflow">while</font> (--numStep);                              
01232                         }
01233                 }
01234         }       
01235 }
01236 
01237 
<a name="l01239"></a><a class="code" href="classNL3D_1_1CPSBrownianForce.html#d0">01239</a> <font class="keywordtype">void</font> CPSBrownianForce::initPrecalc()
01240 {
01242         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a> % <a class="code" href="namespaceNL3D.html#a193">BFPredefinedNumInterp</a> == 0);
01243         
01244         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> p0(0, 0, 0), p1;
01245         <font class="keyword">const</font> uint numStep = <a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a> / <a class="code" href="namespaceNL3D.html#a193">BFPredefinedNumInterp</a>;
01246         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *dest = <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q0">PrecomputedPos</a>;
01247         uint k, <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>;
01248         <font class="keywordflow">for</font> (k = 0; k &lt; numStep; ++k)
01249         {
01250                 <font class="keywordflow">if</font> (k != numStep - 1)
01251                 {
01252                         p1.<a class="code" href="classNLMISC_1_1CVector.html#z332_0">set</a>(2.f * (NLMISC::frand(1.f) - 0.5f),
01253                                    2.f * (NLMISC::frand(1.f) - 0.5f),
01254                                    2.f * (NLMISC::frand(1.f) - 0.5f));
01255                 }
01256                 <font class="keywordflow">else</font>
01257                 {
01258                         p1.<a class="code" href="classNLMISC_1_1CVector.html#z332_0">set</a>(0, 0, 0);
01259                 }
01260                 <font class="keywordtype">float</font> lambda     = 0.f;
01261                 <font class="keywordtype">float</font> lambdaStep = 1.f / <a class="code" href="namespaceNL3D.html#a193">BFPredefinedNumInterp</a>;
01262                 <font class="keywordflow">for</font> (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = 0; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> &lt; <a class="code" href="namespaceNL3D.html#a193">BFPredefinedNumInterp</a>; ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
01263                 {
01264                         *dest++ = lambda * p1 + (1.f - lambda) * p0;
01265                         lambda += lambdaStep;
01266                 }
01267                 p0 = p1;                                
01268         }
01269 
01270         <font class="comment">// now, filter the table several time to get something more smooth</font>
01271         <font class="keywordflow">for</font> (k = 0; k &lt; (<a class="code" href="namespaceNL3D.html#a193">BFPredefinedNumInterp</a> &lt;&lt; 2) ; ++k)
01272         {
01273                 <font class="keywordflow">for</font> (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = 1; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> &lt; (<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a> - 1); ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
01274                 {
01275                         PrecomputedPos[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>] = 0.5f * (PrecomputedPos[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> - 1] + PrecomputedPos[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> + 1]);
01276                 }
01277         }
01278 
01279 
01280         <font class="comment">// compute the table of speeds, by using on a step of 1.s</font>
01281         <font class="keywordflow">for</font> (<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = 1; <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> &lt; (<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a> - 1); ++<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
01282         {
01283                 <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>] = 0.5f * (PrecomputedPos[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> + 1] - PrecomputedPos[<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> - 1]);
01284         }
01285         <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q1">PrecomputedSpeed</a>[<a class="code" href="namespaceNL3D.html#a192">BFNumPredefinedPos</a> - 1] = <a class="code" href="classNLMISC_1_1CVector.html#p0">NLMISC::CVector::Null</a>;
01286 
01287         <font class="comment">// compute the table of impulsion</font>
01288         <font class="keywordflow">for</font> (k = 0; k &lt; <a class="code" href="namespaceNL3D.html#a194">BFNumPrecomputedImpulsions</a>; ++k)
01289         {
01290                 <font class="keyword">static</font> <font class="keywordtype">double</font> divRand = (2.f / RAND_MAX);
01291                 <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q2">PrecomputedImpulsions</a>[k].<a class="code" href="classNLMISC_1_1CVector.html#z332_0">set</a>( (<font class="keywordtype">float</font>) (rand() * divRand - 1),
01292                                                                           (<font class="keywordtype">float</font>) (rand() * divRand - 1),
01293                                                                           (<font class="keywordtype">float</font>) (rand() * divRand - 1) 
01294                                                                         );
01295         }
01296 }
01297 
<a name="l01299"></a><a class="code" href="classNL3D_1_1CPSBrownianForce.html#a5">01299</a> <font class="keywordtype">void</font> CPSBrownianForce::setIntensity(<font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>)
01300 {
01301         <font class="keywordflow">if</font> (_IntensityScheme)
01302         {
01303                 CPSForceIntensity::setIntensity(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>);
01304                 <a class="code" href="classNL3D_1_1CPSForce.html#b2">renewIntegrable</a>(); <font class="comment">// integrable again</font>
01305         }
01306         <font class="keywordflow">else</font>
01307         {
01308                 CPSForceIntensity::setIntensity(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>);
01309         }
01310 }
01311 
01312 
<a name="l01314"></a><a class="code" href="classNL3D_1_1CPSBrownianForce.html#a6">01314</a> <font class="keywordtype">void</font> CPSBrownianForce::setIntensityScheme(CPSAttribMaker&lt;float&gt; *scheme)
01315 {
01316         <font class="keywordflow">if</font> (!<a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a>)
01317         {
01318                 <a class="code" href="classNL3D_1_1CPSForce.html#b1">cancelIntegrable</a>(); <font class="comment">// not integrable anymore</font>
01319         }                       
01320         CPSForceIntensity::setIntensityScheme(scheme);  
01321 }
01322 
<a name="l01324"></a><a class="code" href="classNL3D_1_1CPSBrownianForce.html#a7">01324</a> <font class="keywordtype">void</font> CPSBrownianForce::performDynamic(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
01325 {
01326         <font class="comment">// perform the operation on each target </font>
01327         <font class="keywordflow">for</font> (uint32 k = 0; k &lt; <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize(); ++k)
01328         {               
01329                 <font class="keywordtype">float</font> intensity = <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a> ? <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n1">_IntensityScheme</a>-&gt;get(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>, k) : <a class="code" href="classNL3D_1_1CPSForceIntensity.html#n0">_K</a>;
01330                 <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
01331                 {                       
01332                         uint32 size = (*it)-&gt;getSize();
01333 
01334                         <font class="keywordflow">if</font> (!size) <font class="keywordflow">continue</font>;
01335 
01336                         TPSAttribVector::iterator it2 = (*it)-&gt;getSpeed().begin(), it2End;
01338                         uint startPos = (uint) ::rand() % <a class="code" href="namespaceNL3D.html#a194">BFNumPrecomputedImpulsions</a>;
01339                         <a class="code" href="classNLMISC_1_1CVector.html">NLMISC::CVector</a> *imp = <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q2">PrecomputedImpulsions</a> + startPos;
01340 
01341                         <font class="keywordflow">if</font> ((*it)-&gt;getMassScheme())
01342                         {
01343                                 <font class="keywordtype">float</font> intensityXtime = intensity * ellapsedTime;
01344                                 TPSAttribFloat::const_iterator invMassIt = (*it)-&gt;getInvMass().begin();                                         
01345                                 <font class="keywordflow">do</font>
01346                                 {                       
01347                                         uint toProcess = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>((uint) (<a class="code" href="namespaceNL3D.html#a194">BFNumPrecomputedImpulsions</a> - startPos), (uint) size);
01348                                         it2End = it2 + toProcess;
01349                                         <font class="keywordflow">do</font>
01350                                         {
01351                                                 <font class="keywordtype">float</font> factor = intensityXtime * *invMassIt;
01352                                                 it2-&gt;set(it2-&gt;x + factor * imp-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>,
01353                                                                 it2-&gt;y + factor * imp-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>,
01354                                                                 it2-&gt;z + factor * imp-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>);
01355                                                 ++invMassIt;
01356                                                 ++imp;
01357                                                 ++it2;
01358                                         }
01359                                         <font class="keywordflow">while</font> (it2 != it2End);
01360                                         startPos = 0;
01361                                         imp = <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q2">PrecomputedImpulsions</a>;    
01362                                         size -= toProcess;
01363                                 }
01364                                 <font class="keywordflow">while</font> (size != 0);
01365                         }
01366                         <font class="keywordflow">else</font>
01367                         {                               
01368                                 <font class="keywordflow">do</font>
01369                                 {                       
01370                                         uint toProcess = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>((uint) (<a class="code" href="namespaceNL3D.html#a194">BFNumPrecomputedImpulsions</a> - startPos) , (uint) size);
01371                                         it2End = it2 + toProcess;
01372                                         <font class="keywordtype">float</font> factor = intensity * ellapsedTime / (*it)-&gt;getInitialMass();
01373                                         <font class="keywordflow">do</font>
01374                                         {                                               
01375                                                 it2-&gt;set(it2-&gt;x + factor * imp-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>,
01376                                                                 it2-&gt;y + factor * imp-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m1">y</a>,
01377                                                                 it2-&gt;z + factor * imp-&gt;<a class="code" href="classNLMISC_1_1CVector.html#m0">x</a>);                                              
01378                                                 ++imp;
01379                                                 ++it2;
01380                                         }
01381                                         <font class="keywordflow">while</font> (it2 != it2End);
01382                                         startPos = 0;
01383                                         imp = <a class="code" href="classNL3D_1_1CPSBrownianForce.html#q2">PrecomputedImpulsions</a>;    
01384                                         size -= toProcess;
01385                                 }
01386                                 <font class="keywordflow">while</font> (size != 0);
01387                         }                       
01388                 }
01389         }       
01390 }
01391 
<a name="l01393"></a><a class="code" href="classNL3D_1_1CPSBrownianForce.html#a1">01393</a> <font class="keywordtype">void</font> CPSBrownianForce::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
01394 {
01395         sint ver = f.serialVersion(3);          
01396         <font class="keywordflow">if</font> (ver &lt;= 2)
01397         {
01398                 uint8 dummy;
01399                 f.serial(dummy); <font class="comment">// old data in version 2 not used anymore      </font>
01400                 CPSForce::serial(f);
01401                 f.serial(dummy); <font class="comment">// old data in version 2 not used anymore      </font>
01402                 serialForceIntensity(f);
01403                 <font class="keywordflow">if</font> (f.isReading())
01404                 {
01405                         registerToTargets();
01406                 }
01407         }
01408 
01409         <font class="keywordflow">if</font> (ver &gt;= 2)
01410         {
01411                 CPSForceIntensityHelper::serial(f);
01412                 f.serial(_ParametricFactor);
01413         }
01414 }
01415 
01416 
01417 } <font class="comment">// NL3D</font>
</pre></div>

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