aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a06287.html
blob: aa25e5204e9f43e84509e813d6d42a9d021c1731 (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
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>NeL: ps_zone.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex">  <form class="search" action="search.php" method="get">
<a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a>  | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<h1>ps_zone.cpp</h1><a href="a04864.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <span class="comment">/* Copyright, 2001 Nevrax Ltd.</span>
00008 <span class="comment"> *</span>
00009 <span class="comment"> * This file is part of NEVRAX NEL.</span>
00010 <span class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</span>
00011 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
00012 <span class="comment"> * the Free Software Foundation; either version 2, or (at your option)</span>
00013 <span class="comment"> * any later version.</span>
00014 <span class="comment"></span>
00015 <span class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</span>
00016 <span class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</span>
00017 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
00018 <span class="comment"> * General Public License for more details.</span>
00019 <span class="comment"></span>
00020 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
00021 <span class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</span>
00022 <span class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</span>
00023 <span class="comment"> * MA 02111-1307, USA.</span>
00024 <span class="comment"> */</span>
00025 
00026 <span class="preprocessor">#include "<a class="code" href="a05015.html">std3d.h</a>"</span>
00027 
00028 <span class="preprocessor">#include "<a class="code" href="a04865.html">3d/ps_zone.h</a>"</span>
00029 <span class="preprocessor">#include "<a class="code" href="a05288.html">3d/vertex_buffer.h</a>"</span>
00030 <span class="preprocessor">#include "<a class="code" href="a04775.html">3d/primitive_block.h</a>"</span>
00031 <span class="preprocessor">#include "<a class="code" href="a04546.html">3d/material.h</a>"</span>
00032 <span class="preprocessor">#include "<a class="code" href="a04863.html">3d/ps_util.h</a>"</span>
00033 <span class="preprocessor">#include "<a class="code" href="a04238.html">3d/dru.h</a>"</span>
00034 <span class="preprocessor">#include "<a class="code" href="a04720.html">3d/particle_system.h</a>"</span>
00035 <span class="preprocessor">#include "<a class="code" href="a04748.html">nel/misc/plane.h</a>"</span>
00036 
00037 <span class="comment">// tmp</span>
00038 
00039 <span class="preprocessor">#include "<a class="code" href="a04726.html">3d/particle_system_model.h</a>"</span>
00040 
00041 <span class="preprocessor">#include &lt;math.h&gt;</span>
00042 <span class="preprocessor">#include &lt;limits&gt;</span>
00043 
00044 <span class="keyword">namespace </span>NL3D {
00045 
00046 
00047 <span class="comment">/*</span>
00048 <span class="comment"> * Constructor</span>
00049 <span class="comment"> */</span>
<a name="l00050"></a><a class="code" href="a03255.html#NL3D_1_1CPSZonea6">00050</a> CPSZone::CPSZone() : _BounceFactor(1.f), _CollisionBehaviour(bounce)
00051 {
00052 }
00053 
<a name="l00054"></a><a class="code" href="a03255.html#NL3D_1_1CPSZonea43">00054</a> <span class="keywordtype">void</span> CPSZone::serial(<a class="code" href="a02270.html">NLMISC::IStream</a> &amp;f) <span class="keywordflow">throw</span>(<a class="code" href="a03781.html">NLMISC::EStream</a>)
00055 { 
00056         f.serialVersion(1);
00057         CPSTargetLocatedBindable::serial(f); 
00058         f.serialEnum(_CollisionBehaviour);
00059         f.serial(_BounceFactor);
00060         <span class="keywordflow">if</span> (f.isReading())
00061         {               
00062                 <span class="keywordflow">for</span> (TTargetCont::iterator it = _Targets.begin(); it != _Targets.end(); ++it)
00063                 {
00064                         <span class="comment">// though this is not a force, this prevent parametric motion</span>
00065                         (*it)-&gt;addNonIntegrableForceRef();
00066                 }       
00067         }
00068 }
00069 
<a name="l00073"></a><a class="code" href="a03255.html#NL3D_1_1CPSZoneSpherea0">00073</a> <span class="keywordtype">void</span> CPSZone::attachTarget(<a class="code" href="a03214.html">CPSLocated</a> *ptr)
00074 {
00075                 
00076         CPSTargetLocatedBindable::attachTarget(ptr);
00077         ptr-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda71">queryCollisionInfo</a>();
00078         ptr-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda0">addNonIntegrableForceRef</a>();
00079 }
00080 
00081 
00082 
00083 
00084 
<a name="l00086"></a><a class="code" href="a03255.html#NL3D_1_1CPSZoneSpherea47">00086</a> <span class="keywordtype">void</span> CPSZone::releaseTargetRsc(<a class="code" href="a03214.html">CPSLocated</a> *target)
00087 {
00088         <span class="comment">// tell the target that we were using collision infos and that we won't use them anymore</span>
00089         target-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda75">releaseCollisionInfo</a>();
00090         target-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda76">releaseNonIntegrableForceRef</a>();
00091 }
00092 
00093 
00094 
<a name="l00095"></a><a class="code" href="a03255.html#NL3D_1_1CPSZoneSpherea62">00095</a> <span class="keywordtype">void</span> CPSZone::step(TPSProcessPass pass, <a class="code" href="a05363.html#a366">TAnimationTime</a> ellapsedTime, <a class="code" href="a05363.html#a366">TAnimationTime</a> realEt)
00096 {
00097         <span class="comment">// for zone, the PSCollision pass and the PSToolRenderPass are processed</span>
00098         <span class="keywordflow">switch</span>(pass)
00099         {
00100                 <span class="keywordflow">case</span> <a class="code" href="a05363.html#a556a213">PSCollision</a>:
00101                         <a class="code" href="a03255.html#NL3D_1_1CPSZonea39">performMotion</a>(ellapsedTime);
00102                         <span class="keywordflow">break</span>;
00103                 <span class="keywordflow">case</span> <a class="code" href="a05363.html#a556a217">PSToolRender</a>:
00104                         <a class="code" href="a03255.html#NL3D_1_1CPSZonea52">show</a>(ellapsedTime);
00105                         <span class="keywordflow">break</span>;
00106                 <span class="keywordflow">default</span>: <span class="keywordflow">break</span>;
00107         }
00108 }
00109 
00110 
00111 <span class="comment">// build a basis with K = the normal of the plane</span>
<a name="l00112"></a><a class="code" href="a03258.html#NL3D_1_1CPSZonePlaneb1">00112</a> <a class="code" href="a02851.html">CMatrix</a> CPSZonePlane::buildBasis(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)<span class="keyword"> const</span>
00113 <span class="keyword"></span>{
00114         <a class="code" href="a02851.html">CMatrix</a> m;
00115         m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_4">setPos</a>(_Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>()[<a class="code" href="a04223.html#a566">index</a>]);      
00116         CPSUtil::buildSchmidtBasis(_Normal[<a class="code" href="a04223.html#a566">index</a>], m);
00117         <span class="keywordflow">return</span> m;
00118 }
00119 
00120 
00123 <span class="comment">/*void CPSZone::bounce(uint32 locatedIndex, const CVector &amp;bouncePoint, const CVector &amp;surfNormal, float elasticity, TAnimationTime ellapsedTime)</span>
00124 <span class="comment">{</span>
00125 <span class="comment">        CVector &amp;speed = _Owner-&gt;getSpeed()[locatedIndex];</span>
00126 <span class="comment">        const CVector &amp;pos   = _Owner-&gt;getPos()[locatedIndex];</span>
00127 <span class="comment">        CVector &amp;bounceVect = elasticity  * (speed - 2.0f * (speed * surfNormal) * surfNormal); // speed vector after collision</span>
00128 <span class="comment">        // now check where the located will be after integration</span>
00129 <span class="comment">        CVector d = bouncePoint - pos;</span>
00130 <span class="comment">        TAnimationTime collideDelay = speed.norm() / d.norm();</span>
00131 <span class="comment">        CVector finalPos = bouncePoint + (ellapsedTime - collideDelay) * bounceVect;</span>
00132 <span class="comment">        // now, we must have pos + ellapsedTime * newSpeed = finalPos </span>
00133 <span class="comment">        // newSpeed = alpha * (finalPos - pos)</span>
00134 <span class="comment">        // so alpha = 1 / ellapsedTime</span>
00135 <span class="comment"></span>
00136 <span class="comment">        speed = (1.0f / ellapsedTime) * (finalPos - pos);       </span>
00137 <span class="comment">}*/</span>
00138 
00139 
<a name="l00140"></a><a class="code" href="a03258.html#NL3D_1_1CPSZonePlanea60">00140</a> <span class="keywordtype">void</span> CPSZonePlane::show(<a class="code" href="a05363.html#a366">TAnimationTime</a>)
00141 {
00142         <span class="keyword">const</span> <span class="keywordtype">float</span> planeSize = 2.0f;
00143         <a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea59">setupDriverModelMatrix</a>();
00144 
00145         <a class="code" href="a02434.html">IDriver</a> *driver = <a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea14">getDriver</a>();
00146         <a class="code" href="a04558.html#a15">uint</a> k  = 0;
00147 
00148         <a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea59">setupDriverModelMatrix</a>();
00149 
00150         <a class="code" href="a03214.html">CPSLocated</a> *loc;
00151         <a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>;
00152         <a class="code" href="a02691.html">CPSLocatedBindable</a> *lb;
00153         _Owner-&gt;<a class="code" href="a03054.html#NL3D_1_1CPSLocateda39">getOwner</a>()-&gt;<a class="code" href="a03041.html#NL3D_1_1CParticleSystemz588_0">getCurrentEditedElement</a>(loc, <a class="code" href="a04223.html#a566">index</a>, lb);
00154         
00155 
00156 
00157                 
00158 
00159         <span class="keywordflow">for</span> (TPSAttribVector::const_iterator it = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(); it != _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_3">end</a>(); ++it, ++k)
00160         {       
00161                 <span class="keyword">const</span> <a class="code" href="a03337.html">CRGBA</a> col = ((lb == NULL || <span class="keyword">this</span> == lb) &amp;&amp; loc == _Owner &amp;&amp; <a class="code" href="a04223.html#a566">index</a> == k  ? CRGBA::Red : <a class="code" href="a03337.html">CRGBA</a>(127, 127, 127));
00162                 <a class="code" href="a02851.html">CMatrix</a> mat = <a class="code" href="a03258.html#NL3D_1_1CPSZonePlaneb1">buildBasis</a>(k);
00163 
00164                 CPSUtil::displayBasis(<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea14">getDriver</a>(), <a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea22">getLocalToWorldMatrix</a>(), mat, 1.f, *<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea17">getFontGenerator</a>(), *<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea19">getFontManager</a>());
00165 
00166 
00167                 <a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea59">setupDriverModelMatrix</a>();
00168         
00169                 CDRU::drawLine(*it + (planeSize  + 3) * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_2">getI</a>() + planeSize * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_3">getJ</a>() 
00170                                                 , *it - (planeSize + 3) * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_2">getI</a>() + planeSize * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_3">getJ</a>()
00171                                                 , col
00172                                                 , *driver);
00173 
00174                 CDRU::drawLine(*it + (planeSize  + 3) * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_2">getI</a>() - planeSize * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_3">getJ</a>() 
00175                                                 , *it - (planeSize + 3) * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_2">getI</a>() - planeSize * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_3">getJ</a>()
00176                                                 , col
00177                                                 , *driver);
00178 
00179                 CDRU::drawLine(*it + planeSize  * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_2">getI</a>() + (planeSize + 3) * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_3">getJ</a>() 
00180                                                 , *it + planeSize * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_2">getI</a>() - (planeSize + 3) * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_3">getJ</a>()
00181                                                 , col
00182                                                 , *driver);
00183                 CDRU::drawLine(*it - planeSize  * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_2">getI</a>() + (planeSize + 3) * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_3">getJ</a>() 
00184                                                 , *it - planeSize * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_2">getI</a>() - (planeSize + 3) * mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_3">getJ</a>()
00185                                                 , col
00186                                                 , *driver);
00187         }
00188         
00189 
00190 }
00191 
00192 
00193 
<a name="l00194"></a><a class="code" href="a03258.html#NL3D_1_1CPSZonePlaneb6">00194</a> <span class="keywordtype">void</span> CPSZonePlane::resize(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a587">size</a>)
00195 {
00196         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a587">size</a> &lt; (1 &lt;&lt; 16));
00197         _Normal.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_2">resize</a>(<a class="code" href="a04223.html#a587">size</a>);
00198 }
00199 
00200 
<a name="l00201"></a><a class="code" href="a03258.html#NL3D_1_1CPSZonePlaneb4">00201</a> <span class="keywordtype">void</span> CPSZonePlane::newElement(<a class="code" href="a03214.html">CPSLocated</a> *emitterLocated, <a class="code" href="a04558.html#a11">uint32</a> emitterIndex)
00202 {
00203         <a class="code" href="a04199.html#a6">nlassert</a>(_Normal.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_1">getSize</a>() != _Normal.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_0">getMaxSize</a>());
00204         _Normal.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_1">insert</a>(<a class="code" href="a03128.html">CVector</a>(0, 0, 1));
00205 }
00206 
00207 
<a name="l00208"></a><a class="code" href="a03258.html#NL3D_1_1CPSZonePlaneb2">00208</a> <span class="keywordtype">void</span> CPSZonePlane::deleteElement(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)
00209 {
00210         _Normal.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_2">remove</a>(<a class="code" href="a04223.html#a566">index</a>);
00211 }
00212 
00213 
00214 
<a name="l00215"></a><a class="code" href="a03258.html#NL3D_1_1CPSZonePlanea43">00215</a> <span class="keywordtype">void</span> CPSZonePlane::performMotion(<a class="code" href="a05363.html#a366">TAnimationTime</a> ellapsedTime)
00216 {
00217         <a class="code" href="a04726.html#a0">MINI_TIMER</a>(<a class="code" href="a05363.html#a200">PSStatsZonePlane</a>)
00218         <span class="comment">// for each target, we must check wether they are going through the plane</span>
00219         <span class="comment">// if so they must bounce</span>
00220         TPSAttribVector::const_iterator planePosIt, planePosEnd, normalIt, targetPosIt, targetPosEnd;
00221         <a class="code" href="a03128.html">CVector</a> dest;
00222         <a class="code" href="a03151.html">CPSCollisionInfo</a> ci;
00223         <a class="code" href="a03128.html">CVector</a> startEnd;
00224         <a class="code" href="a04558.html#a11">uint32</a> k;
00225         <span class="keyword">const</span> <a class="code" href="a03135.html">TPSAttribVector</a> *speedAttr;
00226         <span class="keywordtype">float</span> posSide, negSide;
00227 
00228         <span class="comment">// alpha is the ratio that gives the percent of endPos - startPos that hit the plane</span>
00229         <span class="keywordtype">float</span> <a class="code" href="a04223.html#a663">alpha</a>; 
00230 
00231         <span class="keywordflow">for</span> (TTargetCont::iterator it = _Targets.begin(); it != _Targets.end(); ++it)
00232         {
00233 
00234                 speedAttr = &amp;((*it)-&gt;getSpeed());
00235                 <span class="comment">// cycle through the planes</span>
00236 
00237                 planePosEnd = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_3">end</a>();           
00238                 <span class="keywordflow">for</span> (planePosIt = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(), normalIt = _Normal.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(); planePosIt != planePosEnd
00239                                 ; ++planePosIt, ++normalIt)
00240                 {
00241                         
00242                         <span class="comment">// we must setup the plane in the good basis</span>
00243 
00244                         <span class="keyword">const</span> <a class="code" href="a02851.html">CMatrix</a> &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);
00245                         <span class="keyword">const</span> <span class="keywordtype">float</span> epsilon = 0.5f * <a class="code" href="a05363.html#a273">PSCollideEpsilon</a>;
00246                         
00247 
00248                         <a class="code" href="a03082.html">NLMISC::CPlane</a> p;
00249                         p.<a class="code" href="a03082.html#NLMISC_1_1CPlanez1990_2">make</a>(m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1968_1">mulVector</a>(*normalIt), m * (*planePosIt));              
00250                         
00251                         <span class="comment">// deals with each particle</span>
00252                         
00253                         targetPosEnd = (*it)-&gt;getPos().end();
00254                         TPSAttribCollisionInfo::const_iterator ciIt = (*it)-&gt;getCollisionInfo().begin();
00255                         <span class="keywordflow">for</span> (targetPosIt = (*it)-&gt;getPos().begin(), k = 0; targetPosIt != targetPosEnd; ++targetPosIt, ++k, ++ciIt)
00256                         {       
00257                                 <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> &amp;speed = (*speedAttr)[k];
00258                                 <span class="comment">// check whether the located is going through the plane</span>
00259                                 dest = *targetPosIt + ellapsedTime *  speed * ciIt-&gt;TimeSliceRatio;
00260 
00261 
00262                                 posSide = p * *targetPosIt;
00263                                 negSide = p * dest;
00264                                                                                                 
00265                                 <span class="keywordflow">if</span> (posSide &gt;= - epsilon &amp;&amp; negSide &lt;= epsilon)
00266                                 {
00267                                         <span class="keywordflow">if</span> (fabsf(posSide - negSide) &gt; <a class="code" href="a04061.html#a0">std::numeric_limits&lt;float&gt;::min</a>())
00268                                         {
00269                                                 <a class="code" href="a04223.html#a663">alpha</a> = posSide / (posSide - negSide);
00270                                         }
00271                                         <span class="keywordflow">else</span>
00272                                         {
00273                                                 <a class="code" href="a04223.html#a663">alpha</a> = 0.f;
00274                                         }
00275                                         startEnd = <a class="code" href="a04223.html#a663">alpha</a> * (dest - *targetPosIt);                                       
00276                                         ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo1">dist</a> = startEnd.<a class="code" href="a03128.html#NLMISC_1_1CVectorz2049_0">norm</a>();
00277                                         <span class="comment">// we translate the particle from an epsilon so that it won't get hooked to the plane</span>
00278                                         ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo2">newPos</a> = *targetPosIt  + startEnd + <a class="code" href="a05363.html#a273">PSCollideEpsilon</a> * p.<a class="code" href="a03082.html#NLMISC_1_1CPlanez1990_0">getNormal</a>();                                
00279                                         ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo3">newSpeed</a> = _BounceFactor * (speed - 2.0f * (speed * p.<a class="code" href="a03082.html#NLMISC_1_1CPlanez1990_0">getNormal</a>()) * p.<a class="code" href="a03082.html#NLMISC_1_1CPlanez1990_0">getNormal</a>());
00280                                         ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo0">collisionZone</a> = <span class="keyword">this</span>;                                                
00281                                         (*it)-&gt;collisionUpdate(ci, k);                                                                          
00282                                 }
00283                         }
00284                 }
00285         }
00286 }
00287 
<a name="l00288"></a><a class="code" href="a03258.html#NL3D_1_1CPSZonePlanea53">00288</a> <span class="keywordtype">void</span> CPSZonePlane::setMatrix(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>, <span class="keyword">const</span> <a class="code" href="a02851.html">CMatrix</a> &amp;m)
00289 {
00290         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a566">index</a> &lt; _Normal.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_1">getSize</a>());
00291         _Normal[<a class="code" href="a04223.html#a566">index</a>] = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_4">getK</a>();
00292         _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>()[<a class="code" href="a04223.html#a566">index</a>] = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_6">getPos</a>();   
00293 }
00294 
<a name="l00295"></a><a class="code" href="a03258.html#NL3D_1_1CPSZonePlanea23">00295</a> <a class="code" href="a02851.html">CMatrix</a> CPSZonePlane::getMatrix(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)<span class="keyword"> const</span>
00296 <span class="keyword"></span>{
00297         <span class="keywordflow">return</span> <a class="code" href="a03258.html#NL3D_1_1CPSZonePlaneb1">buildBasis</a>(<a class="code" href="a04223.html#a566">index</a>);
00298 }
00299 
00300 
<a name="l00301"></a><a class="code" href="a03258.html#NL3D_1_1CPSZonePlanea26">00301</a> <a class="code" href="a03128.html">CVector</a> CPSZonePlane::getNormal(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)
00302 {
00303         <span class="keywordflow">return</span> _Normal[<a class="code" href="a04223.html#a566">index</a>];
00304 }
<a name="l00305"></a><a class="code" href="a03258.html#NL3D_1_1CPSZonePlanea55">00305</a> <span class="keywordtype">void</span> CPSZonePlane::setNormal(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>, <a class="code" href="a03128.html">CVector</a> n)
00306 {
00307         _Normal[<a class="code" href="a04223.html#a566">index</a>] = n;
00308 }
00309 
00310 
00311 
00312 
<a name="l00313"></a><a class="code" href="a03258.html#NL3D_1_1CPSZonePlanea47">00313</a> <span class="keywordtype">void</span> CPSZonePlane::serial(<a class="code" href="a02270.html">NLMISC::IStream</a> &amp;f) <span class="keywordflow">throw</span>(<a class="code" href="a03781.html">NLMISC::EStream</a>)
00314 {
00315         f.serialVersion(1);             
00316         CPSZone::serial(f);     
00317         f.serial(_Normal);      
00318 }
00319 
00320 
00321 
00323 <span class="comment">// sphere implementation //</span>
00325 <span class="comment"></span>
00326 
00327 
00328 
<a name="l00329"></a><a class="code" href="a03260.html#NL3D_1_1CPSZoneSpherea44">00329</a> <span class="keywordtype">void</span> CPSZoneSphere::performMotion(<a class="code" href="a05363.html#a366">TAnimationTime</a> ellapsedTime)
00330 {
00331         <a class="code" href="a04726.html#a0">MINI_TIMER</a>(<a class="code" href="a05363.html#a201">PSStatsZoneSphere</a>)           
00332         <span class="comment">// for each target, we must check wether they are going through the plane</span>
00333         <span class="comment">// if so they must bounce</span>
00334 
00335         TPSAttribRadiusPair::const_iterator radiusIt = _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>();
00336         TPSAttribVector::const_iterator spherePosIt, spherePosEnd, targetPosIt, targetPosEnd;
00337         <a class="code" href="a03128.html">CVector</a> dest;
00338         <a class="code" href="a03151.html">CPSCollisionInfo</a> ci;
00339         <a class="code" href="a04558.html#a11">uint32</a> k;
00340         <span class="keyword">const</span> <a class="code" href="a03135.html">TPSAttribVector</a> *speedAttr;
00341 
00342 
00343         <span class="keywordtype">float</span> rOut, rIn;
00344 
00345 
00346         <span class="keywordflow">for</span> (TTargetCont::iterator it = _Targets.begin(); it != _Targets.end(); ++it)
00347         {
00348 
00349                 speedAttr = &amp;((*it)-&gt;getSpeed());
00350 
00351 
00352                 <span class="comment">// cycle through the spheres</span>
00353                         
00354                 spherePosEnd = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_3">end</a>();
00355                 <span class="keywordflow">for</span> (spherePosIt = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(), radiusIt = _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(); spherePosIt != spherePosEnd
00356                                 ; ++spherePosIt, ++radiusIt)
00357                 {
00358                         
00359                         <span class="comment">// we must setup the sphere in the good basis</span>
00360 
00361                         <span class="keyword">const</span> <a class="code" href="a02851.html">CMatrix</a> &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);
00362 
00363                         
00364 
00365                         <a class="code" href="a03128.html">CVector</a> center = m * *spherePosIt;
00366                                                 
00367                         <span class="comment">// deals with each particle</span>
00368 
00369 
00370                         targetPosEnd = (*it)-&gt;<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_6">getPos</a>().end();
00371                         TPSAttribCollisionInfo::const_iterator ciIt = (*it)-&gt;getCollisionInfo().begin();
00372                         <span class="keywordflow">for</span> (targetPosIt = (*it)-&gt;getPos().begin(), k = 0; targetPosIt != targetPosEnd; ++targetPosIt, ++k, ++ciIt)
00373                         {       
00374                                 <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> &amp;speed = (*speedAttr)[k];
00375                                 <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> &amp;pos = *targetPosIt;
00376                                 <span class="comment">// check whether the located is going through the sphere</span>
00377 
00378                                 <span class="comment">// we don't use raytracing for now because it is too slow ...</span>
00379                                         
00380 
00381                                 rOut = (pos - center) * (pos - center);
00382 
00383                                 <span class="comment">// initial position outside the sphere ?</span>
00384                                 <span class="keywordflow">if</span> (rOut &gt; radiusIt-&gt;R2)
00385                                 {
00386                                         dest = pos + ellapsedTime *  speed * ciIt-&gt;TimeSliceRatio;
00387                                         rIn = (dest - center) * (dest - center);
00388 
00389                                         <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> D = dest - pos;
00390 
00391                                         <span class="comment">// final position inside the sphere ?</span>
00392 
00393                                         <span class="keywordflow">if</span> ( rIn &lt;= radiusIt-&gt;R2)
00394                                         {                               
00395                                                 <span class="comment">// discriminant of the intersection equation</span>
00396                                                 <span class="keyword">const</span> <span class="keywordtype">float</span> b = 2.f * (pos * D - D * center), a = D * D
00397                                                                         , c = (pos * pos) + (center * center) - 2.f * (pos * center) - radiusIt-&gt;R2;
00398                                                 <span class="keywordtype">float</span> d = b * b - 4 * a * c;
00399 
00400                                                 
00401                                                 <span class="keywordflow">if</span> (d &lt;= 0.f) <span class="keywordflow">continue</span>; <span class="comment">// should never happen, but we never know ...</span>
00402                                                 
00403 
00404                                                 d = sqrtf(d);
00405 
00406                                                 <span class="comment">// roots of the equation, we take the smallest </span>
00407 
00408 
00409                                                 <span class="keyword">const</span> <span class="keywordtype">float</span> r1 = .5f * (-b + 2.f * d) * a
00410                                                                         , r2 = .5f * (-b - 2.f * d) * a;
00411 
00412                                                 <span class="keyword">const</span> <span class="keywordtype">float</span>  <a class="code" href="a04223.html#a628">r</a> = <a class="code" href="a04061.html#a0">std::min</a>(r1, r2);
00413 
00414                                                 <span class="comment">// collision point </span>
00415 
00416                                                 <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> C = pos  + <a class="code" href="a04223.html#a628">r</a> * D;
00417 
00418 
00419 
00420 
00421                                 
00422                                     
00423                                                 <span class="keyword">const</span> <span class="keywordtype">float</span> <a class="code" href="a04223.html#a663">alpha</a> = ((C - pos) * D) * a;
00424 
00425                                                 <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> startEnd = <a class="code" href="a04223.html#a663">alpha</a> * (dest - pos);                                  
00426 
00427                                                 <a class="code" href="a03128.html">CVector</a> normal = C - center;
00428                                                 normal = normal * (1.f / radiusIt-&gt;R);
00429 
00430                                         
00431                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo1">dist</a> = startEnd.<a class="code" href="a03128.html#NLMISC_1_1CVectorz2049_0">norm</a>();
00432                                                 <span class="comment">// we translate the particle from an epsilon so that it won't get hooked to the sphere</span>
00433                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo2">newPos</a> = pos  + startEnd + <a class="code" href="a05363.html#a273">PSCollideEpsilon</a> * normal;                                
00434                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo3">newSpeed</a> = _BounceFactor * (speed - 2.0f * (speed * normal) * normal);
00435 
00436                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo0">collisionZone</a> = <span class="keyword">this</span>;                                                
00437                                                 (*it)-&gt;collisionUpdate(ci, k);
00438                                                 
00439                                         }                                       
00440                                 }
00441                         }
00442                 }
00443         }
00444 }
00445 
00446 
00447 
<a name="l00448"></a><a class="code" href="a03260.html#NL3D_1_1CPSZoneSpherea61">00448</a> <span class="keywordtype">void</span> CPSZoneSphere::show(<a class="code" href="a05363.html#a366">TAnimationTime</a> ellapsedTime)
00449 {
00450         
00451         <a class="code" href="a03214.html">CPSLocated</a> *loc;
00452         <a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>;
00453         <a class="code" href="a02691.html">CPSLocatedBindable</a> *lb;
00454         _Owner-&gt;<a class="code" href="a03054.html#NL3D_1_1CPSLocateda39">getOwner</a>()-&gt;<a class="code" href="a03041.html#NL3D_1_1CParticleSystemz588_0">getCurrentEditedElement</a>(loc, <a class="code" href="a04223.html#a566">index</a>, lb);
00455 
00456 
00457         TPSAttribRadiusPair::const_iterator radiusIt = _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>();
00458         TPSAttribVector::const_iterator posIt = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(), endPosIt = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_3">end</a>();
00459         <a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea59">setupDriverModelMatrix</a>();       
00460         <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> k = 0; posIt != endPosIt; ++posIt, ++radiusIt, ++k) 
00461         {       
00462                 <span class="keyword">const</span> <a class="code" href="a03337.html">CRGBA</a> col = ((lb == NULL || <span class="keyword">this</span> == lb) &amp;&amp; loc == _Owner &amp;&amp; <a class="code" href="a04223.html#a566">index</a> == k  ? CRGBA::Red : <a class="code" href="a03337.html">CRGBA</a>(127, 127, 127));             
00463                 CPSUtil::displaySphere(*<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea14">getDriver</a>(), radiusIt-&gt;R, *posIt, 5, col);
00464         }
00465 }
00466         
<a name="l00467"></a><a class="code" href="a03260.html#NL3D_1_1CPSZoneSpherea54">00467</a> <span class="keywordtype">void</span> CPSZoneSphere::setMatrix(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>, <span class="keyword">const</span> <a class="code" href="a02851.html">CMatrix</a> &amp;m)
00468 {
00469         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a566">index</a> &lt; _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_1">getSize</a>());
00470                 
00471         <span class="comment">// compute new pos</span>
00472         _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>()[<a class="code" href="a04223.html#a566">index</a>] = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_6">getPos</a>();
00473         
00474 }
00475 
00476 
<a name="l00477"></a><a class="code" href="a03260.html#NL3D_1_1CPSZoneSpherea24">00477</a> <a class="code" href="a02851.html">CMatrix</a> CPSZoneSphere::getMatrix(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)<span class="keyword"> const</span>
00478 <span class="keyword"></span>{
00479         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a566">index</a> &lt; _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_1">getSize</a>());
00480         <a class="code" href="a02851.html">CMatrix</a> m;
00481         m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_0">identity</a>();
00482         m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1965_7">translate</a>(_Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>()[<a class="code" href="a04223.html#a566">index</a>]);   
00483         <span class="keywordflow">return</span> m; 
00484 }
00485 
<a name="l00486"></a><a class="code" href="a03260.html#NL3D_1_1CPSZoneSpherea58">00486</a> <span class="keywordtype">void</span> CPSZoneSphere::setScale(<a class="code" href="a04558.html#a11">uint32</a> k, <span class="keywordtype">float</span> scale)
00487 {
00488         _Radius[k].R = scale;
00489         _Radius[k].R2 = scale * scale;
00490 }
<a name="l00491"></a><a class="code" href="a03260.html#NL3D_1_1CPSZoneSpherea31">00491</a> <a class="code" href="a03128.html">CVector</a> CPSZoneSphere::getScale(<a class="code" href="a04558.html#a11">uint32</a> k)<span class="keyword"> const</span>
00492 <span class="keyword"></span>{
00493         <span class="keywordflow">return</span> <a class="code" href="a03128.html">CVector</a>(_Radius[k].R, _Radius[k].R, _Radius[k].R);
00494 }
00495 
00496 
<a name="l00497"></a><a class="code" href="a03260.html#NL3D_1_1CPSZoneSpherea48">00497</a> <span class="keywordtype">void</span> CPSZoneSphere::serial(<a class="code" href="a02270.html">NLMISC::IStream</a> &amp;f) <span class="keywordflow">throw</span>(<a class="code" href="a03781.html">NLMISC::EStream</a>)
00498 {
00499         f.serialVersion(1);
00500         CPSZone::serial(f);
00501         f.serial(_Radius);      
00502 }
00503 
00504 
00505                 
00506 
00507 
00508 
<a name="l00509"></a><a class="code" href="a03260.html#NL3D_1_1CPSZoneSphereb6">00509</a> <span class="keywordtype">void</span> CPSZoneSphere::resize(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a587">size</a>)
00510 {
00511         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a587">size</a> &lt; (1 &lt;&lt; 16));
00512         _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_2">resize</a>(<a class="code" href="a04223.html#a587">size</a>);
00513 }
00514 
<a name="l00515"></a><a class="code" href="a03260.html#NL3D_1_1CPSZoneSphereb4">00515</a> <span class="keywordtype">void</span> CPSZoneSphere::newElement(<a class="code" href="a03214.html">CPSLocated</a> *emitterLocated, <a class="code" href="a04558.html#a11">uint32</a> emitterIndex)
00516 {
00517         <a class="code" href="a03299.html">CRadiusPair</a> rp;
00518         rp.<a class="code" href="a03299.html#NL3D_1_1CRadiusPairo0">R</a> = rp.<a class="code" href="a03299.html#NL3D_1_1CRadiusPairo1">R2</a> = 1.f;
00519         <a class="code" href="a04199.html#a6">nlassert</a>(_Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_1">getSize</a>() != _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_0">getMaxSize</a>());
00520         _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_1">insert</a>(rp);
00521 }
00522 
<a name="l00523"></a><a class="code" href="a03260.html#NL3D_1_1CPSZoneSphereb2">00523</a> <span class="keywordtype">void</span> CPSZoneSphere::deleteElement(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)
00524 {
00525         _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_2">remove</a>(<a class="code" href="a04223.html#a566">index</a>);
00526 }
00527 
00528 
00530 <span class="comment">// CPSZoneDisc implementation //</span>
00532 <span class="comment"></span>
<a name="l00533"></a><a class="code" href="a03257.html#NL3D_1_1CPSZoneDisca44">00533</a> <span class="keywordtype">void</span> CPSZoneDisc::performMotion(<a class="code" href="a05363.html#a366">TAnimationTime</a> ellapsedTime)
00534 {
00535         <a class="code" href="a04726.html#a0">MINI_TIMER</a>(<a class="code" href="a05363.html#a202">PSStatsZoneDisc</a>)             
00536         <span class="comment">// for each target, we must check wether they are going through the disc</span>
00537         <span class="comment">// if so they must bounce</span>
00538         TPSAttribVector::const_iterator discPosIt, discPosEnd, normalIt, targetPosIt, targetPosEnd;
00539         TPSAttribRadiusPair::const_iterator radiusIt;
00540         <a class="code" href="a03128.html">CVector</a> dest;
00541         <a class="code" href="a03151.html">CPSCollisionInfo</a> ci;
00542         <a class="code" href="a03128.html">CVector</a> startEnd;
00543         <a class="code" href="a04558.html#a11">uint32</a> k;
00544         <span class="keyword">const</span> <a class="code" href="a03135.html">TPSAttribVector</a> *speedAttr;
00545         <span class="keywordtype">float</span> posSide, negSide;
00546 
00547         <span class="comment">// the square of radius at the hit point</span>
00548         <span class="keywordtype">float</span> hitRadius2; 
00549 
00550         <span class="comment">// alpha is the ratio that gives the percent of endPos - startPos that hit the disc</span>
00551         <span class="keywordtype">float</span> <a class="code" href="a04223.html#a663">alpha</a>; 
00552 
00553         <a class="code" href="a03128.html">CVector</a> center;
00554 
00555         <span class="keywordflow">for</span> (TTargetCont::iterator it = _Targets.begin(); it != _Targets.end(); ++it)
00556         {
00557 
00558                 speedAttr = &amp;((*it)-&gt;getSpeed());
00559                 <span class="comment">// cycle through the disc</span>
00560 
00561                 discPosEnd = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_3">end</a>();
00562                 <span class="keywordflow">for</span> (discPosIt = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(), radiusIt = _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(), normalIt = _Normal.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(); discPosIt != discPosEnd
00563                                 ; ++discPosIt, ++normalIt, ++radiusIt)
00564                 {
00565                         
00566                         <span class="comment">// we must setup the disc in the good basis</span>
00567 
00568                         <span class="keyword">const</span> <a class="code" href="a02851.html">CMatrix</a> &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);
00569 
00570                         
00571 
00572                         <a class="code" href="a03082.html">NLMISC::CPlane</a> p;
00573                         center = m * (*discPosIt);
00574                         p.<a class="code" href="a03082.html#NLMISC_1_1CPlanez1990_2">make</a>(m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1968_1">mulVector</a>(*normalIt), center);         
00575                         
00576                         <span class="comment">// deals with each particle</span>
00577 
00578                         <span class="keyword">const</span> <span class="keywordtype">float</span> epsilon = 0.5f * <a class="code" href="a05363.html#a273">PSCollideEpsilon</a>;
00579 
00580                         targetPosEnd = (*it)-&gt;getPos().end();
00581                         TPSAttribCollisionInfo::const_iterator ciIt = (*it)-&gt;getCollisionInfo().begin();
00582                         <span class="keywordflow">for</span> (targetPosIt = (*it)-&gt;getPos().begin(), k = 0; targetPosIt != targetPosEnd; ++targetPosIt, ++k, ++ciIt)
00583                         {       
00584                                 <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> &amp;speed = (*speedAttr)[k];
00585                                 <span class="comment">// check whether the located is going through the disc</span>
00586                                 dest = *targetPosIt + ellapsedTime *  speed * ciIt-&gt;TimeSliceRatio;
00587 
00588 
00589                                 posSide = p * *targetPosIt;
00590                                 negSide = p * dest;
00591                                                                 
00592                                 <span class="keywordflow">if</span> (posSide &gt;= - epsilon &amp;&amp; negSide &lt;= epsilon)
00593                                 {                                                                       
00594                                                 <span class="keywordflow">if</span> (fabsf(posSide - negSide) &gt; <a class="code" href="a04061.html#a0">std::numeric_limits&lt;float&gt;::min</a>())
00595                                                 {
00596                                                         <a class="code" href="a04223.html#a663">alpha</a> = posSide / (posSide - negSide);
00597                                                 }
00598                                                 <span class="keywordflow">else</span>
00599                                                 {
00600                                                         <a class="code" href="a04223.html#a663">alpha</a> = 0.f;
00601                                                 }
00602                                                 startEnd = <a class="code" href="a04223.html#a663">alpha</a> * (dest - *targetPosIt);                                       
00603                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo1">dist</a> = startEnd.<a class="code" href="a03128.html#NLMISC_1_1CVectorz2049_0">norm</a>();
00604                                                 <span class="comment">// we translate the particle from an epsilon so that it won't get hooked to the disc</span>
00605                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo2">newPos</a> = *targetPosIt  + startEnd + <a class="code" href="a05363.html#a273">PSCollideEpsilon</a> * p.<a class="code" href="a03082.html#NLMISC_1_1CPlanez1990_0">getNormal</a>();                                
00606 
00607 
00608                                                 <span class="comment">// now, check the collision pos against radius</span>
00609 
00610                                                 hitRadius2 = (ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo2">newPos</a> - center) * (ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo2">newPos</a> - center);
00611 
00612                                                 <span class="keywordflow">if</span> (hitRadius2 &lt; radiusIt-&gt;R2) <span class="comment">// check collision against disc</span>
00613                                                 {
00614                                                         ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo3">newSpeed</a> = _BounceFactor * (speed - 2.0f * (speed * p.<a class="code" href="a03082.html#NLMISC_1_1CPlanez1990_0">getNormal</a>()) * p.<a class="code" href="a03082.html#NLMISC_1_1CPlanez1990_0">getNormal</a>());                                         
00615                                                         ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo0">collisionZone</a> = <span class="keyword">this</span>;                                                
00616                                                         (*it)-&gt;collisionUpdate(ci, k);
00617                                                 }
00618                                         
00619                                 }
00620                         }
00621                 }
00622         }       
00623 }
00624 
<a name="l00625"></a><a class="code" href="a03257.html#NL3D_1_1CPSZoneDisca61">00625</a> <span class="keywordtype">void</span> CPSZoneDisc::show(<a class="code" href="a05363.html#a366">TAnimationTime</a> ellapsedTime)
00626 {
00627         TPSAttribRadiusPair::const_iterator radiusIt = _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>();
00628         TPSAttribVector::const_iterator posIt = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(), endPosIt = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_3">end</a>()
00629                                                                         , normalIt = _Normal.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>();
00630         <a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea59">setupDriverModelMatrix</a>();       
00631         <a class="code" href="a02851.html">CMatrix</a> mat;
00632 
00633         
00634                 
00635         <a class="code" href="a03214.html">CPSLocated</a> *loc;
00636         <a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>;
00637         <a class="code" href="a02691.html">CPSLocatedBindable</a> *lb;
00638         _Owner-&gt;<a class="code" href="a03054.html#NL3D_1_1CPSLocateda39">getOwner</a>()-&gt;<a class="code" href="a03041.html#NL3D_1_1CParticleSystemz588_0">getCurrentEditedElement</a>(loc, <a class="code" href="a04223.html#a566">index</a>, lb);
00639         
00640 
00641         
00642         <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> k = 0; posIt != endPosIt; ++posIt, ++radiusIt, ++normalIt, ++k) 
00643         {       
00644                 <span class="keyword">const</span> <a class="code" href="a03337.html">CRGBA</a> col = ((lb == NULL || <span class="keyword">this</span> == lb) &amp;&amp; loc == _Owner &amp;&amp; <a class="code" href="a04223.html#a566">index</a> == k  ? CRGBA::Red : <a class="code" href="a03337.html">CRGBA</a>(127, 127, 127));
00645                 CPSUtil::buildSchmidtBasis(*normalIt, mat);
00646                 CPSUtil::displayDisc(*<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea14">getDriver</a>(), radiusIt-&gt;R, *posIt, mat, 32, col);
00647 
00648                 mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_4">setPos</a>(*posIt);
00649                 CPSUtil::displayBasis(<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea14">getDriver</a>() ,<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea22">getLocalToWorldMatrix</a>(), mat, 1.f, *<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea17">getFontGenerator</a>(), *<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea19">getFontManager</a>());                          
00650                 <a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea59">setupDriverModelMatrix</a>();                       
00651         }       
00652 }
00653         
00654 
00655 
00656 
00657 
00658 
<a name="l00659"></a><a class="code" href="a03257.html#NL3D_1_1CPSZoneDisca54">00659</a> <span class="keywordtype">void</span> CPSZoneDisc::setMatrix(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>, <span class="keyword">const</span> <a class="code" href="a02851.html">CMatrix</a> &amp;m)
00660 {
00661         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a566">index</a> &lt; _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_1">getSize</a>());    
00662         <span class="comment">// compute new pos</span>
00663         _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>()[<a class="code" href="a04223.html#a566">index</a>] = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_6">getPos</a>();
00664         <span class="comment">// compute new normal</span>
00665         _Normal[<a class="code" href="a04223.html#a566">index</a>] = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_4">getK</a>();
00666 }
00667 
<a name="l00668"></a><a class="code" href="a03257.html#NL3D_1_1CPSZoneDisca24">00668</a> <a class="code" href="a02851.html">CMatrix</a> CPSZoneDisc::getMatrix(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)<span class="keyword"> const</span>
00669 <span class="keyword"></span>{
00670         <a class="code" href="a02851.html">CMatrix</a> m, b;
00671         m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1965_7">translate</a>(_Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>()[<a class="code" href="a04223.html#a566">index</a>]);
00672         CPSUtil::buildSchmidtBasis(_Normal[<a class="code" href="a04223.html#a566">index</a>], b);
00673         m = m * b;
00674         <span class="keywordflow">return</span> m;       
00675 }
00676 
<a name="l00677"></a><a class="code" href="a03257.html#NL3D_1_1CPSZoneDisca27">00677</a> <a class="code" href="a03128.html">CVector</a> CPSZoneDisc::getNormal(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)
00678 {
00679         <span class="keywordflow">return</span> _Normal[<a class="code" href="a04223.html#a566">index</a>];
00680 }
<a name="l00681"></a><a class="code" href="a03257.html#NL3D_1_1CPSZoneDisca56">00681</a> <span class="keywordtype">void</span> CPSZoneDisc::setNormal(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>, <a class="code" href="a03128.html">CVector</a> n)
00682 {
00683         _Normal[<a class="code" href="a04223.html#a566">index</a>] = n;
00684 }
00685 
<a name="l00686"></a><a class="code" href="a03257.html#NL3D_1_1CPSZoneDisca58">00686</a> <span class="keywordtype">void</span> CPSZoneDisc::setScale(<a class="code" href="a04558.html#a11">uint32</a> k, <span class="keywordtype">float</span> scale)
00687 {
00688         _Radius[k].R = scale;
00689         _Radius[k].R2 = scale * scale;
00690 }
00691 
<a name="l00692"></a><a class="code" href="a03257.html#NL3D_1_1CPSZoneDisca31">00692</a> <a class="code" href="a03128.html">CVector</a> CPSZoneDisc::getScale(<a class="code" href="a04558.html#a11">uint32</a> k)<span class="keyword"> const</span>
00693 <span class="keyword"></span>{
00694         <span class="keywordflow">return</span> <a class="code" href="a03128.html">CVector</a>(_Radius[k].R, _Radius[k].R, _Radius[k].R);
00695 }
00696 
00697 
<a name="l00698"></a><a class="code" href="a03257.html#NL3D_1_1CPSZoneDisca48">00698</a> <span class="keywordtype">void</span> CPSZoneDisc::serial(<a class="code" href="a02270.html">NLMISC::IStream</a> &amp;f) <span class="keywordflow">throw</span>(<a class="code" href="a03781.html">NLMISC::EStream</a>)
00699 {
00700         f.serialVersion(1);     
00701         CPSZone::serial(f);
00702         f.serial(_Normal);              
00703         f.serial(_Radius);              
00704 }
00705 
<a name="l00706"></a><a class="code" href="a03257.html#NL3D_1_1CPSZoneDiscb6">00706</a> <span class="keywordtype">void</span> CPSZoneDisc::resize(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a587">size</a>)
00707 {
00708         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a587">size</a> &lt; (1 &lt;&lt; 16));
00709         _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_2">resize</a>(<a class="code" href="a04223.html#a587">size</a>);
00710         _Normal.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_2">resize</a>(<a class="code" href="a04223.html#a587">size</a>);
00711 }
00712 
<a name="l00713"></a><a class="code" href="a03257.html#NL3D_1_1CPSZoneDiscb4">00713</a> <span class="keywordtype">void</span> CPSZoneDisc::newElement(<a class="code" href="a03214.html">CPSLocated</a> *emitterLocated, <a class="code" href="a04558.html#a11">uint32</a> emitterIndex)
00714 {
00715         <a class="code" href="a03299.html">CRadiusPair</a> rp;
00716         rp.<a class="code" href="a03299.html#NL3D_1_1CRadiusPairo0">R</a> = rp.<a class="code" href="a03299.html#NL3D_1_1CRadiusPairo1">R2</a> = 1.f;
00717         <a class="code" href="a04199.html#a6">nlassert</a>(_Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_1">getSize</a>() != _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_0">getMaxSize</a>());
00718         _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_1">insert</a>(rp);
00719         _Normal.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_1">insert</a>(CVector::K);
00720 }
00721 
<a name="l00722"></a><a class="code" href="a03257.html#NL3D_1_1CPSZoneDiscb2">00722</a> <span class="keywordtype">void</span> CPSZoneDisc::deleteElement(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)
00723 {
00724         _Radius.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_2">remove</a>(<a class="code" href="a04223.html#a566">index</a>);
00725         _Normal.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_2">remove</a>(<a class="code" href="a04223.html#a566">index</a>);
00726 }
00727 
00728 
00730 <span class="comment">// CPSZoneCylinder implementation //</span>
00732 <span class="comment"></span>
00733 
00734 <span class="comment">/*</span>
00735 <span class="comment">void CPSZoneCylinder::performMotion(TAnimationTime ellapsedTime)</span>
00736 <span class="comment">{</span>
00737 <span class="comment">        TPSAttribVector::const_iterator dimIt = _Dim.begin();</span>
00738 <span class="comment">        CPSAttrib&lt;CPlaneBasis&gt;::const_iterator basisIt = _Basis.begin();</span>
00739 <span class="comment">        TPSAttribVector::const_iterator cylinderPosIt, cylinderPosEnd, targetPosIt, targetPosEnd;</span>
00740 <span class="comment">        CVector dest;</span>
00741 <span class="comment">        CPSCollisionInfo ci;</span>
00742 <span class="comment">        CVector startEnd;</span>
00743 <span class="comment">        uint32 k;</span>
00744 <span class="comment">        const TPSAttribVector *speedAttr;</span>
00745 <span class="comment"></span>
00746 <span class="comment"></span>
00747 <span class="comment"></span>
00748 <span class="comment">        for (TTargetCont::iterator it = _Targets.begin(); it != _Targets.end(); ++it)</span>
00749 <span class="comment">        {</span>
00750 <span class="comment"></span>
00751 <span class="comment">                speedAttr = &amp;((*it)-&gt;getSpeed());</span>
00752 <span class="comment"></span>
00753 <span class="comment"></span>
00754 <span class="comment">                // cycle through the cylinders</span>
00755 <span class="comment"></span>
00756 <span class="comment">                cylinderPosEnd = _Owner-&gt;getPos().end();</span>
00757 <span class="comment">                for (cylinderPosIt = _Owner-&gt;getPos().begin(); cylinderPosIt != cylinderPosEnd</span>
00758 <span class="comment">                                ; ++cylinderPosIt, ++dimIt, ++basisIt)</span>
00759 <span class="comment">                {</span>
00760 <span class="comment">                        </span>
00761 <span class="comment">                        // we must setup the cylinder in the good basis</span>
00762 <span class="comment"></span>
00763 <span class="comment">                        const CMatrix &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);</span>
00764 <span class="comment"></span>
00765 <span class="comment">                        </span>
00766 <span class="comment"></span>
00767 <span class="comment">                        // compute the new center pos</span>
00768 <span class="comment">                        CVector center = m * *cylinderPosIt;</span>
00769 <span class="comment"></span>
00770 <span class="comment">                        // compute a basis for the cylinder</span>
00771 <span class="comment">                        CVector I = m.mulVector(basisIt-&gt;X);</span>
00772 <span class="comment">                        CVector J = m.mulVector(basisIt-&gt;Y);</span>
00773 <span class="comment">                        CVector K = m.mulVector(basisIt-&gt;X ^ basisIt-&gt;Y);</span>
00774 <span class="comment"></span>
00775 <span class="comment">                                                </span>
00776 <span class="comment">                        // the pos projected (and scale) over the plane basis of the cylinder, the pos minus the center</span>
00777 <span class="comment">                        CVector projectedPos, tPos;</span>
00778 <span class="comment"></span>
00779 <span class="comment">                        // the same, but with the final position</span>
00780 <span class="comment">                        CVector destProjectedPos, destTPos;</span>
00781 <span class="comment"></span>
00782 <span class="comment"></span>
00783 <span class="comment">                        // deals with each particle</span>
00784 <span class="comment">                        targetPosEnd = (*it)-&gt;getPos().end();</span>
00785 <span class="comment">                        for (targetPosIt = (*it)-&gt;getPos().begin(), k = 0; targetPosIt != targetPosEnd; ++targetPosIt, ++k)</span>
00786 <span class="comment">                        {       </span>
00787 <span class="comment">                                const CVector &amp;speed = (*speedAttr)[k];</span>
00788 <span class="comment">                                const CVector &amp;pos = *targetPosIt;</span>
00789 <span class="comment"></span>
00790 <span class="comment">                                </span>
00791 <span class="comment">                                </span>
00792 <span class="comment">                                // check wether current pos was outside the cylinder</span>
00793 <span class="comment"></span>
00794 <span class="comment"></span>
00795 <span class="comment">                                tPos = pos - center;</span>
00796 <span class="comment">                                projectedPos = (1 / dimIt-&gt;x) * (I * tPos) * I + (1 / dimIt-&gt;y)  * (J * tPos) * J;</span>
00797 <span class="comment">                                </span>
00798 <span class="comment">                                if (!</span>
00799 <span class="comment">                                         (</span>
00800 <span class="comment">                                                ((tPos * K) &lt; dimIt-&gt;z)</span>
00801 <span class="comment">                                                &amp;&amp; ((tPos * K) &gt; -dimIt-&gt;z)</span>
00802 <span class="comment">                                                &amp;&amp; (projectedPos * projectedPos &lt; 1.f) </span>
00803 <span class="comment">                                         )</span>
00804 <span class="comment">                                   )</span>
00805 <span class="comment">                                {</span>
00806 <span class="comment">                                        dest = pos + ellapsedTime *  speed;</span>
00807 <span class="comment">                                        destTPos = dest - center;</span>
00808 <span class="comment">                                        destProjectedPos = (1.f / dimIt-&gt;x) * (I * tPos) * I + (1.f / dimIt-&gt;y)  * (J * tPos) * J;</span>
00809 <span class="comment"></span>
00810 <span class="comment">                                        // test wether the new position is inside the cylinder</span>
00811 <span class="comment"></span>
00812 <span class="comment">                                        </span>
00813 <span class="comment">                                        if (!</span>
00814 <span class="comment">                                                 (</span>
00815 <span class="comment">                                                        ((destTPos * K) &lt; dimIt-&gt;z)</span>
00816 <span class="comment">                                                        &amp;&amp; ((destTPos * K) &gt; -dimIt-&gt;z)</span>
00817 <span class="comment">                                                        &amp;&amp; (destProjectedPos * destProjectedPos &lt; 1.f) </span>
00818 <span class="comment">                                                 )</span>
00819 <span class="comment">                                           )</span>
00820 <span class="comment">                                        {</span>
00821 <span class="comment">                                                // now, detect the closest hit point (the smallest alpha, with alpha, the percent of the move vector</span>
00822 <span class="comment">                                                // to reach the hit point)</span>
00823 <span class="comment"></span>
00824 <span class="comment">                                                const float epsilon = 10E-6f;</span>
00825 <span class="comment"></span>
00826 <span class="comment">                                                float alphaTop, alphaBottom, alphaCyl;</span>
00827 <span class="comment"></span>
00828 <span class="comment">                                                const float denum = (dest - pos) * K;</span>
00829 <span class="comment"></span>
00830 <span class="comment">                                                // top plane</span>
00831 <span class="comment"></span>
00832 <span class="comment">                                                if (fabs(denum) &lt; epsilon)</span>
00833 <span class="comment">                                                {</span>
00834 <span class="comment">                                                        alphaTop = (dimIt-&gt;z - (tPos * K)) / denum;</span>
00835 <span class="comment">                                                        if (alphaTop &lt; 0.f) alphaTop = 1.f;</span>
00836 <span class="comment">                                                }</span>
00837 <span class="comment">                                                else</span>
00838 <span class="comment">                                                {</span>
00839 <span class="comment">                                                        alphaTop = 1.f;</span>
00840 <span class="comment">                                                }</span>
00841 <span class="comment"></span>
00842 <span class="comment">                                                // bottom plane</span>
00843 <span class="comment"></span>
00844 <span class="comment">                                                if (fabs(denum) &lt; epsilon)</span>
00845 <span class="comment">                                                {</span>
00846 <span class="comment">                                                        alphaBottom = (- dimIt-&gt;z - (tPos * K)) / denum;</span>
00847 <span class="comment">                                                        if (alphaBottom &lt; 0.f) alphaBottom = 1.f;</span>
00848 <span class="comment">                                                }</span>
00849 <span class="comment">                                                else</span>
00850 <span class="comment">                                                {</span>
00851 <span class="comment">                                                        alphaBottom = 1.f;</span>
00852 <span class="comment">                                                }</span>
00853 <span class="comment"></span>
00854 <span class="comment">                                                // cylinder</span>
00855 <span class="comment"></span>
00856 <span class="comment">                                                //expressed the src and dest positions in the cylinder basis</span>
00857 <span class="comment"></span>
00858 <span class="comment">                                                const float ox = tPos * I, oy = tPos * J, dx = (destTPos - tPos) * I, dy = (destTPos - tPos) * J;</span>
00859 <span class="comment"></span>
00860 <span class="comment">                                                // coefficients of the equation : a * alpha ^ 2 + b * alpha + c = 0</span>
00861 <span class="comment">                                                const float a = (dx * dx) / (dimIt-&gt;x * dimIt-&gt;x)</span>
00862 <span class="comment">                                                                  + (dy * dy) / (dimIt-&gt;y * dimIt-&gt;y);</span>
00863 <span class="comment">                                                const float b = 2.f * (ox * dx) / (dimIt-&gt;x * dimIt-&gt;x)</span>
00864 <span class="comment">                                                                  + (oy * dy) / (dimIt-&gt;y * dimIt-&gt;y);</span>
00865 <span class="comment">                                                const float c = ox * ox + oy * oy - 1;</span>
00866 <span class="comment"></span>
00867 <span class="comment">                                                // discriminant</span>
00868 <span class="comment">                                                const float delta = b * b - 4.f * a * c;</span>
00869 <span class="comment"></span>
00870 <span class="comment">                                                if (delta &lt; epsilon)</span>
00871 <span class="comment">                                                {</span>
00872 <span class="comment">                                                        alphaCyl = 1.f;</span>
00873 <span class="comment">                                                }</span>
00874 <span class="comment">                                                else</span>
00875 <span class="comment">                                                {</span>
00876 <span class="comment">                                                        const float deltaRoot = sqrtf(delta);</span>
00877 <span class="comment">                                                        const float r1 = (- b - deltaRoot) / (2.f / a);</span>
00878 <span class="comment">                                                        const float r2 = (- b - deltaRoot) / (2.f / a);</span>
00879 <span class="comment"></span>
00880 <span class="comment">                                                        if (r1 &lt; 0.f) alphaCyl = r2;</span>
00881 <span class="comment">                                                                else if (r2 &lt; 0.f) alphaCyl = r1;</span>
00882 <span class="comment">                                                                        else alphaCyl = r1 &lt; r2 ? r1 : r2;</span>
00883 <span class="comment">                                                }</span>
00884 <span class="comment"></span>
00885 <span class="comment"></span>
00886 <span class="comment">                                                // now, choose the minimum positive dist</span>
00887 <span class="comment">                                                </span>
00888 <span class="comment">                                                if (alphaTop &lt; alphaBottom &amp;&amp; alphaTop &lt; alphaCyl)</span>
00889 <span class="comment">                                                {</span>
00890 <span class="comment">                                                        // collision with the top plane</span>
00891 <span class="comment">                                                        CVector startEnd = alphaTop * (dest - pos);</span>
00892 <span class="comment">                                                        ci.newPos = pos + startEnd + PSCollideEpsilon * K;</span>
00893 <span class="comment">                                                        ci.dist = startEnd.norm();</span>
00894 <span class="comment">                                                        ci.newSpeed = (-2.f * (speed * K)) * K + speed;</span>
00895 <span class="comment">                                                        ci.collisionZone = this;</span>
00896 <span class="comment">                                                        </span>
00897 <span class="comment">                                                        (*it)-&gt;collisionUpdate(ci, k);</span>
00898 <span class="comment">                                                }</span>
00899 <span class="comment">                                                else</span>
00900 <span class="comment">                                                        if (alphaBottom &lt; alphaCyl)</span>
00901 <span class="comment">                                                        {       </span>
00902 <span class="comment">                                                                // collision with the bottom plane</span>
00903 <span class="comment">                                                                CVector startEnd = alphaBottom * (dest - pos);</span>
00904 <span class="comment">                                                                ci.newPos = pos + startEnd - PSCollideEpsilon * K;</span>
00905 <span class="comment">                                                                ci.dist = startEnd.norm();</span>
00906 <span class="comment">                                                                ci.newSpeed = (-2.f * (speed * K)) * K + speed;</span>
00907 <span class="comment">                                                                ci.collisionZone = this;</span>
00908 <span class="comment">                                                </span>
00909 <span class="comment">                                                                </span>
00910 <span class="comment">                                                                (*it)-&gt;collisionUpdate(ci, k);</span>
00911 <span class="comment">                                                        }</span>
00912 <span class="comment">                                                        else</span>
00913 <span class="comment">                                                        {</span>
00914 <span class="comment">                                                                // collision with the cylinder</span>
00915 <span class="comment"></span>
00916 <span class="comment">                                                                CVector startEnd = alphaCyl * (dest - pos);</span>
00917 <span class="comment"></span>
00918 <span class="comment">                                                                // normal at the hit point. It is the gradient of the implicit equation x^2 / a^2 + y^2 / b^2 - R^ 2=  0</span>
00919 <span class="comment">                                                                // so we got unormalized n =  (2 x / a ^ 2, 2 y / b ^ 2, 0) in the basis of the cylinder</span>
00920 <span class="comment">                                                                // As we'll normalize it, we don't need  the 2 factor</span>
00921 <span class="comment">                                                                </span>
00922 <span class="comment">                                                                float px = ox + alphaCyl * dx;</span>
00923 <span class="comment">                                                                float py = oy + alphaCyl * dy;</span>
00924 <span class="comment"></span>
00925 <span class="comment">                                                                CVector normal = px / (dimIt-&gt;x * dimIt-&gt;x) * I + py / (dimIt-&gt;y * dimIt-&gt;y) * J;</span>
00926 <span class="comment">                                                                normal.normalize();</span>
00927 <span class="comment"></span>
00928 <span class="comment">                                                                ci.newPos = pos + startEnd - PSCollideEpsilon * normal;</span>
00929 <span class="comment">                                                                ci.dist = startEnd.norm();</span>
00930 <span class="comment">                                                                ci.newSpeed = (-2.f * (speed * normal)) * normal + speed;</span>
00931 <span class="comment">                                                                ci.collisionZone = this;</span>
00932 <span class="comment"></span>
00933 <span class="comment">                                                                (*it)-&gt;collisionUpdate(ci, k);</span>
00934 <span class="comment">                                                        }                                               </span>
00935 <span class="comment"></span>
00936 <span class="comment">                                        }</span>
00937 <span class="comment">                                }                                                                       </span>
00938 <span class="comment">                        }</span>
00939 <span class="comment">                }</span>
00940 <span class="comment">        }</span>
00941 <span class="comment">}</span>
00942 <span class="comment">*/</span>
00943 
00944 
00945 
<a name="l00946"></a><a class="code" href="a03256.html#NL3D_1_1CPSZoneCylindera44">00946</a> <span class="keywordtype">void</span> CPSZoneCylinder::performMotion(<a class="code" href="a05363.html#a366">TAnimationTime</a> ellapsedTime)
00947 {
00948         <a class="code" href="a04726.html#a0">MINI_TIMER</a>(<a class="code" href="a05363.html#a204">PSStatsZoneCylinder</a>)
00949         TPSAttribVector::const_iterator dimIt;
00950         <a class="code" href="a03135.html">CPSAttrib&lt;CPlaneBasis&gt;</a>::const_iterator basisIt;
00951         TPSAttribVector::const_iterator cylinderPosIt, cylinderPosEnd, targetPosIt, targetPosEnd;
00952         <a class="code" href="a03128.html">CVector</a> dest;
00953         <a class="code" href="a03151.html">CPSCollisionInfo</a> ci;
00954         <a class="code" href="a04558.html#a11">uint32</a> k;
00955         <span class="keyword">const</span> <a class="code" href="a03135.html">TPSAttribVector</a> *speedAttr;
00956 
00957 
00958 
00959         <span class="keywordflow">for</span> (TTargetCont::iterator it = _Targets.begin(); it != _Targets.end(); ++it)
00960         {
00961 
00962                 speedAttr = &amp;((*it)-&gt;getSpeed());
00963 
00964 
00965                 <span class="comment">// cycle through the cylinders</span>
00966 
00967                 cylinderPosEnd = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_3">end</a>();
00968                 <span class="keywordflow">for</span> (cylinderPosIt = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(), basisIt = _Basis.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(),  dimIt = <a class="code" href="a03256.html#NL3D_1_1CPSZoneCylinderp4">_Dim</a>.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>()
00969                                 ; cylinderPosIt != cylinderPosEnd
00970                                 ; ++cylinderPosIt, ++dimIt, ++basisIt)
00971                 {
00972                         
00973                         <span class="comment">// we must setup the cylinder in the good basis</span>
00974 
00975                         <span class="keyword">const</span> <a class="code" href="a02851.html">CMatrix</a> &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);
00976 
00977                         
00978 
00979                         <span class="comment">// compute the new center pos</span>
00980                         <a class="code" href="a03128.html">CVector</a> center = m * *cylinderPosIt;
00981 
00982                         <span class="comment">// compute a basis for the cylinder</span>
00983                         <a class="code" href="a03128.html">CVector</a> I = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1968_1">mulVector</a>(basisIt-&gt;X);
00984                         <a class="code" href="a03128.html">CVector</a> J = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1968_1">mulVector</a>(basisIt-&gt;Y);
00985                         <a class="code" href="a03128.html">CVector</a> K = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1968_1">mulVector</a>(basisIt-&gt;X ^ basisIt-&gt;Y);
00986 
00987                                                 
00988                         <span class="comment">// the pos projected (and scale) over the plane basis of the cylinder, the pos minus the center</span>
00989                         <a class="code" href="a03128.html">CVector</a> projectedPos, tPos;
00990 
00991                         <span class="comment">// the same, but with the final position</span>
00992                         <a class="code" href="a03128.html">CVector</a> destProjectedPos, destTPos;
00993 
00994 
00995                         <span class="comment">// deals with each particle</span>
00996                         targetPosEnd = (*it)-&gt;getPos().end();
00997                         TPSAttribCollisionInfo::const_iterator ciIt = (*it)-&gt;getCollisionInfo().begin();
00998                         <span class="keywordflow">for</span> (targetPosIt = (*it)-&gt;getPos().begin(), k = 0; targetPosIt != targetPosEnd; ++targetPosIt, ++k, ++ciIt)
00999                         {       
01000                                 <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> &amp;speed = (*speedAttr)[k];
01001                                 <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> &amp;pos = *targetPosIt;
01002 
01003                                 
01004                                 
01005                                 <span class="comment">// check wether current pos was outside the cylinder</span>
01006 
01007 
01008                                 tPos = pos - center;
01009                                 projectedPos = (1 / dimIt-&gt;x) * (I * tPos) * I + (1 / dimIt-&gt;y)  * (J * tPos) * J;
01010                                 
01011                                 <span class="keywordflow">if</span> (!
01012                                          (
01013                                                 ((tPos * K) &lt; dimIt-&gt;z)
01014                                                 &amp;&amp; ((tPos * K) &gt; -dimIt-&gt;z)
01015                                                 &amp;&amp; (projectedPos * projectedPos &lt; 1.f) 
01016                                          )
01017                                    )
01018                                 {
01019                                         dest = pos + ellapsedTime *  speed * ciIt-&gt;TimeSliceRatio;
01020                                         destTPos = dest - center;
01021                                         destProjectedPos = (1.f / dimIt-&gt;x) * (I * destTPos) * I + (1.f / dimIt-&gt;y)  * (J * destTPos) * J;
01022 
01023                                         <span class="comment">// test wether the new position is inside the cylinder</span>
01024 
01025                                         
01026                                         <span class="keywordflow">if</span> (
01027                                                  (
01028                                                         ((destTPos * K) &lt; dimIt-&gt;z)
01029                                                         &amp;&amp; ((destTPos * K) &gt; -dimIt-&gt;z)
01030                                                         &amp;&amp; (destProjectedPos * destProjectedPos &lt; 1.f) 
01031                                                  )
01032                                            )
01033                                         {
01034                                                 <span class="comment">// now, detect the closest hit point (the smallest alpha, with alpha, the percent of the move vector</span>
01035                                                 <span class="comment">// to reach the hit point)</span>
01036 
01037                                                 <span class="keyword">const</span> <span class="keywordtype">float</span> epsilon = 10E-3f;
01038 
01039                                                 <span class="keywordtype">float</span> alphaTop, alphaBottom, alphaCyl;
01040 
01041                                                 <span class="keyword">const</span> <span class="keywordtype">float</span> denum = (dest - pos) * K;
01042 
01043                                                 <span class="comment">// top plane</span>
01044 
01045                                                 <span class="keywordflow">if</span> (fabs(denum) &lt; epsilon)
01046                                                 {
01047                                                         alphaTop = (dimIt-&gt;z - (tPos * K)) / denum;
01048                                                         <span class="keywordflow">if</span> (alphaTop &lt; 0.f) alphaTop = 1.f;
01049                                                 }
01050                                                 <span class="keywordflow">else</span>
01051                                                 {
01052                                                         alphaTop = 1.f;
01053                                                 }
01054 
01055                                                 <span class="comment">// bottom plane</span>
01056 
01057                                                 <span class="keywordflow">if</span> (fabs(denum) &lt; epsilon)
01058                                                 {
01059                                                         alphaBottom = (- dimIt-&gt;z - (tPos * K)) / denum;
01060                                                         <span class="keywordflow">if</span> (alphaBottom &lt; 0.f) alphaBottom = 1.f;
01061                                                 }
01062                                                 <span class="keywordflow">else</span>
01063                                                 {
01064                                                         alphaBottom = 1.f;
01065                                                 }
01066 
01067                                                 <span class="comment">// cylinder</span>
01068 
01069                                                 <span class="comment">//expressed the src and dest positions in the cylinder basis</span>
01070 
01071                                                 <span class="keyword">const</span> <span class="keywordtype">float</span> ox = tPos * I, oy = tPos * J, dx = (destTPos - tPos) * I, dy = (destTPos - tPos) * J;
01072 
01073                                                 <span class="comment">// coefficients of the equation : a * alpha ^ 2 + b * alpha + c = 0</span>
01074                                                 <span class="keyword">const</span> <span class="keywordtype">float</span> a = (dx * dx) / (dimIt-&gt;x * dimIt-&gt;x)
01075                                                                   + (dy * dy) / (dimIt-&gt;y * dimIt-&gt;y);
01076                                                 <span class="keyword">const</span> <span class="keywordtype">float</span> b = 2.f * ((ox * dx) / (dimIt-&gt;x * dimIt-&gt;x)
01077                                                                   + (oy * dy) / (dimIt-&gt;y * dimIt-&gt;y));
01078                                                 <span class="keyword">const</span> <span class="keywordtype">float</span> c = (ox * ox) / (dimIt-&gt;x * dimIt-&gt;x) + (oy * oy) / (dimIt-&gt;y * dimIt-&gt;y)  - 1;
01079 
01080                                                 <span class="comment">// discriminant</span>
01081                                                 <span class="keyword">const</span> <span class="keywordtype">float</span> delta = b * b - 4.f * a * c;
01082 
01083                                                 <span class="keywordflow">if</span> (delta &lt; epsilon)
01084                                                 {
01085                                                         alphaCyl = 1.f;
01086                                                 }
01087                                                 <span class="keywordflow">else</span>
01088                                                 {
01089                                                         <span class="keyword">const</span> <span class="keywordtype">float</span> deltaRoot = sqrtf(delta);
01090                                                         <span class="keyword">const</span> <span class="keywordtype">float</span> r1 = (- b + 2.f * deltaRoot) / (2.f * a);
01091                                                         <span class="keyword">const</span> <span class="keywordtype">float</span> r2 = (- b - 2.f * deltaRoot) / (2.f * a);
01092 
01093                                                         <span class="keywordflow">if</span> (r1 &lt; 0.f) alphaCyl = r2;
01094                                                                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (r2 &lt; 0.f) alphaCyl = r1;
01095                                                                         <span class="keywordflow">else</span> alphaCyl = r1 &lt; r2 ? r1 : r2;
01096 
01097                                                                         <span class="keywordflow">if</span> (alphaCyl &lt; 0.f) alphaCyl = 1.f;
01098                                                 }
01099 
01100 
01101                                                 <span class="comment">// now, choose the minimum positive dist</span>
01102 
01103                                         
01104                                                 
01105                                                 <span class="keywordflow">if</span> (alphaTop &lt; alphaBottom &amp;&amp; alphaTop &lt; alphaCyl)
01106                                                 {
01107                                                         <span class="comment">// collision with the top plane</span>
01108                                                         <a class="code" href="a03128.html">CVector</a> startEnd = alphaTop * (dest - pos);
01109                                                         ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo2">newPos</a> = pos + startEnd + <a class="code" href="a05363.html#a273">PSCollideEpsilon</a> * K;
01110                                                         ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo1">dist</a> = startEnd.<a class="code" href="a03128.html#NLMISC_1_1CVectorz2049_0">norm</a>();
01111                                                         ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo3">newSpeed</a> = (-2.f * (speed * K)) * K + speed;
01112                                                         ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo0">collisionZone</a> = <span class="keyword">this</span>;
01113                                                         
01114                                                         (*it)-&gt;collisionUpdate(ci, k);
01115                                                 }
01116                                                 <span class="keywordflow">else</span>
01117                                                         <span class="keywordflow">if</span> (alphaBottom &lt; alphaCyl)
01118                                                         {       
01119                                                                 <span class="comment">// collision with the bottom plane</span>
01120                                                                 <a class="code" href="a03128.html">CVector</a> startEnd = alphaBottom * (dest - pos);
01121                                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo2">newPos</a> = pos + startEnd - <a class="code" href="a05363.html#a273">PSCollideEpsilon</a> * K;
01122                                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo1">dist</a> = startEnd.<a class="code" href="a03128.html#NLMISC_1_1CVectorz2049_0">norm</a>();
01123                                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo3">newSpeed</a> = (-2.f * (speed * K)) * K + speed;
01124                                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo0">collisionZone</a> = <span class="keyword">this</span>;
01125                                                 
01126                                                                 
01127                                                                 (*it)-&gt;collisionUpdate(ci, k);
01128                                                         }
01129                                                         <span class="keywordflow">else</span>
01130                                                         {
01131                                                                 <span class="comment">// collision with the cylinder</span>
01132 
01133                                                                 <a class="code" href="a03128.html">CVector</a> startEnd = alphaCyl * (dest - pos);
01134 
01135                                                                 <span class="comment">// normal at the hit point. It is the gradient of the implicit equation x^2 / a^2 + y^2 / b^2 - R^ 2=  0</span>
01136                                                                 <span class="comment">// so we got unormalized n =  (2 x / a ^ 2, 2 y / b ^ 2, 0) in the basis of the cylinder</span>
01137                                                                 <span class="comment">// As we'll normalize it, we don't need  the 2 factor</span>
01138                                                                 
01139                                                                 <span class="keywordtype">float</span> px = ox + alphaCyl * dx;
01140                                                                 <span class="keywordtype">float</span> py = oy + alphaCyl * dy;
01141 
01142                                                                 <a class="code" href="a03128.html">CVector</a> normal = px / (dimIt-&gt;x * dimIt-&gt;x) * I + py / (dimIt-&gt;y * dimIt-&gt;y) * J;
01143                                                                 normal.<a class="code" href="a03128.html#NLMISC_1_1CVectorz2049_1">normalize</a>();
01144 
01145                                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo2">newPos</a> = pos + startEnd + <a class="code" href="a05363.html#a273">PSCollideEpsilon</a> * normal;
01146                                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo1">dist</a> = startEnd.<a class="code" href="a03128.html#NLMISC_1_1CVectorz2049_0">norm</a>();
01147                                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo3">newSpeed</a> = (-2.f * (speed * normal)) * normal + speed;
01148                                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo0">collisionZone</a> = <span class="keyword">this</span>;
01149 
01150                                                                 (*it)-&gt;collisionUpdate(ci, k);
01151                                                         }                                               
01152 
01153                                         }
01154                                 }                                                                       
01155                         }
01156                 }
01157         }
01158 }
01159 
<a name="l01160"></a><a class="code" href="a03256.html#NL3D_1_1CPSZoneCylindera61">01160</a> <span class="keywordtype">void</span> CPSZoneCylinder::show(<a class="code" href="a05363.html#a366">TAnimationTime</a> ellapsedTime)
01161 {
01162         TPSAttribVector::const_iterator dimIt = <a class="code" href="a03256.html#NL3D_1_1CPSZoneCylinderp4">_Dim</a>.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>()
01163                                                                         ,posIt = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>()
01164                                                                         , endPosIt = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_3">end</a>();
01165 
01166         <a class="code" href="a03135.html">CPSAttrib&lt;CPlaneBasis&gt;</a>::const_iterator basisIt = _Basis.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>();
01167                                                                         
01168         <a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea59">setupDriverModelMatrix</a>();       
01169         <a class="code" href="a02851.html">CMatrix</a> mat;
01170 
01171 
01172                 
01173         <a class="code" href="a03214.html">CPSLocated</a> *loc;
01174         <a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>;
01175         <a class="code" href="a02691.html">CPSLocatedBindable</a> *lb;
01176         _Owner-&gt;<a class="code" href="a03054.html#NL3D_1_1CPSLocateda39">getOwner</a>()-&gt;<a class="code" href="a03041.html#NL3D_1_1CParticleSystemz588_0">getCurrentEditedElement</a>(loc, <a class="code" href="a04223.html#a566">index</a>, lb);
01177 
01178 
01179         <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a11">uint32</a> k = 0; posIt != endPosIt; ++posIt, ++dimIt, ++basisIt, ++k) 
01180         {                       
01181                 mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_10">setRot</a>(basisIt-&gt;X, basisIt-&gt;Y, basisIt-&gt;X ^ basisIt-&gt;Y);
01182                 mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_4">setPos</a>(CVector::Null);
01183 
01184                 <span class="keyword">const</span> <a class="code" href="a03337.html">CRGBA</a> col = ((lb == NULL || <span class="keyword">this</span> == lb) &amp;&amp; loc == _Owner &amp;&amp; <a class="code" href="a04223.html#a566">index</a> == k  ? CRGBA::Red : <a class="code" href="a03337.html">CRGBA</a>(127, 127, 127));
01185 
01186                 
01187                 CPSUtil::displayCylinder(*<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea14">getDriver</a>(), *posIt, mat, *dimIt, 32, col); 
01188 
01189                 mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_4">setPos</a>(*posIt);
01190                 CPSUtil::displayBasis(<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea14">getDriver</a>() ,<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea22">getLocalToWorldMatrix</a>(), mat, 1.f, *<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea17">getFontGenerator</a>(), *<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea19">getFontManager</a>());                          
01191                 <a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea59">setupDriverModelMatrix</a>();       
01192         
01193         }
01194 }
01195         
01196 
01197 
<a name="l01198"></a><a class="code" href="a03256.html#NL3D_1_1CPSZoneCylindera54">01198</a> <span class="keywordtype">void</span> CPSZoneCylinder::setMatrix(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>, <span class="keyword">const</span> <a class="code" href="a02851.html">CMatrix</a> &amp;m)
01199 {
01200         <span class="comment">// transform the basis  </span>
01201         _Basis[<a class="code" href="a04223.html#a566">index</a>].X = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_2">getI</a>();     
01202         _Basis[<a class="code" href="a04223.html#a566">index</a>].Y = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_3">getJ</a>();     
01203 
01204         <span class="comment">// compute new pos</span>
01205         _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>()[<a class="code" href="a04223.html#a566">index</a>] = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_6">getPos</a>();
01206         
01207                                  
01208 }
01209 
01210 
01211 
<a name="l01212"></a><a class="code" href="a03256.html#NL3D_1_1CPSZoneCylindera24">01212</a> <a class="code" href="a02851.html">CMatrix</a> CPSZoneCylinder::getMatrix(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)<span class="keyword"> const</span>
01213 <span class="keyword"></span>{
01214         <a class="code" href="a02851.html">CMatrix</a> m;
01215         m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_10">setRot</a>(_Basis[<a class="code" href="a04223.html#a566">index</a>].X, _Basis[<a class="code" href="a04223.html#a566">index</a>].Y, _Basis[<a class="code" href="a04223.html#a566">index</a>].X ^_Basis[<a class="code" href="a04223.html#a566">index</a>].Y);
01216         m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_4">setPos</a>(_Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>()[<a class="code" href="a04223.html#a566">index</a>]);      
01217         <span class="keywordflow">return</span> m;
01218 }
01219 
01220 
<a name="l01221"></a><a class="code" href="a03256.html#NL3D_1_1CPSZoneCylindera58">01221</a> <span class="keywordtype">void</span> CPSZoneCylinder::setScale(<a class="code" href="a04558.html#a11">uint32</a> k, <span class="keywordtype">float</span> scale)
01222 {
01223         <a class="code" href="a03256.html#NL3D_1_1CPSZoneCylinderp4">_Dim</a>[k] = <a class="code" href="a03128.html">CVector</a>(scale, scale, scale);
01224 }
01225 
<a name="l01226"></a><a class="code" href="a03256.html#NL3D_1_1CPSZoneCylindera31">01226</a> <a class="code" href="a03128.html">CVector</a> CPSZoneCylinder::getScale(<a class="code" href="a04558.html#a11">uint32</a> k)<span class="keyword"> const</span>
01227 <span class="keyword"></span>{
01228         <span class="keywordflow">return</span> <a class="code" href="a03256.html#NL3D_1_1CPSZoneCylinderp4">_Dim</a>[k];
01229 }
01230 
<a name="l01231"></a><a class="code" href="a03256.html#NL3D_1_1CPSZoneCylindera57">01231</a> <span class="keywordtype">void</span> CPSZoneCylinder::setScale(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>, <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> &amp;<a class="code" href="a04223.html#a626">s</a>)
01232 {
01233         <a class="code" href="a03256.html#NL3D_1_1CPSZoneCylinderp4">_Dim</a>[<a class="code" href="a04223.html#a566">index</a>] = <a class="code" href="a04223.html#a626">s</a>;
01234 }
01235 
01236 
<a name="l01237"></a><a class="code" href="a03256.html#NL3D_1_1CPSZoneCylindera48">01237</a> <span class="keywordtype">void</span> CPSZoneCylinder::serial(<a class="code" href="a02270.html">NLMISC::IStream</a> &amp;f) <span class="keywordflow">throw</span>(<a class="code" href="a03781.html">NLMISC::EStream</a>)
01238 {
01239         f.serialVersion(1);
01240         CPSZone::serial(f);
01241         f.serial(_Basis);               
01242         f.serial(_Dim);
01243 }
01244 
01245 
01246 
<a name="l01247"></a><a class="code" href="a03256.html#NL3D_1_1CPSZoneCylinderb6">01247</a> <span class="keywordtype">void</span> CPSZoneCylinder::resize(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a587">size</a>)
01248 {
01249         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a587">size</a> &lt; (1 &lt;&lt; 16));
01250         _Basis.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_2">resize</a>(<a class="code" href="a04223.html#a587">size</a>);
01251         <a class="code" href="a03256.html#NL3D_1_1CPSZoneCylinderp4">_Dim</a>.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_2">resize</a>(<a class="code" href="a04223.html#a587">size</a>);
01252 }
01253 
<a name="l01254"></a><a class="code" href="a03256.html#NL3D_1_1CPSZoneCylinderb4">01254</a> <span class="keywordtype">void</span> CPSZoneCylinder::newElement(<a class="code" href="a03214.html">CPSLocated</a> *emitterLocated, <a class="code" href="a04558.html#a11">uint32</a> emitterIndex)
01255 {
01256         _Basis.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_1">insert</a>(<a class="code" href="a03083.html">CPlaneBasis</a>(CVector::K));
01257         <a class="code" href="a03256.html#NL3D_1_1CPSZoneCylinderp4">_Dim</a>.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_1">insert</a>(<a class="code" href="a03128.html">CVector</a>(1, 1, 1));
01258 }
01259 
<a name="l01260"></a><a class="code" href="a03256.html#NL3D_1_1CPSZoneCylinderb2">01260</a> <span class="keywordtype">void</span> CPSZoneCylinder::deleteElement(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)
01261 {
01262         _Basis.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_2">remove</a>(<a class="code" href="a04223.html#a566">index</a>);
01263         <a class="code" href="a03256.html#NL3D_1_1CPSZoneCylinderp4">_Dim</a>.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_2">remove</a>(<a class="code" href="a04223.html#a566">index</a>);
01264 }
01265 
01266 
01268 <span class="comment">//      implementation of CPSZoneRectangle      //</span>
01270 <span class="comment"></span>
01271 
01272 
01273 
01274 
<a name="l01275"></a><a class="code" href="a03259.html#NL3D_1_1CPSZoneRectanglea44">01275</a> <span class="keywordtype">void</span> CPSZoneRectangle::performMotion(<a class="code" href="a05363.html#a366">TAnimationTime</a> ellapsedTime)
01276 {
01277         <a class="code" href="a04726.html#a0">MINI_TIMER</a>(<a class="code" href="a05363.html#a203">PSStatsZoneRectangle</a>)
01278         <span class="comment">// for each target, we must check wether they are going through the rectangle</span>
01279         <span class="comment">// if so they must bounce</span>
01280         TPSAttribVector::const_iterator rectanglePosIt, rectanglePosEnd, targetPosIt, targetPosEnd;
01281         <a class="code" href="a03135.html">CPSAttrib&lt;CPlaneBasis&gt;</a>::const_iterator basisIt;
01282         TPSAttribFloat::const_iterator widthIt, heightIt;
01283 
01284         <a class="code" href="a03128.html">CVector</a> dest;
01285         <a class="code" href="a03151.html">CPSCollisionInfo</a> ci;
01286         <a class="code" href="a03128.html">CVector</a> startEnd;
01287         <a class="code" href="a04558.html#a11">uint32</a> k;
01288         <span class="keyword">const</span> <a class="code" href="a03135.html">TPSAttribVector</a> *speedAttr;
01289         <span class="keywordtype">float</span> posSide, negSide;
01290         
01291         <span class="comment">// alpha is the ratio that gives the percent of endPos - startPos that hit the rectangle</span>
01292         <span class="keywordtype">float</span> <a class="code" href="a04223.html#a663">alpha</a>; 
01293 
01294         <a class="code" href="a03128.html">CVector</a> center;
01295 
01296         <span class="keywordflow">for</span> (TTargetCont::iterator it = _Targets.begin(); it != _Targets.end(); ++it)
01297         {
01298 
01299                 basisIt = _Basis.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>();
01300                 heightIt = _Height.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>();
01301                 widthIt = _Width.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>();
01302 
01303                 speedAttr = &amp;((*it)-&gt;getSpeed());
01304                 <span class="comment">// cycle through the rectangle</span>
01305 
01306                 rectanglePosEnd = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_3">end</a>();
01307                 <span class="keywordflow">for</span> (rectanglePosIt = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>().<a class="code" href="a03135.html#NL3D_1_1CPSAttribz708_1">begin</a>(); rectanglePosIt != rectanglePosEnd
01308                                 ; ++rectanglePosIt, ++basisIt, ++widthIt, ++heightIt)
01309                 {
01310                         
01311                         <span class="comment">// we must setup the rectangle in the good basis</span>
01312 
01313                         <span class="keyword">const</span> <a class="code" href="a02851.html">CMatrix</a> &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);
01314 
01315                         
01316 
01317                         <a class="code" href="a03082.html">NLMISC::CPlane</a> p;
01318                         center = m * (*rectanglePosIt);
01319 
01320                         <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> X = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1968_1">mulVector</a>(basisIt-&gt;X);
01321                         <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> Y = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1968_1">mulVector</a>(basisIt-&gt;Y);
01322 
01323                         p.<a class="code" href="a03082.html#NLMISC_1_1CPlanez1990_2">make</a>(X ^ Y, center);          
01324                         
01325                         <span class="comment">// deals with each particle</span>
01326 
01327                         <span class="keyword">const</span> <span class="keywordtype">float</span> epsilon = 0.5f * <a class="code" href="a05363.html#a273">PSCollideEpsilon</a>;
01328 
01329                         targetPosEnd = (*it)-&gt;getPos().end();
01330                         TPSAttribCollisionInfo::const_iterator ciIt = (*it)-&gt;getCollisionInfo().begin();
01331                         <span class="keywordflow">for</span> (targetPosIt = (*it)-&gt;getPos().begin(), k = 0; targetPosIt != targetPosEnd; ++targetPosIt, ++k, ++ciIt)
01332                         {       
01333                                 <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> &amp;pos = *targetPosIt;
01334                                 <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> &amp;speed = (*speedAttr)[k];
01335                                 <span class="comment">// check whether the located is going through the rectangle</span>
01336                                 dest = pos + ellapsedTime *  speed * ciIt-&gt;TimeSliceRatio;
01337 
01338 
01339                                 posSide = p * pos;
01340                                 negSide = p * dest;
01341                                                                 
01342                                 <span class="keywordflow">if</span> (posSide &gt;= - epsilon &amp;&amp; negSide &lt;= epsilon)
01343                                 {                                                                       
01344                                                 <span class="keywordflow">if</span> (fabsf(posSide - negSide) &gt; <a class="code" href="a04061.html#a0">std::numeric_limits&lt;float&gt;::min</a>())
01345                                                 {
01346                                                         <a class="code" href="a04223.html#a663">alpha</a> = posSide / (posSide - negSide);
01347                                                 }
01348                                                 <span class="keywordflow">else</span>
01349                                                 {
01350                                                         <a class="code" href="a04223.html#a663">alpha</a> = 0.f;
01351                                                 }
01352                                                 startEnd = <a class="code" href="a04223.html#a663">alpha</a> * (dest - pos);                                        
01353                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo1">dist</a> = startEnd.<a class="code" href="a03128.html#NLMISC_1_1CVectorz2049_0">norm</a>();
01354                                                 <span class="comment">// we translate the particle from an epsilon so that it won't get hooked to the rectangle</span>
01355                                                 ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo2">newPos</a> = pos + startEnd;                             
01356                                         
01357 
01358                                                 
01359 
01360                                                 <span class="keywordflow">if</span> ( fabs( (pos - center) * X ) &lt; *widthIt &amp;&amp; fabs( (pos - center) * Y ) &lt; *heightIt) <span class="comment">// check collision against rectangle</span>
01361                                                 {
01362                                                         ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo2">newPos</a> += <a class="code" href="a05363.html#a273">PSCollideEpsilon</a> * p.<a class="code" href="a03082.html#NLMISC_1_1CPlanez1990_0">getNormal</a>();
01363                                                         ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo3">newSpeed</a> = _BounceFactor * (speed - 2.0f * (speed * p.<a class="code" href="a03082.html#NLMISC_1_1CPlanez1990_0">getNormal</a>()) * p.<a class="code" href="a03082.html#NLMISC_1_1CPlanez1990_0">getNormal</a>());                                         
01364                                                         ci.<a class="code" href="a03151.html#NL3D_1_1CPSCollisionInfoo0">collisionZone</a> = <span class="keyword">this</span>;                                                
01365                                                         (*it)-&gt;collisionUpdate(ci, k);
01366                                                 }
01367                                         
01368                                 }
01369                         }       
01370                 }
01371         }
01372 }
01373 
01374 
<a name="l01375"></a><a class="code" href="a03259.html#NL3D_1_1CPSZoneRectanglea61">01375</a> <span class="keywordtype">void</span> CPSZoneRectangle::show(<a class="code" href="a05363.html#a366">TAnimationTime</a> ellapsedTime)
01376 {
01377         <a class="code" href="a04199.html#a6">nlassert</a>(_Owner);
01378         <span class="keyword">const</span> <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a587">size</a> = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda44">getSize</a>();
01379         <span class="keywordflow">if</span> (!<a class="code" href="a04223.html#a587">size</a>) <span class="keywordflow">return</span>;
01380         <a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea59">setupDriverModelMatrix</a>();       
01381         <a class="code" href="a02851.html">CMatrix</a> mat;
01382         
01383         <a class="code" href="a03214.html">CPSLocated</a> *loc;
01384         <a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>;
01385         <a class="code" href="a02691.html">CPSLocatedBindable</a> *lb;
01386         _Owner-&gt;<a class="code" href="a03054.html#NL3D_1_1CPSLocateda39">getOwner</a>()-&gt;<a class="code" href="a03041.html#NL3D_1_1CParticleSystemz588_0">getCurrentEditedElement</a>(loc, <a class="code" href="a04223.html#a566">index</a>, lb);
01387 
01388         <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> k = 0; k &lt; <a class="code" href="a04223.html#a587">size</a>; ++k) 
01389         {       
01390                 <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> &amp;I = _Basis[k].X;
01391                 <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> &amp;J = _Basis[k].Y;
01392                 mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_10">setRot</a>(I, J , I ^J);
01393                 mat.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_4">setPos</a>(_Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>()[k]);
01394                 CPSUtil::displayBasis(<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea14">getDriver</a>(), <a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea22">getLocalToWorldMatrix</a>(), mat, 1.f, *<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea17">getFontGenerator</a>(), *<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea19">getFontManager</a>());                          
01395                 <a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea59">setupDriverModelMatrix</a>();       
01396 
01397                 <span class="keyword">const</span> <a class="code" href="a03337.html">CRGBA</a> col = ((lb == NULL || <span class="keyword">this</span> == lb) &amp;&amp; loc == _Owner &amp;&amp; <a class="code" href="a04223.html#a566">index</a> == k  ? CRGBA::Red : <a class="code" href="a03337.html">CRGBA</a>(127, 127, 127));
01398         
01399 
01400 
01401                 <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> &amp;pos = _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>()[k];
01402                 CPSUtil::display3DQuad(*<a class="code" href="a02691.html#NL3D_1_1CPSZoneSpherea14">getDriver</a>(), pos + I * _Width[k] + J * _Height[k]
01403                                                                                    , pos + I * _Width[k] - J * _Height[k]
01404                                                                                    , pos - I * _Width[k] - J * _Height[k]
01405                                                                                    , pos - I * _Width[k] + J * _Height[k], col);
01406         }
01407 }
01408         
<a name="l01409"></a><a class="code" href="a03259.html#NL3D_1_1CPSZoneRectanglea54">01409</a> <span class="keywordtype">void</span> CPSZoneRectangle::setMatrix(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>, <span class="keyword">const</span> <a class="code" href="a02851.html">CMatrix</a> &amp;m)
01410 {
01411         <a class="code" href="a04199.html#a6">nlassert</a>(_Owner);
01412 
01413         _Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>()[<a class="code" href="a04223.html#a566">index</a>] = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_6">getPos</a>();
01414         _Basis[<a class="code" href="a04223.html#a566">index</a>].X = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_2">getI</a>();
01415         _Basis[<a class="code" href="a04223.html#a566">index</a>].Y = m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1963_3">getJ</a>();
01416 }
01417 
01418 
<a name="l01419"></a><a class="code" href="a03259.html#NL3D_1_1CPSZoneRectanglea24">01419</a> <a class="code" href="a02851.html">CMatrix</a> CPSZoneRectangle::getMatrix(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)<span class="keyword"> const</span>
01420 <span class="keyword"></span>{
01421         <a class="code" href="a04199.html#a6">nlassert</a>(_Owner);
01422         <a class="code" href="a02851.html">CMatrix</a> m;      
01423         m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_10">setRot</a>(_Basis[<a class="code" href="a04223.html#a566">index</a>].X, _Basis[<a class="code" href="a04223.html#a566">index</a>].Y, _Basis[<a class="code" href="a04223.html#a566">index</a>].X ^ _Basis[<a class="code" href="a04223.html#a566">index</a>].Y);
01424         m.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_4">setPos</a>(_Owner-&gt;<a class="code" href="a03214.html#NL3D_1_1CPSLocateda42">getPos</a>()[<a class="code" href="a04223.html#a566">index</a>]);
01425         <span class="keywordflow">return</span> m;
01426 }
01427 
<a name="l01428"></a><a class="code" href="a03259.html#NL3D_1_1CPSZoneRectanglea58">01428</a> <span class="keywordtype">void</span> CPSZoneRectangle::setScale(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>, <span class="keywordtype">float</span> scale)
01429 {
01430         _Width[<a class="code" href="a04223.html#a566">index</a>] = scale;
01431         _Height[<a class="code" href="a04223.html#a566">index</a>] = scale;
01432 }
<a name="l01433"></a><a class="code" href="a03259.html#NL3D_1_1CPSZoneRectanglea57">01433</a> <span class="keywordtype">void</span> CPSZoneRectangle::setScale(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>, <span class="keyword">const</span> <a class="code" href="a03128.html">CVector</a> &amp;<a class="code" href="a04223.html#a626">s</a>)
01434 {
01435         _Width[<a class="code" href="a04223.html#a566">index</a>] = <a class="code" href="a04223.html#a626">s</a>.x;
01436         _Height[<a class="code" href="a04223.html#a566">index</a>] = <a class="code" href="a04223.html#a626">s</a>.y;
01437 }
<a name="l01438"></a><a class="code" href="a03259.html#NL3D_1_1CPSZoneRectanglea31">01438</a> <a class="code" href="a03128.html">CVector</a> CPSZoneRectangle::getScale(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)<span class="keyword"> const</span>
01439 <span class="keyword"></span>{
01440         <span class="keywordflow">return</span> <a class="code" href="a03128.html">CVector</a>(_Width[<a class="code" href="a04223.html#a566">index</a>], _Height[<a class="code" href="a04223.html#a566">index</a>], 1.f);
01441 }
01442 
01443 
01444 
<a name="l01445"></a><a class="code" href="a03259.html#NL3D_1_1CPSZoneRectanglea48">01445</a> <span class="keywordtype">void</span> CPSZoneRectangle::serial(<a class="code" href="a02270.html">NLMISC::IStream</a> &amp;f) <span class="keywordflow">throw</span>(<a class="code" href="a03781.html">NLMISC::EStream</a>)
01446 {
01447         f.serialVersion(1);
01448         CPSZone::serial(f);
01449         f.serial(_Basis);       
01450         f.serial(_Width);
01451         f.serial(_Height);
01452 }
01453 
01454 
<a name="l01455"></a><a class="code" href="a03259.html#NL3D_1_1CPSZoneRectangleb6">01455</a> <span class="keywordtype">void</span> CPSZoneRectangle::resize(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a587">size</a>)
01456 {
01457         <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a587">size</a> &lt; (1 &lt;&lt; 16));
01458         _Basis.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_2">resize</a>(<a class="code" href="a04223.html#a587">size</a>);
01459         _Width.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_2">resize</a>(<a class="code" href="a04223.html#a587">size</a>);
01460         _Height.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz704_2">resize</a>(<a class="code" href="a04223.html#a587">size</a>);
01461 }
01462 
<a name="l01463"></a><a class="code" href="a03259.html#NL3D_1_1CPSZoneRectangleb4">01463</a> <span class="keywordtype">void</span> CPSZoneRectangle::newElement(<a class="code" href="a03214.html">CPSLocated</a> *emitterLocated, <a class="code" href="a04558.html#a11">uint32</a> emitterIndex)
01464 {
01465         _Basis.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_1">insert</a>(<a class="code" href="a03083.html">CPlaneBasis</a>(CVector::K));
01466         _Width.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_1">insert</a>(1.f);
01467         _Height.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_1">insert</a>(1.f);
01468 }
01469 
<a name="l01470"></a><a class="code" href="a03259.html#NL3D_1_1CPSZoneRectangleb2">01470</a> <span class="keywordtype">void</span> CPSZoneRectangle::deleteElement(<a class="code" href="a04558.html#a11">uint32</a> <a class="code" href="a04223.html#a566">index</a>)
01471 {
01472         _Basis.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_2">remove</a>(<a class="code" href="a04223.html#a566">index</a>);
01473         _Width.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_2">remove</a>(<a class="code" href="a04223.html#a566">index</a>);
01474         _Height.<a class="code" href="a03135.html#NL3D_1_1CPSAttribz710_2">remove</a>(<a class="code" href="a04223.html#a566">index</a>);
01475 }
01476 
01477 
01478 
01479 } <span class="comment">// NL3D</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 06:35:02 2004 for NeL by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
</a>1.3.6 </small></address>
</body>
</html>