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
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
Entity
Entity. ApplyAngularlmpulse
Brief
Applies an angular impulse to the entity.
Definition
Entity.ApplyAngularlmpulse( Entity entity, Vector4 impulse )
Arguments
entity - The entity to update.impulse - World space vector specifying angular impulse to be applied to the entity.
Return Values
None.
Description
Applies an angular impulse to the entity around the center of mass, creating angular velocity.
Examples
! � Apply angular impulse around Y axis
! Entity.ApplyAngularlmpulse( entity, Vector4.Create( 0, 0.1, 0.0) )
See Also
None
Entity. Applylmpulse
Brief
Applies an impulse around a point.
Definition
Entity.Applylmpulse( Entity entity, Vector4 impulse )
Entity.Applylmpulse( Entity entity, Vector4 impulse, Vector4 point )
Arguments
entity - The entity to update.impulse - World space vector specifying impulse (or force) to be applied to the entity.point - World space vector
specifying the point around which the impulse acts.
Return Values
None.
Description
Applies an impulse around a point. If no point is specified, the center of mass of the entity's rigid body is used.
Examples
! � Apply an impulse around the entity's center of mass
i Entity.Applylmpulse( entity, Vector4.Create( 5, 10, 5 ) )
! � Apply an impulse around the origin of world space
? Entity.Applylmpulse( entity, Vector4.Create( 0, 10, 0 ), Vector4.Create( 0, 0, 0 ) )
See Also
None
Entity. AttachPersonLabel
Brief
Attach a person label to the entity.
Definition
! Entity.AttachPersonLabel(Entity entity. Person person, Vector4 offset)
Arguments
person - The person to take the label from.offset - The offset of the label from the entity's position. (Optional. Defaults to 0, 0, 0).
Return Values
Description
This function will detach the person label from the given person, and attach it to the entity instead. Any number of person labels can be attached
to the entity.
Examples
j Entity.AttachPersonLabel(entity, person, labelOffset)
See Also
� Entity.DetachPersonLabel
Entity. AttachToBone
Brief
Attach the entity to the specified bone of its parent.
Definition
Entity.AttachToBone( Entity entity, string boneName )
Arguments
entity - The entity to update.boneName - The name of the bone to attach to or nil to clear it. Can be one of the following:
"pelvis�
"hips"
"leftleg"
"leftfoot"
"rightleg"
"rightfoot"
"spine"
"neck"
"head"
"leftshoulder�
"leftarm"
"leftforearm"
"lefthand"
"rightshoulder"
"rightarm"
"rightforearm"
"righthand"
Return Values
None.
Description
Attach the entity to the specified bone of its parent. In addition to specifying the bone to which the entity is to be attached, it is also necessary to
specify the person to which the bone belongs. This is done by calling Entity.AttachToParent and supplying the desired person.
Examples
entity = Entity.Create()
Entity.AttachToParent( entity, LocalPlayer.GetPerson() )
Entity.AttachToBone( entity, "head" )
See Also
� Entity.Create
� Entity.AttachToParent
� Entity.SetAttachType
Entity. AttachToParent
Brief
Attaches the entity to the specified parent.
Definition
Entity.AttachToParent( Entity child. Entity parent, string boneName = nil )
Entity.AttachToParent( Entity child. Person parent, string boneName = nil )
Arguments
entity - The entity to update.parent - The parent to attach the entity to or nil to remove it.boneName - The name of the bone to attach to, if any.
For a person, it must be from the following list:
"pelvis�
"hips"
"leftleg"
"leftfoot"
"rightleg"
"rightfoot"
"spine"
"neck"
"head"
"leftshoulder�
"leftarm"
"leftforearm"
"lefthand"
"rightshoulder"
"rightarm"
"rightforearm"
"righthand"
Return Values
None.
Description
Attaches the entity to the specified parent. The parent�s world matrix will be applied to the entity so the entity's position, rotation and scale are
relative to the parent. If a bone is specified, the entity will be attached to the specified bone in the parent's skeleton.
Examples
� Parent an entity to an entity
entityl = Entity.Create()
parent = Entity.Create()
Entity.AttachToParent( entityl, parent );
� Parent an entity to a person's right hand
entity2 = Entity.Create()
person = Person.Findlnlnstance( personld )
Entity.AttachToParent( entity2, person, "righthand" )
See Also
� Entity.Create
� Person.Findlnlnstance
� Entity.SetAttachType
Entity. BlendAnimln
Brief
Blends an animation into, and alongside the currently playing animations.
Definition
Entity.BlendAnimln( Entity entity, string resourceName, boolean isLooping = true, number time = 0,
number easeType = AnimBlendType.Linear, number blendDuration = 0.25, number priority = 0, Animation
anim = nil)
Entity.BlendAnimln( Entity entity, Resource animResource, boolean isLooping = true, number time = 0,
number easeType = AnimBlendType.Linear, number blendDuration = 0.25, number priority = 0, Animation
anim = nil)
Arguments
entity - entity to blend animation ontoresourceName - the name of the animation resource to blend inanimResource - the animation resource to
blend inisLooping - flag indicating if the animation played should loop, (default is true)time - point in at which the animation should start playing
from (default is 0.0)easeType - the easing method to be used. The values used are in the enumerated type AnimBlendType (default value is
AnimBlendType.Linear )blendDuration - the period in seconds, over which the blend factor will increase from 0.0 to 1.0 (default is 0.25)priority -
The priority affects where in the animation list an animation will be played. The higher the number, the later it will be played.
If a prior animation is being played at the same priority, then the new animation will be placed after the old animation in the list, (default is 0)anim
if supplied, the animation handle is set to the newly created active animation
Return Values
None.
Description
Values for the ease type are provided by the enumeration AnimBlendType:
AnimBlendType.None
AnimBlendType. Linear
AnimBlendType.SCurve
AnimBlendType. Accelerate
AnimBlendType. Decelerate
Examples
Entity.BlendAnimln( entity, "myAnim" )
Entity.BlendAnimln( entity, "myWalk", true, 0.0, AnimBlendType.Linear, 0.25, 0, animHandleToSave)
See Also
� Entity. GetlndexOfAnim
� Entity. GetActiveAnim
Entity. BlendAnimOut
Brief
Blends the specified active animation out.
Definition
Entity.BlendAnimOut(Entity entity. Animation anim, number easeType = AnimBlendType.Linear, number
blendDuration = 0.25)
Arguments
entity - entity to blend anim out fromanim - animation to blend outeaseType - the blend curve to use when blending out, default is
AnimBlendType.LinearblendDuration - the duration over which the animation is blended out, default is 0.25
Return Values
None.
Description
Begins to blend out a currently active animation. To check the progress of the blend, use Animation.GetBlendState and/or
Animation.GetBlendTime. An invalid animation handle will have no effect.
Examples
local animlndex = Entity.GetlndexOfAnim( entity, "idleAnim" )
local hAnim = Entity.GetActiveAnim( entity, animlndex )
Entity.BlendAnimOut( entity, hAnim, AnimBlendType.Linear, 0.25 )
See Also
� Entity. BlendAnimln
� Entity.GetlndexOfAnim
� Entity.GetActiveAnim
� Entity. PlayAnim
� Animation.GetBlendWeight
Entity.Copy
Brief
Clone an entity's state to another entity.
Definition
! Entity.Copy(Entity dest, Entity source)
Arguments
dest - Destination entity to modify.source - Source entity to copy.
Return Values
None.
Description
Copies all state from the source entity to the destination entity, leaving the source entity unchanged. The only state that will not be copied is
transform state (position and orientation), as having two identical entities in the same place may cause issues with collision and other systems.
The destination entity is still a different entity (it will not compare equal and will have a different unique ID) but will have the same state as the
source entity. Similarly to Reset, the hierarchy state of the destination entity will not be modified; if the script wishes to detach the entity and its
children this must be done explicitly.
Examples
! myDestEntity:Copy(mySourceEntity)
See Also
� Entity. Reset
Entity.Create
Brief
Creates a new entity.
Definition
j Entity Entity.Create()
Arguments
None
Return Values
A new Entity instance.
Description
Creates a new entity.
Examples
! entity = Entity.Create()
See Also
None
Entity.CreateForceAction
Brief
Creates a new 'force' action for an entity.
Definition
number Entity.CreateForceAction( Entity entity, boolean autoEnable = false )
Arguments
entity - The entity to which the action will belong.autoEnable - true to automatically enable the action, false otherwise.
Return Values
A numerical action ID.
Description
Creates a new 'force' action for an entity. If autoEnable is false, the action can be enabled with Entity.EnableAction. This action applies a force to
an entity every physics update. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource")
e:EnableDynamics()
actionld = Entity.CreateForceAction( e, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionForce( e, actionld, f )
See Also
� Entity.CreateTorqueAction
� Entity. CreatePointForceAction
� Entity.EnableAction
� Entity.SetActionForce
Entity.CreatePointForceAction
Brief
Creates a new 'point-force' action for an entity.
Definition
number Entity.CreatePointForceAction( Entity entity, boolean localSpace = true, boolean autoEnable =
i false )
Arguments
entity - The entity to which the action will belonglocalSpace - true to use a local-space point, false to use a world-space point.autoEnable - true to
automatically enable the action, false otherwise.
Return Values
A numerical action ID.
Description
Creates a new 'point-force' action for an entity. If autoEnable is false, the action can be enabled with Entity.EnableAction. This action applies a
force at a given position to an entity. The position can a local-space point or a world-space point. This function is only available if the entity has a
collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource" )
e:EnableDynamics()
actionld = Entity.CreatePointForceAction( e, true, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionForce( e, actionld, f )
Entity.SetActionPosition( e, actionld, p )
See Also
� Entity.CreateTorqueAction
� Entity.CreateForceAction
� Entity.SetActionPosition
Entity.CreateTorqueAction
Brief
Creates a new 'torque' action for an entity.
Definition
number Entity.CreateTorqueAction( Entity entity, boolean autoEnable = false )
Arguments
entity - The entity to which the action will belong.autoEnable - true to automatically enable the action, false otherwise.
Return Values
A numerical action ID.
Description
Creates a new 'torque' action for an entity. If autoEnable is false, the action can be enabled with Entity.EnableAction. This action applies a torque
to an entity every physics update. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e : SetCollision ( ,, kCollisionResource ,, )
e:EnableDynamics()
actionld = Entity.CreateTorqueAction( e, false )
t = Vector4.Create( 10.0, 0.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionTorque( e, actionld, t )
See Also
� Entity.CreateForceAction
� Entity.CreatePointForceAction
� Entity.EnableAction
� Entity.SetActionTorque
Entity.DebugSetAxesVisible
Brief
Sets the entity to show its axis or not.
Definition
Entity.DebugSetAxesVisible( Entity entity, boolean value, boolean recursive, number size = 1)
Arguments
entity - The entity to update.value - If true the entity shows its axis and if false it hides it.recursive - If true the entity also sets the values of all the
children below it.size - The size of the line drawn to represent the axis (in meters).
Return Values
None.
Description
Sets the entity to show its axis or not. Entities default to not show their axis when created. Note that this function is provided for debugging
purposes and should not be used in a finalized script.
Examples
entity = Entity.Create()
Entity.DebugSetAxesVisible( entity, true, true, 1.0 )
See Also
� Entity.DebugSetHierarchyVisible
� Entity.DebugSetCollisionVisible
Entity.DebugSetCollisionVisible
Brief
Sets the entity to show its collision or not.
Definition
! Entity.DebugSetCollisionVisible( Entity entity, boolean value, boolean recursive )
Arguments
entity - The entity to update.value - If true the entity shows its collision shape.recursive - If true the entity also sets the values of all the children
below it.
Return Values
None.
Description
Sets the entity to show its collision or not. Entities default to not show their collision when created. Note that this function is provided for
debugging purposes and should not be used in a finalized script.
Examples
j entity = Entity.Create()
1 Entity.DebugSetCollisionVisible( entity, true, true )
See Also
� Entity.DebugSetAxesVisible
� Entity.DebugSetHierarchyVisible
Entity.DebugSetHierarchyVisible
Brief
Sets the entity to show its hierarchy or not.
Definition
Entity.DebugSetHierarchyVisible( Entity entity, boolean value, boolean recursive )
Arguments
entity - The entity to update.value - If true the entity shows its hierarchy with its immediate children and if false it hides it.recursive - If true the
entity also sets the values of all the children below it.
Return Values
None.
Description
Sets the entity to show its hierarchy or not. Entities default to not show their hierarchy when created. Note that this function is provided for
debugging purposes and should not be used in a finalized script.
Examples
entity = Entity.Create()
Entity.DebugSetHierarchyVisible( entity, true, true )
See Also
� Entity.DebugSetAxesVisible
� Entity.DebugSetCollisionVisible
Entity.DestroyAction
Brief
Destroy an entity action.
Definition
Entity.DestroyAction( Entity entity, number actionld )
Arguments
entity - The entity to which the action belongsactionld - The numerical action ID, obtained at action creation time
Return Values
None.
Description
Destroy an entity action. It is good practice to destroy ail actions when no longer required, however the system will also automatically destroy
them if the target entity is destroyed. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource")
e:EnableDynamics()
actionld = Entity.CreatePointForceAction( e, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionForce( e, actionld, f )
Entity.SetActionPosition( e, actionld, p )
Entity.DestroyAction( e, actionld )
See Also
� Entity.CreateForceAction
� Entity.CreateTorqueAction
Entity.DetachPersonLabel
Brief
Detaches a previously attached person label from the entity.
Definition
Entity.DetachPersonLabel(Entity entity. Person person)
Arguments
person - The person the label was taken from.
Return Values
Description
This function will detach the person label previously attached to the entity, and will re-attach it to the person it was taken from.
Examples
1 Entity.DetachPersonLabel(entity, person)
See Also
� Entity.AttachPersonLabel
Entity.EnableAction
Brief
Make entity action take effect.
Definition
1 Entity.EnableAction( Entity entity, number actionld, boolean enable = true )
Arguments
entity - The entity to which the action belongsactionld - The numerical action IDenable - true to enable the action, false otherwise
Return Values
None.
Description
Make entity action take effect. A disabled action will not be applied to the entity. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource" )
e:EnableDynamics()
actionld = Entity.CreatePointForceAction( e, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld, true )
Entity.SetActionForce( e, actionld, f )
Entity.SetActionPosition( e, actionld, p )
Entity.DestroyAction( e, actionld )
See Also
� Entity. IsActionEnabled
Entity.EnableCollision
Brief
Enables/disables collision on the specified entity.
Definition
Entity.EnableCollision( Entity entity, boolean enable = true, Phys3dWorld world = nil )
Arguments
entity - The entity to update.enable - true to enable collision, false otherwise (defaults to true if not specified).world - The Phys3dWorld to add to
the entity to, or nil to add to the default world.
Return Values
None.
Description
If collision is enabled for the specified entity, the local player's avatar and other physical entities can collide with it, thereby preventing
penetrations. If collision is disabled, the local player's avatar and other physical entities will be able to pass through this entity. Note that the
collision world specified in this call will override the collision world specified to SetCollision, if any; specifying nil here will cause the item to be
removed from the world specified in SetCollision and added to the default Phys3dWorld. Limitation: Although collision can be enabled for
translated and/or rotated entities, scaling is not supported.
Examples
� Turn off collisions
Entity.EnableCollision( entity, false )
� Turn on collisions
Entity.EnableCollision( entity )
See Also
� Entity.EnableDynamics
� Phys3dWorld.Create
Entity.EnableCollisionCallbacks
Brief
Enable or disable collision callbacks for the specified entity.
Definition
Entity.EnableCollisionCallbacks(Entity entity, boolean enable)
Arguments
entity - the entity to enable/disable collision callbacks forenable - enable or disable
Return Values
None.
Description
Enable or disable collision callbacks for the specified entity. Note that in order to receive callbacks, you must register your interest in the particular
type(s) of collision event you want to receive, using Entity.RegisterCollisionCallbackQ. You must also set the maximum contacts using
Entity.SetMaxContacts(). Finally, the entity must have collision set and enabled for the callback(s) to occur. The entity need not have dynamics
enabled as static entities will also report collisions.
Examples
� set up a collision data buffer
Entity.SetMaxContacts( 64 )
foo = Entity.Create()
foo:SetModel("model")
foo:SetCollision("collision" )
foo:SetPosition(Vector4.Create(0, 5, 0))
foo:SetVisible(true)
foo:EnableCollision(true)
foo:EnableDynamics(true)
foo:EnableCollisionCallbacks(true)
foo:RegisterCollisionCallback(EntityCollision.ContactAdded, ContactAddedCallback, foo)
See Also
� Entity. RegisterCollisionCallback
� Entity.SetMaxContacts
� Entity.SetCollision
� Entity.EnableCollision
Entity.EnableDynamics
Brief
Enables/disables dynamics on the specified entity.
Definition
! Entity.EnableDynamics( Entity entity, boolean enable = true )
Arguments
entity - The entity to update.enable - true to enable dynamics, false otherwise (defaults to true if not specified).
Return Values
None.
Description
If dynamics is enabled, the rigid body attached to the entity will be activated in PS Home's physics simulation. If dynamics is disabled, the entity
will become fixed in its current position and will no longer be affected by the simulation. Note that collision must be enabled on the entity if
dynamics is to be enabled. Attempts to set absolute translations or rotations on an entity that has dynamics enabled will be ignored. For this to
succeed, dynamics must be temporarily disabled while the transformation is explicitly applied to the entity. Limitation: This function must not be
called for entities that have been scaled in any way.
Examples
� Turn off dynamics
Entity.EnableDynamics( entity, false )
� Turn on dynamics (collision must be enabled as well)
Entity.EnableCollision ( entity )
Entity.EnableDynamics( entity )
See Also
� Entity.EnableCollision
Entity.EnableDynamicsAutoDeactivation
Brief
Enable/disable auto-deactivation of dynamics on the specified entity.
Definition
Entity.EnableDynamicsAutoDeactivation( Entity entity, boolean enable = true )
Arguments
entity - The entity to update.enable - true to enable auto-deactivation, false otherwise (defaults to true if not specified).
Return Values
None.
Description
Dynamics must be enabled with Entity.EnableDynamicsf) for the activated/deactivated state to take effect. An Entity with activated dynamics is
one that is having it's motion updated. If dynamics are deactivated, Home's physics engine will stop updating the Entity's motion, until it is
activated again. Entities can be activated by another call to Entity.SetDynamicsActive or by the application of forces/torques/impulses or by
coming into contact with other activated Entities. Entities can be deactivated with Entity.SetDynamicsActive or by allowing auto-deactivation which
will deactivate the Entity if it has not been moving for a while. Auto-deactivation can be enabled/disabled with this function.
Examples
� Disable auto-deactivation
Entity.EnableDynamicsAutoDeactivation( entity, false )
� Enable auto-deactivation
Entity.EnableCollision( entity )
Entity.EnableDynamics( entity )
Entity.SetDynamicsActive( entity )
Entity.EnableDynamicsAutoDeactivation( entity )
See Also
� Entity.EnableDynamics
� Entity.SetDynamicsActive
� Entity. IsDynamicsAutoDeactivationEnabled
Entity.EnablelnterpolatedMode
Brief
Enable/disable interpolated mode.
Definition
| Entity.EnablelnterpolatedMode( Entity entity, boolean enable )
Arguments
entity - The entity.enable - true to enable interpolated mode, false otherwise.
Return Values
None
Description
Enable/disable interpolated mode. Interpolated mode can help smooth the motion of dynamic entities, however there is an extra processing
overhead.
Examples
j Entity.EnablelnterpolatedMode( entity, true )
See Also
� Entity. IsinterpolatedModeEnabled
Entity.EnableKeepUpright
Brief
Set whether or not to keep the entity upright.
Definition
! Entity.EnableKeepUpright( Entity entity, boolean keepUpright = true, number softness =0.0 )
Arguments
entity - entity to be affected.keepUpright - true to keep the entity upright, false otherwisesoftness - the softness of the constraint: 0 is strongest, 1
is weakest.
Return Values
None.
Description
Adds a dynamic constraint to try to keep the entity upright. The softness value is only necessary when enabling the keep upright constraint.
Examples
e = Entity.Create()
e:SetCollision("kCollisionResource")
e:EnableCollision()
e:EnableDynamics()
e:EnableKeepUpright( true, 0.1 )
See Also
� Entity.IsKeepUprightEnabled
Entity. EnableLayerCollision
Brief
Set whether or not an entity can collide with collision of the specified layer.
Definition
Entity.EnableLayerCollision( Entity entity, enum layer, boolean enable )
Arguments
entity - The entity.layer - The collision layer (a CollisionLayer enum).enable - true to enabled collision, false otherwise.
Return Values
None.
Description
Set whether or not an entity can collide with collision of the specified layer. Changes will only take effect for new collisions/overlaps. If two objects
are already colliding (or very close), disabling their collisions via this function will not take effect until they separate. Also, if two objects are
overlapping but do not currently collide with each other (due to disabled layer collisions), then enabling their collision via this function will not take
effect until they separate.
Examples
Entity.EnableLayerCollision( entityl. Entity.GetCollisionLayer ( entity2 ), false )
See Also
� Entity.IsLayerCollisionEnabled
Entity. EvaluateAnims
Brief
Evaluates all current animation(s) active on the entity, and updates the skeleton.
Definition
Entity.EvaluateAnims( Entity entity )
Arguments
entity - The entity to update.
Return Values
None.
Description
In the general case, changes made to the animation state on an entity will be reflected in the next frame. In certain situations, a script may wish to
modify the animation list and have it immediately reflected in the current frame. In this event, the script can call this function, and PS Home will
re-evaluate the entire animation blend list on the entity, and apply the results to the entity's skeleton. Use this function sparingly, as this evaluation
is synchronous and significantly slower than the core animation update. Generally the single-frame delay in the normal case can be hidden with
appropriate blending, rather than relying on this function.
Examples
entity = Entity.Create()
Entity.SetModel( entity, "mymodel" )
Entity.SetSkeleton( entity, "myskel" )
Entity.PlayAnim( entity, "myanim" )
function OnUpdateO
if (playlnstantDeathAnim) then
local animlndex = Entity.GetIndexOfAnim( entity, "myanim" )
local anim = Entity.GetActiveAnim( entity, animlndex )
Entity.BlendAnimOut( entity, anim, AnimBlendType.Linear, 0.1 )
Entity.BlendAnimln( entity, "instantDeath", false, 0.0, AnimBlendType.Linear, 0.1, 0)
Entity.EvaluateAnims( entity )
end
end
See Also
None
Entity.FindMaterials
Brief
Get an array of materials on an entity's model.
Definition
Material[] Entity.FindMaterials( Entity entity, string materialld=nil)
Arguments
entity - The entity to search on.materialld - The material's scriptld as set in max/maya, or nil to get all materials on the entity
Return Values
An array of Materials that matches the given materialld, or all materials on the entity if no id is given.
Description
Gets an array of Materials that matches the given materialld, or all materials on the entity if no id is given.
Examples
entity = Entity.Create()
Entity.SetModel( entity, "mymodel" )
allMaterials = Entity.FindMaterials(entity)
print( "Found " .. #allMaterials .. " materials." );
for i, v in ipairs(array) do
print( tostring( v ) )
end
See Also
� Material. GetParam
� Material.SetAlphaRef
� Material.SetBlendMode
� Material.SetMatrix
� Material.SetTexture
� Material.SetVector
Entity.GetActiveAnim
Brief
Returns a handle to a currently active animation
Definition
Animation Entity.GetActiveAnim( Entity entity, number index )
Entity.GetActiveAnim( Entity entity, number index. Animation anim )
Arguments
entity - the entity to accessindex - the index of the animation handle (within the entity's animation list) to retrieve.anim - the animation object to set,
instead of returning a new one
Return Values
If animation is not specified as a parameter, either a handle to the animation, or nil if no current anim.
If an animation is specified as a parameter, there is no return value.
Description
Get a handle to the current active animation. Note that if there is no current active animation and the user has specified an animation object to set,
the animation object will be marked as invalid. To check this, use Animation.IsValid.
Examples
local animlndex = entity:GetlndexOfAnim("myAnim")
local anim = entity:GetActiveAnim( animlndex )
See Also
� Animation.IsValid
� Animation.Create
Entity. GetAngularDamping
Brief
Gets the angular damping of the collision resource attached to the entity.
Definition
! number Entity.GetAngularDamping( Entity entity )
Arguments
entity - The entity to query.
Return Values
The angular damping for the entity.
Description
Gets the angular damping of the collision resource attached to the entity. This function is only valid if the entity has a collision item.
Examples
! local damping = Entity.GetAngularDamping( entity )
See Also
� Entity.EnableCollision
� Entity. EnableDynamics
� Entity. SetCollision
� Entity. SetAngularDamping
Entity.GetAngularVelocity
Brief
Returns the angular velocity around the center of mass of the entity.
Definition
! Vector4 Entity.GetAngularVelocity( Entity entity )
i Entity.GetAngularVelocity( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The Vector4 to store the result to.
Return Values
The entity's current angular velocity.
Description
Returns the angular velocity around the center of mass of the entity's rigid body in world space. The W component of the returned vector is zero.
If outVec is specified it stores the result in there instead of returning a new Vector4.
Examples
� Add the entity to the physics simulation
Entity.EnableCollision ( entity, true )
Entity.EnableDynamics( entity, true )
� Query the angular velocity
angularVel = Entity.GetAngularVelocity( entity )
See Also
� Entity.GetLinearVelocity
Entity.GetBoneCount
Brief
Get the number of bones in the entity's skeleton.
Definition
number Entity.GetBoneCount(Entity entity)
Arguments
entity - Entity to query.
Return Values
Number of bones in the skeleton, or 0 if the entity has no skeleton attached.
Description
Retrieves the number of bones/joints in the entity's skeleton. If no skeleton is present, 0 is returned.
Examples
! local boneCount = myEntity:GetBoneCount()
See Also
� Entity.GetBonelndex
Entity. GetBonelndex
Brief
Find the index of a bone in the entity's skeleton.
Definition
number Entity.GetBonelndex(Entity entity, string boneName)
Arguments
entity - Entity to query.boneName - Name of bone to locate.
Return Values
The index of the bone in the skeleton (in range 1 - GetBoneCount()), or 0 if not found.
Description
Retrieves the index of the specified bone/joint in the entity's skeleton. The index is 1 -based. If the bone cannot be found, or there is no skeleton
attached, 0 is returned.
Examples
! local leftHandlndex = myEntity:GetBonelndex("lefthand")
See Also
� Entity.GetBoneCount
� Entity.GetBoneLocalMatrix
� Entity.GetBoneWorldMatrix
Entity.GetBoneLocalMatrix
Brief
Get the local transform matrix for a bone in the skeleton.
Definition
! Entity.GetBoneLocalMatrix(Entity entity, string|number bone, Matrix44 result)
Arguments
entity - Entity to query.bone - Bone name or index.result (out) - Matrix44 value to store result into.
Return Values
None.
Description
Retrieve the local-space transform matrix for a specified bone in the skeleton. If the bone is not found an error will result. Retrieving the matrix by
index will be more efficient if done more than once.
Examples
local mat = Matrix44.Create()
myEntity:GetBoneLocalMatrix("lefthand", mat)
� or
local leftHandlndex = myEntity:GetBonelndex("lefthand")
myEntity:GetBoneLocalMatrix(leftHandlndex, mat)
See Also
� Entity.GetBoneWorldMatrix
� Entity.GetBonelndex
Entity.GetBoneWorldMatrix
Brief
Get the world transform matrix for a bone in the skeleton.
Definition
Entity.GetBoneWorldMatrix(Entity entity, string|number bone, Matrix44 result)
Arguments
entity - Entity to query.bone - Bone name or index.result (out) - Matrix44 value to store result into.
Return Values
None.
Description
Retrieve the world-space transform matrix for a specified bone in the skeleton. If the bone is not found an error will result. Retrieving the matrix by
index will be more efficient if done more than once.
Examples
local mat = Matrix44.Create()
myEntity:GetBoneWorldMatrix("lefthand", mat)
� or
local leftHandlndex = myEntity:GetBonelndex("lefthand")
myEntity:GetBoneWorldMatrix(leftHandlndex, mat)
See Also
� Entity.GetBoneLocalMatrix
� Entity.GetBonelndex
Entity.GetCenterOfMassLocal
Brief
Returns the position of the entity's center of mass in local space.
Definition
Vector4 Entity.GetCenterOfMassLocal( Entity entity )
Entity.GetCenterOfMassLocal( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The Vector4 to store the result to.
Return Values
The position of the entity's center of mass in local space.
Description
Returns the position of the entity's center of mass in local space. This may be offset from the coordinate origin of the entity depending on its
physics configuration. If outVec is specified it is used to store the result instead of returning a new Vector4. This function is only available if the
entity has a collision item.
Examples
print( "Entity COM = " .. Entity.GetCenterOfMassLocal( entity ) )
See Also
� Entity. EnableDynamics
� Entity.GetCenterOfMassLocal
Entity.GetCenterOfMassWorld
Brief
Returns the position of the entity's center of mass in world space.
Definition
Vector4 Entity.GetCenterOfMassWorld( Entity entity )
Entity.GetCenterOfMassWorld( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The Vector4 to store the result to.
Return Values
The position of the entity's center of mass in world space.
Description
Returns the position of the entity's center of mass in world space. This may differ from the position of the entity depending on its physics
configuration. If outVec is specified it stores the result in there instead of returning a new Vector4.
Examples
! print( "Entity COM = " .. Entity.GetCenterOfMassWorld( entity ) )
See Also
� Entity.EnableDynamics
Entity.GetChildren
Brief
Get an array of the child entities of a specified entity.
Definition
table Entity.GetChildren(Entity entity)
Arguments
entity - entity to obtain children from.
Return Values
An array of the child entities of the specified entity.
Description
If an entity has had children attached using Entity.AttachToParent, this function will return an array of all the child entities, in the order in which
they were attached. If there are no children, an empty table will be returned.
Examples
parent = Entity.Create()
childl = Entity.Create()
child2 = Entity.Create()
childl:AttachToParent(parent)
child2:AttachToParent(parent)
children = parent:GetChildren()
print(#children) � prints 2 , children[1] == childl and children[2] == child2
print(#childl:GetChildren()) � prints 0, childl has no children
See Also
� Entity.AttachToParent
� Entity.GetParent
� Entity.GetSiblings
Entity.GetCloth
Brief
Retrieve a handle to the entity's cloth meshes, if any.
Definition
Cloth Entity.GetCloth(Entity entity)
Arguments
entity - Entity to query.
Return Values
A Cloth object, or nil if the entity has no model or model contains no cloth elements.
Description
If the entity's model contains cloth elements, this function can be used to obtain a handle to the cloth elements to alter their parameters. All cloth
elements in the model are modified when using the cloth handle.
Examples
myEntity:SetModel("ModelWithCloth")
local cloth = myEntity:GetCloth()
if (cloth) then
cloth:SetWindAngle(135)
end
See Also
� Cloth.SetWindAngle
Entity.GetCollisionLayer
Brief
Query the collision layer of an entity.
Definition
! enum Entity.GetCollisionLayer( Entity entity )
Arguments
entity - The entity.
Return Values
The collision layer (a CollisionLayer enum).
Description
Query the collision layer of an entity.
Examples
i print( "collisionLayer="..Entity.GetCollisionLayer( entity )
See Also
� Entity.SetCollisionLayer
Entity.GetContactCount
Brief
Retrieve the number of contacts passed to a collision callback.
Definition
! number Entity.GetContactCount()
Arguments
None
Return Values
Number of contacts passed to collision callback.
Description
Retrieve the number of contacts available in a collision callback. This function is only valid inside a collision callback.
Examples
function ContactAddedCallback(entity)
local numContacts = Entity.GetContactCount()
print(numContacts .. ' contacts added')
end
See Also
� Entity.GetContactPoint
� Entity.GetContactEntity
� Entity.GetContactRelVelocity
� Entity.GetContactld
Entity.GetContactEntity
Brief
Retrieve the other entity that has been contacted in a collision.
Definition
! Entity Entity.GetContactEntity(number index)
Arguments
index - index of the contact point
Return Values
The contacted entity, or nil in a collision with the world.
Description
Retrieve the other entity contacted in a collision, that is, the entity that is not reporting the collision. In a collision with world geometry or another
physics object not owned by an Entity, nil is returned. It is important to realise that the entity returned is not the exact same entity instance from
Lua's perspective. It will compare equal using == or ~=, and all API functions are available, but if used as a table key it will not match the "original''
entity. If you wish to match the entities using a table, it is recommended to insert them using a unique key based on the entity itself. Note that this
function is only valid from within a collision callback, and will not be available for ContactRemoved callbacks.
Examples
function ContactAddedCallback(entity)
local numContacts = Entity.GetContactCount ()
for i = 1, numContacts do
local entity = Entity.GetContactEntity(i)
if (entity == nil) then
print("I've hit the world!\n")
end
end
end
See Also
� Entity.GetContactCount
� Entity.GetContactPoint
� Entity.GetContactRelVelocity
Entity. GetContactld
Entity.GetContactld
Brief
Retrieve the unique contact ID.
Definition
number Entity.GetContactld(number index)
Arguments
index - index of the contact point
Return Values
The contact ID.
Description
Retrieve the unique ID number assigned the contact. This number will be preserved across multiple frames and so can be used to track individual
contacts over the duration of the collision. Do not make any assumptions about the ID numbers returned. Note that this function is only valid from
within a collision callback.
Examples
function ContactProcessCallback(entity)
local numContacts = Entity.GetContactCount ()
for i = 1, numContacts do
local id = Entity.GetContactld(i)
UpdateContactTracker(id) � do something with contacts being tracked
end
end
See Also
Entity.GetContactPoint
Brief
Retrieve the position and/or normal of the specified contact.
Definition
Entity.GetContactPoint(number index, Vector4 position = nil, Vector4 normal = nil)
Arguments
index - index of the contact pointposition - Vector4 to store the position into, or nil if unwantednormal - Vector4 to store the normal into, or nil if
unwanted
Return Values
None.
Description
Retrieve the position and/or normal of a contact, specified by an index which must be between 1 and the contact count. Passing nil to position
and/or normal will skip retrieval of that value. Both values will be given in world space. Note that this function is only valid from within a collision
callback, and will not be available for ContactRemoved callbacks.
Examples
function ContactAddedCallback(entity)
local numContacts = Entity.GetContactCount ()
local pos = Vector4.Create ()
local norm = Vector4.Create()
for i = l r numContacts do
Entity.GetContactPoint(i, pos, norm)
SpawnlmpactEffeet(pos, norm) � user function to spawn an impact particle effect
end
end
See Also
� Entity.GetContactCount
� Entity.GetContactEntity
� Entity.GetContactRelVelocity
� Entity.GetContactld
Entity.GetContactRelVelocity
Brief
Retrieve the relative velocity of the colliding objects.
Definition
number Entity.GetContactRelVelocity(number index)
Arguments
index - index of the contact point
Return Values
The relative velocity, projected onto the contact normal.
Description
Retrieve the relative velocity of the colliding objects, projected onto the contact normal. Note that the value may be negative or positive. Note also
that this function is only valid from within a collision callback, and only in reponse to the ContactAdded event.
Examples
function ContactAddedCallback(entity)
local numContacts = Entity.GetContactCount()
local pos = Vector4.Create()
local norm = Vector4.Create()
for i = 1, numContacts do
local relVel = math.abs(Entity.GetContactRelVelocity(i))
Entity.GetContactPoint(i, pos, norm)
if (relVel > 10) then
SpawnBigParticle(pos, norm)
else
SpawnSmallParticle(pos, norm)
end
end
end
See Also
Entity.GetContactUserld
Brief
Retrieve the user ID of the part of a party (entity or collision geometry) involved in a contact.
Definition
number, number Entity.GetContactUserld(number contactIndex)
number Entity.GetContactUserld(number contactlndex, number partylndex)
Arguments
contactlndex - index of the contact pointpartylndex - index of the party; 1 or 2
Return Values
In the first usage, both user IDs in order, or the single user ID requested in the second usage. If a value is
nil, no user ID is available.
Description
Retrieve the user ID(s) of the part of a party (entity or collision geometry) involved in a contact. Note that this function is only valid from within a
collision callback. Note that there are two collision items involved in a contact, so there are two corresponding user IDs. The user IDs are ordered
such that party 1 is the entity registered for collision callbacks, and party 2 is the other collision item.
Examples
function ContactProcessCallback(entity)
local numContacts = Entity.GetContactCount()
for i = 1, numContacts do
local idA = Entity.GetContactUserld(i, 1)
local idB = Entity.GetContactUserld(i, 2)
� or local idA, idB = Entity.GetContactUserld(i)
if idA == 100 then
print("UserlD 100 has been hit!")
end
end
end
See Also
Entity.GetCullDistance
Brief
Get the cull distance for an entity.
Definition
! number Entity.GetCullDistance(Entity entity)
Arguments
entity - The entity to modify.
Return Values
The cull distance of the entity, or 0 if disabled.
Description
Get the cull distance of an entity set with SetCullDistance.
Examples
! if (myEntity:GetCullDistance() > 500) then
print("This entity has a very large cull distance!")
| end
See Also
� Entity.SetCullDistance
Entity.GetGravity
Brief
Query the gravity vector of the entity.
Definition
Vector4 Entity.GetGravity( Entity entity )
Entity.GetGravity( Entity entity, Vector4 gravityVectorOut )
Arguments
entity - entity to be queried.gravityVectorOut - gravity vector storage.
Return Values
The gravity vector
Description
Query the gravity vector of the entity. This function is only valid if the entity has a collision item.
Examples
� first form
print( Entity.GetGravity( entity ) )
� second form
local grav = Vector4.Create()
Entity.GetGravity( entity, grav )
print( grav )
See Also
� Entity.SetGravity
Entity. GetlndexOfAnim
Brief
Find the index of the active animation that is using the specified animation resource.
Definition
number Entity.GetIndexOfAnim( Entity entity, string resourceName, number startlndex = 1 )
Arguments
entity - the entity to queryresourceName - the name of the animation we are looking forstartlndex - index to begin search at
Return Values
The index of the animation being queried, or nil if not found.
Description
The start index is provided so that multiple searches can be made if the same resorce is being played multiple times.
Examples
; local animlndex = Entity.GetlndexOfAnim( myEntity, "myAnim" )
See Also
� Entity. GetActiveAnim
� Entity. BlendAnimln
� Entity. BlendAnimOut
� Entity. StopAnim
Entity. GetLinearDamping
Brief
Gets the linear damping of the collision resource attached to the entity.
Definition
number Entity.GetLinearDamping( Entity entity )
Arguments
entity - The entity to query.
Return Values
The linear damping for the entity.
Description
Gets the linear damping of the collision resource attached to the entity. This function is only valid if the entity has a collision item.
Examples
I local damping = Entity.GetLinearDamping( entity )
See Also
� Entity.EnableCollision
� Entity. EnableDynamics
� Entity.SetCollision
� Entity. SetLinearDamping
Entity.GetLinearVelocity
Brief
Returns the linear velocity of the entity.
Definition
! Vector4 Entity.GetLinearVelocity( Entity entity )
! Entity.GetLinearVelocity( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The vector to write the result to.
Return Values
The entity's current linear velocity.
Description
Returns the linear velocity of the center of mass of the entity's rigid body in world space. The W component of the returned vector is zero. If
outVec is specified it stores the result in there instead of returning a new Vector4.
Examples
� Add the entity to the physics simulation
Entity.EnableCollision ( entity, true )
Entity.EnableDynamics( entity, true )
� Query the linear velocity
linearVel = Entity.GetLinearVelocity( entity )
See Also
� Entity. GetAngularVelocity
Entity. GetLocalBounds
Brief
Retrieve the local-space bounds of an entity's model.
Definition
Entity.GetLocalBounds(Entity entity, Vector4 min, Vector4 max)
Arguments
entity - The entity to query.min (out) - Vector4 to receive the minimum extents.max (out) - Vector4 to receive the maximum extents.
Return Values
None.
Description
This function will retrieve the local-space bounds of the entity's model. If no model is set then an error will be raised. The returned vectors indicate
the minimum and maximum extents on each axis in local space, and define an axis-aligned bounding box. The W components will be 1.
Examples
Vector4 min = Vector4.Create()
Vector4 max = Vector4.Create()
myEntity:GetLocalBounds(min, max)
local center = (min + max) * 0.5
local extents = max - center
See Also
� Entity.GetWorldBounds
Entity.GetLocalMatrix
Brief
Returns the current local transformation matrix of the entity.
Definition
Matrix44 Entity.GetLocalMatrix( Entity entity )
Entity.GetLocalMatrix( Entity entity, Matrix44 outMat )
Arguments
entity - The entity to query.outMat - The Matrix44 to store the result to.
Return Values
The current local matrix of the entity.
Description
Returns the current local transformation matrix of the entity. This matrix is relative to the coordinate system of the entity's parent, if one exists. If
the entity has no parent, the matrix is relative to the world space coordinate system. If outMat is specified it stores the result in there instead of
returning a new Matrix44.
Examples
entity = Entity.Create()
mat = Entity.GetLocalMatrix( entity )
print( mat )
See Also
� Entity.Create
Entity.GetMass
Brief
Returns the mass of the collision resource attached to the entity.
Definition
number Entity.GetMass( Entity entity )
Arguments
entity - The entity to query.
Return Values
The mass of the collision resource attached to the entity.
Description
Gets the mass of the rigid body that is attached to the entity. This function can only be called if the entity has a collision resource.
Examples
! local mass = Entity.GetMass( entity )
See Also
� Entity.EnableCollision
� Entity. EnableDynamics
� Entity.SetColiision
� Entity.SetMass
Entity.GetNumActiveAnims
Brief
Returns the number of active animations currently being played on the specified entity.
Definition
! number Entity.GetNumActiveAnims( Entity entity )
Arguments
entity - the entity to query
Return Values
The number of active anims running.
Description
Returns the number of active animations currently being played on the specified entity.
Examples
! local numAnims = Entity.GetNumActiveAnims( myEntity )
See Also
None
Entity.GetParent
Brief
Get the parent entity for the specified entity, if any.
Definition
Entity Entity.GetParent(Entity entity)
Arguments
entity - entity to obtain parent from.
Return Values
The parent entity, or nil if no parent.
Description
If an entity has been attached to another entity using Entity.AttachToParent, the parent entity can be retrieved with this function.
Examples
! parent = Entity.Create()
i entity = Entity.Create()
| entity:AttachToParent(parent)
if (entity:GetParent () == parent) then
print("Attached!") � prints Attached!
| end
L_I
See Also
Entity.AttachToParent
� Entity.GetChildren
� Entity.GetSiblings
Entity.GetPointVelocity
Brief
Returns the velocity of a point on a physics collision item.
Definition
Vector4 Entity.GetPointVelocity( Entity entity, Vector4 point )
Entity.GetPointVelocity( Entity entity, Vector4 point, Vector4 outVec )
Arguments
entity - The entity to query.point - The point of which you wish to know the velocity.outVec - The Vector4 to store the result to.
Return Values
The velocity of the point on the rigid body.
Description
Returns the velocity of a point on a physics collision item in world space. If outVec is specified it stores the result it is used to store the result
instead of returning a new Vector4. This function is only available if the entity has a collision item.
Examples
j print( "Point velocity lm up = " .. Entity.GetPointVelocity( entity, Vector4.Create( 0, 1, 0 ) )
See Also
� Entity. EnableDynamics
Entity.GetPosition
Brief
Returns the entity's position.
Definition
Vector4 Entity.GetPosition( Entity entity )
Entity.GetPosition( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The Vector4 to store the result to.
Return Values
The entity's position.
Description
Returns the entity's position. If the entity has a parent, the returned position is relative to the parent's coordinate system. If outVec is specified it
stores the result in there instead of returning a new Vector4.
Examples
print( "Entity position = " .. Entity.GetPosition( entity ) )
See Also
None
Entity.GetRotationQuat
Brief
Gets the rotation as a quaternion.
Definition
Quaternion Entity.GetRotationQuat( Entity entity )
Entity.GetRotationQuat( Entity entity, Quaternion outQuat )
Arguments
entity - The entity to query.outQuat - The Quaternion to store the result to.
Return Values
The rotation of the entity in quaternion form, or none using the second syntax.
Description
Gets the rotation of the entity in quaternion form. If outQuat is specified it is used for storing the result instead of returning a new Quaternion.
Examples
j entity = Entity.Create()
i rotation = entity:GetRotationQuat()
See Also
� Entity.SetRotationQuat
Entity.GetRotationXyz
Brief
Gets the rotation about the x, y, and z-axis in degrees.
Definition
Vector4 Entity.GetRotationXyz( Entity entity )
Entity.GetRotationXyz( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The Vector4 to store the result to.
Return Values
The XYZ-ordered axis rotation of the entity.
Description
Gets the rotation about the x, y, and z-axis of the entity's local coordinate system in degrees. The rotation order is x, y, z. The W component of the
returned vector is set to 0.0. If outVec is specified it stores the result in there instead of returning a new Vector4.
Examples
j entity = Entity.Create()
i rotation = Entity.GetRotationXyz( entity )
See Also
� Entity.SetRotationXyz
Entity.GetScale
Brief
Returns the entity's scale.
Definition
Vector4 Entity.GetScale( Entity entity )
Entity.GetScale( Entity entity, Vector4 outVec )
Arguments
entity - The entity to query.outVec - The Vector4 to store the result to.
Return Values
The entity's scale.
Description
Returns the entity's scale. If the entity has a parent, the returned scale is relative to the parent's coordinate system. If outVec is specified it stores
the result in there instead of returning a new Vector4.
Examples
! print( "Entity scale = " .. Entity.GetScale( entity ) )
See Also
� Entity.AttachToParent
� Entity.SetScale
Entity.GetSiblings
Brief
Get an array of the sibling entities of a specified entity.
Definition
table Entity.GetSiblings(Entity entity)
Arguments
entity - entity to obtain siblings from.
Return Values
An array of the sibling entities of the specified entity.
Description
If an entity has been attached to a parent entity using Entity.AttachToParent, this function will return an array of all other entities attached to the
same parent, excluding this entity. If this entity is the only child, the table will be empty.
Examples
parent = Entity.Create()
childl = Entity.Create()
child2 = Entity.Create()
childl:AttachToParent(parent)
child2:AttachToParent(parent)
childlSiblings = childl:GetSiblings()
child2Siblings = child2:GetSiblings()
if (childlSublings[1] ~= child2 or child2Siblings[1] ~= childl) then
error("This will never happen")
end
See Also
� Entity.AttachToParent
� Entity.GetParent
� Entity.GetChildren
Entity.GetUniqueld
Brief
Returns a unique integer ID that identifies the entity.
Definition
number Entity.GetUniqueld(Entity entity)
Arguments
entity - The entity to query.
Return Values
A unique integer ID value.
Description
The integer ID returned is guaranteed to be unique for all currently active entities on the local client, and it is guaranteed that if entityl == entity2
is true, then entityl :GetUniqueld() == entity2:GetUniqueld() is also true, and vice versa. No assumptions should be made about the nature of the
ID value, and it is not guaranteed to be persistent or reproducible across instances or PS Home versions. Note that the ID value isn't replicated in
any way, it only applies to local entities.
Examples
local hitEntity = raycast:GetHitEntity()
if (myEntityTable[ hitEntity:GetUniqueld() ] == nil) then
print("New entity hit!")
myEntityTable[ hitEntity:GetUniqueld() ] = hitEntity
end
See Also
None
Entity.GetWorldBounds
Brief
Retrieve the world-space bounds of an entity's model.
Definition
Entity.GetWorldBounds(Entity entity, Vector4 min, Vector4 max)
Arguments
entity - The entity to query.min (out) - Vector4 to receive the minimum extents.max (out) - Vector4 to receive the maximum extents.
Return Values
None.
Description
This function will retrieve the world-space bounds of the entity's model. If no model is set then an error will be raised. The returned vectors
indicate the minimum and maximum extents on each axis in world space, and define a world-space axis-aligned bounding box. The W
components will be 1. NOTE: the world bounds are only updated when the model renders. Thus if you move the object in current frame, the world
bounds will be out of date until the following frame. If you wish to compute up to date world bounds in this specific case, transform the local
bounds and take the AABB of the OBB thus formed.
Examples
Vector4 min = Vector4.Create()
Vector4 max = Vector4.Create()
myEntity:GetWorldBounds(min, max)
local center = (min + max) * 0.5
local extents = max - center
See Also
� Entity.GetLocalBounds
Entity. GetWorldMatrix
Brief
Returns the current world matrix of the entity.
Definition
Matrix44 Entity.GetWorldMatrix( Entity entity )
Entity.GetWorldMatrix( Entity entity, Matrix44 outMat )
Arguments
entity - The entity to query.outMat - The Matrix44 to store the result to.
Return Values
The current world matrix of the entity.
Description
Returns the current world matrix of the entity. If outMat is specified it stores the result in there instead of returning a new Matrix44.
Examples
j entity = Entity.Create()
; mat = Entity.GetWorldMatrix( entity )
j print( mat )
See Also
� Entity.Create
Entity.HasActiveAnims
Brief
Indicates if there are any active animations on the entity.
Definition
boolean Entity.HasActiveAnims( Entity entity )
Arguments
entity - the entity to query
Return Values
True if there are any active animations being played on the entity, or false if not.
Description
This function is more efficient than checking if Entity.GetNumActiveAnims() is 0.
Examples
! if ( Entity.HasActiveAnims( myEntity ) ) then
Entity.StopAnim( myEntity )
| end
See Also
Entity. BlendAnimln
� Entity. BlendAnimOut
� Entity.GetlndexOfAnim
� Entity.GetActiveAnim
Entity. IsActionEnabled
Brief
Query whether entity action is enabled.
Definition
! boolean Entity.IsActionEnabled( Entity entity, number actionld )
Arguments
entity - The entity to which the action belongsactionld - The numerical action ID
Return Values
true if enabled, false otherwise
Description
Query whether an entity action is currently enabled.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource" )
e:EnableDynamics()
actionld = Entity.CreatePointForceAction( e, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld, true )
print( Entity.IsActionEnabled( e, actionld ) )
Entity.SetActionForce( e, actionld, f )
Entity.SetActionPosition( e, actionld, p )
Entity.DestroyAction( e, actionld )
See Also
� Entity.EnableAction
Entity.lsDynamicsActive
Brief
Query whether dynamics is active on the specified entity.
Definition
boolean Entity.IsDynamicsActive( Entity entity )
Arguments
entity - The entity to update.
Return Values
true if dynamics is active, false otherwise.
Description
Query whether dynamics is active on the specified entity. See Entity.SetDynamicsActive documentation for more information. This function is only
valid if the entity has a collision item.
Examples
� Activate dynamics (collision must be enabled as well)
Entity.EnableCollision( entity )
Entity.EnableDynamics( entity )
Entity.SetDynamicsActive( entity )
print( Entity.IsDynamicsActive( entity ) )
See Also
� Entity.EnableDynamics
� Entity.SetDynamicsActive
Entity.lsDynamicsAutoDeactivationEnabled
Brief
Query whether auto-deactivation of dynamics is enabled on the specified entity.
Definition
boolean Entity.IsDynamicsAutoDeactivationEnabled( Entity entity )
Arguments
entity - The entity to update.
Return Values
true if enabled, false otherwise.
Description
Query whether auto-deactivation of dynamics is enabled on the specified entity. See Entity.EnableDynamicsAutoDeactivation for more
information.
Examples
� Enable auto-deactivation
Entity.EnableCollision ( entity )
Entity.EnableDynamics( entity )
Entity.SetDynamicsActive( entity )
Entity.EnableDynamicsAutoDeactivation( entity )
print( ( Entity.IsDynamicsAutoDeactivationEnabled( entity ) ) )
See Also
Entity. EnableDynamics
� Entity.SetDynamicsActive
� Entity. EnableDynamicsAutoDeactivation
Entity.IsInterpolatedModeEnabled
Brief
Query whether or not interpolated mode is enabled.
Definition
! boolean Entity.IsInterpolatedModeEnabled( Entity entity )
Arguments
entity - The entity.
Return Values
true if interpolated mode is enabled, false otherwise.
Description
Query whether or not interpolated mode is enabled. Interpolated mode can help smooth the motion of dynamic entities, particularly those that are
directly controlled by the user; however, there is an extra processing overhead.
Examples
! print( Entity.IsInterpolatedModeEnabled( entity ) )
See Also
� Entity.EnablelnterpolatedMode
Entity. IsKeepUprightEnabled
Brief
Query whether or not the entity is being kept upright.
Definition
! boolean Entity.IsKeepUprightEnabled( Entity entity )
Arguments
entity - entity to be queried.
Return Values
true if the entity is being kept upright, false otherwise.
Description
Query whether or not the entity is being kept upright, e = Entity.Create() e:SetCollision("kCollisionResource") e:EnableCollision()
e:EnableDynamics() e:EnableKeepUpright( true, 0.1 ) print( e:lsKeepUprightEnabled())
Examples
! Entity.EnableKeepUpright
See Also
None
Entity.IsLayerCollisionEnabled
Brief
Query whether or not an entity can collide with collision of the specified layer.
Definition
! boolean Entity.IsLayerCollisionEnabled( Entity entity, enum layer )
Arguments
entity - The entity.layer - The collision layer (a CollisionLayer enum).
Return Values
true if collision is enabled, false otherwise.
Description
Query whether or not an entity can collide with collision of the specified layer.
Examples
: print( Entity.IsLayerCollisionEnabled( entityl, Entity.GetCollisionLayer( entity2 ) ) )
See Also
� Entity.EnableLayerCollision
Entity.IsVisible
Brief
Indicates if the entity is currently marked as visible.
Definition
! Entity.IsVisible(Entity entity)
Arguments
entity - the entity to query.
Return Values
true if the object is marked as visible, false otherwise.
Description
An entity can be marked as invisible for several reasons: the script can do so using SetVisible, entities attached to a person that is invisible or too
close to the camera, and entities that represent scene objects hidden by the client (for example, active furniture during removal). This function will
indicate whether an entity has been marked invisible for any reason. It is not possible to tell from the return value why the entity is invisible, but it
may be helpful to a script if it is desired to hide other entities/effects when one entity is invisible. It is not required to check this for all entities, as
only entities attached to scene objects as indicated above can be affected outside the script's control. Visibility is also inherited, so children of an
invisible entity are automatically made invisible also, and this functionality should be leveraged if it is desired to hide groups of entities when a
parent entity is made invisible for any reason.
Examples
if (not Active.GetEntity():IsVisible()) then
� active has been hidden, pause our special unattached particle effects
PauseParticles()
end
See Also
� Active.GetEntity
� Entity.SetVisible
Entity. LookAt
Brief
Rotate an entity to look at a specified point.
Definition
Entity.LookAt( Entity entity, Vector4 targetPoint, Vector up=[0,l,0,0] )
Arguments
entity - The entity to update.targetPoint - The point to look at, in the entity's parent space.up - The up vector of the entity, in the entity's parent
space.
Return Values
None.
Description
Rotate the entity to look at the specified point. The entity looks down its forward/front vector, the z-axis. Note that this is a one-off reorientation of
the entity, it will not track the look-at point if the entity (or its parent) moves.
Examples
! entity = Entity.Create()
Entity.LookAt( entity, Vector4.Create( 0.5, 0.5, 0 ) )
See Also
� Entity.Create
� Vector4. Create
Entity. LookAtWorld
Entity.LookAtWorld
Brief
Rotate an entity to look at a specified point in world space.
Definition
! Entity.LookAtWorld( Entity entity, Vector4 targetPoint, Vector up=[0,l,0,0] )
Arguments
entity - The entity to update.targetPoint - The point to look at in world space.up - The up vector of the entity in world space.
Return Values
None.
Description
Rotate the entity to look at the specified point in world space. The entity looks down its forward/front vector, the z-axis. Note that this is a one-off
reorientation of the entity, it will not track the look-at point if the entity (or its parent) moves.
Examples
1 entity = Entity.Create()
j Entity.LookAtWorld( entity, Vector4.Create( 0.5, 0.5, 0 ) )
See Also
� Entity.Create
� Vector4.Create
� Entity.LookAt
Entity.ParticlelsAlive
Brief
Returns true if particle effect is still alive.
Definition
! boolean Entity.ParticlelsAlive( Entity entity )
Arguments
entity - The entity to query.
Return Values
true if any particles are still active, false otherwise.
Description
Returns true if particle effect is still alive.
Examples
entity = Entity.Create()
Entity.ParticleSetEffeet( entity, "myparticle" )
if Entity.ParticlelsAlive( entity ) then
print( "Particle system still active!" )
end
See Also
� Entity.Create
� Entity. ParticleSetEffect
Entity.ParticleReset
Brief
Resets the particle effect.
Definition
Entity.ParticleReset( Entity entity )
Arguments
entity - The entity to update.
Return Values
None.
Description
Resets the particle effect by clearing the particle buffer and resetting time to 0.0.
Examples
! entity = Entity.Create()
| Entity.ParticleSetEffeet( entity, "myparticle" )
j Entity.ParticleReset( entity )
See Also
� Entity.Create
� Entity. ParticleSetEffect
Entity.ParticleSetAttachType
Brief
Sets how the particle is attached to the entity's world matrix.
Definition
Entity.ParticleSetAttachType( Entity entity, string type )
Arguments
entity - The entity to update.type - The type of attachment the entity has over the particle effect. Can be one of the following:
"render"
"emitter"
Return Values
None.
Description
Sets how the particle is attached to the entity's world matrix. Can be one of the following: "render" - The entity's world matrix is used as the render
matrix of the particle effect. This is the default, "emitter� - The entity's world matrix is used as the emitter matrix of the particle effect.
Examples
e = Entity.Create()
Entity.ParticleSetEffeet( e, "flaming_torch" )
Entity.ParticleSetAttachType( e, "emitter" )
See Also
� Entity. ParticleSetEffect
Entity.ParticleSetEffect
Brief
Sets the entity's particle effect.
Definition
Entity.ParticleSetEffeet( Entity entity, string resourceName )
Entity.ParticleSetEffeet( Entity entity. Resource particleResource )
Arguments
entity - The entity to update.resourceName - The resource name of the particle effect or nil to remove it.particleResource - The particle effect
resource or nil to remove it.
Return Values
None.
Description
Sets the entity's particle effect to the named resource as specified in the HDK's Object Editor application.
Examples
! entity = Entity.Create()
i Entity.ParticleSetEffeet( entity, "myparticle" )
See Also
None
Entity.ParticleSetEmitting
Brief
Starts/Stops particle emission.
Definition
Entity.ParticleSetEmitting( Entity entity, boolean value )
Arguments
entity - The entity to update.value - true to enable emission and false to stop emission.
Return Values
None.
Description
Starts/Stops particle emission.
Examples
| entity = Entity.Create()
Entity.ParticleSetEffeet( entity, "myparticle" )
j Entity.ParticleSetEmitting( entity, false )
See Also
� Entity.Create
Entity.ParticleSetUpdate
Brief
Starts/stops particle updating.
Definition
Entity.ParticleSetUpdate( Entity entity, boolean value )
Arguments
entity - The entity to update.value - true to enable particle updates and false to disable them.
Return Values
None.
Description
Starts/stops particle updating. This effectively starts/stops time.
Examples
! entity = Entity.Create()
Entity.ParticleSetEffeet( entity, "myparticle" )
| Entity.ParticleSetUpdate( entity, false )
See Also
� Entity.Create
� Entity. ParticleSetEffect
Entity.ParticleSetUserParam
Brief
Sets a user parameter in the particle system
Definition
boolean Entity.ParticleSetUserParam( Entity entity, string paramName, number paramValue )
boolean Entity.ParticleSetUserParam( Entity entity, string paramName, Vector4 paramValue )
Arguments
entity - The entity to update.paramName - The name of the parameter to set in the particle graph.paramValue - The value to set.
Return Values
true if the assignment was made, false if parameter not present in particle system.
Description
The particle editor tool allows for input of user parameters from runtime code. Access this via the "HomeLua..." nodes in the particle editor. There
are many supported types. 1->4 float components. (Scalar, Scale, Vector, Colour, etc...) The Scalar types can use the number or Vector4
interface. All other types need to use the Vector4 interface.
Examples
entity = Entity.Create()
Entity.ParticleSetEffeet( entity, "myparticle" )
Entity.ParticleSetUserParam( entity, "homelua_scalarl"
Entity.ParticleSetUserParam( entity, "homelua_scalar2"
Entity.ParticleSetUserParam( entity, "homelua_colourl"
Entity.ParticleSetUserParam( entity, "homelua_vector5"
5.0 )
Vector4(5.0) )
Vector4(0.3,0.4,0.5,1.0) )
Vector4(1.0,0.0,1.0) )
See Also
None
Entity.PauseAnim
Brief
Pauses all current animation(s) if any are playing.
Definition
Entity.PauseAnim( Entity entity )
Arguments
entity - The entity to update.
Return Values
None.
Description
Pauses all current animation(s) if any are playing. Use ResumeAnim to continue to play the animation(s).
Examples
entity = Entity.Create()
Entity.SetModel( entity, "mymodel" )
Entity.SetSkeleton( entity, "myskel" )
Entity.PlayAnim( entity, "myanim" )
Entity.PauseAnim( entity )
See Also
� Entity.ResumeAnim
Entity.PlayAnim
Brief
Plays the specified animation resource.
Definition
Entity.PlayAnim( Entity entity,
priority = 0 )
Entity.PlayAnim( Entity entity,
priority = 0 )
string resourceName, boolean looping = true, number time = 0, number
Resource animResource, boolean looping = true, number time = 0, number
Arguments
entity - The entity to update.resourceName - The resource name of the animation.animResource - The animation resource.looping - flag indicating
if animation should loop, or only play once. Default is true.time - the time at which the animation is played from. If the time is greater than the
duration, is taken as 0. Default is 0.priority - The priority affects where in the animation list an animation will be played. The higher the number, the
later it will be played.
If a prior animation is being played at the same priority, then the new animation will be placed after the old animation in the list, (default is 0).
*NB Internally, priority is treated as an integer.
Return Values
None.
Description
Plays the specified animation resource as specified in the HDK's Object Editor application. Stops all other animations that are currently playing.
Examples
entity = Entity.Create()
Entity.SetModel( entity, "mymodel" )
Entity.SetSkeleton( entity, "myskel" )
Entity.PlayAnim( entity, "myanim" )
See Also
Entity.Create
� Entity. SetModel
� Entity.SetSkeleton
Entity.RegisterCollisionCallback
Brief
Register a function to be called in response to a collision event involving the specified entity.
Definition
Entity.RegisterCollisionCallback( Entity entity, EntityCollision eventType, function callback,
userData = nil )
Arguments
entity - the entity to register for the collision callbackeventType - an EntityCollision enum value:
EntityCollision.ContactAdded - a new contact point has been added
EntityCollision.ContactProcess - called for all active contact points each frame while they exist
EntityCollision.ContactRemoved - a contact point has been removedcallback - the Lua function to be calleduserData - arbitrary user data of the
user's choice
Return Values
None.
Description
Register a function to be called in response to a collision event involving the specified entity. You must enable collision callbacks for the specified
entity using EnableCollisionCallbacksQ in order to begin receiving callbacks to your registered function(s). You must also set the maximum
contacts buffer using Entity.SetMaxContacts(). Finally, the entity must have collision set and enabled for the callbacks to occur.
Examples
� set up a collision data buffer
Entity.SetMaxContacts( 128 )
foo = Entity.Create ()
foo:SetModel("model")
foo:SetCollision("collision")
foo:SetPosition(Vector4.Create(0, 5, 0))
foo:SetVisible(true)
foo:EnableCollision(true)
foo:EnableDynamics(true)
foo:EnableCollisionCallbacks(true)
foo:RegisterCollisionCallback(EntityCollision.ContactAdded, ContactAddedCallback, foo)
foo:RegisterCollisionCallback(EntityCollision.ContactRemoved, ContactRemovedCallback, foo)
See Also
� Entity. RegisterCollisionCallback
� Entity.SetMaxContacts
� Entity.SetCollision
� Entity.EnableCollision
Entity. Reset
Brief
Reset an entity to a newly-created state.
Definition
Entity.Reset(Entity entity)
Arguments
entity - Entity to reset.
Return Values
None.
Description
Resets all non-hierarchy entity state, including model, animation, collision, particles, attached cameras, lights and other state. The entity's
hierarchy state (parent and children) and transform state (position and rotation) will not be reset, if this is desired it must be done explicitly. Of
particular use if using a pool of entities, as entities can be reset upon being released back into the pool (or when allocated from the pool).
Examples
myEntity:Reset()
See Also
� Entity.Copy
Entity.ResumeAnim
Brief
Resumes all current animation(s) if they are paused.
Definition
Entity.ResumeAnim( Entity entity )
Arguments
entity - The entity to update.
Return Values
None.
Description
Resumes all current animation(s) if they are paused. Use PauseAnim to pause the animation(s).
Examples
entity = Entity.Create()
Entity.SetModel( entity, "mymodel" )
Entity.SetSkeleton( entity, "myskel" )
Entity.PlayAnim( entity, "myanim" )
Entity.PauseAnim( entity )
Entity.ResumeAnim( entity )
See Also
� Entity.PauseAnim
Entity.SetActionForce
Brief
Set the force of an entity action.
Definition
Entity.SetActionForce( Entity entity, number actionld, Vector4 force )
Arguments
entity - The entity to which the action belongsactionld - The numerical action IDforce - The force in world-space
Return Values
None.
Description
Set the force of an entity action. Only applicable to force-based actions. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource" )
e:EnableDynamics()
actionld = Entity.CreatePointForceAction( e, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionForce( e, actionld, f )
Entity.SetActionPosition( e, actionld, p )
Entity.DestroyAction( e, actionld )
See Also
� Entity. SetActionTorque
� Entity.SetActionPosition
Entity.SetActionPosition
Brief
Set the position of an entity action.
Definition
Entity.SetActionPosition( Entity entity, number actionld, Vector4 position )
Arguments
entity - The entity to which the action belongsactionld - The numerical action IDposition - The position in world-space.
Return Values
None.
Description
Set the position of an entity action. Only applicable to position-based actions. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource" )
e:EnableDynamics()
actionld = Entity.CreatePointForceAction( e, false )
f = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionForce( e, actionld, f )
Entity.SetActionPosition( e, actionld, p )
Entity.DestroyAction( e, actionld )
See Also
� Entity.SetActionTorque
� Entity.SetActionForce
Entity.SetActionTorque
Brief
Set the torque of an entity action.
Definition
Entity.SetActionTorque( Entity entity, number actionld, Vector4 torque )
Arguments
entity - The entity to which the action belongsactionld - The numerical action IDtorque - The torque in world-space.
Return Values
None.
Description
Set the torque of an entity action. Only applicable to torque-based actions. This function is only available if the entity has a collision item.
Examples
entity = Entity.Create()
e:SetCollision("kCollisionResource" )
e:EnableDynamics()
actionld = Entity.CreateTorqueAction( e, false )
t = Vector4.Create( 10.0, 0.0, 0.0 )
p = Vector4.Create( 0.0, 1.0, 0.0 )
Entity.EnableAction( e, actionld )
Entity.SetActionTorque( e, actionld, t )
Entity.DestroyAction( e, actionld )
See Also
� Entity.SetActionForce
� Entity.SetActionPosition
Entity. SetAngularDamping
Brief
Sets the angular damping of the collision resource attached to the entity.
Definition
! Entity.SetAngularDamping( Entity entity, number damping )
Arguments
entity - The entity to update.damping - The angular damping to apply to the entity.
Return Values
None.
Description
Sets the angular damping of the collision resource attached to the entity. Angular damping reduces the rotational velocity of the entity over time.
For example, if you set the angular damping to 0.2, then every second about 20% of the object's angular velocity will be removed. This function is
only valid if the entity has a collision item.
Examples
! Entity.SetAngularDamping( entity, 0.2 )
See Also
� Entity.EnableCollision
� Entity.EnableDynamics
� Entity.SetCollision
� Entity.GetAngularDamping
Entity.SetAngularVelocity
Brief
Sets the angular velocity around the center of mass of the entity.
Definition
Entity.SetAngularVelocity( Entity entity, Vector4 velocity )
Arguments
entity - The entity to update.velocity - vector specifying angular velocity.
Return Values
None.
Description
Sets the angular velocity around the center of mass of the entity's rigid body in world space. The W component of the specified vector is ignored.
Examples
! � Add the entity to the physics simulation
i Entity.EnableCollision( entity, true )
| Entity.EnableDynamics( entity, true )
| Entity.SetAngularVelocity( entity, Vector4.Create( 0, 10, 0 ) )
See Also
� Entity. SetLinearVelocity
� Vector4.Create
Entity .Set AttachT ype
Brief
Set the type of attachment used by the entity.
Definition
Entity.SetAttachType( Entity entity, AttachType type )
Arguments
entity - The entity to affect (must be attached to another entity or person).type - The type of attachment to use:
AttachType.T ranslation
AttachType. Rotation
AttachType.Scale
AttachType.Transform (default)
Return Values
None.
Description
The default behaviour for attached entities is to inherit all of their parent's transform, including translation, rotation and scaling. A script can use
this function to only inherit some of the parent's transform, to only translate an object with its parent and not alter its rotation for example. Scale is
handled so that if translation and scale are both inherited, then the local translation of the child entity will be scaled also, as per normal
attachment. If translation is not inherited, the local translation will not be scaled.
Examples
child:AttachToParent(parent)
child:SetAttachType(AttachType.Translation) � only inherit parent translation
child:SetAttachType(AttachType.Translation + AttachType.Rotation) � ignore parent scale
child:SetAttachType(AttachType.Transform) � same as default
See Also
� Entity.AttachToParent
� Entity.AttachToBone
Entity.SetCenterOfMassLocal
Brief
Sets the position of the entity's center of mass in local space.
Definition
Entity.SetCenterOfMassLocal( Entity entity, Vector4 com )
Arguments
entity - The entity to update.com - The position of the entity's center of mass in local space.
Return Values
None.
Description
Sets the position of the entity's center of mass in local space. This may be offset from the coordinate origin of the entity depending on its physics
configuration. This function is only available if the entity has a collision item.
Examples
: Entity.SetCenterOfMassLocal( entity, Vector4.Create( 0.5, 0.5, 0.5 ) )
See Also
� Entity. EnableDynamics
Entity.SetCollision
Brief
Sets the entity's collision.
Definition
Entity.SetCollision( Entity entity, string resourceName, Phys3dWorld world = nil )
Entity.SetCollision( Entity entity, Resource collisionResource, Phys3dWorld world = nil )
Arguments
entity - The entity to update.resourceName - The collision's resource name or nil to remove it.collisionResource - The collision resource or nil to
remove it.world - Phys3dWorld to add the entity to, or nil for the default.
Return Values
None.
Description
Sets the entity's collision to the named resource as specified in the HDK�s Object Editor application. Note that an entity with collision will no longer
respect attachments specified prior to calling SetCollision. The current world transform of the entity is preserved across this function call. This
function will automatically enable collision on the entity.
Examples
entity = Entity.Create()
Entity.SetCollision( entity, "mycollision" )
� Remove the collision from the entity
Entity.SetCollision( entity, nil )
See Also
� Entity.Create
� Phys3dWorld.Create
Entity.SetCollision Layer
Brief
Set the collision layer of an entity.
Definition
Entity.SetCollisionLayer( Entity entity, enum layer, boolean preserveCurrentLayerCollisions = true )
Arguments
entity - The entity.layer - The collision layer; can be either CollisionLayer.Entity or a "User Layer".preserveCurrentLayerCollisions - true to
preserve which layers the entity collides with, false otherwise.
Return Values
None.
Description
Set the collision layer of an entity. If preserveCurrentLayerCollisions is false, the layers with which the entity collides are reset to the default for the
specified layer. The defaults can be changed using Scene.SetLayerCollisionDefault.
Examples
Entity.SetCollisionLayer( entity, CollisionLayer.Userl, false )
See Also
� Entity.GetCollisionLayer
� Scene.SetLayerCollisionDefault
Entity.SetCullDistance
Brief
Set a distance at which the entity will be automatically made invisible.
Definition
! Entity.SetCullDistance(Entity entity, number distance)
Arguments
entity - The entity to modify.distance - The distance from camera at which to visibility cull the entity, or 0 to disable.
Return Values
None.
Description
For situations involving a large scene, it may be beneficial for efficiency reasons to set objects to invisible when they are located far away. Setting
a cull distance will automatically compute the entity's distance from camera every frame and hide it and any child entities if the distance is greater
than the specified cull distance. Note that internally squared distances are compared, so the cull distance should not overflow a floating point
number when squared.
Examples
! myEntity:SetCullDistance(80) � set cull distance to 80m
See Also
� Entity.GetCullDistance
Entity.SetDynamicsActive
Brief
Activate/deactivate dynamics on the specified entity.
Definition
! Entity.SetDynamicsActive( Entity entity, boolean activate = true )
Arguments
entity - The entity to update.activate - true to activate dynamics, false otherwise (defaults to true if not specified).
Return Values
None.
Description
Dynamics must be enabled with Entity.EnableDynamicsf) for the activated/deactivated state to take effect. An Entity with activated dynamics is
one that is having it�s motion updated. If dynamics are deactivated with this function, Flome's physics engine will stop updating the Entity's motion,
until it is activated again. Entities can be activated by another call to this function or by the application of forces/torques/impulses or by coming
into contact with other activated Entities. Entities can be deactivated with this function or by allowing auto-deactivation which will deactivate the
Entity if it has not been moving for a while. Auto-deactivation can be enabled/disabled with Entity.EnableDynamicsAutoDeactivation. This function
is only valid if the entity has a collision item.
Examples
� Deactivate dynamics
Entity.SetDynamicsActive( entity, false )
� Activate dynamics (collision must be enabled as well)
Entity.EnableCollision( entity )
Entity.EnableDynamics( entity )
Entity.SetDynamicsActive( entity )
See Also
� Entity.EnableDynamics
� Entity. EnableDynamicsAutoDeactivation
Entity.SetFrictionCoeff
Brief
Set the friction coefficient of the collision resource attached to the entity.
Definition
Entity.SetFrictionCoeff( Entity entity, number f )
Arguments
entity - The entity to updated - the coefficient of friction.
Return Values
None.
Description
Set the coefficient of friction for the surface of the rigid body that is attached to the entity. This affects the entity's motion relative to surfaces it
comes into contact with. Although this is actually a pair-wise coefficient, friction is specified on a per rigid body basis. When affecting the relative
motion of two surfaces, the surfaces' friction coefficients are combined to produce a coefficient for the interaction. Usual values for friction are
between 0 and 1. Values greater than 1, although physically invalid, are allowed. However, values must be less than or equal to 255.
Examples
Entity.SetFrictionCoeff( entity, 0.0 )
See Also
� Entity.EnableCollision
� Entity.EnableDynamics
� Entity. SetCollision
Entity.SetGravity
Brief
Set the gravity vector to apply to the entity.
Definition
Entity.SetGravity( Entity entity, Vector4 gravityVector )
Arguments
entity - entity to be affected.gravityVector - new gravity vector.
Return Values
None.
Description
Only the specified entity is affected by the new gravity force.
Examples
! � set gravity to half strength
j local g = Scene.GetGravity() * 0.5
j entity:SetGravity( g )
See Also
� Entity.GetGravity
Entity.SetLight
Brief
Set the entity's light.
Definition
Entity.SetLight( Entity entity, Light light = nil )
Arguments
entity - The entity to update.light - The Light to attach to the entity or nil to detach the existing light.
Return Values
None.
Description
Set the entity's light.
Examples
i entity = Entity.Create()
! Entity.SetLight( entity, light )
See Also
Entity.Create
Entity. SetLinearDamping
Brief
Sets the linear damping of the collision resource attached to the entity.
Definition
! Entity.SetLinearDamping( Entity entity, number damping )
Arguments
entity - The entity to update.damping - The linear damping to apply to the entity.
Return Values
None.
Description
Sets the linear damping of the collision resource attached to the entity. Linear damping reduces the linear velocity of the entity over time. For
example, if you set the linear damping to 0.2, then every second about 20% of the object's linear velocity will be removed. This function is only
valid if the entity has a collision item.
Examples
! Entity.SetLinearDamping( entity, 0.2 )
See Also
� Entity.EnableCollision
� Entity. EnableDynamics
� Entity.SetCollision
� Entity.GetLinearDamping
Entity.SetLinearVelocity
Brief
Sets the linear velocity of this object.
Definition
! Entity.SetLinearVelocity( Entity entity, Vector4 velocity )
Arguments
entity - The entity to update.velocity - Vector specifying linear velocity.
Return Values
None.
Description
Sets the linear velocity of the center of mass of the entity's rigid body in world space. The W component of the specified vector is ignored.
Examples
� Add the entity to the physics simulation
Entity.EnableCollision( entity, true )
Entity.EnableDynamics( entity, true )
Entity.SetLinearVelocity( entity, Vector4.Create( 0, 10, 0 ) )
See Also
� Entity.SetAngularVelocity
� Vector4.Create
Entity.SetLocalMatrix
Brief
Sets the entity's local transformation matrix.
Definition
Entity.SetLocalMatrix( Entity entity, Matrix44 matrix )
Arguments
entity - The entity to update.matrix - The matrix to set the entity's transform to.
Return Values
None.
Description
Sets the entity's local transformation matrix. The specified matrix is relative to the coordinate system of the entity's parent, if one exists. If the
entity has no parent, the matrix is relative to the world space coordinate system.
Examples
entity = Entity.Create()
matrix = Matrix44.Create()
� Set up a uniform scale matrix
Matrix44.SetScale( matrix, 2, 2, 2, 1, MATRIX_REPLACE )
Entity.SetLocalMatrix( entity, matrix )
print( mat )
See Also
� Entity.Create
� Matrix44.Create
� Matrix44.SetScale
Entity.SetMass
Brief
Sets the mass of the collision resource attached to the entity.
Definition
! Entity.SetMass( Entity entity, number mass )
Arguments
entity - The entity to update.mass - The mass of the entity's collision resource in kilograms.
Return Values
None.
Description
Sets the mass of the collision resource that is attached to the specified entity. Very large or very small masses should be avoided, as these can
create instability in the simulation. This function can only be called if the entity has a collision resource.
Examples
! Entity.SetMass( entity, 5 )
See Also
� Entity.EnableCollision
� Entity. EnableDynamics
� Entity.SetCollision
� Entity.GetMass
Entity.SetMaxContacts
Brief
Specify the maximum number of contacts to buffer for collision callbacks.
Definition
boolean Entity.SetMaxContacts(number maxContacts)
Arguments
maxContacts - maximum number of contact events to buffer
Return Values
true if sufficient memory could be allocated or false otherwise.
Description
Allocates an internal buffer to record contact events for provision via collision callbacks. Each contact event generated by PS Home for the types
for which the script has registered callbacks will be buffered in this internal buffer, until the contacts are passed to the script via the callbacks. All
entities registered for callbacks in the current script environment will share this buffer. If more contacts are generated than the buffer can store,
subsequent contacts will not be buffered and will not be available to the script, and a message indicating this will be displayed in the console.
Note that each contact currently requires 64 bytes of memory. If this function fails, there was insufficient memory available to the script to allocate
the buffer. In this case, collision callbacks will be disabled until a subsequent call to this function (with a lower maximum) succeeds. This function
is not available from within a collision callback and will generate an error.
Examples
! Entity.SetMaxContacts(128) � enough memory for 128 contact events (added/processed/removed) per
; frame
See Also
� Entity. RegisterCollisionCallback
� Entity. EnableCollisionCallbacks
� Entity.SetColiision
� Entity. EnableCollision
Entity.SetModel
Brief
Set the entity's model.
Definition
Entity.SetModel( Entity entity, string resourceName )
Entity.SetModel( Entity entity, Resource modelResource )
Arguments
entity - The entity to update.resourceName - The model's resource name or nil to remove the model.modelResource - The model resource or nil
to remove the model.
Return Values
None.
Description
Set the entity's model to the named resource as specified in the HDK's Object Editor application.
Examples
! entity = Entity.Create()
i Entity.SetModel( entity, "mymodel" )
! � Remove the model from the entity
; Entity.SetModel( entity, nil )
See Also
� Entity.Create
Entity.SetPosition
Brief
Sets the entity's position.
Definition
Entity.SetPosition( Entity entity, Vector4 position )
Arguments
entity - The entity to update.position - The new position for the entity.
Return Values
None.
Description
Sets the entity's position. If the entity has a parent, the specified position is relative to local coordinate system of the parent.
Examples
! entity = Entity.Create()
Entity.SetPosition( entity, Vector4.Create( 10, 10, 0 ) )
See Also
� Entity.Create
Entity.SetRestitutionCoeff
Brief
Sets the restitution coefficient of the collision resource attached to the entity.
Definition
! Entity.SetRestitutionCoeff( Entity entity, number r )
Arguments
entity - The entity to update.r - the coefficient of restitution.
Return Values
None.
Description
Sets the restitution (or elasticity) coefficient for the rigid body attached to the entity. This governs the effect that collisions have on the velocities of
colliding entities. Like friction, this is a pair-wise coefficient - when two physical entities collide, their restitution values are combined to produce a
coefficient for the interaction. Usual values for restitution are between 0 and 1. Values greater than 1, although physically invalid, are allowed.
However, values must be less than 1.99.
Examples
� Prevent entity from bouncing
Entity.SetRestitutionCoeff( entity, 0.0 )
See Also
Entity. EnableCollision
� Entity.EnableDynamics
� Entity.SetCollision
Entity.SetRotationQuat
Brief
Sets the rotation using the supplied quaternion.
Definition
| Entity.SetRotationQuat( Entity entity, Quaternion quat )
Arguments
entity - The entity to update.quat - The quaternion.
Return Values
None.
Description
Sets the rotation of the specified entity using the supplied quaternion.
Examples
! entity = Entity.Create()
j quat = Quaternion.Create()
| entity:SetRotationQuat(quat)
See Also
� Entity.GetRotationQuat
Entity.SetRotationX
Brief
Sets the rotation about the x-axis in degrees.
Definition
! Entity.SetRotationX( Entity entity, number rotation )
Arguments
entity - The entity to update.rotation - The specified angle of rotation about the x-axis in degrees.
Return Values
None.
Description
Sets the rotation about the x-axis of the entity's local coordinate system in degrees. The rotation order is x, y, z.
Examples
entity = Entity.Create()
Entity.SetRotationX( entity, 90.0 )
See Also
� Entity.Create
Entity.SetRotationXyz
Brief
Sets the rotation about the x, y, and z-axis in degrees.
Definition
Entity.SetRotationXyz( Entity entity, Vector4 rotation )
Arguments
entity - The entity to update.rotation - The specified x, y, and z angles of rotation in degrees.
Return Values
None.
Description
Sets the rotation about the x, y, and z-axis of the entity's local coordinate system in degrees. The rotation order is x, y, z.
Examples
! entity = Entity.Create()
i Entity.SetRotationXyz( entity, Vector4.Create( 45, 30, 90 ) )
See Also
� Entity.Create
Entity.SetRotationY
Brief
Sets the rotation about the y-axis in degrees.
Definition
! Entity.SetRotationY( Entity entity, number rotation )
Arguments
entity - The entity to update.rotation - The specified angle of rotation about the y-axis in degrees.
Return Values
None.
Description
Sets the rotation about the y-axis of the entity's local coordinate system in degrees. The rotation order is x, y, z.
Examples
: entity = Entity.Create()
i Entity.SetRotationY( entity, 90.0 )
See Also
� Entity.Create
Entity.SetRotationZ
Brief
Sets the rotation about the z-axis in degrees.
Definition
Entity.SetRotationZ( Entity entity, number rotation )
Arguments
entity - The entity to update.rotation - The specified angle of rotation about the z-axis in degrees.
Return Values
None.
Description
Sets the rotation about the z-axis of the entity's local coordinate system in degrees. The rotation order is x, y, z.
Examples
! entity = Entity.Create()
i Entity.SetRotationZ( entity, 90.0 )
See Also
� Entity.Create
Entity.SetScale
Brief
Sets the entity's scale.
Definition
Entity.SetScale( Entity entity, Vector4 scale )
Arguments
entity - The entity to update.scale - The new scale of the entity.
Return Values
None.
Description
Sets the entity's scale. The specified scale is applied to the local transformation matrix of the entity. On creation, an entity has a scale of (1,1,1)
or no scaling, in other words. Note that the W component of the specified vector is ignored. Note that scale should not be applied to entities with
collision enabled.
Examples
entity = Entity.Create()
Entity.SetScale( entity, Vector4.Create( 45, 30, 90 ) )
See Also
� Entity.Create
� Vector4. Create
Entity.SetScreen
Brief
Set the entity's screen.
Definition
Entity.SetScreen( Entity entity, Screen screen )
Arguments
entity - The entity to update.screen - The screen to attach to the entity or nil to remove it.
Return Values
None.
Description
Set the entity's screen. The screen's corner coordinates will be transformed by the entity's world transformation matrix.
Examples
j entity = Entity.Create()
i Entity.SetScreen( entity, screen )
! � Remove the screen from the entity
Entity.SetScreen( entity, nil )
See Also
Entity.Create
Entity.SetSkeleton
Brief
Set the entity's skeleton.
Definition
Entity.SetSkeleton( Entity entity, string resourceName )
Entity.SetSkeleton( Entity entity. Resource skeletonResource )
Arguments
entity - The entity to update.resourceName - The skeleton's resource name or nil to remove it.skeletonResource - Pre-loaded skeleton resource
object.
Return Values
None.
Description
Set the entity's skeleton to the named resource as specified in the HDK's Object Editor application.
Examples
! entity = Entity.Create()
i Entity.SetSkeleton( entity, "myskel" )
! � Remove the skeleton from the entity
i Entity.SetSkeleton( entity, nil )
See Also
� Entity.Create
Entity.SetVisible
Brief
Sets the entity to visible or invisible.
Definition
Entity.SetVisible( Entity entity, boolean value )
Arguments
entity - The entity to update.value - If true the entity is visible and it false it is invisible.
Return Values
None.
Description
Sets the entity to visible or invisible. Entities default to visible when created.
Examples
entity = Entity.Create()
Entity.SetVisible( entity, false )
See Also
� Entity.Create
Entity.StopAnim
Brief
Stops the current animation if it is playing.
Definition
Entity.StopAnim( Entity entity )
Entity.StopAnim( Entity entity, Animation anim )
Arguments
entity - The entity to update.anim - The animation to stop.
Return Values
None.
Description
If the Animation anim passed in is nil, or invalid, nothing is done. If an animation is specified, it will be stopped immediately with no blend out. If no
animation is specified, all animations on the entity will be stopped immediately, with no blend out.
Examples
entity = Entity.Create()
local animHandle = Animation.Create()
Entity.SetModel( entity, "mymodel" )
Entity.SetSkeleton( entity, "myskel" )
Entity.PlayAnim( entity, "mylstAnim" )
Entity. BlendAnim ( entity, "my2ndAnim ,, , true, 0, 0, animHandle )
Entity.StopAnim( entity, animHandle ) � stops specific animation
Entity.StopAnim( entity ) � stops all other animations
See Also
� Entity.Create
� Entity.PlayAnim
� Entity.SetModel
� Entity.SetSkeleton
Camera
Camera.Activate
Brief
Activates the specified camera.
Definition
! Camera.Activate( Camera camera, number transitionTime =0.0 )
Arguments
camera - The camera to activate.transitionTime - The time taken to smoothly move from the previously active camera's position, to the
specified camera's position.
Return Values
None.
Description
Activates the specified camera.
Examples
! Camera.Activate( gameCamera, 1.0 )
See Also
� Camera. Deactivate
� Camera. IsActivated
Camera. AttachToParent
Brief
Links the camera to the given entity so that the camera inherits the entity's transform.
Definition
Camera.AttachToParent( Camera camera, Entity parent )
Arguments
camera - The camera to update.parent - The entity to attach this camera to, or nil to detach the camera.
Return Values
None.
Description
Links the camera to the given entity so that the camera inherits the entity's transform. This will override any values set via Camera.SetPosition, or
Camera.SetLookAtPosition until the connection is cleared by passing in nil as the parent. If the entity is destroyed then the camera will be
unparented. It is not possible at present to specify a local transform offset from the entity.
Examples
! Camera.AttachToParent( gameCamera, myEntity ) � connect the camera to myEntity
; Camera.AttachToParent( gameCamera, nil ) � detach the camera from any connected entity
See Also
None
Camera.Create
Brief
Creates a new 3D camera.
Definition
Camera Camera.Create( string constructionMethod = nil )
Arguments
constructionMethod - How to construct the camera, either nil or "current".
Return Values
Returns a Camera instance.
Description
Creates a new 3D camera. This camera is, by default, positioned at the origin (0, 0, 0). If constructionMethod is "current" it creates a new camera
with the properties of the currently active camera.
Examples
gameCamera = Camera.Create( "current" )
Camera.SetPosition( gameCamera, Camera.GetPosition() + Vector4.Create( 0, 1, 0 ) )
See Also
� Camera.Activate
Camera. Deactivate
Brief
Deactivates the specified camera.
Definition
Camera.Deactivate( Camera camera, number transitionTime =0.0 )
Arguments
camera - The camera to deactivate.transitionTime - The time taken to smoothly move from the specified camera's position back to the
previously active camera's position.
Return Values
None.
Description
Deactivates the specified camera.
Examples
! if Camera.IsActivated( gameCamera ) then
Camera.Deactivate( gameCamera, 1.0 )
| end
See Also
� Camera.Activate
� Camera. IsActivated
Camera.EnableAvatarCameraSync
Brief
Tell the normal Avatar camera to face the same direction as a deactivating custom camera, minimizing the camera transition.
Definition
i Camera.EnableAvatarCameraSync()
Arguments
None
Return Values
Description
When enabled, the normal Avatar Camera will sync with any active custom camera to face the same direction. This simply means that when the
custom camera is deactivated, the normal Avatar Camera will be facing the same direction, and the magnitude of the transition between the two
will be minimized. This defaults to on. It�s rare, and generally not advised to disable this.
Examples
Camera.EnableAvatarCameraSync(false)
See Also
None
Camera.GetlnverseViewMatrix
Brief
Get the view to world transform for the currently active camera.
Definition
Camera.GetInverseViewMatrix(Matrix44 matrix)
Arguments
matrix - The matrix to set.
Return Values
None.
Description
Retrieves the view to world transform for the currently active camera. This can be considered as the world transform of the camera object itself.
Examples
! local invViewMat = Matrix44.Create ()
; Camera.GetlnverseViewMatrix(invViewMat)
See Also
� Camera.GetViewMatrix
� Camera.GetProjectionMatrix
Camera.GetLookAtPosition
Brief
Retrieves the camera's world space target position.
Definition
Vector4 Camera.GetLookAtPosition( Camera camera )
Camera.GetLookAtPosition( Camera camera, Vector4 outPos )
Vector4 Camera.GetLookAtPosition ()
Camera.GetLookAtPosition( Vector4 outPos )
Arguments
camera - The camera to query.outPos - (out) The vector to receive the target position.
Return Values
Returns a Vector4 specifying the world space target position of the camera.
Description
Retrieves the camera's world space target position. Only the X, Y and Z components of the Vector4 are valid. If no camera is specified it uses the
currently active camera.
Examples
! camtarget = Camera.GetLookAtPosition( gameCamera )
See Also
� Camera.SetLookAtPosition
Camera.GetPosition
Brief
Retrieves the camera's world space position.
Definition
Vector4 Camera.GetPosition( Camera camera )
Camera.GetPosition( Camera camera, Vector4 outPos )
Vector4 Camera.GetPosition()
Camera.GetPosition( Vector4 outPos )
Arguments
camera - The camera to query.outPos - (out) The vector to receive the camera position.
Return Values
A Vector4 specifying the world space position of the camera.
Description
Retrieves the camera's world space position. Only the X, Y and Z components of the Vector4 are valid. If no camera is specified it uses the
currently active camera. Note that inactive cameras are not updated, and therefore if a position is requested for an inactive camera the most
recent position available will be returned. For the currently active camera the position will match the translation of the inverse view matrix.
Examples
campos = Camera.GetPosition( gameCamera )
See Also
� Camera.SetPosition
� Camera.GetlnverseViewMatrix
Camera.GetProjectionMatrix
Brief
Get the projection matrix for the currently active camera.
Definition
Camera.GetProjectionMatrix(Matrix44 matrix)
Arguments
matrix - The matrix to set.
Return Values
None.
Description
Retrieves the projection transform for the currently active camera. A script should not assume a particular projection transform format. The
projection matrix is used to transform a point from view to clip space.
Examples
j local projMat = Matrix44.Create()
; Camera.GetProjectionMatrix(projMat)
See Also
� Camera.GetViewMatrix
� Camera.GetlnverseViewMatrix
Camera.GetViewMatrix
Brief
Get the world to view transform for the currently active camera.
Definition
Camera.GetViewMatrix(Matrix44 matrix)
Arguments
matrix - The matrix to set.
Return Values
None.
Description
This matrix will transform from world space to view space.
Examples
j local worldToViewMat = Matrix44.Create()
| Camera.GetViewMatrix(worldToViewMat)
See Also
Camera.GetlnverseViewMatrix
� Camera. GetProjectionMatrix
Camera.GetViewPortFOV
Brief
Retrieves the vertical field of view for the specified camera.
Definition
! number Camera.GetViewPortFOV( Camera camera )
i number Camera.GetViewPortFOV()
Arguments
camera - The camera to query.
Return Values
The vertical field of view for the camera, specified in degrees.
Description
Retrieves the vertical field of view (FOV) for the specified camera. If no camera is specified it uses the currently active camera.
Examples
I fov = Camera.GetViewPortFOV( gameCamera )
See Also
� Camera.SetViewPortFOV
Camera.GetViewPortZFar
Brief
Retrieves the camera's far clip plane.
Definition
number Camera.GetViewPortZFar( Camera camera )
number Camera.GetViewPortZFar()
Arguments
camera - The camera to query.
Return Values
The far clip plane of the camera in units of meters.
Description
Retrieves the camera's far clip plane. Units are specified in meters. The default far clip plane for a newly created camera is 4000.0. If no camera
is specified it uses the currently active camera.
Examples
! farz = Camera.GetViewPortZFar( gameCamera )
See Also
� Camera.SetViewPortZFar
Camera.GetViewPortZNear
Brief
Retrieves the camera's near clip plane.
Definition
! number Camera.GetViewPortZNear( Camera camera )
i number Camera.GetViewPortZNear()
Arguments
camera - The camera to query.
Return Values
The near clip plane of the camera in units of meters.
Description
Retrieves the camera's near clip plane. Units are specified in metres. The default near clip plane for a newly created camera is 0.1. If no camera
is specified it uses the currently active camera.
Examples
! nearz = Camera.GetViewPortZNear( gameCamera )
See Also
� Camera.SetViewPortZNear
Camera.IsActivated
Brief
Determines whether the specified camera is currently active.
Definition
! boolean Camera.IsActivated( Camera camera )
Arguments
camera - The camera to query.
Return Values
true if the specified camera is activated, false otherwise.
Description
Determines whether the specified camera is currently active.
Examples
1 if Camera.IsActivated( gameCamera ) then
Camera.Dectivate( gameCamera, 1.0 )
| end
See Also
� Camera.Activate
� Camera. Deactivate
Camera.SetLookAtPosition
Brief
Sets the camera's world space target position.
Definition
! Camera.SetLookAtPosition( Camera camera, Vector4 target )
Arguments
camera - The camera to update.target - Vector4 specifying the world space target position for the camera.
Return Values
None.
Description
Sets the camera's world space target position. Only the X, Y and Z components of the Vector4 are used to position the camera. The W
component is ignored.
Examples
1 Camera.SetLookAtPosition( gameCamera, Vector4.Create( 0, 10, 0, 0 ) )
See Also
� Camera.GetLookAtPosition
Camera.SetPosition
Brief
Sets the camera's world space position.
Definition
! Camera.SetPosition( Camera camera, Vector4 position )
Arguments
camera - The camera to update.position - Vector4 specifying the world space position of the camera.
Return Values
None.
Description
Sets the camera's world space position. Only the X, Y and Z components of the Vector4 are used to position the camera. The W component is
ignored.
Examples
! Camera.SetPosition( gameCamera, Vector4.Create( 0, 10, 0, 0 ) )
See Also
� Camera.GetPosition
Camera.SetViewPortAspect
Brief
Sets the aspect ratio for the specified camera's viewport.
Definition
! Camera.SetViewPortAspect( Camera camera, number aspect )
Arguments
camera - The camera to update.aspect - aspect ratio for the camera's viewport (width / height).
Return Values
None.
Description
Sets the aspect ratio for the specified camera's viewport.
Examples
! Camera.SetViewPortAspect( gameCamera, 16.0 / 9.0 )
See Also
Camera.SetViewPortFOV
Brief
Sets the vertical field of view of the specified camera.
Definition
! Camera.SetViewPortFOV( Camera camera, number fov )
Arguments
camera - The camera to update.fov - Vertical field of view for the camera, specified in degrees.
Return Values
None.
Description
Sets the vertical field of view of the specified camera in degrees.
Examples
! Camera.SetViewPortFOV( gameCamera, 60.0 )
See Also
� Camera.GetViewPortFOV
Camera.SetViewPortZFar
Brief
Sets the camera's far clip plane.
Definition
! Camera.SetViewPortZFar( Camera camera, number zfar )
Arguments
camera - The camera to update.znear - The far clip plane of the camera in units of metres.
Return Values
None.
Description
Sets the camera's far clip plane. Units are specified in metres. The default far clip plane for a newly created camera is 4000.0.
Examples
! Camera.SetViewPortZFar( gameCamera, 5000.0 )
See Also
� Camera.GetViewPortZFar
Camera.SetViewPortZNear
Brief
Sets the camera's near clip plane.
Definition
! Camera.SetViewPortZNear( Camera camera, number znear )
Arguments
camera - The camera to update.znear - The near clip plane of the camera in units of meters.
Return Values
None.
Description
Sets the camera's near clip plane. Units are specified in metres. The default near clip plane for a newly created camera is 0.1. The minimum
value that the function will accept is 0.001.
Examples
! Camera.SetViewPortZNear( gameCamera, 0.2 )
See Also
� Camera.GetViewPortZNear
Person
Person. AttachToEntity
Brief
Attaches the person to specified entity so when the entity moves around the person moves with it.
Definition
Person.AttachToEntity( Person person, Entity entity = nil, Matrix44 localTransform = nil )
Arguments
entity - the entity to attach to or nil to detach player from current entity.
Return Values
None.
Description
When attached to an entity, setting position and rotation will affect the local transform only. The transform must be locked by the calling lua
environment otherwise a lua error is generated. If the person is unlocked it automatically detaches from the entity.
Examples
person = LocalPlayer.GetPerson ()
car = Entity.Create ()
Person.AttachToEntity( person, car )
See Also
None
Person. DoAction
Brief
Plays an action on a Person
Definition
Person.DoAction( Person person, string actionName, boolean autoUnlock = false )
Person.DoAction( Person person, string actionName, boolean autoUnlock, number unlockFeatures )
Arguments
person - the person to play an action on.actionName - Name of the action to be performed. It can be a custom animation loaded remotely through
LocalPlayer.AddRepertoire as well as one of the following standard actions:
"agree�
"beckon"
"bow"
"cheer"
"clap"
"disagree"
"frustration"
"laugh"
"point"
"wave"
"stand_up_from_seat"autoUnlock - if true, then the animation lock on the person is automatically released after the action has completed.
Defaults to false.unlockFeatures - only used if the autoUnlock parameter is true. If omitted then defaults to releasing the locks that were set when
Person.DoAction was called, otherwise will only release the locks specified,
features specified.
Return Values
Returns true if the action succeeds.
Description
The animation must be locked by the calling lua environment otherwise a lua error is generated. If the action isn't recognized a lua error is
generated. If it fails and autollnlock is true it unlocks immediately.
Examples
if Person.HasLock ( person ) then
Person.DoAction( person, "clap" )
end
See Also
� Person.Lock
� Person.Unlock
� Person.IsLocked
� Person.HasLock
� Person.SetBehavior
� Person.DoActionBroadcast
Person.DoActionBroadcast
Brief
Piays an action on a Person
Definition
Person.DoActionBroadcast( Person person, string actionName, boolean autoUnlock = false )
Person.DoActionBroadcast( Person person, string actionName, boolean autoUnlock, number unlockFeatures
)
Arguments
person - the person to play an action on.actionName - Name of the action to be performed. It can be a custom animation loaded remotely through
LocalPlayer.AddRepertoire as well as one of the following standard actions:
"agree�
"beckon"
"bow�
"cheer"
"clap"
"disagree"
"frustration"
"laugh"
"point"
"wave"
"stand_up_from_seat"autoUnlock - if true, then the animation lock on the person is automatically released after the action has completed.
Defaults to false.unlockFeatures - only used if the autoUnlock parameter is true. If omitted then defaults to releasing the locks that were set when
Person.DoActionBroadcast was called, otherwise will only release the locks specified,
features specified.
Return Values
Returns true if the action succeeds.
Description
The animation must be locked by the calling lua environment otherwise a lua error is generated. If the action isn't recognized a lua error is
generated. If it fails and autoUnlock is true it unlocks immediately. If calling DoActionBroadcast on the LocalPlayer, this function will broadcast the
action to other clients in the scene. Using DoActionBroadcast impacts on the amount of network traffic, so avoid calling this function frequently.
Examples
if Person.HasLock( person ) then
Person.DoActionBroadcast( person, "clap" )
end
See Also
� Person.Lock
� Person.Unlock
� Person. IsLocked
� Person.HasLock
� Person.SetBehavior
� Person.DoAction
Person.EnableChatBubbles
Brief
Sets chat bubbles on or off.
Definition
! Person.EnableChatBubbles( Person person, boolean enabled )
Arguments
enabled - True to enable chat bubbles or false to disable.
Return Values
None.
Description
With this function, a script can allow chat bubbles to be switched on or off at will. Chat will still appear in the chat log as normal. Please note: In
order to use this function, the is_allowed_chat_bubble_change property in the object's mini_game component must be set to true.
Examples
local person = LocalPlayer.GetPerson( );
if ( Person.Lock( person, PersonLockType.ChatBubbles ) == true ) then
Person.EnableChatBubbles( person, false );
end
See Also
� Person.Lock
� Person.Unlock
Person.EnableCollision
Brief
Toggles collision detection for the person's avatar.
Definition
! Person.EnableCollision( Person person, boolean value )
Arguments
person - the person to modify.value - Whether collision should be on or off.
Return Values
None.
Description
Toggles collision detection for the person's avatar. The collision must be locked by the calling lua environment otherwise a lua error is generated.
Examples
! if Person.IsCollision ( person ) then
Person.EnableCollision( person, false )
| end
See Also
� Person.IsCollision
Person.Findlnlnstance
Brief
Finds a person in the instance from the person ID.
Definition
! Person Person.Findlnlnstance( string personld )
Arguments
personld - The person to find.
Return Values
A Person if found and nil otherwise.
Description
Finds a person in the instance from the specified person ID.
Examples
me = Person.Findlnlnstance( LocalPlayer.GetPersonld() )
See Also
Local Player.GetPersonld
Person. GetAnimReg
Brief
Returns the value of the specified animation register.
Definition
number|boolean|string Person.GetAnimReg(Person person, string registerName)
Arguments
person - person to query.registerName - the name of the animation register to get.
Return Values
The value of the register, with the type based on the register type.
Description
If the register doesn't exist or the animation register doesn't have Lua read access an error will be thrown.
Examples
! fatness = person:GetAnimReg("Fatness")
See Also
� Person. SetAnimReg
Person.GetAvatarStatusType
Brief
Returns the current avatar status type of the person specified
Definition
number Person.GetAvatarStatusId( Person person )
Arguments
person - The person to query.
Return Values
The enumerated value of the current status type.
Description
The user can change the status of their avatar from the emotes menu. This method returns the current user status type. Changing the status type
affects the facial animation (mood) used, and the status text above the avatar that remote users see. The possible status types are:
AvatarStatusType.Neutral
AvatarStatusT ype. Happy
AvatarStatusType.Sad
AvatarStatusType. Angry
AvatarStatusType.Confused
AvatarStatusType. Unwell
AvatarStatusType.Busy
AvatarStatusType. IsLookingForHelp
AvatarStatusT ype. WantT oChat
AvatarStatusType. WantToPlayGame
Examples
me = LocalPlayer.GetPerson()
if Person.GetAvatarStatusType( me ) == AvatarStatusType.Happy then
DoSomethingHappy()
end
See Also
� Person.GetMood
Person.GetBehavior
Brief
Returns the name of the current behavior playing on the person.
Definition
string Person.GetBehavior( Person person )
Arguments
person - The person to query.
Return Values
The name of the current behavior playing on the person.
Description
Returns the name of the current behavior playing on the person or nil if the behavior is a Plome internal behavior. For a list of Home's public
behaviors see Person.SetBehavior. For post 1.40 behaviour, if the behaviour belongs to the calling script environment, will only specify the name.
If the behaviour belongs to another object, that has allowed its behaviours to be public, then will specify the object id, as well as the name. For
pre-1.40 behaviour. For the local player, will only return the name of the behaviour, but for remote persons, will return the fully qualified name
(objectld:name) - this is for backwards compatibility. If the behaviour is a system public behaviour, will return the name only.
Examples
behaviorName = Person.GetBehavior( person )
See Also
� Person.SetBehavior
Person. GetBehaviorCategory
Brief
Returns the specified person's behavior state.
Definition
string|nil Person.GetBehaviorCategory( Person person )
Arguments
person - The person to update.
Return Values
Returns the specified person's behavior state.
Description
Returns nil if in an internal behavior or be one of the following: "dancing'' "posing" �sitting_on_floor" "sitting_on_seat" "standing" "moving"
Behaviors should be catagorized into one of the above states. This function can be used to check if a person is dancing etc. without checking the
animation behavior name.
Examples
! if Person.GetBehaviorCategory( LocalPlayer.GetPerson() ) == 'dancing* then
StartTheParty()
| end
See Also
� Person.GetBehavior
� Person.SetBehavior
Person. GetBoneCount
Brief
Get the number of bones in the person's skeleton.
Definition
! number Person.GetBoneCount(Person person)
Arguments
person - Person to query.
Return Values
Number of bones in the skeleton, or 0 if the skeleton is not available.
Description
Retrieves the number of bones/joints in the person's skeleton. If no skeleton is present or loaded, 0 is returned.
Examples
! local boneCount = LocalPlayer.GetPerson():GetBoneCount()
See Also
Person.GetBonelndex
Person.GetBonelndex
Brief
Find the index of a bone in the person's skeleton.
Definition
! number Person.GetBonelndex(Person person, string boneName)
Arguments
person - Person to query.boneName - Name of bone to locate.
Return Values
The index of the bone in the skeleton (in range 1 - GetBoneCount()), or 0 if not found.
Description
Retrieves the index of the specified bone/joint in the person's skeleton. The index is 1 -based. If the bone cannot be found, or there is no skeleton
attached or loaded, 0 is returned.
Examples
1 local leftHandlndex = LocalPlayer.GetPerson():GetBonelndex("lefthand")
See Also
� Person.GetBoneCount
� Person.GetBoneLocalMatrix
� Person.GetBoneWorldMatrix
Person.GetBoneLocalMatrix
Brief
Get the local transform matrix for a bone in the skeleton.
Definition
! Person.GetBoneLocalMatrix(Person person, string|number bone, Matrix44 result)
Arguments
person - Person to query.bone - Bone name or index.result (out) - Matrix44 value to store result into.
Return Values
None.
Description
Retrieve the local-space transform matrix for a specified bone in the skeleton. If the bone is not found an error will result. Retrieving the matrix by
index will be more efficient if done more than once.
Examples
local mat = Matrix44.Create ()
LocalPlayer.GetPerson():GetBoneLocalMatrix("lefthand", mat)
� or
local leftHandlndex = LocalPlayer.GetPerson():GetBonelndex("lefthand")
LocalPlayer.GetPerson():GetBoneLocalMatrix(leftHandlndex, mat)
See Also
� Person. GetBoneWorldMatrix
� Person.GetBonelndex
Person.GetBoneWorldMatrix
Brief
Get the world transform matrix for a bone in the skeleton.
Definition
Person.GetBoneWorldMatrix(Person person, string|number bone, Matrix44 result)
Arguments
person - Person to query.bone - Bone name or index.result (out) - Matrix44 value to store result into.
Return Values
None.
Description
Retrieve the world-space transform matrix for a specified bone in the skeleton. If the bone is not found an error will result. Retrieving the matrix by
index will be more efficient if done more than once.
Examples
local mat = Matrix44.Create ()
LocalPlayer.GetPerson():GetBoneWorldMatrix("lefthand", mat)
� or
local leftHandlndex = LocalPlayer.GetPerson():GetBonelndex("lefthand")
LocalPlayer.GetPerson():GetBoneWorldMatrix(leftHandlndex, mat)
See Also
� Person.GetBoneLocalMatrix
� Person.GetBonelndex
Person.GetCurrentAction
Brief
Returns the name of the current action the person is in, if any.
Definition
! string Person.GetCurrentAction( Person person )
Arguments
person - The person to query.
Return Values
Returns the name of the current action.
Description
If the person is not in an action nil is returned. Home internal actions will also return nil. For a list of Home public actions see Person.DoAction.
Examples
I actionName = Person.GetCurrentAction( LocalPlayer.GetPerson() )
See Also
� Local Player. DoAction
� LocalPlayer.IsDoingAction
Person. GetGroundllserld
Brief
Return the userlD of the collision on which the person is standing.
Definition
! number Person.GetGroundUserld( Person person )
Arguments
person - The person to query
Return Values
The userlD.
Description
Return the userlD of the collision on which the person is standing. Check Person.IsOnGround before calling this function; if the person is not on
the ground an error will occur.
Examples
! if ( person:IsOnGround() ) then
print( Person.GetGroundUserld( person ) )
| end
See Also
� Person.IsOnGround
Person.GetHeight
Brief
Retrieve the avatar's height in meters.
Definition
! number Person.GetHeight(Person person)
Arguments
person - the person to query.
Return Values
The height of the person's avatar in meters, or nil if the avatar is not yet loaded.
Description
The value returned is the height of the avatar when in the bind pose, given the current height settings, in meters. This will return nil if the avatar is
currently a fallback.
Examples
! if ( person:GetHeight() <1.0 ) then print ("Hello shorty") end
See Also
None
Person.Getld
Brief
Returns the person's ID.
Definition
j string Person.GetId( Person person )
Arguments
person - The person to query.
Return Values
The person's ID.
Description
Returns the person's ID. A person's ID value is unique per instance, but not across instances and is not persistent. That is, a person ID can be
used within an instance to uniquely identify any person in that instance, but it should be assumed to be assigned at random to players entering
the instance, and only valid while that player is in the instance. Players in another instance of the same scene will not be accessible by person ID.
Players exiting and re-entering the instance will almost certainly be assigned a different person ID, but a person's ID will not change while they
remain in the same instance.
Examples
me = LocalPlayer.GetPerson()
if Person.GetId( me ) ~= LocalPlayer.GetPersonld() then
print( "Oh no!" )
end
See Also
� LocalPlayer.GetPerson
� LocalPlayer.GetPersonld
Person.GetldsOfFriendsInlnstance
Brief
Returns a table of people IDs in the current instance that are friends.
Definition
string[] Person.GetldsOfFriendsInlnstance()
Arguments
None
Return Values
A table of person ID strings.
Description
Returns a table of person IDs in the current instance that are friends.
Examples
! ids = Person.GetIdsOfFriendsInlnstance()
; numFriends = #ids
j print( "There are " .. numFriends .. " friends in the instance." )
See Also
None
Person. GetldsOfRemotePeoplelnlnstance
Brief
Returns a table of all remote person IDs in the current instance.
Definition
string[] Person.GetldsOfRemotePeoplelnlnstance()
Arguments
None
Return Values
A table of person ID strings.
Description
Returns a table of person IDs for all remote avatars in the current instance.
Examples
! ids = Person.GetIdsOfRemotePeoplelnlnstance()
i numAvatars = #ids + 1
I print( "There are " .. numAvatars .. " avatars in the instance." )
See Also
None
Person.GetlnstanceSessionMasterld
Brief
Returns the current instance's session master Person ID.
Definition
string Person.GetlnstanceSessionMasterld()
Arguments
None
Return Values
A person ID of the session master or nil if not ready yet.
Description
Returns the current instance's session master Person ID. Each instance has a session master automatically assigned to it. When a new instance
is created the first person in that instance will be the session master and if they leave then a new session master is chosen if other users are in
the instance.
Examples
local sessionMasterld = Person.GetInstanceSessionMasterld()
local sessionMaster = nil
if sessionMasterld ~= nil then
sessionMaster = Person.Findlnlnstance( sessionMasterld )
SendNetworkMessageToRequestlnstanceState( sessionMaster )
end
See Also
� User.GetSceneOwner
Person. GetlnventoryltemObjectld
Brief
Obtain the object id of the currently deployed companion object.
Definition
! string Person.GetInventoryltemObjectId(Person person)
Arguments
person - The person to query.
Return Values
The object ID of the deployed inventory item if present, and nil otherwise.
Description
Obtains the object id of the currently deployed companion object, or returns nil if one is not currently active.
Examples
if (Person.GetlnventoryltemObjectld(person) == "12345678-12345678-12345678-12345678") then
isAllowedlntoMiniGame = true
| end
See Also
None
Person.GetLocalBounds
Brief
Retrieve the local-space bounds of a person.
Definition
! boolean Person.GetLocalBounds(Person person, Vector4 min, Vector4 max)
Arguments
person - The person to query.min (out) - Vector4 value to receive the minimum extent.max (out) - Vector4 value to receive the maximum extent.
Return Values
True if the bounds were retrieved successfully, false if the person is not yet loaded.
Description
Get the local-space bounds of a person's model. This will reflect the user's clothing choices and height selection. If the person's avatar is not
loaded, this function will return false.
Examples
local min = Vector4.Create ()
local max = Vector4.Create()
if (LocalPlayer.GetPerson():GetLocalBounds(min, max)) then
print("Local player avatar is", max:Y() - min:Y(), "metres tall")
end
See Also
� Person.GetWorldBounds
Person. GetMood
Brief
Returns the mood of the specified person.
Definition
MoodType Person.GetMood(Person person)
Arguments
person - the person to interrogate the mood value for.
Return Values
The enumerated value of the mood.
Description
The mood type is the facial animation that is used on the idling person. This is controlled by the user through the status option in the emotes
menu. Different statuses can share the same mood, ie Confused and IsLookingForHelp statuses both use the same mood Confused. The
enumerated type of MoodType is:
MoodType.Neutral
MoodType.Happy
MoodType.Sad
MoodType.Angry
MoodType.Confused
Examples
if (person:GetMood() == MoodType.Sad) then
print("Why the long face?")
end
See Also
� Person. GetAvatarStatusType
Person. GetName
Brief
Returns the person's Online ID.
Definition
string Person.GetName( Person person )
Arguments
person - The person to query.
Return Values
The person's Online ID.
Description
Returns the person's Online ID, but only if you launch HomeDeveloper.self in online mode. If launching in offline mode, only the local player's
Person will be accessible, and the function will return the string "Me".
Examples
! me = LocalPlayer.GetPerson()
i print( "My name is " .. Person.GetName( me ) )
See Also
� LocalPlayer.GetPerson
Person.GetPosition
Brief
Returns the position of the person.
Definition
Vector4 Person.GetPosition( Person person )
Person.GetPosition( Person person, Vector4 outVec )
Arguments
person - The person to query.outVec - The Vector4 to store the result to.
Return Values
The position of the person.
Description
Returns a vector containing the position of the specified person.
Examples
! me = LocalPlayer.GetPerson()
print( "I am at: ", Person.GetPosition( me ) )
See Also
Local Player.GetPerson
Person.GetRigComponentObjectld
Brief
Returns the specified component type's object ID.
Definition
! string Person.GetRigComponentObjectId( Person person, string componentType )
Arguments
person - The person to query.componentType - The component type to search for. It is case sensitive.
Return Values
The component's object ID or nil if not found.
Description
Returns the specified component type's object ID. The component must be loaded to identity its type.
Examples
! me = LocalPlayer.GetPerson()
i types = Person.GetRigComponentTypes( person )
| print( 'type=* .. types[ 1 ] ' object id=' .. Person.GetRigComponentObjectId( person, types[ 1 ] )
)
See Also
� Person.GetRigComponentTypes
Person.GetRigComponentTypes
Brief
Returns a table of strings for the current rig's component types.
Definition
! string[] Person.GetRigComponentTypes( Person person )
Arguments
person - The person to query.
Return Values
Table of strings for the rig component types.
Description
Returns a table of strings for the current rig's component types. The rig must be loaded to obtain the information.
Examples
me = LocalPlayer.GetPerson()
rigCompTypes = Person.GetRigComponentTypes( me )
if rigCompTypes ~= nil then
for index, item in ipairs( rigCompTypes ) do
print( 'type = ' .. item )
end
end
See Also
� Person.GetRigComponentObjectld
Person.GetRigField
Brief
Returns the value of the field and nil if not found
Definition
string|number|boolean Person.GetRigField( Person person, string field )
Arguments
person - The person to query.field - The field to retrieve. Can be one of the following:
"sex" (returns the string "male" or "female")
Return Values
The value of the field and nil if not found. Supported types are boolean, string and number.
Description
Returns the value of the field and nil if not found. The rig must be loaded to get the correct result.
Examples
me = LocalPlayer.GetPerson()
| print( "My gender is " .. Person.GetRigField( me, "sex" ) )
See Also
� LocalPlayer.GetPerson
Person. GetRotationY
Brief
Returns the y-axis rotation of the person.
Definition
number Person.GetRotationY( Person person )
Arguments
person - The person to query.
Return Values
The rotation in the y-axis of the person in degrees.
Description
Returns the rotation in the y-axis of the specified person in degrees.
Examples
i me = LocalPlayer.GetPerson()
! print( "My rotation is: " .. Person.GetRotationY( me ) )
See Also
� LocalPlayer.GetPerson
Person.GetUser
Brief
Returns the User object for this person.
Definition
User Person.GetUser( Person person )
Arguments
person - The person to query.
Return Values
The User object for the specified person.
Description
Returns the User object attached to the specified person.
Examples
local user = person:GetUser()
print(person:GetName() .. (user:IsFriend() and " is " or " is not ") .. "your friend!")
See Also
Person.GetVelocity
Brief
Returns the current velocity of the person.
Definition
Vector4 GetVelocity( Person person )
locity( Person person, Vector4 outVec )
Arguments
person - the person to queryoutVec - The Vector4 to store the result in
Return Values
Returns the current velocity of the person specified if no outVec is supplied.
Description
Returns a vector containing the velocity of the person specified.
Examples
1 local me = LocalPlayer.GetPerson()
i elocity is: ", Person.GetVelocity( me ) )
See Also
None
Person.GetWidth
Brief
Retrieves the width factor of an avatar.
Definition
! number Person.GetWidth(Person person)
Arguments
person - the person to query.
Return Values
The width factor of the person in the range [ -1, 1 ], or nil if the avatar isn't yet loaded and available.
Description
Return the width factor of the avatar, which is in the range -1 to 1, with -1 being thin, 0 being average, and 1 being fat.
Examples
1 if ( Person.GetWidth() == 1) then BreakChair() end
See Also
None
Person.GetWorldBounds
Brief
Retrieve the world-space bounds of a person.
Definition
boolean Person.GetWorldBounds(Person person, Vector4 min, Vector4 max)
Arguments
person - The person to query.min (out) - Vector4 value to receive the minimum extent.max (out) - Vector4 value to receive the maximum extent.
Return Values
True if the bounds were retrieved successfully, false if the person is not yet loaded.
Description
Get the world-space bounds of a person's model. This will reflect the user's clothing choices and height selection. If the person's avatar is not
loaded, this function will return false.
Examples
local min = Vector4.Create ()
local max = Vector4.Create ()
if (LocalPlayer.GetPerson():GetWorldBounds(min, max)) then
print("Local player avatar is", max:Y() - min:Y(), "metres tall")
end
See Also
� Person.GetLocalBounds
Person.HasLock
Brief
true if the person is locked by the calling Lua environment and false otherwise.
Definition
boolean Person.HasLock( Person person )
boolean Person.HasLock( Person person , number lockFeatures, boolean any = false )
Arguments
person - the person to query.lockFeatures - specific lock features to test to see if they are locked by this lua environmentany - if lockFeatures is
specified, then this parameter is used to indicate that if any of the features specified are locked, then return true
otherwise will only return true if all the features specified are locked.
Return Values
true if the person is locked by the calling Lua environment and false otherwise.
Description
true if the person is locked by the calling Lua environment and false otherwise.
Examples
if Person.HasLock( person ) == true then
Person.DoAction( person, "Clap" )
end
See Also
� Person.Lock
� Person.Unlock
� Person.IsLocked
� Person.DoAction
� Person.SetBehavior
Person.InterpolatePosition
Brief
Allows the client to interpolate the position of the person in the frames between successive calls to InterpolatePosition.
Definition
! Person.InterpolatePosition( Person person, Vector4 position, Vector4 velocity, number facingAngle,
i number timeOffset = 0)
Arguments
person - the person to interpolate the position onposition - the position to use for the interpolationvelocity - the velocity to use for the
interpolationfacinqAnqle - the anqle the person is facinqtimeOffset - the difference in time between the session clocks (in seconds) - if omitted
then defaults to 0.0
Return Values
None.
Description
The calling lua environment must have atleast a Transform lock on the person for the call to succeed This call will only work on NPC persons (will
throw a Lua error for the the local player person).
Examples
person:InterpolatePosition( recvdPos, recvdVel, recvdAngle, timeOffset )
See Also
� Person.Lock
� Person.GetPosition
� Person.GetVelocity
Person.IsCollision
Brief
Reports whether the person's collision is enabled.
Definition
boolean Person.IsCollision( Person person )
Arguments
person - the person to query.
Return Values
true if collision for the player is on and false otherwise.
Description
Reports whether the person's collision is enabled.
Examples
! if Person.IsCollision( person ) then
Person.EnableCollision( person, false )
| end
See Also
� Person.EnableCollision
Person.IsLoaded
Brief
Indicates when a person's avatar is fully loaded and visible.
Definition
boolean Person.IsLoaded(Person person)
Arguments
person - The person to query.
Return Values
True if the person's avatar is fully loaded and ready, or false if still loading or invalid.
Description
When a person initially enters the scene, their avatar and associated components may still be loading in the background. Some functionality such
as locking is not available until the avatar is ready, so this function can be used to query the loading state of the person. If the person object is
invalid, this function will return false.
Examples
if (person:IsValid() and person:IsLoaded()) then
if (not person:Lock(PersonLockType.All)) then
print("Unable to get lock!")
end
end
See Also
� Person.IsValid
Person.IsLocked
Brief
true if the person is locked by any lua environment and false otherwise.
Definition
! boolean Person.IsLocked(Person person)
Arguments
person - the person to query.
Return Values
true if the person is locked by any lua environment and false otherwise.
Description
true if the person is locked by any lua environment and false otherwise.
Examples
if Person.IsLocked( person ) == true and Person.HasLock( person ) == false then
print( �Waiting to get the lock' )
| end
See Also
� Person.Lock
� Person.Unlock
� Person.HasLock
� Person.DoAction
� Person.SetBehavior
Person. IsOnGround
Brief
Return whether the person is on the ground or not.
Definition
! boolean Person.IsOnGround( Person person )
Arguments
person - The person to query
Return Values
true if on the ground, false otherwise.
Description
Return whether the person is on the ground or not.
Examples
! print( Person.IsOnGround( person ) );
See Also
� Person.GetGroundllserld
Person.IsRigUsingComponent
Brief
Returns true if the specified object is being used and false otherwise.
Definition
boolean Person.IsRigUsingComponent( Person person, string objectld )
Arguments
person - The person to query.objectld - The object ID to test for its usage.
Return Values
true if the specified object is being used and false otherwise.
Description
Returns true if the specified object is being used and false otherwise. Does not require the specified object have have completed its loading for
the function to succeed.
Examples
me = LocalPlayer.GetPerson()
smartJacketId = "853B950D-ACF84EE7-920D819B-5A9A6C16"
if Person.IsRigUsingComponent( me, smartJacketld ) then
accessGranted = true
end
See Also
� LocalPlayer.GetPerson
Person.IsValid
Brief
Returns whether the handle to the person is valid or not.
Definition
boolean Person.IsValid( Person person )
Arguments
person - The person to query.
Return Values
Returns whether the handle to the person is valid or not.
Description
Returns whether the handle to the person is valid or not. Invalid persons can be caused if the person leaves the scene while you still have a
handle to that person.
Examples
if Person.IsValid( randomPerson ) == false then
person = GetAnotherPerson()
| end
See Also
� Person.Findlnlnstance
� Person. IsLoaded
Person.IsVisible
Brief
Return whether the person is visible or not to the user.
Definition
boolean Person.IsVisible( Person person )
Arguments
None
Return Values
Return whether the person is visible or not
Description
If a user can see a Person in game this will return true, otherwise false. No lock is required since you are only querying the value.
Examples
Person.SetVisibile( person, true );
print( Person.IsVisible( person ) );
See Also
� Person.Lock
� Person.Unlock
Person.Lock
Brief
Locks a combination of the person's animation, collision state, transform, label or chatbubbles so it can be controlled by script rather than network
messages or pad input.
Definition
boolean Person.Lock( Person person, number lockType = nil )
Arguments
person - the person to query.lockType - Can be one of the following or nil:
PersonLockType. Animation
PersonLockType.Transform
PersonLockType.Collision
PersonLockType. Visibility
PersonLockType. Label
PersonLockType.ChatBubbles
PersonLockType. EmoteMenu
PersonLockType. Wardrobe
PersonLockType.Default = PersonLockType.Animation + PersonLockType.Transform + PersonLockType.Collision + PersonLockType.Visibility
PersonLockType.All - all the lock types together
If lockType is nil then PersonLockType.Default is used.
Return Values
True if the Lua environment was able to obtain the lock (or already has the lock) on the person, otherwise false.
Description
A Lua error is generated if the lockType passed in aren't one of the possible values above. Lua errors are also generated if
PersonLockType.Label or PersonLockType.ChatBubbles is used when not in a minigame which supports it. A lock can only be obtained for
people currently joined to the active game, and will be released automatically for all people when the local player quits the game. A script should
not rely on this automatic behaviour however, and locks should be explicitly released as soon as they are no longer required. *NB To prevent a
delay in character loading causing scripts to fail, always ensure that calls to Person.Lock() return true before using any functions which require a
locked character. If the function returns false, wait for a short period and then attempt to lock the character again. This can be performed in a
co-routine if necessary. 1.55 Added PersonLockType.Wardrobe. This lock type can only be used on the Local Player person, otherwise a Lua
error is thrown.
Examples
� Example 1, locking specific types.
Person.Lock( person, PersonLockType.Transform ) � Locked the transform
Person.Lock( person, PersonLockType.Collision ) � Unlocked the transform and now locked the collision
Person.Lock( person, PersonLockType.Collision + PersonLockType.Visibility ) � Now additionally locked
the visibility
� Example 2, locking transform, collision, animation and visibility,
if Person.Lock ( person ) then
Person.DoAction( person, "clap" )
end
See Also
� Person.Unlock
� Person.IsLocked
� Person.HasLock
� Person.DoAction
� Person.SetBehavior
Person.ResetCurrentStatusText
Brief
Reset the status text to show in the over-head person label.
Definition
| Person.ResetCurrentStatusText( Person person )
Arguments
person - The person to update.
Return Values
None.
Description
Reset the status text to show in the over-head person label.
Examples
me = LocalPlayer.GetPerson()
j Person.ResetCurrentStatusText( me )
See Also
� LocalPlayer.GetPerson
Person.SetAnimReg
Brief
Sets the value of the specified animation register for the specified person.
Definition
! Person.SetAnimReg(Person person, string registerName, number|boolean|string value)
Arguments
person - person to set the animation register for.registerName - the name of the animation register to set.value - the value to set the register (the
type should agree with the register type).
Return Values
None.
Description
If the register doesn't exist or does not have Lua write access, or the value type and the register type don't match, then an error will be thrown.
Examples
person:SetAnimReg("myReg", 0.3)
See Also
� Person. GetAnimReg
Person.SetBehavior
Brief
Sets the current behavior of the person
Definition
Person.SetBehavior( Person person, string behaviorName, number unlockPeriodSeconds = 0, boolean
snapAnimation = false )
Person.SetBehavior( Person person, string behaviorName, number unlockPeriodSeconds, boolean
snapAnimation, number unlockFeatures )
Arguments
person - The Person to set the behavior onbehaviorName - The name of the behavior.unlockPeriodSeconds - if great than 0 then the animation
lock on the person is automatically released after
the period specified has elapsed. Defaults to 0.snapAnimation - if true, then removes blend from previous action/behavior (defaults
false)unlockFeatures - only used if the unlockPeriodSeconds parameter is greater than 0. If omitted then defaults to releasing the locks that were
set when
Person.SetBehavior was called, otherwise will only release the locks specified.
Return Values
Error code. BehaviorError.None if everything was fine, BehaviorError.Invalid if the behavior cannot be set, BehaviorError.NotReady if the person
is not ready for setting the behavior
Description
The following behaviors Home behaviors are available for use:
sitjow
sit_mid
sit_high
sit_low_recline
sit_mid_recline
standing
Additionally, any behaviors defined by the developer within an objects repertoire are available for use by the developer. The animation must be
locked by the calling lua environment otherwise a lua error is generated. If the behavior specified isn't recognised, then a lua error is thrown.
Examples
if Person.HasLock ( person ) == true then
Person.SetBehavior( person, "sit_mid" )
end
See Also
� Person.Lock
� Person.Unlock
� Person. IsLocked
Person.HasLock
� Person.DoAction
Person.SetCurrentStatusText
Brief
Set the status text to show in the over-head person label.
Definition
Person.SetCurrentStatusText( Person person, string text, bool persist = false )
Arguments
person - The person to update.text - The status text to show in the over-head person label.persist - boolean which determines whether the text is
displayed in picture captures.
Return Values
None.
Description
Set the status text to show in the over-head person label. The status text is used to indicate an activity that the user is currently partaking in. This
function must not be used without first obtaining permission from your RHQ.
Examples
! me = LocalPlayer.GetPerson()
i Person.SetCurrentStatusText( me,
"Racing!" )
See Also
None
Person.SetLabelText
Brief
Change the current text label displayed atop the avatar.
Definition
Person.SetLabelText( Person person, enumeration setting )
Arguments
setting - the current setting to use for player labels.
PersonLabelText.On
PersonLabelText.Off
PersonLabelText.Name
Return Values
None.
Description
With this function, a script can set the labels above a person to show full labels, just the name, or even switch them off. Please note: In order to
use this function, the is_allowed_label_change property in the object's mini_game component must be set to true.
Examples
local person = LocalPlayer.GetPerson( );
if ( Person.Lock( person, PersonLockType.Label ) == true ) then
Person.SetLabelText( person, PersonLabelText.Off );
end
See Also
� Person.Lock
� Person.Unlock
Person.SetPosition
Brief
Sets the position of the the person, assuming the calling Lua environment owns the lock (with transformation attribute)
Definition
SetPosition( Person person, Vector4 position )
Arguments
position - the desired world position of the person
Return Values
None.
Description
The transform must be locked by the calling lua environment otherwise a lua error is generated.
Examples
! Person.SetPosition( person, pos )
See Also
� Person.Lock
� Person.Unlock
Person.SetRotationY
Brief
Sets the rotation in the (world) Y axis of the person.
Definition
Person.SetRotationY( Person person, number angle)
Arguments
person - The Person to set.angle - The world angle in degrees.
Return Values
None.
Description
The transform must be locked by the calling lua environment otherwise a lua error is generated.
Examples
I Person.SetRotationY( person, 180 )
See Also
� Person.Lock
� Person.Unlock
Person.SetVisible
Brief
Sets the visibility of the the person.
Definition
! Person.SetVisible( Person person, boolean enable )
Arguments
enable - whether to switch visibility on or off for that person
Return Values
None.
Description
Sets the visibility of the the person. The visibility must be locked with visibility attribute PersonLockType.Visibility by the calling lua environment
otherwise a lua error is generated. If the person is not valid the call is ignored.
Examples
I Person.SetVisible( person, false )
See Also
� Person.Lock
� Person.Unlock
� Person.IsLocked
� Person.HasLock
Person.Unlock
Brief
Unlocks the features specified on the person. If all features are unlocked, then lock is released, allowing other Lua environments to get a lock.
Definition
Arguments
person - the Person to unlock.unlockFlags - the features to unlock. If 0 is passed in will return false.
Return Values
A true return value only indicates that the features requested to be unlocked were unlocked, which may mean that other features are still locked
and that the person is not yet free to be locked by another calling environment - Use if (Person.HasLock(person, PersonLockType.AII )==false)
to verify if lock has been released on the person. 'Return value behaviour has changed for 1.45 - see history for previous behaviour.
Description
If all features are unlocked, it then allows other lua environments to lock the person. The features are:
PersonLockType. Animation
PersonLockType.Transform
PersonLockType.Collision
PersonLockType. Visibility
PersonLockType. Label
PersonLockType.ChatBubbles
PersonLockType. EmoteMenu
PersonLockType.Default = PersonLockType.Animation + PersonLockType.Transform + PersonLockType.Collision + PersonLockType.Visibility
PersonLockType.AII - all the lock types together
Examples
Person.Unlock( person , PersonLockType.Animation + PersonLockType.Transform )
See Also
� Person.Lock
� Person.IsLocked
� Person.HasLock
� Person.DoAction
� Person.SetBehavior
Vector4
Vector4.Abs
Brief
Compute the component-wise absolute value of a vector.
Definition
! Vector4.Abs(Vector4 dest, Vector4 v)
Arguments
dest - destination vector to store result.v - vector to negate.
Return Values
None.
Description
Sets dest to [math.abs(v:XQ), math.abs(v:Y()), math.abs(v:Z()), math.abs(v:W())].
Examples
� local v = Vector4.Create(-1, 2 , -3)
i v:Abs(v)
; print (v) � [1, 2 , 3]
See Also
None
Vector4.Add
Brief
Adds one vector or number to another and stores the result in the destination.
Definition
! Vector4.Add( Vector4 destination, Vector4|number sourcel, Vector4|number source2 )
Arguments
destination - Vector to store the result of the addition.sourcel - Vector or number to be added to source2.source2 - Vector or number to be added
to sourcel.
Return Values
None.
Description
Adds one vector or number to another and stores the result in the destination.
Descriptive notation:
destination.x = sourcel .x[source1 + source2.x|source2
destination.y = sourcel ,y|source1 + source2.y|source2
destination.z = sourcel .z|source1 + source2.z|source2
destination, w = sourcel .w|source1 + source2.w|source2
Examples
result = Vector4.Create()
vl = Vector4.Create(
1, 2, 3, 4 )
v2 = Vector4.Create(
4 , 3, 2, 1 )
Vector4.Add( result,
vl, v2 )
Vector4.Add( result.
3, v2 )
See Also
� Vector4.Create
Vector4.Calculate2dLinelntersection
Brief
Calculates a 2-dimensional line intersection.
Definition
boolean Vector4.Calculate2dLineIntersection( Vector4 intersectionPoint, Vector4 pO, Vector4 pi,
Vector4 qO, Vector4 ql, boolean infinitelntersection = false )
Arguments
intersectionPoint - The result of the line intersection.pO - First endpoint of first line.pi - Second endpoint of first line.qO - First endpoint of second
line.ql - Second endpoint of second line.infinitelntersection - true if the supplied lines are to be treated as infinite rays, false otherwise
Return Values
Returns true if lines intersect, false otherwise.
Description
Calculates a 2-dimensional line intersection with the line p, defined by points pO and pi, with the line q, defined by points qO and ql. If the
infinitelntersection is true it returns false if p and q are parallel. If infinitelntersection is false it returns false if the lines are parallel or the
intersection does not lie on both p and q.
Examples
pO = Vector4.Create( 1, 0 )
pi = Vector4.Create( 0, 0 )
qO = Vector4.Create( 0, 0.5 )
ql = Vector4.Create( 1, 0.5 )
ip = Vector4.Create()
if Vector4.Calculate2dLineIntersection( ip, pO, pi, qO, ql ) then
print ( "The lines intersect!" )
end
See Also
� Vector4.Create
Vector4.Copy
Brief
Copies the values of one vector into another.
Definition
Vector4.Copy( Vector4 destination, Vector4 source )
Arguments
destination - The vector to copy to.source - The vector to be copied.
Return Values
None.
Description
Copies the values of the source vector and stores them in the destination. This is used to copy the values as opposed to pointing to the same
vector as an assignment would do. Use copy as vec2 = vecl does not copy values but instead makes vec2 point to vecl.
Examples
vecl = Vector4.Create( 4, 3, 2, 1 )
vec2 = Vector4.Create()
Vector4.Copy( vec2, vecl )
See Also
� Vector4.Create
Vector4.Create
Brief
Creates a new Vector4 object using the specified values.
Definition
Vector4 Vector4.Create( Vector4 source )
Vector4 Vector4.Create( number x = 0.0, number y = 0.0, number z = 0.0, number w = 0.0 )
Arguments
source - Vector whose values are used to initialize newly created vector.x - Number to be written into the first element of the vector (defaults to
0).y - Number to be written into the second element of the vector (defaults to 0).z - Number to be written into the third element of the vector
(defaults to 0).w - Number to be written into the fourth element of the vector (defaults to 0).
Return Values
A new Vector4 instance.
Description
Creates a new Vector4 object using the specified values.
Examples
� Create a default zero (0, 0, 0, 0) vector
vecl = Vector4.Create ()
� Create a vector with supplied values
vec2 = Vector4.Create ( 1, 2, 3, 4 )
� Create a vector using the values of another
vec3 = Vector4.Create( vec2 )
See Also
� Vector4.CreateBroadcast
Vector4.CreateBroadcast
Brief
Creates a new Vector4 and sets all its elements to the specified value.
Definition
Vector4 Vector4.CreateBroadcast( number value )
Arguments
value - The value to broadcast to all the elements of the new vector.
Return Values
A new Vector4 instance.
Description
Creates a new Vector4 and sets all its elements to the specified value.
Examples
vecHalf = Vector4.CreateBroadcast( 0.5 )
vec = Vector4.Create( 1, 2 , 3 )
Vector4.Multiply( vec, vec, vecHalf )
See Also
� Vector4. Create
Vector4.Cross
Brief
Performs a cross product between two 3-dimensional vectors.
Definition
Vector4.Cross( Vector4 destination, Vector4 srcl, Vector4 src2 )
Arguments
destination - Vector to store the result of the cross product.srcl - First vector to take part in the cross product.src2 - Second vector to take part in
the cross product.
Return Values
None.
Description
Performs a 3-dimensional cross product between srcl and src2 storing the result in destination. The vector generated will be perpendicular to
both srcl and src2.
Vector algebra notation:
srcl X src2
Descriptive notation:
destination.x = ( srcl .y * src2.z ) - ( srcl .z * src2.y )
destination.y = ( srcl .z * src2.x ) - ( srcl .x * src2.z )
destination.z = ( srcl .x * src2.y ) - ( srcl .y * src2.x )
Examples
xAxis = Vector4.Create( 1, 0, 0 )
yAxis = Vector4.Create( 0, 1, 0 )
result = Vector4.Create()
Vector4.Cross( result, xAxis, yAxis )
See Also
� Vector4.Create
Vector4.Dist2Sqr
Brief
Computes the squared Euclidean distance between two points in 2D space.
Definition
number Vector4.Dist2Sqr( Vector4 pi, Vector4 p2 )
Arguments
pi - A point in 2D space.p2 - A second point in 2D space.
Return Values
The squared Euclidean distance between the two points.
Description
Computes the squared Euclidean distance between two points in 2D space.
Vector algebra notation:
((p2-p1) dot (p2-p1))
Examples
vl = Vector4.Create (1, 2)
v2 = Vector4.Create (2, 3)
print("Distance between", vl, "and", v2, "is:", math.sqrt(Vector4.Dist2Sqr(vl, v2)))
See Also
� Vector4.Dist3Sqr
� Vector4.Dist4Sqr
Vector4.Dist3Sqr
Brief
Computes the squared Euclidean distance between two points in 3D space.
Definition
number Vector4.Dist3Sqr( Vector4 pi, Vector4 p2 )
Arguments
pi - A point in 3D space.p2 - A second point in 3D space.
Return Values
The squared Euclidean distance between the two points.
Description
Computes the squared Euclidean distance between two points in 3D space.
Vector algebra notation:
(( P 2-p1) dot ( P 2-p1))
Examples
j vl = Vector4.Create(1, 2, 3)
I v2 = Vector4.Create(2, 3, 4)
j print("Distance between", vl, "and", v2, "is:", math.sqrt(Vector4.Dist3Sqr(vl, v2)))
See Also
� Vector4.Dist2Sqr
� Vector4.Dist4Sqr
Vector4.Dist4Sqr
Brief
Computes the squared Euclidean distance between two points in 4D space.
Definition
number Vector4.Dist4Sqr( Vector4 pi, Vector4 p2 )
Arguments
pi - A point in 4D space.p2 - A second point in 4D space.
Return Values
The squared Euclidean distance between the two points.
Description
Computes the squared Euclidean distance between two points in 4D space.
Vector algebra notation:
((p2-p1) dot (p2-p1))
Examples
vl = Vector4.Create ( 1, 2, 3, 4 )
v2 = Vector4.Create ( 2 , 3, 4, 5 )
print("Distance between", vl, "and", v2, "is:", math.sqrt(Vector4.Dist4Sqr(vl, v2)))
See Also
� Vector4.Dist2Sqr
� Vector4.Dist3Sqr
Vector4. Divide
Brief
Divides one vector or scalar by the other vector or scalar.
Definition
Vector4.Divide( Vector4 destination, Vector4|number sourcel, Vector4|number source2 )
Arguments
destination - Vector to store the result of the division.sourcel - The dividend of the vector division.source2 - The divisor of the vector division.
Return Values
None.
Description
Divides sourcel by source2 storing the result in destination.
Descriptive notation:
destination.x = sourcel .x|source1 / source2.x]source2
destination.y = sourcel .y|source1 / source2.y|source2
destination, z = sourcel ,z|source1 / source2.z|source2
destination.w = sourcel .w|source1 / source2.w|source2
Examples
result = Vector4.Create()
vl = Vector4.Create( 1, 2, 3, 4 )
v2 = Vector4.Create( 4, 3 , 2 , 1 )
Vector4.Divide( result, vl, v2 )
Vector4.Divide( result, 1.0, v2 )
See Also
� Vector4.Create
Vector4.Dot2
Brief
Performs a dot product between two 2-dimensional vectors.
Definition
number Vector4.Dot2( Vector4 srcl, Vector4 src2 )
Arguments
srcl - First vector to take part in the dot product.src2 - Second vector to take part in the dot product.
Return Values
The number representing the dot product of the two supplied 2-dimensional vectors.
Description
Performs a 2-dimensional dot product with srcl and src2 returning the result.
Vector algebra notation:
srcl . src2
Descriptive notation:
returnvalue = ( srcl .x * src2.x ) + ( srcl .y * src2.y )
Examples
vl = Vector4.Create ( 1, 2 )
v2 = Vector4.Create ( 4, 3 )
result = Vector4.Dot2( vl, v2 )
See Also
� Vector4.Create
� Vector4.Dot3
� Vector4.Dot4
Vector4.Dot3
Brief
Performs a dot product between two 3-dimensional vectors.
Definition
number Vector4.Dot3( Vector4 srcl, Vector4 src2 )
Arguments
srcl - First vector to take part in the dot product.src2 - Second vector to take part in the dot product.
Return Values
The number representing the dot product of the two supplied 3-dimensional vectors.
Description
Performs a 3-dimensional dot product with srcl and src2 returning the result.
Vector algebra notation:
srcl . src2
Descriptive notation:
returnvalue = ( srcl .x * src2.x ) + ( srcl .y * src2.y ) + ( srcl .z * src2.z )
Examples
j vl = Vector4.Create( 1, 2, 3 )
! v2 = Vector4.Create( 4, 3, 2 )
j result = Vector4.Dot3( vl, v2 )
See Also
� Vector4.Create
� Vector4.Dot2
� Vector4.Dot4
Vector4.Dot4
Brief
Performs a dot product between two 4-dimensional vectors.
Definition
1 number Vector4.Dot4( Vector4 srcl, Vector4 src2 )
Arguments
srcl - First vector to take part in the dot product.src2 - Second vector to take part in the dot product.
Return Values
The number representing the dot product of the two supplied 4-dimensional vectors.
Description
Performs a 4-dimensional dot product with srcl and src2 returning the result.
Vector algebra notation:
srcl . src2
Descriptive notation:
returnvalue = ( srcl .x * src2.x ) + ( srcl .y * src2.y ) + ( srcl .z * src2.z ) + ( srcl .w * src2.w )
Examples
vl = Vector4.Create ( 1, 2, 3, 4 )
v2 = Vector4.Create ( 4, 3, 2, 1 )
result = Vector4.Dot4( vl, v2 )
See Also
� Vector4.Create
� Vector4.Dot2
� Vector4.Dot3
Vector4.HorizAdd3
Brief
Compute the horizontal sum of a 3D vector.
Definition
number Vector4.HorizAdd3(Vector4 v)
Arguments
v - input vector.
Return Values
The sum of the X, Y and Z components of the input vector.
Description
Returns v:X() + v:Y() + v:Z(). W is ignored.
Examples
! local v = Vector4.Create(1, 2, 3)
I print(v:HorizAdd3()) � 6
See Also
� Vector4.HorizAdd4
Vector4.HorizAdd4
Brief
Compute the horizontal sum of a 4D vector.
Definition
number Vector4.HorizAdd4(Vector4 v)
Arguments
v - input vector.
Return Values
The sum of the X, Y, Z and W components of the input vector.
Description
Returns v:X() + v:Y() + v:Z() + v:W().
Examples
local v = Vector4.Create (1, 2, 3 , 4)
print(v:HorizAdd4()) � 10
See Also
� Vector4.HorizAdd3
Vector4.Length2
Brief
Calculates the length of a 2-dimensional vector.
Definition
number Vector4.Length2( Vector4 vector )
Arguments
vector - Source vector for the calculation.
Return Values
A number holding the magnitude of the specified 2-dimensional vector.
Description
Calculates the length of the specified 2-dimensional vector.
Vector algebra notation:
vector
or sqrt( vector dot vector)
Descriptive notation:
returnvalue = sqrt( ( vector.x * vector.x ) + ( vector.y * vector.y ))
Examples
vl = Vector4.Create( 1, 2 )
print( "Vector magnitude is: " .. Vector4.Length2( vl ) )
See Also
� Vector4.Create
� Vector4.Length3
� Vector4.Length4
Vector4.Length2Sqr
Brief
Calculates the squared length of a 2-dimensional vector.
Definition
! number Vector4.Length2Sqr( Vector4 vector )
Arguments
vector - Source vector for the calculation.
Return Values
A number holding the squared magnitude of the specified 2-dimensional vector.
Description
Calculates the squared length of the specified 2-dimensional vector.
Vector algebra notation:
( vector dot vector)
Descriptive notation:
returnvalue = ( vector.x * vector.x ) + ( vector.y * vector.y )
Examples
! vl = Vector4.Create( 1, 2 )
j print( "Vector squared magnitude is: " .. Vector4.Length2Sqr( vl ) )
See Also
� Vector4. Create
� Vector4.Length3Sqr
� Vector4.Length4Sqr
� Vector4.Length2
Vector4.Length3
Brief
Calculates the length of a 3-dimensional vector.
Definition
number Vector4.Length3( Vector4 vector )
Arguments
vector - Source vector for the calculation.
Return Values
A number holding the magnitude of the specified 3-dimensional vector.
Description
Calculates the length of the specified 3-dimensional vector.
Vector algebra notation:
vector
or sqrt( vector dot vector)
Descriptive notation:
returnvalue = sqrt( ( vector.x * vector.x ) + ( vector.y * vector.y ) + ( vector.z * vector.z ))
Examples
vl = Vector4.Create ( 1, 2, 3 )
print( "Vector magnitude is: " .. Vector4.Length3( vl ) )
See Also
� Vector4.Create
� Vector4.Length2
� Vector4.Length4
Vector4.Length3Sqr
Brief
Calculates the squared length of a 3-dimensional vector.
Definition
! number Vector4.Length3Sqr( Vector4 vector )
Arguments
vector - Source vector for the calculation.
Return Values
A number holding the squared magnitude of the specified 3-dimensional vector.
Description
Calculates the squared length of the specified 3-dimensional vector.
Vector algebra notation:
( vector dot vector)
Descriptive notation:
retumvalue = ( vector.x * vector.x ) + ( vector.y * vector.y ) + ( vector.z * vector.z )
Examples
vl = Vector4.Create( 1 , 2, 3 )
print( "Vector squared magnitude is: " .. Vector4.Length34Sqr( vl ) )
See Also
� Vector4.Create
� Vector4.Length2Sqr
� Vector4.Length4Sqr
� Vector4.Length3
Vector4.Length4
Brief
Calculates the length of a 4-dimensional vector.
Definition
! number Vector4.Length4( Vector4 vector )
Arguments
vector - Source vector for the calculation.
Return Values
A number holding the magnitude of the specified 4-dimensional vector.
Description
Calculates the length of the specified 4-dimensional vector.
Vector algebra notation:
vector
or sqrt( vector dot vector)
Descriptive notation:
returnvalue = sqrt( ( vector.x * vector.x ) + ( vector.y * vector.y ) + ( vector.z * vector.z ) + ( vector.w * vector.w ))
Examples
vl = Vector4.Create( 1, 2, 3, 4 )
print( "Vector magnitude is: " .. Vector4.Length4( vl ) )
See Also
� Vector4.Create
� Vector4.Length2
� Vector4.Length3
Vector4.Length4Sqr
Brief
Calculates the squared length of a 4-dimensional vector.
Definition
! number Vector4.Length4Sqr( Vector4 vector )
Arguments
vector - Source vector for the calculation.
Return Values
A number holding the squared magnitude of the specified 4-dimensional vector.
Description
Calculates the squared length of the specified 4-dimensional vector.
Vector algebra notation:
( vector dot vector)
Descriptive notation:
returnvalue = ( vector.x * vector.x ) + ( vector.y * vector.y ) + ( vector.z * vector.z ) + ( vector.w * vector.w )
Examples
j vl = Vector4.Create( 1, 2 , 3 , 4 )
I print( "Vector squared magnitude is: " .. Vector4.Length4Sqr( vl ) )
See Also
� Vector4. Create
� Vector4.Length2Sqr
� Vector4.Length3Sqr
� Vector4.Length4
Vector4.Max
Brief
Compute the maximum element values of two vectors.
Definition
! Vector4.Max(Vector4 dest, Vector4 sourcel, Vector4 source2)
Arguments
dest - Vector to hold result. May be the same vector as either of source vectors if desired.sourcel - First source vector.source2 - Second source
vector.
Return Values
None.
Description
Compares each element in sourcel with equivalent element in source2 and stores the greater value in the equivalent element of dest. That is:
dest =
Unknown macro: { max(source1 .x, source2.x), max(source1 .y, source2.y), max(source1 .z, source2.z), max(source1 .w, source2.w)}
Examples
� assuming verts is an array of Vector4 values
local min = Vector4.Create(Const.MaxNum, Const.MaxNum, Const.MaxNum)
local max = Vector4.Create(-Const.MaxNum, -Const.MaxNum, -Const.MaxNum)
for i = 1, numVerts do
Vector4.Min(min, min, verts[i])
Vector4.Max(max, max, verts[i])
end
� min and max now store bounds of vert list
See Also
� Vector4.Min
� StreamOps.BoundsVec4
Vector4.Min
Brief
Compute the minimum element values of two vectors.
Definition
Vector4.Min(Vector4 dest, Vector4 sourcel, Vector4 source2)
Arguments
dest - Vector to hold result. May be the same vector as either of source vectors if desired.sourcel - First source vector.source2 - Second source
vector.
Return Values
None.
Description
Compares each element in sourcel with equivalent element in source2 and stores the lower value in the equivalent element of dest. That is:
dest =
Unknown macro: { min(source1.x, source2.x), min(source1 .y, source2.y), min(source1 .z, source2.z), minfsourcel .w, source2.w)}
Examples
� assuming verts is an array of Vector4 values
local min = Vector4.Create(Const.MaxNum, Const.MaxNum, Const.MaxNum)
local max = Vector4.Create(-Const.MaxNum, -Const.MaxNum, -Const.MaxNum)
for i = 1, numVerts do
Vector4.Min(min, min, verts[i])
Vector4.Max(max, max, verts[i])
end
� min and max now store bounds of vert list
See Also
� Vector4.Max
� StreamOps.BoundsVec4
Vector4.Multiply
Brief
Multiplies two vectors or scalars together storing the result as a vector.
Definition
Vector4.Multiply( Vector4 destination, Vector4|number sourcel, Vector4|number source2 )
Arguments
destination - Vector to store the result of the multiplication.sourcel - The first argument for the multiplication, can be a Vector4 or a scalar.source2
- The second argument for the multiplication, can be a Vector4 or a scalar.
Return Values
None.
Description
Multiplies sourcel and source2 together storing the result in the destination vector.
Descriptive notation:
destination.x = sourcel .x|source1 * source2.x|source2
destination.y = sourcel ,y|source1 * source2.y|source2
destination.z = sourcel ,z|source1 * source2.z|source2
destination.w = sourcel.w|source1 * source2.w|source2
Examples
result = Vector4.Create()
vl = Vector4.Create( 1, 2, 3, 4 )
v2 = Vector4.Create( 4, 3, 2, 1 )
Vector4.Multiply( result, vl, v2 )
Vector4.Multiply( result, vl, 4.0 )
Vector4.Multiply( result, -3.0, v2 )
Vector4.Multiply( result, -3.0, 4 )
See Also
Vector4. Create
Vector4.MultiplyAdd
Brief
Multiplies two vectors together and then adds the third vector.
Definition
Vector4.MultiplyAdd( Vector4 destination, Vector4|number sourcel, Vector4|number source2,
Vector4|number source3 )
Arguments
destination - Vector to store the result of the multiplication.sourcel - The first vector argument for the multiplication.source2 - The second vector
argument for the multiplication.source3 - The third vector argument for the addition.
Return Values
None.
Description
Multiplies sourcel and source2 together and then adds the third vector, storing the result in destination.
Descriptive notation:
destination.x = ( sourcel.x|source1 * source2.x|source2 ) + source3.x|source3
destination.y = ( sourcel.y|source1 * source2.y|source2 ) + source3.y|source3
destination.z = ( sourcel.z|source1 * source2.z|source2 ) + source3.z|source3
destination.w = ( sourcel .w]source1 * source2.w|source2 ) + source3.w|source3
Examples
result = Vector4.Create()
vl = Vector4.Create( 1, 2, 3, 4 )
v2 = Vector4.Create( 4, 3, 2, 1 )
v3 = Vector4.Create( 1, 0, 0, 1 )
Vector4.MultiplyAdd( result, vl, v2, v3 )
Vector4.MultiplyAdd( result, 1, 2, 6 )
See Also
� Vector4.Create
Vector4.Negate
Brief
Negate a vector in-place.
Definition
Vector4.Negate(Vector4 v)
Arguments
v - vector to negate.
Return Values
None.
Description
Sets v to -v.
Examples
! local v = Vector4.Create(1, 2, 3)
! v:Negate()
| print(v) � [-1, - 2 , -3]
See Also
None
Vector4.Normal2
Brief
Returns the normalization of a 2-dimensional vector.
Definition
Vector4 Vector4.Normal2( Vector4 vector )
Arguments
vector - The vector to normalize.
Return Values
A new Vector4 instance containing a normalized copy of the source vector.
Description
Returns the normalization of the specified 2-dimensional vector (i.e. a new vector of unit length). The source vector is not modified.
Descriptive notation:
length = sqrt( src.x * src.x + src.y * src.y )
returnvec.x = src.x / length
returnvec.y = src.y / length
retumvec.z = 0
returnvec.w = 0
Examples
| vec = Vector4.Create( 1, 2 )
; result = Vector4.Normal2( vec )
j print( result )
See Also
Vector4.Create
� Vector4.Normal3
� Vector4.Normal4
Vector4.Normal3
Brief
Returns the normalization of a 3-dimensional vector.
Definition
! Vector4 Vector4.Normal3( Vector4 src )
Arguments
src - The vector to use as a source to normalize.
Return Values
A new Vector4 instance containing a normalized copy of the source vector.
Description
Returns the normalization of the specified 3-dimensional vector (i.e. a new vector of unit length). The source vector is not modified.
Descriptive notation:
length = sqrt( src.x*src.x + src.y*src.y + src.z*src.z )
returnvec.x = src.x / length
returnvec.y = src.y / length
retumvec.z = src.z / length
retumvec.w = 0
Examples
j vec = Vector4.Create( 1, 2, 3 )
; result = Vector4.Normal3( vec )
j print( result )
See Also
� Vector4.Create
� Vector4.Normal2
� Vector4.Normal4
Vector4.Normal4
Brief
Returns the normalization of a 4-dimensional vector.
Definition
Vector4 Vector4.Normal4( Vector4 src )
Arguments
src - The vector to use as a source to normalize.
Return Values
A new Vector4 instance containing a normalized copy of the source vector.
Description
Returns the normalization of the specified 4-dimensional vector (i.e. a new vector of unit length). The source vector is not modified.
Descriptive notation:
length = sqrt( src.x*src.x + src.y*src.y + src.z*src.z + src.w*src.w )
returnvec.x = src.x / length
returnvec.y = src.y / length
returnvec.z = src.z / length
returnvec.w = src.z / length
Examples
j vec = Vector4.Create( 1, 2 , 3, 4 )
; result = Vector4.Normal4( vec )
| print( result )
See Also
� Vector4. Create
� Vector4.Normal2
� Vector4.Normal3
Vector4.Normalize2
Brief
Normalizes a vector using Length2 of that vector.
Definition
! Vector4.Normalize2( Vector4 vector )
Arguments
vector - The vector to normalize.
Return Values
None.
Description
Normalizes the specified vector using Length2 of the vector.
Descriptive notation:
length = sqrt( vector.x*vector.x + vector.y'vector.y )
vector.x = vector.x / length
vector.y = vector.y / length
vector.z = 0
vector.w = 0
Examples
! vector = Vector4.Create( 1, 3 , 2 , 4 )
! Vector4.Normalize2( vector )
| print( vector )
See Also
� Vector4.Create
� Vector4.Normalize3
� Vector4.Normalize4
Vector4.Normalizes
Brief
Normalizes a vector using Length3 of that vector.
Definition
! Vector4.Normalize3( Vector4 vector )
Arguments
vector - The vector to normalize.
Return Values
None.
Description
Normalizes the specified vector using Length3 of the vector.
Descriptive notation:
length = sqrt( vector.x*vector.x + vector.y'vector.y + vector.z*vector.z )
vector.x = vector.x / length
vector.y = vector.y / length
vector.z = vector.z / length
vector.w = 0
Examples
vector = Vector4.Create ( 1 , 3 , 2 , 4 )
Vector4.Normalize3( vector )
print ( vector )
See Also
� Vector4.Create
� Vector4.Normalize2
� Vector4.Normalize4
Vector4.Normalize4
Brief
Normalizes a vector using Length4 of that vector.
Definition
Vector4.Normalize4( Vector4 vector )
Arguments
vector - The vector to normalize.
Return Values
None.
Description
Normalizes the specified vector using Length4 of the vector.
Descriptive notation:
length = sqrt( vector.x*vector.x + vector.y'vector.y + vector.z*vector.z + vector.w'vector.w )
vector.x = vector.x / length
vector.y = vector.y / length
vector.z = vector.z / length
vector.w = vector.w / length
Examples
j vector = Vector4.Create( 1 , 3 , 2 , 4 )
I Vector4.Normalize4( vector )
| print( vector )
See Also
� Vector4. Create
� Vector4.Normalize2
� Vector4. Normalizes
Vector4.Recip
Brief
Compute the component-wise reciprocal of a vector.
Definition
Vector4.Recip(Vector4 dest, Vector4 v)
Arguments
dest - destination vector to store result.v - input vector.
Return Values
None.
Description
Sets dest to [1 / v:X(), 1 / v:Y(), 1 / v:Z(), 1 / v:W()]. If any elements of v are 0 the result is undefined. Note that due to floating point arithmetic
precision, Recip(Recip^) is not necessarily x.
Examples
j local v = Vector4.Create (-1, 2, -3)
I v:Recip(v)
| print(v) � [-1, 0.5, -0.333333]
See Also
� Vector4.RecipSqrt
Vector4.RecipSqrt
Brief
Compute the component-wise reciprocal square root of a vector.
Definition
Vector4.RecipSqrt(Vector4 dest, Vector4 v)
Arguments
dest - destination vector to store result.v - input vector.
Return Values
None.
Description
Sets dest to [1 / math.sqrt(v:X()), 1 / math.sqrt(v:Y()), 1 / math.sqrt(v:Z()), 1 / math.sqrt(v:W()]. If any elements of v are <= 0 the result is
undefined. This operation is faster than the equivalent combination of Sqrt and Recip.
Examples
local v = Vector4.Create(1, 4, 9)
v:RecipSqrt(v)
print(v) � [1, 0.5, 0.333333]
See Also
� Vector4.Recip
� Vector4.Sqrt
Vector4. Rotate
Brief
Rotate a vector about and axis.
Definition
Vector4.Rotate( Vector4 destination, Vector4 source, Vector4 axis, number angle )
Arguments
destination - Vector to store the result of the rotation.source - Vector to be rotated.axis - Axis to rotate about.angle - Angle (in degrees) to rotate
by.
Return Values
Description
Rotate a vector about and axis.
Examples
src = Vector4.Create( 12, 2, -3 )
axis = Vector4.Create( 0, 0.707, -0.707 )
dst = Vector4.Create()
Vector4.Rotate( dst, src, axis, 45 )
See Also
� Vector4. Create
Vector4.SetBroadcast
Brief
Sets the all of the vector's elements to the specified value.
Definition
Vector4 Vector4.SetBroadcast( Vector4 vector, number value )
Arguments
vector - Vector to be set.value - The value to broadcast to all the elements of the vector.
Return Values
None.
Description
Sets the all of the vector's elements to the specified value.
Examples
vecHalf = Vector4.Create()
Vector4.SetBroadcast( vecHalf, 0.5 )
vec = Vector4.Create( 1, 2, 3 )
Vector4.Multiply( vec, vec, vecHalf )
See Also
� Vector4.Create
� Vector4.CreateBroadcast
Vector4.SetW
Brief
Sets the w value of the vector.
Definition
Vector4.SetW( Vector4 vector, number value )
Arguments
vector - Vector to be set.value - A numerical value that is copied into the w component of the vector.
Return Values
None.
Description
Sets the w value of the vector.
Examples
j vec = Vector4.Create( 1, 2, 3, 4 )
! Vector4.SetW( vec, 6 )
See Also
� Vector4. Create
� Vector4.SetX
� Vector4.SetY
Vector4.SetZ
Vector4.SetX
Brief
Sets the x value of the vector.
Definition
Vector4.SetX( Vector4 vector, number value )
Arguments
vector - Vector to be set.value - A numerical value that is copied into the x component of the vector.
Return Values
None.
Description
Sets the x value of the vector.
Examples
j vec = Vector4.Create( 1, 2, 3, 4 )
i Vector4.SetX( vec, 6 )
See Also
� Vector4.Create
� Vector4.SetY
� Vector4.SetZ
� Vector4.SetW
Vector4.SetXyzw
Brief
Sets a Vector4 object with the specified values.
Definition
! Vector4.SetXyzw( Vector4 vector, number x = 0, number y = 0, number z = 0, number w = 0 )
Arguments
vector - Vector to be set.x - Number to be written into the first element of the vector (defaults to 0).y - Number to be written into the second
element of the vector (defaults to 0).z - Number to be written into the third element of the vector (defaults to 0).w - Number to be written into the
fourth element of the vector (defaults to 0).
Return Values
None.
Description
Sets a Vector4 object with the specified values.
Examples
vec = Vector4.Create()
Vector4.SetXyzw( vec, 1, 2, 3, 4 )
See Also
� Vector4.Create
Vector4.SetY
Brief
Sets the y value of the vector.
Definition
1 Vector4.SetY( Vector4 vector, number value )
Arguments
vector - Vector to be set.value - A numerical value that is copied into the y component of the vector.
Return Values
None.
Description
Sets the y value of the vector.
Examples
vec = Vector4.Create( 1, 2, 3, 4 )
Vector4.SetY( vec, 6 )
See Also
� Vector4.Create
� Vector4.SetX
� Vector4.SetZ
� Vector4.SetW
Vector4.SetZ
Brief
Sets the z value of the vector.
Definition
Vector4.SetZ( Vector4 vector, number value )
Arguments
vector - Vector to be set.value - A numerical value that is copied into the z component of the vector.
Return Values
None.
Description
Sets the z value of the vector.
Examples
j vec = Vector4.Create( 1, 2, 3, 4 )
: Vector4.SetZ( vec, 6 )
See Also
� Vector4.Create
� Vector4.SetX
� Vector4.SetY
� Vector4.SetW
Vector4.Sign
Brief
Compute the sign (-1 or 1) of all elements in a vector.
Definition
! Vector4.Sign(Vector4 dest, Vector4 v)
Arguments
dest - destination vector to store result.v - input vector.
Return Values
None.
Description
Each element of dest is set to the sign (-1 or 1) of the equivalent element of v. 0 is considered positive and thus becomes 1, if a separate 0 value
is required use the Signum function.
Examples
j local v = Vector4.Create (-3.1, 0, -0.4, 1.2)
i v:Sign(v)
j print (v) � [-1, 1, -1, 1]
See Also
Vector4.Signum
Vector4.Signum
Brief
Compute the sign (-1,0 or 1) of all elements in a vector.
Definition
! Vector4.Signum(Vector4 dest, Vector4 v)
Arguments
dest - destination vector to store result.v - input vector.
Return Values
None.
Description
Each element of dest is set to the sign (-1,0 or 1) of the equivalent element of v. If a separate 0 value is not required, use the Sign function.
Examples
! local v = Vector4.Create(-3.1, 0, -0.4, 1.2)
i v:Signum(v)
| print (v) � [-1, 0, -1, 1]
See Also
� Vector4.Sign
Vector4.Sqrt
Brief
Compute the component-wise square root of a vector.
Definition
j Vector4.Sqrt(Vector4 dest, Vector4 v)
Arguments
dest - destination vector to store result.v - input vector.
Return Values
None.
Description
Sets dest to [math.sqrt(v:XQ), math.sqrt(v:Y()), math.sqrt(v:Z()), math.sqrt(v:W())]. If any elements of v are < 0 the result is undefined.
Examples
local v = Vector4.Create(1, 4, 9)
v: Sqrt (v)
print (v) � [1, 2, 3]
See Also
� Vector4.RecipSqrt
Vector4.Subtract
Brief
Subtracts one vector from another.
Definition
Vector4.Subtract( Vector4 destination, Vector4|number sourcel, Vector4|number source2 )
Arguments
destination - Vector to store the result of the subtraction.sourcel - The minuend for the subtraction.source2 - The subtrahend for the subtraction.
Return Values
None.
Description
Subtracts source2 from sourcel storing the result in destination.
Descriptive notation:
destination.x = sourcel .x|source1 - source2.x|source2
destination.y = sourcel ,y|source1 - source2.y|source2
destination.z = sourcel .z|source1 - source2.z|source2
destination.w = sourcel.w|source1 - source2.w|source2
Examples
result = Vector4.Create()
vl = Vector4.Create( 1, 2 , 3, 4 )
v2 = Vector4.Create( 4 , 3, 2 , 1 )
Vector4.Subtract( result, vl, v2 )
Vector4.Subtract( result, vl, 3 )
See Also
� Vector4.Create
Vector4.T ransform
Brief
Transforms a vector by a matrix.
Definition
Vector4.Transform( Vector4 destination, Matrix44 matrix, Vector4 source )
Vector4.Transform( table destination, Matrix44 matrix, table source )
Arguments
destination - Vector or table of vectors to store the result of the multiplication.matrix - Matrix to transform the source vector or table of
vectors.source - Vector or table of vectors to be transformed.
Return Values
Description
Transforms the specified source vector by a matrix and stores the resultant vector in the destination. It is equivalent to:
destination = matrix * source
It is also possible to transform a table of vectors by the specified matrix. The result is stored in a destination table with the same number of
vectors as the source table. This can be considerably faster than transforming vectors individually.
Examples
� Create the matrix for the example code below
matrix = Matrix44.Create()
Matrix44.SetRotationXyz( matrix, 45, 12, 7 )
� Example 1: Transform a single vector by a matrix
src = Vector4.Create ( 12, 2, -3, 1 )
dst = Vector4.Create ()
Vector4.Transform( dst, matrix, src )
� Example 2: Transform a table of vectors by a matrix
source = {}
destination = {}
for v = 1, 10 do
source[v] = Vector4.Create(v, v, v, v)
destination[v] = Vector4.Create ()
end
Vector4.Transform( destination, matrix, source )
See Also
� Matrix44. Create
� Vector4. Create
Vector4.TransformPoint
Brief
Transforms a point by a matrix.
Definition
Vector4.TransformPoint( Vector4 destination, Matrix44 matrix, Vector4 source )
Vector4.TransformPoint( table destination, Matrix44 matrix, table source )
Arguments
destination - Point or table of points to store the result of the multiplication.matrix - Matrix to transform the source vector or table of vectors.source
- Point or table of points to be transformed.
Return Values
Description
Transforms the specified source point by a matrix and stores the resultant point in the destination. It is equivalent to:
destination = matrix * source (where source.w is substituted with 1.0)
It is also possible to transform a table of points by the specified matrix. The result is stored in a destination table with the same number of points
as the source table. This can be considerably faster than transforming points individually.
Examples
� Create the matrix for the example code below
matrix = Matrix44.Create()
Matrix44.SetRotationXyz( matrix, 45, 12, 7 )
� Example 1: Transform a single point by a matrix
src = Vector4.Create ( 12, 2, -3 )
dst = Vector4.Create ()
Vector4.TransformPoint( dst, matrix, src )
� Example 2: Transform a table of points by a matrix
source = {}
destination = {}
for v = 1, 10 do
source[v] = Vector4.Create(v, v, v)
destination[v] = Vector4.Create ()
end
Vector4.TransformPoint( destination, matrix, source )
See Also
� Matrix44.Create
� Vector4.Create
Vector4.T ransform Vector
Brief
Transforms a vector by a matrix.
Definition
Vector4.TransformVector( Vector4 destination, Matrix44 matrix, Vector4 source )
Vector4.TransformVector( table destination, Matrix44 matrix, table source )
Arguments
destination - Vector or table of vectors to store the result of the multiplication.matrix - Matrix to transform the source vector or table of
vectors.source - Vector or table of vectors to be transformed.
Return Values
Description
Transforms the specified source vector by a matrix and stores the resultant vector in the destination. It is equivalent to:
destination = matrix * source (where source.w is substituted with 0.0)
It is also possible to transform a table of vectors by the specified matrix. The result is stored in a destination table with the same number of
vectors as the source table. This can be considerably faster than transforming vectors individually.
Examples
� Create the matrix for the example code below
matrix = Matrix44.Create()
Matrix44.SetRotationXyz( matrix, 45, 12, 7 )
� Example 1: Transform a single vector by a matrix
src = Vector4.Create ( 12, 2, -3 )
dst = Vector4.Create ()
Vector4.TransformVector( dst, matrix, src )
� Example 2: Transform a table of vectors by a matrix
source = {}
destination = {}
for v = 1, 10 do
source[v] = Vector4.Create(v, v, v)
destination[v] = Vector4.Create ()
end
Vector4.TransformVector( destination, matrix, source )
See Also
� Matrix44.Create
� Vector4.Create
Vector4.W
Brief
Returns the w value of the vector.
Definition
! number Vector4.W( Vector4 vector )
Arguments
vector - Vector to be queried.
Return Values
Returns the fourth element of the vector, the w component.
Description
Returns the w value of the vector.
Examples
j vec = Vector4.Create( 1, 2, 3, 4 )
j print( "Value of W is: " .. Vector4.W( vec ) )
See Also
� Vector4.Create
� Vector4.X
� Vector4.Y
� Vector4.Z
Vector4.X
Brief
Returns the x value of the vector.
Definition
! number Vector4.X( Vector4 vector )
Arguments
vector - Vector to be queried.
Return Values
The first element of the vector, the x component.
Description
Returns the x value of the vector.
Examples
j vec = Vector4.Create( 10 )
i print( "Value of X is: " .. Vector4.X( vec ) )
See Also
� Vector4.Create
� Vector4.Y
� Vector4.Z
� Vector4.W
Vector4.Y
Brief
Returns the y value of the vector.
Definition
! number Vector4.Y( Vector4 vector )
Arguments
vector - Vector to be queried.
Return Values
Returns the second element of the vector, the y component.
Description
Returns the y value of the vector.
Examples
vec = Vector4.Create( 1, 2 )
print( "Value of Y is: " .. Vector4.Y( vec ) )
See Also
� Vector4.Create
� Vector4.X
� Vector4.Z
� Vector4.W
Vector4.Z
Brief
Returns the z value of the vector.
Definition
! number Vector4.Z( Vector4 vector )
Arguments
vector - Vector to be queried.
Return Values
Returns the third element of the vector, the z component.
Description
Returns the z value of the vector.
Examples
vec = Vector4.Create( 1, 2, 3 )
print( "Value of Z is: " .. Vector4.Z( vec ) )
See Also
� Vector4.Create
� Vector4.X
� Vector4.Y
� Vector4.W