aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/ps__zone_8cpp-source.html
blob: e5ed09e5afb2ae30a1688b4b848c4b1d83baa6c3 (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
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
	<TITLE>nevrax.org : docs</TITLE>
	<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
	<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">

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

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

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

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

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

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

<!-- block -->
<TABLE  bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0  BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
	<TD><B>Documentation</B></TD>
	<TD ALIGN=RIGHT>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
<hr><h1>ps_zone.cpp</h1><a href="ps__zone_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 
00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00013 <font class="comment"> * any later version.</font>
00014 <font class="comment"></font>
00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"></font>
00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00023 <font class="comment"> * MA 02111-1307, USA.</font>
00024 <font class="comment"> */</font>
00025 
00026 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font>
00027 
00028 <font class="preprocessor">#include "<a class="code" href="ps__zone_8h.html">3d/ps_zone.h</a>"</font>
00029 <font class="preprocessor">#include "<a class="code" href="vertex__buffer_8h.html">3d/vertex_buffer.h</a>"</font>
00030 <font class="preprocessor">#include "<a class="code" href="3d_2primitive__block_8h.html">3d/primitive_block.h</a>"</font>
00031 <font class="preprocessor">#include "<a class="code" href="material_8h.html">3d/material.h</a>"</font>
00032 <font class="preprocessor">#include "<a class="code" href="ps__util_8h.html">3d/ps_util.h</a>"</font>
00033 <font class="preprocessor">#include "<a class="code" href="dru_8h.html">3d/dru.h</a>"</font>
00034 <font class="preprocessor">#include "<a class="code" href="particle__system_8h.html">3d/particle_system.h</a>"</font>
00035 <font class="preprocessor">#include "<a class="code" href="plane_8h.html">nel/misc/plane.h</a>"</font>
00036 
00037 <font class="preprocessor">#include &lt;math.h&gt;</font>
00038 <font class="preprocessor">#include &lt;limits&gt;</font>
00039 
00040 <font class="keyword">namespace </font>NL3D {
00041 
00042 
00043 <font class="comment">/*</font>
00044 <font class="comment"> * Constructor</font>
00045 <font class="comment"> */</font>
<a name="l00046"></a><a class="code" href="classNL3D_1_1CPSZone.html#a0">00046</a> CPSZone::CPSZone() : _BounceFactor(1.f), _CollisionBehaviour(bounce)
00047 {
00048 }
00049 
<a name="l00050"></a><a class="code" href="classNL3D_1_1CPSZone.html#a7">00050</a> <font class="keywordtype">void</font> CPSZone::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00051 { 
00052         f.serialVersion(1);
00053         CPSTargetLocatedBindable::serial(f); 
00054         f.serialEnum(_CollisionBehaviour);
00055         f.serial(_BounceFactor);
00056         <font class="keywordflow">if</font> (f.isReading())
00057         {               
00058                 <font class="keywordflow">for</font> (TTargetCont::iterator it = _Targets.begin(); it != _Targets.end(); ++it)
00059                 {
00060                         <font class="comment">// though this is not a force, this prevent parametric motion</font>
00061                         (*it)-&gt;addNonIntegrableForceRef();
00062                 }       
00063         }
00064 }
00065 
<a name="l00069"></a><a class="code" href="classNL3D_1_1CPSZone.html#a6">00069</a> <font class="keywordtype">void</font> CPSZone::attachTarget(CPSLocated *ptr)
00070 {
00071                 
00072         CPSTargetLocatedBindable::attachTarget(ptr);
00073         ptr-&gt;queryCollisionInfo();
00074         ptr-&gt;addNonIntegrableForceRef();
00075 }
00076 
00077 
00078 
00079 
00080 
<a name="l00082"></a><a class="code" href="classNL3D_1_1CPSZone.html#a8">00082</a> <font class="keywordtype">void</font> CPSZone::releaseTargetRsc(CPSLocated *target)
00083 {
00084         <font class="comment">// tell the target that we were using collision infos and that we won't use them anymore</font>
00085         target-&gt;releaseCollisionInfo();
00086         target-&gt;releaseNonIntegrableForceRef();
00087 }
00088 
00089 
00090 
<a name="l00091"></a><a class="code" href="classNL3D_1_1CPSZone.html#a3">00091</a> <font class="keywordtype">void</font> CPSZone::step(<a class="code" href="namespaceNL3D.html#a484">TPSProcessPass</a> pass, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime, <a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> realEt)
00092 {
00093         <font class="comment">// for zone, the PSCollision pass and the PSToolRenderPass are processed</font>
00094         <font class="keywordflow">switch</font>(pass)
00095         {
00096                 <font class="keywordflow">case</font> <a class="code" href="namespaceNL3D.html#a484a167">PSCollision</a>:
00097                         <a class="code" href="classNL3D_1_1CPSZone.html#a4">performMotion</a>(ellapsedTime);
00098                         <font class="keywordflow">break</font>;
00099                 <font class="keywordflow">case</font> <a class="code" href="namespaceNL3D.html#a484a171">PSToolRender</a>:
00100                         <a class="code" href="classNL3D_1_1CPSZone.html#a5">show</a>(ellapsedTime);
00101                         <font class="keywordflow">break</font>;
00102                 <font class="keywordflow">default</font>: <font class="keywordflow">break</font>;
00103         }
00104 }
00105 
00106 
00107 <font class="comment">// build a basis with K = the normal of the plane</font>
<a name="l00108"></a><a class="code" href="classNL3D_1_1CPSZonePlane.html#b0">00108</a> CMatrix CPSZonePlane::buildBasis(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font>
00109 <font class="keyword"></font>{
00110         CMatrix m;
00111         m.setPos(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>]);      
00112         CPSUtil::buildSchmidtBasis(<a class="code" href="classNL3D_1_1CPSZonePlane.html#n0">_Normal</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], m);
00113         <font class="keywordflow">return</font> m;
00114 }
00115 
00116 
00119 <font class="comment">/*void CPSZone::bounce(uint32 locatedIndex, const CVector &amp;bouncePoint, const CVector &amp;surfNormal, float elasticity, TAnimationTime ellapsedTime)</font>
00120 <font class="comment">{</font>
00121 <font class="comment">        CVector &amp;speed = _Owner-&gt;getSpeed()[locatedIndex];</font>
00122 <font class="comment">        const CVector &amp;pos   = _Owner-&gt;getPos()[locatedIndex];</font>
00123 <font class="comment">        CVector &amp;bounceVect = elasticity  * (speed - 2.0f * (speed * surfNormal) * surfNormal); // speed vector after collision</font>
00124 <font class="comment">        // now check where the located will be after integration</font>
00125 <font class="comment">        CVector d = bouncePoint - pos;</font>
00126 <font class="comment">        TAnimationTime collideDelay = speed.norm() / d.norm();</font>
00127 <font class="comment">        CVector finalPos = bouncePoint + (ellapsedTime - collideDelay) * bounceVect;</font>
00128 <font class="comment">        // now, we must have pos + ellapsedTime * newSpeed = finalPos </font>
00129 <font class="comment">        // newSpeed = alpha * (finalPos - pos)</font>
00130 <font class="comment">        // so alpha = 1 / ellapsedTime</font>
00131 <font class="comment"></font>
00132 <font class="comment">        speed = (1.0f / ellapsedTime) * (finalPos - pos);       </font>
00133 <font class="comment">}*/</font>
00134 
00135 
<a name="l00136"></a><a class="code" href="classNL3D_1_1CPSZonePlane.html#a1">00136</a> <font class="keywordtype">void</font> CPSZonePlane::show(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a>)
00137 {
00138         <font class="keyword">const</font> <font class="keywordtype">float</font> planeSize = 2.0f;
00139         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();
00140 
00141         IDriver *driver = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>();
00142         uint k  = 0;
00143 
00144         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();
00145 
00146         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#l0">CPSLocated</a> *loc;
00147         uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>;
00148         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#z720_0">CPSLocatedBindable</a> *lb;
00149         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getOwner()-&gt;getCurrentEditedElement(loc, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, lb);
00150         
00151 
00152 
00153                 
00154 
00155         <font class="keywordflow">for</font> (TPSAttribVector::const_iterator it = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().begin(); it != <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().end(); ++it, ++k)
00156         {       
00157                 <font class="keyword">const</font> CRGBA col = ((lb == NULL || <font class="keyword">this</font> == lb) &amp;&amp; loc == <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> &amp;&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> == k  ? CRGBA::Red : CRGBA(127, 127, 127));
00158                 CMatrix mat = <a class="code" href="classNL3D_1_1CPSZonePlane.html#b0">buildBasis</a>(k);
00159 
00160                 CPSUtil::displayBasis(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>(), <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a17">getLocatedMat</a>(), mat, 1.f, *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a11">getFontGenerator</a>(), *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a13">getFontManager</a>());
00161 
00162 
00163                 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();
00164         
00165                 CDRU::drawLine(*it + (planeSize  + 3) * mat.getI() + planeSize * mat.getJ() 
00166                                                 , *it - (planeSize + 3) * mat.getI() + planeSize * mat.getJ()
00167                                                 , col
00168                                                 , *driver);
00169 
00170                 CDRU::drawLine(*it + (planeSize  + 3) * mat.getI() - planeSize * mat.getJ() 
00171                                                 , *it - (planeSize + 3) * mat.getI() - planeSize * mat.getJ()
00172                                                 , col
00173                                                 , *driver);
00174 
00175                 CDRU::drawLine(*it + planeSize  * mat.getI() + (planeSize + 3) * mat.getJ() 
00176                                                 , *it + planeSize * mat.getI() - (planeSize + 3) * mat.getJ()
00177                                                 , col
00178                                                 , *driver);
00179                 CDRU::drawLine(*it - planeSize  * mat.getI() + (planeSize + 3) * mat.getJ() 
00180                                                 , *it - planeSize * mat.getI() - (planeSize + 3) * mat.getJ()
00181                                                 , col
00182                                                 , *driver);
00183         }
00184         
00185 
00186 }
00187 
00188 
00189 
<a name="l00190"></a><a class="code" href="classNL3D_1_1CPSZonePlane.html#b1">00190</a> <font class="keywordtype">void</font> CPSZonePlane::resize(uint32 size)
00191 {
00192         <a class="code" href="debug_8h.html#a6">nlassert</a>(size &lt; (1 &lt;&lt; 16));
00193         <a class="code" href="classNL3D_1_1CPSZonePlane.html#n0">_Normal</a>.resize(size);
00194 }
00195 
00196 
<a name="l00197"></a><a class="code" href="classNL3D_1_1CPSZonePlane.html#b2">00197</a> <font class="keywordtype">void</font> CPSZonePlane::newElement(CPSLocated *emitterLocated, uint32 emitterIndex)
00198 {
00199         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSZonePlane.html#n0">_Normal</a>.getSize() != <a class="code" href="classNL3D_1_1CPSZonePlane.html#n0">_Normal</a>.getMaxSize());
00200         <a class="code" href="classNL3D_1_1CPSZonePlane.html#n0">_Normal</a>.insert(CVector(0, 0, 1));
00201 }
00202 
00203 
<a name="l00204"></a><a class="code" href="classNL3D_1_1CPSZonePlane.html#b3">00204</a> <font class="keywordtype">void</font> CPSZonePlane::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00205 {
00206         <a class="code" href="classNL3D_1_1CPSZonePlane.html#n0">_Normal</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00207 }
00208 
00209 
00210 
<a name="l00211"></a><a class="code" href="classNL3D_1_1CPSZonePlane.html#a0">00211</a> <font class="keywordtype">void</font> CPSZonePlane::performMotion(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00212 {
00213         <font class="comment">// for each target, we must check wether they are going through the plane</font>
00214         <font class="comment">// if so they must bounce</font>
00215         TPSAttribVector::const_iterator planePosIt, planePosEnd, normalIt, targetPosIt, targetPosEnd;
00216         CVector dest;
00217         CPSCollisionInfo ci;
00218         CVector startEnd;
00219         uint32 k;
00220         <font class="keyword">const</font> <a class="code" href="namespaceNL3D.html#a180">TPSAttribVector</a> *speedAttr;
00221         <font class="keywordtype">float</font> posSide, negSide;
00222 
00223         <font class="comment">// alpha is the ratio that gives the percent of endPos - startPos that hit the plane</font>
00224         <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>; 
00225 
00226         <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00227         {
00228 
00229                 speedAttr = &amp;((*it)-&gt;getSpeed());
00230                 <font class="comment">// cycle through the planes</font>
00231 
00232                 planePosEnd = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().end();           
00233                 <font class="keywordflow">for</font> (planePosIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().begin(), normalIt = <a class="code" href="classNL3D_1_1CPSZonePlane.html#n0">_Normal</a>.begin(); planePosIt != planePosEnd
00234                                 ; ++planePosIt, ++normalIt)
00235                 {
00236                         
00237                         <font class="comment">// we must setup the plane in the good basis</font>
00238 
00239                         <font class="keyword">const</font> CMatrix &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);
00240                         <font class="keyword">const</font> <font class="keywordtype">float</font> epsilon = 0.5f * <a class="code" href="namespaceNL3D.html#a221">PSCollideEpsilon</a>;
00241                         
00242 
00243                         <a class="code" href="classNLMISC_1_1CPlane.html">NLMISC::CPlane</a> p;
00244                         p.<a class="code" href="classNLMISC_1_1CPlane.html#z305_0">make</a>(m.mulVector(*normalIt), m * (*planePosIt));              
00245                         
00246                         <font class="comment">// deals with each particle</font>
00247                         
00248                         targetPosEnd = (*it)-&gt;getPos().end();
00249                         TPSAttribCollisionInfo::const_iterator ciIt = (*it)-&gt;getCollisionInfo().begin();
00250                         <font class="keywordflow">for</font> (targetPosIt = (*it)-&gt;getPos().begin(), k = 0; targetPosIt != targetPosEnd; ++targetPosIt, ++k, ++ciIt)
00251                         {       
00252                                 <font class="keyword">const</font> CVector &amp;speed = (*speedAttr)[k];
00253                                 <font class="comment">// check whether the located is going through the plane</font>
00254                                 dest = *targetPosIt + ellapsedTime *  speed * ciIt-&gt;TimeSliceRatio;
00255 
00256 
00257                                 posSide = p * *targetPosIt;
00258                                 negSide = p * dest;
00259                                                                                                 
00260                                 <font class="keywordflow">if</font> (posSide &gt;= - epsilon &amp;&amp; negSide &lt;= epsilon)
00261                                 {
00262                                         <font class="keywordflow">if</font> (fabsf(posSide - negSide) &gt; <a class="code" href="bit__set_8cpp.html#a0">std::numeric_limits&lt;float&gt;::min</a>())
00263                                         {
00264                                                 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a> = posSide / (posSide - negSide);
00265                                         }
00266                                         <font class="keywordflow">else</font>
00267                                         {
00268                                                 <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a> = 0.f;
00269                                         }
00270                                         startEnd = <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a> * (dest - *targetPosIt);                                       
00271                                         ci.dist = startEnd.norm();
00272                                         <font class="comment">// we translate the particle from an epsilon so that it won't get hooked to the plane</font>
00273                                         ci.newPos = *targetPosIt  + startEnd + <a class="code" href="namespaceNL3D.html#a221">PSCollideEpsilon</a> * p.<a class="code" href="classNLMISC_1_1CPlane.html#z305_2">getNormal</a>();                                
00274                                         ci.newSpeed = <a class="code" href="classNL3D_1_1CPSZone.html#n0">_BounceFactor</a> * (speed - 2.0f * (speed * p.<a class="code" href="classNLMISC_1_1CPlane.html#z305_2">getNormal</a>()) * p.<a class="code" href="classNLMISC_1_1CPlane.html#z305_2">getNormal</a>());
00275                                         ci.collisionZone = <font class="keyword">this</font>;                                                
00276                                         (*it)-&gt;collisionUpdate(ci, k);                                                                          
00277                                 }
00278                         }
00279                 }
00280         }
00281 }
00282 
<a name="l00283"></a><a class="code" href="classNL3D_1_1CPSZonePlane.html#a3">00283</a> <font class="keywordtype">void</font> CPSZonePlane::setMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">const</font> CMatrix &amp;m)
00284 {
00285         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> &lt; <a class="code" href="classNL3D_1_1CPSZonePlane.html#n0">_Normal</a>.getSize());
00286         <a class="code" href="classNL3D_1_1CPSZonePlane.html#n0">_Normal</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = m.getK();
00287         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = m.getPos();   
00288 }
00289 
<a name="l00290"></a><a class="code" href="classNL3D_1_1CPSZonePlane.html#a4">00290</a> CMatrix CPSZonePlane::getMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font>
00291 <font class="keyword"></font>{
00292         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSZonePlane.html#b0">buildBasis</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00293 }
00294 
00295 
<a name="l00296"></a><a class="code" href="classNL3D_1_1CPSZonePlane.html#a6">00296</a> CVector CPSZonePlane::getNormal(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00297 {
00298         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSZonePlane.html#n0">_Normal</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>];
00299 }
<a name="l00300"></a><a class="code" href="classNL3D_1_1CPSZonePlane.html#a7">00300</a> <font class="keywordtype">void</font> CPSZonePlane::setNormal(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, CVector n)
00301 {
00302         <a class="code" href="classNL3D_1_1CPSZonePlane.html#n0">_Normal</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = n;
00303 }
00304 
00305 
00306 
00307 
<a name="l00308"></a><a class="code" href="classNL3D_1_1CPSZonePlane.html#a8">00308</a> <font class="keywordtype">void</font> CPSZonePlane::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00309 {
00310         f.serialVersion(1);             
00311         CPSZone::serial(f);     
00312         f.serial(_Normal);      
00313 }
00314 
00315 
00316 
00318 <font class="comment">// sphere implementation //</font>
00320 <font class="comment"></font>
00321 
00322 
00323 
<a name="l00324"></a><a class="code" href="classNL3D_1_1CPSZoneSphere.html#a0">00324</a> <font class="keywordtype">void</font> CPSZoneSphere::performMotion(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00325 {
00326         <font class="comment">// for each target, we must check wether they are going through the plane</font>
00327         <font class="comment">// if so they must bounce</font>
00328 
00329         TPSAttribRadiusPair::const_iterator radiusIt = <a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>.begin();
00330         TPSAttribVector::const_iterator spherePosIt, spherePosEnd, targetPosIt, targetPosEnd;
00331         CVector dest;
00332         CPSCollisionInfo ci;
00333         uint32 k;
00334         <font class="keyword">const</font> <a class="code" href="namespaceNL3D.html#a180">TPSAttribVector</a> *speedAttr;
00335 
00336 
00337         <font class="keywordtype">float</font> rOut, rIn;
00338 
00339 
00340         <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00341         {
00342 
00343                 speedAttr = &amp;((*it)-&gt;getSpeed());
00344 
00345 
00346                 <font class="comment">// cycle through the spheres</font>
00347                         
00348                 spherePosEnd = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().end();
00349                 <font class="keywordflow">for</font> (spherePosIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().begin(), radiusIt = <a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>.begin(); spherePosIt != spherePosEnd
00350                                 ; ++spherePosIt, ++radiusIt)
00351                 {
00352                         
00353                         <font class="comment">// we must setup the sphere in the good basis</font>
00354 
00355                         <font class="keyword">const</font> CMatrix &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);
00356 
00357                         
00358 
00359                         CVector center = m * *spherePosIt;
00360                                                 
00361                         <font class="comment">// deals with each particle</font>
00362 
00363 
00364                         targetPosEnd = (*it)-&gt;getPos().end();
00365                         TPSAttribCollisionInfo::const_iterator ciIt = (*it)-&gt;getCollisionInfo().begin();
00366                         <font class="keywordflow">for</font> (targetPosIt = (*it)-&gt;getPos().begin(), k = 0; targetPosIt != targetPosEnd; ++targetPosIt, ++k, ++ciIt)
00367                         {       
00368                                 <font class="keyword">const</font> CVector &amp;speed = (*speedAttr)[k];
00369                                 <font class="keyword">const</font> CVector &amp;pos = *targetPosIt;
00370                                 <font class="comment">// check whether the located is going through the sphere</font>
00371 
00372                                 <font class="comment">// we don't use raytracing for now because it is too slow ...</font>
00373                                         
00374 
00375                                 rOut = (pos - center) * (pos - center);
00376 
00377                                 <font class="comment">// initial position outside the sphere ?</font>
00378                                 <font class="keywordflow">if</font> (rOut &gt; radiusIt-&gt;R2)
00379                                 {
00380                                         dest = pos + ellapsedTime *  speed * ciIt-&gt;TimeSliceRatio;
00381                                         rIn = (dest - center) * (dest - center);
00382 
00383                                         <font class="keyword">const</font> CVector D = dest - pos;
00384 
00385                                         <font class="comment">// final position inside the sphere ?</font>
00386 
00387                                         <font class="keywordflow">if</font> ( rIn &lt;= radiusIt-&gt;R2)
00388                                         {                               
00389                                                 <font class="comment">// discriminant of the intersection equation</font>
00390                                                 <font class="keyword">const</font> <font class="keywordtype">float</font> b = 2.f * (pos * D - D * center), a = D * D
00391                                                                         , c = (pos * pos) + (center * center) - 2.f * (pos * center) - radiusIt-&gt;R2;
00392                                                 <font class="keywordtype">float</font> d = b * b - 4 * a * c;
00393 
00394                                                 
00395                                                 <font class="keywordflow">if</font> (d &lt;= 0.f) <font class="keywordflow">continue</font>; <font class="comment">// should never happen, but we never know ...</font>
00396                                                 
00397 
00398                                                 d = sqrtf(d);
00399 
00400                                                 <font class="comment">// roots of the equation, we take the smallest </font>
00401 
00402 
00403                                                 <font class="keyword">const</font> <font class="keywordtype">float</font> r1 = .5f * (-b + 2.f * d) * a
00404                                                                         , r2 = .5f * (-b - 2.f * d) * a;
00405 
00406                                                 <font class="keyword">const</font> <font class="keywordtype">float</font>  <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a> = <a class="code" href="bit__set_8cpp.html#a0">std::min</a>(r1, r2);
00407 
00408                                                 <font class="comment">// collision point </font>
00409 
00410                                                 <font class="keyword">const</font> CVector C = pos  + <a class="code" href="driver__opengl__extension__def_8h.html#a385">r</a> * D;
00411 
00412 
00413 
00414 
00415                                 
00416                                     
00417                                                 <font class="keyword">const</font> <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a> = ((C - pos) * D) * a;
00418 
00419                                                 <font class="keyword">const</font> CVector startEnd = <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a> * (dest - pos);                                  
00420 
00421                                                 CVector normal = C - center;
00422                                                 normal = normal * (1.f / radiusIt-&gt;R);
00423 
00424                                         
00425                                                 ci.dist = startEnd.norm();
00426                                                 <font class="comment">// we translate the particle from an epsilon so that it won't get hooked to the sphere</font>
00427                                                 ci.newPos = pos  + startEnd + <a class="code" href="namespaceNL3D.html#a221">PSCollideEpsilon</a> * normal;                                
00428                                                 ci.newSpeed = <a class="code" href="classNL3D_1_1CPSZone.html#n0">_BounceFactor</a> * (speed - 2.0f * (speed * normal) * normal);
00429 
00430                                                 ci.collisionZone = <font class="keyword">this</font>;                                                
00431                                                 (*it)-&gt;collisionUpdate(ci, k);
00432                                                 
00433                                         }                                       
00434                                 }
00435                         }
00436                 }
00437         }
00438 }
00439 
00440 
00441 
<a name="l00442"></a><a class="code" href="classNL3D_1_1CPSZoneSphere.html#a1">00442</a> <font class="keywordtype">void</font> CPSZoneSphere::show(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00443 {
00444         
00445         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#l0">CPSLocated</a> *loc;
00446         uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>;
00447         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#z720_0">CPSLocatedBindable</a> *lb;
00448         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getOwner()-&gt;getCurrentEditedElement(loc, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, lb);
00449 
00450 
00451         TPSAttribRadiusPair::const_iterator radiusIt = <a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>.begin();
00452         TPSAttribVector::const_iterator posIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().begin(), endPosIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().end();
00453         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();       
00454         <font class="keywordflow">for</font> (uint k = 0; posIt != endPosIt; ++posIt, ++radiusIt, ++k) 
00455         {       
00456                 <font class="keyword">const</font> CRGBA col = ((lb == NULL || <font class="keyword">this</font> == lb) &amp;&amp; loc == <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> &amp;&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> == k  ? CRGBA::Red : CRGBA(127, 127, 127));             
00457                 CPSUtil::displaySphere(*<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>(), radiusIt-&gt;R, *posIt, 5, col);
00458         }
00459 }
00460         
<a name="l00461"></a><a class="code" href="classNL3D_1_1CPSZoneSphere.html#a6">00461</a> <font class="keywordtype">void</font> CPSZoneSphere::setMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">const</font> CMatrix &amp;m)
00462 {
00463         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> &lt; <a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>.getSize());
00464                 
00465         <font class="comment">// compute new pos</font>
00466         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = m.getPos();
00467         
00468 }
00469 
00470 
<a name="l00471"></a><a class="code" href="classNL3D_1_1CPSZoneSphere.html#a7">00471</a> CMatrix CPSZoneSphere::getMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font>
00472 <font class="keyword"></font>{
00473         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> &lt; <a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>.getSize());
00474         CMatrix m;
00475         m.identity();
00476         m.translate(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>]);   
00477         <font class="keywordflow">return</font> m; 
00478 }
00479 
<a name="l00480"></a><a class="code" href="classNL3D_1_1CPSZoneSphere.html#a8">00480</a> <font class="keywordtype">void</font> CPSZoneSphere::setScale(uint32 k, <font class="keywordtype">float</font> scale)
00481 {
00482         <a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>[k].R = scale;
00483         <a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>[k].R2 = scale * scale;
00484 }
<a name="l00485"></a><a class="code" href="classNL3D_1_1CPSZoneSphere.html#a9">00485</a> CVector CPSZoneSphere::getScale(uint32 k)<font class="keyword"> const</font>
00486 <font class="keyword"></font>{
00487         <font class="keywordflow">return</font> CVector(<a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>[k].R, <a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>[k].R, <a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>[k].R);
00488 }
00489 
00490 
<a name="l00491"></a><a class="code" href="classNL3D_1_1CPSZoneSphere.html#a4">00491</a> <font class="keywordtype">void</font> CPSZoneSphere::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00492 {
00493         f.serialVersion(1);
00494         CPSZone::serial(f);
00495         f.serial(_Radius);      
00496 }
00497 
00498 
00499                 
00500 
00501 
00502 
<a name="l00503"></a><a class="code" href="classNL3D_1_1CPSZoneSphere.html#b1">00503</a> <font class="keywordtype">void</font> CPSZoneSphere::resize(uint32 size)
00504 {
00505         <a class="code" href="debug_8h.html#a6">nlassert</a>(size &lt; (1 &lt;&lt; 16));
00506         <a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>.resize(size);
00507 }
00508 
<a name="l00509"></a><a class="code" href="classNL3D_1_1CPSZoneSphere.html#b2">00509</a> <font class="keywordtype">void</font> CPSZoneSphere::newElement(CPSLocated *emitterLocated, uint32 emitterIndex)
00510 {
00511         CRadiusPair rp;
00512         rp.R = rp.R2 = 1.f;
00513         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>.getSize() != <a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>.getMaxSize());
00514         <a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>.insert(rp);
00515 }
00516 
<a name="l00517"></a><a class="code" href="classNL3D_1_1CPSZoneSphere.html#b3">00517</a> <font class="keywordtype">void</font> CPSZoneSphere::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00518 {
00519         <a class="code" href="classNL3D_1_1CPSZoneSphere.html#n0">_Radius</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00520 }
00521 
00522 
00524 <font class="comment">// CPSZoneDisc implementation //</font>
00526 <font class="comment"></font>
<a name="l00527"></a><a class="code" href="classNL3D_1_1CPSZoneDisc.html#a0">00527</a> <font class="keywordtype">void</font> CPSZoneDisc::performMotion(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00528 {
00529         <font class="comment">// for each target, we must check wether they are going through the disc</font>
00530         <font class="comment">// if so they must bounce</font>
00531         TPSAttribVector::const_iterator discPosIt, discPosEnd, normalIt, targetPosIt, targetPosEnd;
00532         TPSAttribRadiusPair::const_iterator radiusIt;
00533         CVector dest;
00534         CPSCollisionInfo ci;
00535         CVector startEnd;
00536         uint32 k;
00537         <font class="keyword">const</font> <a class="code" href="namespaceNL3D.html#a180">TPSAttribVector</a> *speedAttr;
00538         <font class="keywordtype">float</font> posSide, negSide;
00539 
00540         <font class="comment">// the square of radius at the hit point</font>
00541         <font class="keywordtype">float</font> hitRadius2; 
00542 
00543         <font class="comment">// alpha is the ratio that gives the percent of endPos - startPos that hit the disc</font>
00544         <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>; 
00545 
00546         CVector center;
00547 
00548         <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00549         {
00550 
00551                 speedAttr = &amp;((*it)-&gt;getSpeed());
00552                 <font class="comment">// cycle through the disc</font>
00553 
00554                 discPosEnd = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().end();
00555                 <font class="keywordflow">for</font> (discPosIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().begin(), radiusIt = <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n1">_Radius</a>.begin(), normalIt = <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n0">_Normal</a>.begin(); discPosIt != discPosEnd
00556                                 ; ++discPosIt, ++normalIt, ++radiusIt)
00557                 {
00558                         
00559                         <font class="comment">// we must setup the disc in the good basis</font>
00560 
00561                         <font class="keyword">const</font> CMatrix &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);
00562 
00563                         
00564 
00565                         <a class="code" href="classNLMISC_1_1CPlane.html">NLMISC::CPlane</a> p;
00566                         center = m * (*discPosIt);
00567                         p.<a class="code" href="classNLMISC_1_1CPlane.html#z305_0">make</a>(m.mulVector(*normalIt), center);         
00568                         
00569                         <font class="comment">// deals with each particle</font>
00570 
00571                         <font class="keyword">const</font> <font class="keywordtype">float</font> epsilon = 0.5f * <a class="code" href="namespaceNL3D.html#a221">PSCollideEpsilon</a>;
00572 
00573                         targetPosEnd = (*it)-&gt;getPos().end();
00574                         TPSAttribCollisionInfo::const_iterator ciIt = (*it)-&gt;getCollisionInfo().begin();
00575                         <font class="keywordflow">for</font> (targetPosIt = (*it)-&gt;getPos().begin(), k = 0; targetPosIt != targetPosEnd; ++targetPosIt, ++k, ++ciIt)
00576                         {       
00577                                 <font class="keyword">const</font> CVector &amp;speed = (*speedAttr)[k];
00578                                 <font class="comment">// check whether the located is going through the disc</font>
00579                                 dest = *targetPosIt + ellapsedTime *  speed * ciIt-&gt;TimeSliceRatio;
00580 
00581 
00582                                 posSide = p * *targetPosIt;
00583                                 negSide = p * dest;
00584                                                                 
00585                                 <font class="keywordflow">if</font> (posSide &gt;= - epsilon &amp;&amp; negSide &lt;= epsilon)
00586                                 {                                                                       
00587                                                 <font class="keywordflow">if</font> (fabsf(posSide - negSide) &gt; <a class="code" href="bit__set_8cpp.html#a0">std::numeric_limits&lt;float&gt;::min</a>())
00588                                                 {
00589                                                         <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a> = posSide / (posSide - negSide);
00590                                                 }
00591                                                 <font class="keywordflow">else</font>
00592                                                 {
00593                                                         <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a> = 0.f;
00594                                                 }
00595                                                 startEnd = <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a> * (dest - *targetPosIt);                                       
00596                                                 ci.dist = startEnd.norm();
00597                                                 <font class="comment">// we translate the particle from an epsilon so that it won't get hooked to the disc</font>
00598                                                 ci.newPos = *targetPosIt  + startEnd + <a class="code" href="namespaceNL3D.html#a221">PSCollideEpsilon</a> * p.<a class="code" href="classNLMISC_1_1CPlane.html#z305_2">getNormal</a>();                                
00599 
00600 
00601                                                 <font class="comment">// now, check the collision pos against radius</font>
00602 
00603                                                 hitRadius2 = (ci.newPos - center) * (ci.newPos - center);
00604 
00605                                                 <font class="keywordflow">if</font> (hitRadius2 &lt; radiusIt-&gt;R2) <font class="comment">// check collision against disc</font>
00606                                                 {
00607                                                         ci.newSpeed = <a class="code" href="classNL3D_1_1CPSZone.html#n0">_BounceFactor</a> * (speed - 2.0f * (speed * p.<a class="code" href="classNLMISC_1_1CPlane.html#z305_2">getNormal</a>()) * p.<a class="code" href="classNLMISC_1_1CPlane.html#z305_2">getNormal</a>());                                         
00608                                                         ci.collisionZone = <font class="keyword">this</font>;                                                
00609                                                         (*it)-&gt;collisionUpdate(ci, k);
00610                                                 }
00611                                         
00612                                 }
00613                         }
00614                 }
00615         }       
00616 }
00617 
<a name="l00618"></a><a class="code" href="classNL3D_1_1CPSZoneDisc.html#a1">00618</a> <font class="keywordtype">void</font> CPSZoneDisc::show(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00619 {
00620         TPSAttribRadiusPair::const_iterator radiusIt = <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n1">_Radius</a>.begin();
00621         TPSAttribVector::const_iterator posIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().begin(), endPosIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().end()
00622                                                                         , normalIt = <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n0">_Normal</a>.begin();
00623         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();       
00624         CMatrix mat;
00625 
00626         
00627                 
00628         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#l0">CPSLocated</a> *loc;
00629         uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>;
00630         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#z720_0">CPSLocatedBindable</a> *lb;
00631         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getOwner()-&gt;getCurrentEditedElement(loc, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, lb);
00632         
00633 
00634         
00635         <font class="keywordflow">for</font> (uint k = 0; posIt != endPosIt; ++posIt, ++radiusIt, ++normalIt, ++k) 
00636         {       
00637                 <font class="keyword">const</font> CRGBA col = ((lb == NULL || <font class="keyword">this</font> == lb) &amp;&amp; loc == <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> &amp;&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> == k  ? CRGBA::Red : CRGBA(127, 127, 127));
00638                 CPSUtil::buildSchmidtBasis(*normalIt, mat);
00639                 CPSUtil::displayDisc(*<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>(), radiusIt-&gt;R, *posIt, mat, 32, col);
00640 
00641                 mat.setPos(*posIt);
00642                 CPSUtil::displayBasis(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>() ,<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a17">getLocatedMat</a>(), mat, 1.f, *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a11">getFontGenerator</a>(), *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a13">getFontManager</a>());                          
00643                 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();                       
00644         }       
00645 }
00646         
00647 
00648 
00649 
00650 
00651 
<a name="l00652"></a><a class="code" href="classNL3D_1_1CPSZoneDisc.html#a5">00652</a> <font class="keywordtype">void</font> CPSZoneDisc::setMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">const</font> CMatrix &amp;m)
00653 {
00654         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> &lt; <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n1">_Radius</a>.getSize());    
00655         <font class="comment">// compute new pos</font>
00656         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = m.getPos();
00657         <font class="comment">// compute new normal</font>
00658         <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n0">_Normal</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = m.getK();
00659 }
00660 
<a name="l00661"></a><a class="code" href="classNL3D_1_1CPSZoneDisc.html#a6">00661</a> CMatrix CPSZoneDisc::getMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font>
00662 <font class="keyword"></font>{
00663         CMatrix m, b;
00664         m.translate(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>]);
00665         CPSUtil::buildSchmidtBasis(<a class="code" href="classNL3D_1_1CPSZoneDisc.html#n0">_Normal</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], b);
00666         m = m * b;
00667         <font class="keywordflow">return</font> m;       
00668 }
00669 
<a name="l00670"></a><a class="code" href="classNL3D_1_1CPSZoneDisc.html#a10">00670</a> CVector CPSZoneDisc::getNormal(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00671 {
00672         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n0">_Normal</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>];
00673 }
<a name="l00674"></a><a class="code" href="classNL3D_1_1CPSZoneDisc.html#a11">00674</a> <font class="keywordtype">void</font> CPSZoneDisc::setNormal(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, CVector n)
00675 {
00676         <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n0">_Normal</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = n;
00677 }
00678 
<a name="l00679"></a><a class="code" href="classNL3D_1_1CPSZoneDisc.html#a7">00679</a> <font class="keywordtype">void</font> CPSZoneDisc::setScale(uint32 k, <font class="keywordtype">float</font> scale)
00680 {
00681         <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n1">_Radius</a>[k].R = scale;
00682         <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n1">_Radius</a>[k].R2 = scale * scale;
00683 }
00684 
<a name="l00685"></a><a class="code" href="classNL3D_1_1CPSZoneDisc.html#a8">00685</a> CVector CPSZoneDisc::getScale(uint32 k)<font class="keyword"> const</font>
00686 <font class="keyword"></font>{
00687         <font class="keywordflow">return</font> CVector(<a class="code" href="classNL3D_1_1CPSZoneDisc.html#n1">_Radius</a>[k].R, <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n1">_Radius</a>[k].R, <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n1">_Radius</a>[k].R);
00688 }
00689 
00690 
<a name="l00691"></a><a class="code" href="classNL3D_1_1CPSZoneDisc.html#a12">00691</a> <font class="keywordtype">void</font> CPSZoneDisc::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
00692 {
00693         f.serialVersion(1);     
00694         CPSZone::serial(f);
00695         f.serial(_Normal);              
00696         f.serial(_Radius);              
00697 }
00698 
<a name="l00699"></a><a class="code" href="classNL3D_1_1CPSZoneDisc.html#b1">00699</a> <font class="keywordtype">void</font> CPSZoneDisc::resize(uint32 size)
00700 {
00701         <a class="code" href="debug_8h.html#a6">nlassert</a>(size &lt; (1 &lt;&lt; 16));
00702         <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n1">_Radius</a>.resize(size);
00703         <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n0">_Normal</a>.resize(size);
00704 }
00705 
<a name="l00706"></a><a class="code" href="classNL3D_1_1CPSZoneDisc.html#b2">00706</a> <font class="keywordtype">void</font> CPSZoneDisc::newElement(CPSLocated *emitterLocated, uint32 emitterIndex)
00707 {
00708         CRadiusPair rp;
00709         rp.R = rp.R2 = 1.f;
00710         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSZoneDisc.html#n1">_Radius</a>.getSize() != <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n1">_Radius</a>.getMaxSize());
00711         <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n1">_Radius</a>.insert(rp);
00712         <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n0">_Normal</a>.insert(CVector::K);
00713 }
00714 
<a name="l00715"></a><a class="code" href="classNL3D_1_1CPSZoneDisc.html#b3">00715</a> <font class="keywordtype">void</font> CPSZoneDisc::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00716 {
00717         <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n1">_Radius</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00718         <a class="code" href="classNL3D_1_1CPSZoneDisc.html#n0">_Normal</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
00719 }
00720 
00721 
00723 <font class="comment">// CPSZoneCylinder implementation //</font>
00725 <font class="comment"></font>
00726 
00727 <font class="comment">/*</font>
00728 <font class="comment">void CPSZoneCylinder::performMotion(TAnimationTime ellapsedTime)</font>
00729 <font class="comment">{</font>
00730 <font class="comment">        TPSAttribVector::const_iterator dimIt = _Dim.begin();</font>
00731 <font class="comment">        CPSAttrib&lt;CPlaneBasis&gt;::const_iterator basisIt = _Basis.begin();</font>
00732 <font class="comment">        TPSAttribVector::const_iterator cylinderPosIt, cylinderPosEnd, targetPosIt, targetPosEnd;</font>
00733 <font class="comment">        CVector dest;</font>
00734 <font class="comment">        CPSCollisionInfo ci;</font>
00735 <font class="comment">        CVector startEnd;</font>
00736 <font class="comment">        uint32 k;</font>
00737 <font class="comment">        const TPSAttribVector *speedAttr;</font>
00738 <font class="comment"></font>
00739 <font class="comment"></font>
00740 <font class="comment"></font>
00741 <font class="comment">        for (TTargetCont::iterator it = _Targets.begin(); it != _Targets.end(); ++it)</font>
00742 <font class="comment">        {</font>
00743 <font class="comment"></font>
00744 <font class="comment">                speedAttr = &amp;((*it)-&gt;getSpeed());</font>
00745 <font class="comment"></font>
00746 <font class="comment"></font>
00747 <font class="comment">                // cycle through the cylinders</font>
00748 <font class="comment"></font>
00749 <font class="comment">                cylinderPosEnd = _Owner-&gt;getPos().end();</font>
00750 <font class="comment">                for (cylinderPosIt = _Owner-&gt;getPos().begin(); cylinderPosIt != cylinderPosEnd</font>
00751 <font class="comment">                                ; ++cylinderPosIt, ++dimIt, ++basisIt)</font>
00752 <font class="comment">                {</font>
00753 <font class="comment">                        </font>
00754 <font class="comment">                        // we must setup the cylinder in the good basis</font>
00755 <font class="comment"></font>
00756 <font class="comment">                        const CMatrix &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);</font>
00757 <font class="comment"></font>
00758 <font class="comment">                        </font>
00759 <font class="comment"></font>
00760 <font class="comment">                        // compute the new center pos</font>
00761 <font class="comment">                        CVector center = m * *cylinderPosIt;</font>
00762 <font class="comment"></font>
00763 <font class="comment">                        // compute a basis for the cylinder</font>
00764 <font class="comment">                        CVector I = m.mulVector(basisIt-&gt;X);</font>
00765 <font class="comment">                        CVector J = m.mulVector(basisIt-&gt;Y);</font>
00766 <font class="comment">                        CVector K = m.mulVector(basisIt-&gt;X ^ basisIt-&gt;Y);</font>
00767 <font class="comment"></font>
00768 <font class="comment">                                                </font>
00769 <font class="comment">                        // the pos projected (and scale) over the plane basis of the cylinder, the pos minus the center</font>
00770 <font class="comment">                        CVector projectedPos, tPos;</font>
00771 <font class="comment"></font>
00772 <font class="comment">                        // the same, but with the final position</font>
00773 <font class="comment">                        CVector destProjectedPos, destTPos;</font>
00774 <font class="comment"></font>
00775 <font class="comment"></font>
00776 <font class="comment">                        // deals with each particle</font>
00777 <font class="comment">                        targetPosEnd = (*it)-&gt;getPos().end();</font>
00778 <font class="comment">                        for (targetPosIt = (*it)-&gt;getPos().begin(), k = 0; targetPosIt != targetPosEnd; ++targetPosIt, ++k)</font>
00779 <font class="comment">                        {       </font>
00780 <font class="comment">                                const CVector &amp;speed = (*speedAttr)[k];</font>
00781 <font class="comment">                                const CVector &amp;pos = *targetPosIt;</font>
00782 <font class="comment"></font>
00783 <font class="comment">                                </font>
00784 <font class="comment">                                </font>
00785 <font class="comment">                                // check wether current pos was outside the cylinder</font>
00786 <font class="comment"></font>
00787 <font class="comment"></font>
00788 <font class="comment">                                tPos = pos - center;</font>
00789 <font class="comment">                                projectedPos = (1 / dimIt-&gt;x) * (I * tPos) * I + (1 / dimIt-&gt;y)  * (J * tPos) * J;</font>
00790 <font class="comment">                                </font>
00791 <font class="comment">                                if (!</font>
00792 <font class="comment">                                         (</font>
00793 <font class="comment">                                                ((tPos * K) &lt; dimIt-&gt;z)</font>
00794 <font class="comment">                                                &amp;&amp; ((tPos * K) &gt; -dimIt-&gt;z)</font>
00795 <font class="comment">                                                &amp;&amp; (projectedPos * projectedPos &lt; 1.f) </font>
00796 <font class="comment">                                         )</font>
00797 <font class="comment">                                   )</font>
00798 <font class="comment">                                {</font>
00799 <font class="comment">                                        dest = pos + ellapsedTime *  speed;</font>
00800 <font class="comment">                                        destTPos = dest - center;</font>
00801 <font class="comment">                                        destProjectedPos = (1.f / dimIt-&gt;x) * (I * tPos) * I + (1.f / dimIt-&gt;y)  * (J * tPos) * J;</font>
00802 <font class="comment"></font>
00803 <font class="comment">                                        // test wether the new position is inside the cylinder</font>
00804 <font class="comment"></font>
00805 <font class="comment">                                        </font>
00806 <font class="comment">                                        if (!</font>
00807 <font class="comment">                                                 (</font>
00808 <font class="comment">                                                        ((destTPos * K) &lt; dimIt-&gt;z)</font>
00809 <font class="comment">                                                        &amp;&amp; ((destTPos * K) &gt; -dimIt-&gt;z)</font>
00810 <font class="comment">                                                        &amp;&amp; (destProjectedPos * destProjectedPos &lt; 1.f) </font>
00811 <font class="comment">                                                 )</font>
00812 <font class="comment">                                           )</font>
00813 <font class="comment">                                        {</font>
00814 <font class="comment">                                                // now, detect the closest hit point (the smallest alpha, with alpha, the percent of the move vector</font>
00815 <font class="comment">                                                // to reach the hit point)</font>
00816 <font class="comment"></font>
00817 <font class="comment">                                                const float epsilon = 10E-6f;</font>
00818 <font class="comment"></font>
00819 <font class="comment">                                                float alphaTop, alphaBottom, alphaCyl;</font>
00820 <font class="comment"></font>
00821 <font class="comment">                                                const float denum = (dest - pos) * K;</font>
00822 <font class="comment"></font>
00823 <font class="comment">                                                // top plane</font>
00824 <font class="comment"></font>
00825 <font class="comment">                                                if (fabs(denum) &lt; epsilon)</font>
00826 <font class="comment">                                                {</font>
00827 <font class="comment">                                                        alphaTop = (dimIt-&gt;z - (tPos * K)) / denum;</font>
00828 <font class="comment">                                                        if (alphaTop &lt; 0.f) alphaTop = 1.f;</font>
00829 <font class="comment">                                                }</font>
00830 <font class="comment">                                                else</font>
00831 <font class="comment">                                                {</font>
00832 <font class="comment">                                                        alphaTop = 1.f;</font>
00833 <font class="comment">                                                }</font>
00834 <font class="comment"></font>
00835 <font class="comment">                                                // bottom plane</font>
00836 <font class="comment"></font>
00837 <font class="comment">                                                if (fabs(denum) &lt; epsilon)</font>
00838 <font class="comment">                                                {</font>
00839 <font class="comment">                                                        alphaBottom = (- dimIt-&gt;z - (tPos * K)) / denum;</font>
00840 <font class="comment">                                                        if (alphaBottom &lt; 0.f) alphaBottom = 1.f;</font>
00841 <font class="comment">                                                }</font>
00842 <font class="comment">                                                else</font>
00843 <font class="comment">                                                {</font>
00844 <font class="comment">                                                        alphaBottom = 1.f;</font>
00845 <font class="comment">                                                }</font>
00846 <font class="comment"></font>
00847 <font class="comment">                                                // cylinder</font>
00848 <font class="comment"></font>
00849 <font class="comment">                                                //expressed the src and dest positions in the cylinder basis</font>
00850 <font class="comment"></font>
00851 <font class="comment">                                                const float ox = tPos * I, oy = tPos * J, dx = (destTPos - tPos) * I, dy = (destTPos - tPos) * J;</font>
00852 <font class="comment"></font>
00853 <font class="comment">                                                // coefficients of the equation : a * alpha ^ 2 + b * alpha + c = 0</font>
00854 <font class="comment">                                                const float a = (dx * dx) / (dimIt-&gt;x * dimIt-&gt;x)</font>
00855 <font class="comment">                                                                  + (dy * dy) / (dimIt-&gt;y * dimIt-&gt;y);</font>
00856 <font class="comment">                                                const float b = 2.f * (ox * dx) / (dimIt-&gt;x * dimIt-&gt;x)</font>
00857 <font class="comment">                                                                  + (oy * dy) / (dimIt-&gt;y * dimIt-&gt;y);</font>
00858 <font class="comment">                                                const float c = ox * ox + oy * oy - 1;</font>
00859 <font class="comment"></font>
00860 <font class="comment">                                                // discriminant</font>
00861 <font class="comment">                                                const float delta = b * b - 4.f * a * c;</font>
00862 <font class="comment"></font>
00863 <font class="comment">                                                if (delta &lt; epsilon)</font>
00864 <font class="comment">                                                {</font>
00865 <font class="comment">                                                        alphaCyl = 1.f;</font>
00866 <font class="comment">                                                }</font>
00867 <font class="comment">                                                else</font>
00868 <font class="comment">                                                {</font>
00869 <font class="comment">                                                        const float deltaRoot = sqrtf(delta);</font>
00870 <font class="comment">                                                        const float r1 = (- b - deltaRoot) / (2.f / a);</font>
00871 <font class="comment">                                                        const float r2 = (- b - deltaRoot) / (2.f / a);</font>
00872 <font class="comment"></font>
00873 <font class="comment">                                                        if (r1 &lt; 0.f) alphaCyl = r2;</font>
00874 <font class="comment">                                                                else if (r2 &lt; 0.f) alphaCyl = r1;</font>
00875 <font class="comment">                                                                        else alphaCyl = r1 &lt; r2 ? r1 : r2;</font>
00876 <font class="comment">                                                }</font>
00877 <font class="comment"></font>
00878 <font class="comment"></font>
00879 <font class="comment">                                                // now, choose the minimum positive dist</font>
00880 <font class="comment">                                                </font>
00881 <font class="comment">                                                if (alphaTop &lt; alphaBottom &amp;&amp; alphaTop &lt; alphaCyl)</font>
00882 <font class="comment">                                                {</font>
00883 <font class="comment">                                                        // collision with the top plane</font>
00884 <font class="comment">                                                        CVector startEnd = alphaTop * (dest - pos);</font>
00885 <font class="comment">                                                        ci.newPos = pos + startEnd + PSCollideEpsilon * K;</font>
00886 <font class="comment">                                                        ci.dist = startEnd.norm();</font>
00887 <font class="comment">                                                        ci.newSpeed = (-2.f * (speed * K)) * K + speed;</font>
00888 <font class="comment">                                                        ci.collisionZone = this;</font>
00889 <font class="comment">                                                        </font>
00890 <font class="comment">                                                        (*it)-&gt;collisionUpdate(ci, k);</font>
00891 <font class="comment">                                                }</font>
00892 <font class="comment">                                                else</font>
00893 <font class="comment">                                                        if (alphaBottom &lt; alphaCyl)</font>
00894 <font class="comment">                                                        {       </font>
00895 <font class="comment">                                                                // collision with the bottom plane</font>
00896 <font class="comment">                                                                CVector startEnd = alphaBottom * (dest - pos);</font>
00897 <font class="comment">                                                                ci.newPos = pos + startEnd - PSCollideEpsilon * K;</font>
00898 <font class="comment">                                                                ci.dist = startEnd.norm();</font>
00899 <font class="comment">                                                                ci.newSpeed = (-2.f * (speed * K)) * K + speed;</font>
00900 <font class="comment">                                                                ci.collisionZone = this;</font>
00901 <font class="comment">                                                </font>
00902 <font class="comment">                                                                </font>
00903 <font class="comment">                                                                (*it)-&gt;collisionUpdate(ci, k);</font>
00904 <font class="comment">                                                        }</font>
00905 <font class="comment">                                                        else</font>
00906 <font class="comment">                                                        {</font>
00907 <font class="comment">                                                                // collision with the cylinder</font>
00908 <font class="comment"></font>
00909 <font class="comment">                                                                CVector startEnd = alphaCyl * (dest - pos);</font>
00910 <font class="comment"></font>
00911 <font 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</font>
00912 <font class="comment">                                                                // so we got unormalized n =  (2 x / a ^ 2, 2 y / b ^ 2, 0) in the basis of the cylinder</font>
00913 <font class="comment">                                                                // As we'll normalize it, we don't need  the 2 factor</font>
00914 <font class="comment">                                                                </font>
00915 <font class="comment">                                                                float px = ox + alphaCyl * dx;</font>
00916 <font class="comment">                                                                float py = oy + alphaCyl * dy;</font>
00917 <font class="comment"></font>
00918 <font class="comment">                                                                CVector normal = px / (dimIt-&gt;x * dimIt-&gt;x) * I + py / (dimIt-&gt;y * dimIt-&gt;y) * J;</font>
00919 <font class="comment">                                                                normal.normalize();</font>
00920 <font class="comment"></font>
00921 <font class="comment">                                                                ci.newPos = pos + startEnd - PSCollideEpsilon * normal;</font>
00922 <font class="comment">                                                                ci.dist = startEnd.norm();</font>
00923 <font class="comment">                                                                ci.newSpeed = (-2.f * (speed * normal)) * normal + speed;</font>
00924 <font class="comment">                                                                ci.collisionZone = this;</font>
00925 <font class="comment"></font>
00926 <font class="comment">                                                                (*it)-&gt;collisionUpdate(ci, k);</font>
00927 <font class="comment">                                                        }                                               </font>
00928 <font class="comment"></font>
00929 <font class="comment">                                        }</font>
00930 <font class="comment">                                }                                                                       </font>
00931 <font class="comment">                        }</font>
00932 <font class="comment">                }</font>
00933 <font class="comment">        }</font>
00934 <font class="comment">}</font>
00935 <font class="comment">*/</font>
00936 
00937 
00938 
<a name="l00939"></a><a class="code" href="classNL3D_1_1CPSZoneCylinder.html#a0">00939</a> <font class="keywordtype">void</font> CPSZoneCylinder::performMotion(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
00940 {
00941         TPSAttribVector::const_iterator dimIt;
00942         CPSAttrib&lt;CPlaneBasis&gt;::const_iterator basisIt;
00943         TPSAttribVector::const_iterator cylinderPosIt, cylinderPosEnd, targetPosIt, targetPosEnd;
00944         CVector dest;
00945         CPSCollisionInfo ci;
00946         uint32 k;
00947         <font class="keyword">const</font> <a class="code" href="namespaceNL3D.html#a180">TPSAttribVector</a> *speedAttr;
00948 
00949 
00950 
00951         <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
00952         {
00953 
00954                 speedAttr = &amp;((*it)-&gt;getSpeed());
00955 
00956 
00957                 <font class="comment">// cycle through the cylinders</font>
00958 
00959                 cylinderPosEnd = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().end();
00960                 <font class="keywordflow">for</font> (cylinderPosIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().begin(), basisIt = <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n0">_Basis</a>.begin(),  dimIt = <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n1">_Dim</a>.begin()
00961                                 ; cylinderPosIt != cylinderPosEnd
00962                                 ; ++cylinderPosIt, ++dimIt, ++basisIt)
00963                 {
00964                         
00965                         <font class="comment">// we must setup the cylinder in the good basis</font>
00966 
00967                         <font class="keyword">const</font> CMatrix &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);
00968 
00969                         
00970 
00971                         <font class="comment">// compute the new center pos</font>
00972                         CVector center = m * *cylinderPosIt;
00973 
00974                         <font class="comment">// compute a basis for the cylinder</font>
00975                         CVector I = m.mulVector(basisIt-&gt;X);
00976                         CVector J = m.mulVector(basisIt-&gt;Y);
00977                         CVector K = m.mulVector(basisIt-&gt;X ^ basisIt-&gt;Y);
00978 
00979                                                 
00980                         <font class="comment">// the pos projected (and scale) over the plane basis of the cylinder, the pos minus the center</font>
00981                         CVector projectedPos, tPos;
00982 
00983                         <font class="comment">// the same, but with the final position</font>
00984                         CVector destProjectedPos, destTPos;
00985 
00986 
00987                         <font class="comment">// deals with each particle</font>
00988                         targetPosEnd = (*it)-&gt;getPos().end();
00989                         TPSAttribCollisionInfo::const_iterator ciIt = (*it)-&gt;getCollisionInfo().begin();
00990                         <font class="keywordflow">for</font> (targetPosIt = (*it)-&gt;getPos().begin(), k = 0; targetPosIt != targetPosEnd; ++targetPosIt, ++k, ++ciIt)
00991                         {       
00992                                 <font class="keyword">const</font> CVector &amp;speed = (*speedAttr)[k];
00993                                 <font class="keyword">const</font> CVector &amp;pos = *targetPosIt;
00994 
00995                                 
00996                                 
00997                                 <font class="comment">// check wether current pos was outside the cylinder</font>
00998 
00999 
01000                                 tPos = pos - center;
01001                                 projectedPos = (1 / dimIt-&gt;x) * (I * tPos) * I + (1 / dimIt-&gt;y)  * (J * tPos) * J;
01002                                 
01003                                 <font class="keywordflow">if</font> (!
01004                                          (
01005                                                 ((tPos * K) &lt; dimIt-&gt;z)
01006                                                 &amp;&amp; ((tPos * K) &gt; -dimIt-&gt;z)
01007                                                 &amp;&amp; (projectedPos * projectedPos &lt; 1.f) 
01008                                          )
01009                                    )
01010                                 {
01011                                         dest = pos + ellapsedTime *  speed * ciIt-&gt;TimeSliceRatio;
01012                                         destTPos = dest - center;
01013                                         destProjectedPos = (1.f / dimIt-&gt;x) * (I * destTPos) * I + (1.f / dimIt-&gt;y)  * (J * destTPos) * J;
01014 
01015                                         <font class="comment">// test wether the new position is inside the cylinder</font>
01016 
01017                                         
01018                                         <font class="keywordflow">if</font> (
01019                                                  (
01020                                                         ((destTPos * K) &lt; dimIt-&gt;z)
01021                                                         &amp;&amp; ((destTPos * K) &gt; -dimIt-&gt;z)
01022                                                         &amp;&amp; (destProjectedPos * destProjectedPos &lt; 1.f) 
01023                                                  )
01024                                            )
01025                                         {
01026                                                 <font class="comment">// now, detect the closest hit point (the smallest alpha, with alpha, the percent of the move vector</font>
01027                                                 <font class="comment">// to reach the hit point)</font>
01028 
01029                                                 <font class="keyword">const</font> <font class="keywordtype">float</font> epsilon = 10E-3f;
01030 
01031                                                 <font class="keywordtype">float</font> alphaTop, alphaBottom, alphaCyl;
01032 
01033                                                 <font class="keyword">const</font> <font class="keywordtype">float</font> denum = (dest - pos) * K;
01034 
01035                                                 <font class="comment">// top plane</font>
01036 
01037                                                 <font class="keywordflow">if</font> (fabs(denum) &lt; epsilon)
01038                                                 {
01039                                                         alphaTop = (dimIt-&gt;z - (tPos * K)) / denum;
01040                                                         <font class="keywordflow">if</font> (alphaTop &lt; 0.f) alphaTop = 1.f;
01041                                                 }
01042                                                 <font class="keywordflow">else</font>
01043                                                 {
01044                                                         alphaTop = 1.f;
01045                                                 }
01046 
01047                                                 <font class="comment">// bottom plane</font>
01048 
01049                                                 <font class="keywordflow">if</font> (fabs(denum) &lt; epsilon)
01050                                                 {
01051                                                         alphaBottom = (- dimIt-&gt;z - (tPos * K)) / denum;
01052                                                         <font class="keywordflow">if</font> (alphaBottom &lt; 0.f) alphaBottom = 1.f;
01053                                                 }
01054                                                 <font class="keywordflow">else</font>
01055                                                 {
01056                                                         alphaBottom = 1.f;
01057                                                 }
01058 
01059                                                 <font class="comment">// cylinder</font>
01060 
01061                                                 <font class="comment">//expressed the src and dest positions in the cylinder basis</font>
01062 
01063                                                 <font class="keyword">const</font> <font class="keywordtype">float</font> ox = tPos * I, oy = tPos * J, dx = (destTPos - tPos) * I, dy = (destTPos - tPos) * J;
01064 
01065                                                 <font class="comment">// coefficients of the equation : a * alpha ^ 2 + b * alpha + c = 0</font>
01066                                                 <font class="keyword">const</font> <font class="keywordtype">float</font> a = (dx * dx) / (dimIt-&gt;x * dimIt-&gt;x)
01067                                                                   + (dy * dy) / (dimIt-&gt;y * dimIt-&gt;y);
01068                                                 <font class="keyword">const</font> <font class="keywordtype">float</font> b = 2.f * ((ox * dx) / (dimIt-&gt;x * dimIt-&gt;x)
01069                                                                   + (oy * dy) / (dimIt-&gt;y * dimIt-&gt;y));
01070                                                 <font class="keyword">const</font> <font class="keywordtype">float</font> c = (ox * ox) / (dimIt-&gt;x * dimIt-&gt;x) + (oy * oy) / (dimIt-&gt;y * dimIt-&gt;y)  - 1;
01071 
01072                                                 <font class="comment">// discriminant</font>
01073                                                 <font class="keyword">const</font> <font class="keywordtype">float</font> delta = b * b - 4.f * a * c;
01074 
01075                                                 <font class="keywordflow">if</font> (delta &lt; epsilon)
01076                                                 {
01077                                                         alphaCyl = 1.f;
01078                                                 }
01079                                                 <font class="keywordflow">else</font>
01080                                                 {
01081                                                         <font class="keyword">const</font> <font class="keywordtype">float</font> deltaRoot = sqrtf(delta);
01082                                                         <font class="keyword">const</font> <font class="keywordtype">float</font> r1 = (- b + 2.f * deltaRoot) / (2.f * a);
01083                                                         <font class="keyword">const</font> <font class="keywordtype">float</font> r2 = (- b - 2.f * deltaRoot) / (2.f * a);
01084 
01085                                                         <font class="keywordflow">if</font> (r1 &lt; 0.f) alphaCyl = r2;
01086                                                                 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (r2 &lt; 0.f) alphaCyl = r1;
01087                                                                         <font class="keywordflow">else</font> alphaCyl = r1 &lt; r2 ? r1 : r2;
01088 
01089                                                                         <font class="keywordflow">if</font> (alphaCyl &lt; 0.f) alphaCyl = 1.f;
01090                                                 }
01091 
01092 
01093                                                 <font class="comment">// now, choose the minimum positive dist</font>
01094 
01095                                         
01096                                                 
01097                                                 <font class="keywordflow">if</font> (alphaTop &lt; alphaBottom &amp;&amp; alphaTop &lt; alphaCyl)
01098                                                 {
01099                                                         <font class="comment">// collision with the top plane</font>
01100                                                         CVector startEnd = alphaTop * (dest - pos);
01101                                                         ci.newPos = pos + startEnd + <a class="code" href="namespaceNL3D.html#a221">PSCollideEpsilon</a> * K;
01102                                                         ci.dist = startEnd.norm();
01103                                                         ci.newSpeed = (-2.f * (speed * K)) * K + speed;
01104                                                         ci.collisionZone = <font class="keyword">this</font>;
01105                                                         
01106                                                         (*it)-&gt;collisionUpdate(ci, k);
01107                                                 }
01108                                                 <font class="keywordflow">else</font>
01109                                                         <font class="keywordflow">if</font> (alphaBottom &lt; alphaCyl)
01110                                                         {       
01111                                                                 <font class="comment">// collision with the bottom plane</font>
01112                                                                 CVector startEnd = alphaBottom * (dest - pos);
01113                                                                 ci.newPos = pos + startEnd - <a class="code" href="namespaceNL3D.html#a221">PSCollideEpsilon</a> * K;
01114                                                                 ci.dist = startEnd.norm();
01115                                                                 ci.newSpeed = (-2.f * (speed * K)) * K + speed;
01116                                                                 ci.collisionZone = <font class="keyword">this</font>;
01117                                                 
01118                                                                 
01119                                                                 (*it)-&gt;collisionUpdate(ci, k);
01120                                                         }
01121                                                         <font class="keywordflow">else</font>
01122                                                         {
01123                                                                 <font class="comment">// collision with the cylinder</font>
01124 
01125                                                                 CVector startEnd = alphaCyl * (dest - pos);
01126 
01127                                                                 <font 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</font>
01128                                                                 <font class="comment">// so we got unormalized n =  (2 x / a ^ 2, 2 y / b ^ 2, 0) in the basis of the cylinder</font>
01129                                                                 <font class="comment">// As we'll normalize it, we don't need  the 2 factor</font>
01130                                                                 
01131                                                                 <font class="keywordtype">float</font> px = ox + alphaCyl * dx;
01132                                                                 <font class="keywordtype">float</font> py = oy + alphaCyl * dy;
01133 
01134                                                                 CVector normal = px / (dimIt-&gt;x * dimIt-&gt;x) * I + py / (dimIt-&gt;y * dimIt-&gt;y) * J;
01135                                                                 normal.normalize();
01136 
01137                                                                 ci.newPos = pos + startEnd + <a class="code" href="namespaceNL3D.html#a221">PSCollideEpsilon</a> * normal;
01138                                                                 ci.dist = startEnd.norm();
01139                                                                 ci.newSpeed = (-2.f * (speed * normal)) * normal + speed;
01140                                                                 ci.collisionZone = <font class="keyword">this</font>;
01141 
01142                                                                 (*it)-&gt;collisionUpdate(ci, k);
01143                                                         }                                               
01144 
01145                                         }
01146                                 }                                                                       
01147                         }
01148                 }
01149         }
01150 }
01151 
<a name="l01152"></a><a class="code" href="classNL3D_1_1CPSZoneCylinder.html#a1">01152</a> <font class="keywordtype">void</font> CPSZoneCylinder::show(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
01153 {
01154         TPSAttribVector::const_iterator dimIt = <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n1">_Dim</a>.begin()
01155                                                                         ,posIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().begin()
01156                                                                         , endPosIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().end();
01157 
01158         CPSAttrib&lt;CPlaneBasis&gt;::const_iterator basisIt = <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n0">_Basis</a>.begin();
01159                                                                         
01160         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();       
01161         CMatrix mat;
01162 
01163 
01164                 
01165         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#l0">CPSLocated</a> *loc;
01166         uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>;
01167         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#z720_0">CPSLocatedBindable</a> *lb;
01168         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getOwner()-&gt;getCurrentEditedElement(loc, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, lb);
01169 
01170 
01171         <font class="keywordflow">for</font> (uint32 k = 0; posIt != endPosIt; ++posIt, ++dimIt, ++basisIt, ++k) 
01172         {                       
01173                 mat.setRot(basisIt-&gt;X, basisIt-&gt;Y, basisIt-&gt;X ^ basisIt-&gt;Y);
01174                 mat.setPos(CVector::Null);
01175 
01176                 <font class="keyword">const</font> CRGBA col = ((lb == NULL || <font class="keyword">this</font> == lb) &amp;&amp; loc == <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> &amp;&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> == k  ? CRGBA::Red : CRGBA(127, 127, 127));
01177 
01178                 
01179                 CPSUtil::displayCylinder(*<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>(), *posIt, mat, *dimIt, 32, col); 
01180 
01181                 mat.setPos(*posIt);
01182                 CPSUtil::displayBasis(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>() ,<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a17">getLocatedMat</a>(), mat, 1.f, *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a11">getFontGenerator</a>(), *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a13">getFontManager</a>());                          
01183                 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();       
01184         
01185         }
01186 }
01187         
01188 
01189 
<a name="l01190"></a><a class="code" href="classNL3D_1_1CPSZoneCylinder.html#a6">01190</a> <font class="keywordtype">void</font> CPSZoneCylinder::setMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">const</font> CMatrix &amp;m)
01191 {
01192         <font class="comment">// transform the basis  </font>
01193         <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].X = m.getI();     
01194         <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].Y = m.getJ();     
01195 
01196         <font class="comment">// compute new pos</font>
01197         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = m.getPos();
01198         
01199                                  
01200 }
01201 
01202 
01203 
<a name="l01204"></a><a class="code" href="classNL3D_1_1CPSZoneCylinder.html#a7">01204</a> CMatrix CPSZoneCylinder::getMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font>
01205 <font class="keyword"></font>{
01206         CMatrix m;
01207         m.setRot(<a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].X, <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].Y, <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].X ^<a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].Y);
01208         m.setPos(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>]);      
01209         <font class="keywordflow">return</font> m;
01210 }
01211 
01212 
<a name="l01213"></a><a class="code" href="classNL3D_1_1CPSZoneCylinder.html#a8">01213</a> <font class="keywordtype">void</font> CPSZoneCylinder::setScale(uint32 k, <font class="keywordtype">float</font> scale)
01214 {
01215         <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n1">_Dim</a>[k] = CVector(scale, scale, scale);
01216 }
01217 
<a name="l01218"></a><a class="code" href="classNL3D_1_1CPSZoneCylinder.html#a10">01218</a> CVector CPSZoneCylinder::getScale(uint32 k)<font class="keyword"> const</font>
01219 <font class="keyword"></font>{
01220         <font class="keywordflow">return</font> <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n1">_Dim</a>[k];
01221 }
01222 
<a name="l01223"></a><a class="code" href="classNL3D_1_1CPSZoneCylinder.html#a9">01223</a> <font class="keywordtype">void</font> CPSZoneCylinder::setScale(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">const</font> CVector &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>)
01224 {
01225         <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n1">_Dim</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
01226 }
01227 
01228 
<a name="l01229"></a><a class="code" href="classNL3D_1_1CPSZoneCylinder.html#a11">01229</a> <font class="keywordtype">void</font> CPSZoneCylinder::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
01230 {
01231         f.serialVersion(1);
01232         CPSZone::serial(f);
01233         f.serial(_Basis);               
01234         f.serial(_Dim);
01235 }
01236 
01237 
01238 
<a name="l01239"></a><a class="code" href="classNL3D_1_1CPSZoneCylinder.html#b1">01239</a> <font class="keywordtype">void</font> CPSZoneCylinder::resize(uint32 size)
01240 {
01241         <a class="code" href="debug_8h.html#a6">nlassert</a>(size &lt; (1 &lt;&lt; 16));
01242         <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n0">_Basis</a>.resize(size);
01243         <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n1">_Dim</a>.resize(size);
01244 }
01245 
<a name="l01246"></a><a class="code" href="classNL3D_1_1CPSZoneCylinder.html#b2">01246</a> <font class="keywordtype">void</font> CPSZoneCylinder::newElement(CPSLocated *emitterLocated, uint32 emitterIndex)
01247 {
01248         <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n0">_Basis</a>.insert(CPlaneBasis(CVector::K));
01249         <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n1">_Dim</a>.insert(CVector(1, 1, 1));
01250 }
01251 
<a name="l01252"></a><a class="code" href="classNL3D_1_1CPSZoneCylinder.html#b3">01252</a> <font class="keywordtype">void</font> CPSZoneCylinder::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
01253 {
01254         <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n0">_Basis</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01255         <a class="code" href="classNL3D_1_1CPSZoneCylinder.html#n1">_Dim</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01256 }
01257 
01258 
01260 <font class="comment">//      implementation of CPSZoneRectangle      //</font>
01262 <font class="comment"></font>
01263 
01264 
01265 
01266 
<a name="l01267"></a><a class="code" href="classNL3D_1_1CPSZoneRectangle.html#a0">01267</a> <font class="keywordtype">void</font> CPSZoneRectangle::performMotion(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
01268 {
01269 
01270         <font class="comment">// for each target, we must check wether they are going through the rectangle</font>
01271         <font class="comment">// if so they must bounce</font>
01272         TPSAttribVector::const_iterator rectanglePosIt, rectanglePosEnd, targetPosIt, targetPosEnd;
01273         CPSAttrib&lt;CPlaneBasis&gt;::const_iterator basisIt;
01274         TPSAttribFloat::const_iterator widthIt, heightIt;
01275 
01276         CVector dest;
01277         CPSCollisionInfo ci;
01278         CVector startEnd;
01279         uint32 k;
01280         <font class="keyword">const</font> <a class="code" href="namespaceNL3D.html#a180">TPSAttribVector</a> *speedAttr;
01281         <font class="keywordtype">float</font> posSide, negSide;
01282         
01283         <font class="comment">// alpha is the ratio that gives the percent of endPos - startPos that hit the rectangle</font>
01284         <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a>; 
01285 
01286         CVector center;
01287 
01288         <font class="keywordflow">for</font> (TTargetCont::iterator it = <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.begin(); it != <a class="code" href="classNL3D_1_1CPSTargetLocatedBindable.html#n0">_Targets</a>.end(); ++it)
01289         {
01290 
01291                 basisIt = <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n0">_Basis</a>.begin();
01292                 heightIt = <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n2">_Height</a>.begin();
01293                 widthIt = <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n1">_Width</a>.begin();
01294 
01295                 speedAttr = &amp;((*it)-&gt;getSpeed());
01296                 <font class="comment">// cycle through the rectangle</font>
01297 
01298                 rectanglePosEnd = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().end();
01299                 <font class="keywordflow">for</font> (rectanglePosIt = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos().begin(); rectanglePosIt != rectanglePosEnd
01300                                 ; ++rectanglePosIt, ++basisIt, ++widthIt, ++heightIt)
01301                 {
01302                         
01303                         <font class="comment">// we must setup the rectangle in the good basis</font>
01304 
01305                         <font class="keyword">const</font> CMatrix &amp;m = CPSLocated::getConversionMatrix(*it, this-&gt;_Owner);
01306 
01307                         
01308 
01309                         <a class="code" href="classNLMISC_1_1CPlane.html">NLMISC::CPlane</a> p;
01310                         center = m * (*rectanglePosIt);
01311 
01312                         <font class="keyword">const</font> CVector X = m.mulVector(basisIt-&gt;X);
01313                         <font class="keyword">const</font> CVector Y = m.mulVector(basisIt-&gt;Y);
01314 
01315                         p.<a class="code" href="classNLMISC_1_1CPlane.html#z305_0">make</a>(X ^ Y, center);          
01316                         
01317                         <font class="comment">// deals with each particle</font>
01318 
01319                         <font class="keyword">const</font> <font class="keywordtype">float</font> epsilon = 0.5f * <a class="code" href="namespaceNL3D.html#a221">PSCollideEpsilon</a>;
01320 
01321                         targetPosEnd = (*it)-&gt;getPos().end();
01322                         TPSAttribCollisionInfo::const_iterator ciIt = (*it)-&gt;getCollisionInfo().begin();
01323                         <font class="keywordflow">for</font> (targetPosIt = (*it)-&gt;getPos().begin(), k = 0; targetPosIt != targetPosEnd; ++targetPosIt, ++k, ++ciIt)
01324                         {       
01325                                 <font class="keyword">const</font> CVector &amp;pos = *targetPosIt;
01326                                 <font class="keyword">const</font> CVector &amp;speed = (*speedAttr)[k];
01327                                 <font class="comment">// check whether the located is going through the rectangle</font>
01328                                 dest = pos + ellapsedTime *  speed * ciIt-&gt;TimeSliceRatio;
01329 
01330 
01331                                 posSide = p * pos;
01332                                 negSide = p * dest;
01333                                                                 
01334                                 <font class="keywordflow">if</font> (posSide &gt;= - epsilon &amp;&amp; negSide &lt;= epsilon)
01335                                 {                                                                       
01336                                                 <font class="keywordflow">if</font> (fabsf(posSide - negSide) &gt; <a class="code" href="bit__set_8cpp.html#a0">std::numeric_limits&lt;float&gt;::min</a>())
01337                                                 {
01338                                                         <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a> = posSide / (posSide - negSide);
01339                                                 }
01340                                                 <font class="keywordflow">else</font>
01341                                                 {
01342                                                         <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a> = 0.f;
01343                                                 }
01344                                                 startEnd = <a class="code" href="driver__opengl__extension__def_8h.html#a420">alpha</a> * (dest - pos);                                        
01345                                                 ci.dist = startEnd.norm();
01346                                                 <font class="comment">// we translate the particle from an epsilon so that it won't get hooked to the rectangle</font>
01347                                                 ci.newPos = pos + startEnd;                             
01348                                         
01349 
01350                                                 
01351 
01352                                                 <font class="keywordflow">if</font> ( fabs( (pos - center) * X ) &lt; *widthIt &amp;&amp; fabs( (pos - center) * Y ) &lt; *heightIt) <font class="comment">// check collision against rectangle</font>
01353                                                 {
01354                                                         ci.newPos += <a class="code" href="namespaceNL3D.html#a221">PSCollideEpsilon</a> * p.<a class="code" href="classNLMISC_1_1CPlane.html#z305_2">getNormal</a>();
01355                                                         ci.newSpeed = <a class="code" href="classNL3D_1_1CPSZone.html#n0">_BounceFactor</a> * (speed - 2.0f * (speed * p.<a class="code" href="classNLMISC_1_1CPlane.html#z305_2">getNormal</a>()) * p.<a class="code" href="classNLMISC_1_1CPlane.html#z305_2">getNormal</a>());                                         
01356                                                         ci.collisionZone = <font class="keyword">this</font>;                                                
01357                                                         (*it)-&gt;collisionUpdate(ci, k);
01358                                                 }
01359                                         
01360                                 }
01361                         }       
01362                 }
01363         }
01364 }
01365 
01366 
<a name="l01367"></a><a class="code" href="classNL3D_1_1CPSZoneRectangle.html#a1">01367</a> <font class="keywordtype">void</font> CPSZoneRectangle::show(<a class="code" href="namespaceNL3D.html#a1">TAnimationTime</a> ellapsedTime)
01368 {
01369         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
01370         <font class="keyword">const</font> uint size = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getSize();
01371         <font class="keywordflow">if</font> (!size) <font class="keywordflow">return</font>;
01372         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();       
01373         CMatrix mat;
01374         
01375         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#l0">CPSLocated</a> *loc;
01376         uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>;
01377         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#z720_0">CPSLocatedBindable</a> *lb;
01378         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getOwner()-&gt;getCurrentEditedElement(loc, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, lb);
01379 
01380         <font class="keywordflow">for</font> (uint k = 0; k &lt; size; ++k) 
01381         {       
01382                 <font class="keyword">const</font> CVector &amp;I = <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n0">_Basis</a>[k].X;
01383                 <font class="keyword">const</font> CVector &amp;J = <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n0">_Basis</a>[k].Y;
01384                 mat.setRot(I, J , I ^J);
01385                 mat.setPos(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[k]);
01386                 CPSUtil::displayBasis(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>() ,<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a17">getLocatedMat</a>(), mat, 1.f, *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a11">getFontGenerator</a>(), *<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a13">getFontManager</a>());                          
01387                 <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a21">setupDriverModelMatrix</a>();       
01388 
01389                 <font class="keyword">const</font> CRGBA col = ((lb == NULL || <font class="keyword">this</font> == lb) &amp;&amp; loc == <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a> &amp;&amp; <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> == k  ? CRGBA::Red : CRGBA(127, 127, 127));
01390         
01391 
01392 
01393                 <font class="keyword">const</font> CVector &amp;pos = <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[k];
01394                 CPSUtil::display3DQuad(*<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#a10">getDriver</a>(), pos + I * <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n1">_Width</a>[k] + J * <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n2">_Height</a>[k]
01395                                                                                    , pos + I * <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n1">_Width</a>[k] - J * <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n2">_Height</a>[k]
01396                                                                                    , pos - I * <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n1">_Width</a>[k] - J * <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n2">_Height</a>[k]
01397                                                                                    , pos - I * <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n1">_Width</a>[k] + J * <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n2">_Height</a>[k], col);
01398         }
01399 }
01400         
<a name="l01401"></a><a class="code" href="classNL3D_1_1CPSZoneRectangle.html#a7">01401</a> <font class="keywordtype">void</font> CPSZoneRectangle::setMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">const</font> CMatrix &amp;m)
01402 {
01403         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
01404 
01405         <a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = m.getPos();
01406         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].X = m.getI();
01407         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].Y = m.getJ();
01408 }
01409 
01410 
<a name="l01411"></a><a class="code" href="classNL3D_1_1CPSZoneRectangle.html#a8">01411</a> CMatrix CPSZoneRectangle::getMatrix(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font>
01412 <font class="keyword"></font>{
01413         <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>);
01414         CMatrix m;      
01415         m.setRot(<a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].X, <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].Y, <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].X ^ <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n0">_Basis</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>].Y);
01416         m.setPos(<a class="code" href="classNL3D_1_1CPSLocatedBindable.html#n0">_Owner</a>-&gt;getPos()[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>]);
01417         <font class="keywordflow">return</font> m;
01418 }
01419 
<a name="l01420"></a><a class="code" href="classNL3D_1_1CPSZoneRectangle.html#a9">01420</a> <font class="keywordtype">void</font> CPSZoneRectangle::setScale(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keywordtype">float</font> scale)
01421 {
01422         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n1">_Width</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = scale;
01423         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n2">_Height</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = scale;
01424 }
<a name="l01425"></a><a class="code" href="classNL3D_1_1CPSZoneRectangle.html#a10">01425</a> <font class="keywordtype">void</font> CPSZoneRectangle::setScale(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>, <font class="keyword">const</font> CVector &amp;<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>)
01426 {
01427         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n1">_Width</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>.x;
01428         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n2">_Height</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>.y;
01429 }
<a name="l01430"></a><a class="code" href="classNL3D_1_1CPSZoneRectangle.html#a11">01430</a> CVector CPSZoneRectangle::getScale(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)<font class="keyword"> const</font>
01431 <font class="keyword"></font>{
01432         <font class="keywordflow">return</font> CVector(<a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n1">_Width</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n2">_Height</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>], 1.f);
01433 }
01434 
01435 
01436 
<a name="l01437"></a><a class="code" href="classNL3D_1_1CPSZoneRectangle.html#a4">01437</a> <font class="keywordtype">void</font> CPSZoneRectangle::serial(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &amp;f) <font class="keywordflow">throw</font>(NLMISC::EStream)
01438 {
01439         f.serialVersion(1);
01440         CPSZone::serial(f);
01441         f.serial(_Basis);       
01442         f.serial(_Width);
01443         f.serial(_Height);
01444 }
01445 
01446 
<a name="l01447"></a><a class="code" href="classNL3D_1_1CPSZoneRectangle.html#b1">01447</a> <font class="keywordtype">void</font> CPSZoneRectangle::resize(uint32 size)
01448 {
01449         <a class="code" href="debug_8h.html#a6">nlassert</a>(size &lt; (1 &lt;&lt; 16));
01450         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n0">_Basis</a>.resize(size);
01451         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n1">_Width</a>.resize(size);
01452         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n2">_Height</a>.resize(size);
01453 }
01454 
<a name="l01455"></a><a class="code" href="classNL3D_1_1CPSZoneRectangle.html#b2">01455</a> <font class="keywordtype">void</font> CPSZoneRectangle::newElement(CPSLocated *emitterLocated, uint32 emitterIndex)
01456 {
01457         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n0">_Basis</a>.insert(CPlaneBasis(CVector::K));
01458         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n1">_Width</a>.insert(1.f);
01459         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n2">_Height</a>.insert(1.f);
01460 }
01461 
<a name="l01462"></a><a class="code" href="classNL3D_1_1CPSZoneRectangle.html#b3">01462</a> <font class="keywordtype">void</font> CPSZoneRectangle::deleteElement(uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
01463 {
01464         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n0">_Basis</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01465         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n1">_Width</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01466         <a class="code" href="classNL3D_1_1CPSZoneRectangle.html#n2">_Height</a>.remove(<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>);
01467 }
01468 
01469 
01470 
01471 } <font class="comment">// NL3D</font>
</pre></div>

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