1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
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
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
|
Game Types (bge.types)
======================
.. module:: bge.types
.. class:: PyObjectPlus
PyObjectPlus base class of most other types in the Game Engine.
.. attribute:: invalid
Test if the object has been freed by the game engine and is no longer valid.
Normally this is not a problem but when storing game engine data in the GameLogic module,
KX_Scenes or other KX_GameObjects its possible to hold a reference to invalid data.
Calling an attribute or method on an invalid object will raise a SystemError.
The invalid attribute allows testing for this case without exception handling.
:type: boolean
.. class:: CValue(PyObjectPlus)
This class is a basis for other classes.
.. attribute:: name
The name of this CValue derived object (read-only).
:type: string
.. class:: CPropValue(CValue)
This class has no python functions
.. class:: SCA_ILogicBrick(CValue)
Base class for all logic bricks.
.. attribute:: executePriority
This determines the order controllers are evaluated, and actuators are activated (lower priority is executed first).
:type: executePriority: int
.. attribute:: owner
The game object this logic brick is attached to (read-only).
:type: :class:`KX_GameObject` or None in exceptional cases.
.. attribute:: name
The name of this logic brick (read-only).
:type: string
.. class:: SCA_PythonKeyboard(PyObjectPlus)
The current keyboard.
.. attribute:: events
A dictionary containing the status of each keyboard event or key. (read-only).
:type: dictionary {:ref:`keycode<keyboard-keys>`::ref:`status<input-status>`, ...}
.. class:: SCA_PythonMouse(PyObjectPlus)
The current mouse.
.. attribute:: events
a dictionary containing the status of each mouse event. (read-only).
:type: dictionary {:ref:`keycode<mouse-keys>`::ref:`status<input-status>`, ...}
.. attribute:: position
The normalized x and y position of the mouse cursor.
:type: list [x, y]
.. attribute:: visible
The visibility of the mouse cursor.
:type: boolean
.. class:: SCA_IObject(CValue)
This class has no python functions
.. class:: SCA_ISensor(SCA_ILogicBrick)
Base class for all sensor logic bricks.
.. attribute:: usePosPulseMode
Flag to turn positive pulse mode on and off.
:type: boolean
.. attribute:: useNegPulseMode
Flag to turn negative pulse mode on and off.
:type: boolean
.. attribute:: frequency
The frequency for pulse mode sensors.
:type: integer
.. attribute:: level
level Option whether to detect level or edge transition when entering a state.
It makes a difference only in case of logic state transition (state actuator).
A level detector will immediately generate a pulse, negative or positive
depending on the sensor condition, as soon as the state is activated.
A edge detector will wait for a state change before generating a pulse.
note: mutually exclusive with :data:`tap`, enabling will disable :data:`tap`.
:type: boolean
.. attribute:: tap
When enabled only sensors that are just activated will send a positive event,
after this they will be detected as negative by the controllers.
This will make a key thats held act as if its only tapped for an instant.
note: mutually exclusive with :data:`level`, enabling will disable :data:`level`.
:type: boolean
.. attribute:: invert
Flag to set if this sensor activates on positive or negative events.
:type: boolean
.. attribute:: triggered
True if this sensor brick is in a positive state. (read-only).
:type: boolean
.. attribute:: positive
True if this sensor brick is in a positive state. (read-only).
:type: boolean
.. attribute:: status
The status of the sensor (read-only): can be one of :ref:`these constants<sensor-status>`.
:type: int
.. note::
This convenient attribute combines the values of triggered and positive attributes.
.. method:: reset()
Reset sensor internal state, effect depends on the type of sensor and settings.
The sensor is put in its initial state as if it was just activated.
.. class:: SCA_IController(SCA_ILogicBrick)
Base class for all controller logic bricks.
.. attribute:: state
The controllers state bitmask. This can be used with the GameObject's state to test if the controller is active.
:type: int bitmask
.. attribute:: sensors
A list of sensors linked to this controller.
:type: sequence supporting index/string lookups and iteration.
.. note::
The sensors are not necessarily owned by the same object.
.. note::
When objects are instanced in dupligroups links may be lost from objects outside the dupligroup.
.. attribute:: actuators
A list of actuators linked to this controller.
:type: sequence supporting index/string lookups and iteration.
.. note::
The sensors are not necessarily owned by the same object.
.. note::
When objects are instanced in dupligroups links may be lost from objects outside the dupligroup.
.. attribute:: useHighPriority
When set the controller executes always before all other controllers that dont have this set.
:type: boolen
.. note::
Order of execution between high priority controllers is not guaranteed.
.. class:: SCA_IActuator(SCA_ILogicBrick)
Base class for all actuator logic bricks.
.. class:: BL_ActionActuator(SCA_IActuator)
Action Actuators apply an action to an actor.
.. attribute:: action
The name of the action to set as the current action.
:type: string
.. attribute:: channelNames
A list of channel names that may be used with :data:`setChannel` and :data:`getChannel`.
:type: list of strings
.. attribute:: frameStart
Specifies the starting frame of the animation.
:type: float
.. attribute:: frameEnd
Specifies the ending frame of the animation.
:type: float
.. attribute:: blendIn
Specifies the number of frames of animation to generate when making transitions between actions.
:type: float
.. attribute:: priority
Sets the priority of this actuator. Actuators will lower priority numbers will override actuators with higher numbers.
:type: integer
.. attribute:: frame
Sets the current frame for the animation.
:type: float
.. attribute:: propName
Sets the property to be used in FromProp playback mode.
:type: string
.. attribute:: blendTime
Sets the internal frame timer. This property must be in the range from 0.0 to blendIn.
:type: float
.. attribute:: mode
The operation mode of the actuator. Can be one of :ref:`these constants<action-actuator>`.
:type: integer
.. attribute:: useContinue
The actions continue option, True or False. When True, the action will always play from where last left off, otherwise negative events to this actuator will reset it to its start frame.
:type: boolean
.. attribute:: framePropName
The name of the property that is set to the current frame number.
:type: string
.. method:: setChannel(channel, matrix)
Alternative to the 2 arguments, 4 arguments (channel, matrix, loc, size, quat) are also supported.
:arg channel: A string specifying the name of the bone channel, error raised if not in :data:`channelNames`.
:type channel: string
:arg matrix: A 4x4 matrix specifying the overriding transformation as an offset from the bone's rest position.
:arg matrix: list [[float]]
.. note::
These values are relative to the bones rest position, currently the api has no way to get this info (which is annoying), but can be worked around by using bones with a rest pose that has no translation.
.. method:: getChannel(channel)
:arg channel: A string specifying the name of the bone channel. error raised if not in :data:`channelNames`.
:type channel: string
:return: (loc, size, quat)
:rtype: tuple
.. class:: BL_Shader(PyObjectPlus)
BL_Shader GLSL shaders.
TODO - Description
.. method:: setUniformfv(name, fList)
Set a uniform with a list of float values
:arg name: the uniform name
:type name: string
:arg fList: a list (2, 3 or 4 elements) of float values
:type fList: list[float]
.. method:: delSource()
Clear the shader. Use this method before the source is changed with :data:`setSource`.
.. method:: getFragmentProg()
Returns the fragment program.
:return: The fragment program.
:rtype: string
.. method:: getVertexProg()
Get the vertex program.
:return: The vertex program.
:rtype: string
.. method:: isValid()
Check if the shader is valid.
:return: True if the shader is valid
:rtype: boolean
.. method:: setAttrib(enum)
Set attribute location. (The parameter is ignored a.t.m. and the value of "tangent" is always used.)
:arg enum: attribute location value
:type enum: integer
.. method:: setNumberOfPasses( max_pass )
Set the maximum number of passes. Not used a.t.m.
:arg max_pass: the maximum number of passes
:type max_pass: integer
.. method:: setSampler(name, index)
Set uniform texture sample index.
:arg name: Uniform name
:type name: string
:arg index: Texture sample index.
:type index: integer
.. method:: setSource(vertexProgram, fragmentProgram)
Set the vertex and fragment programs
:arg vertexProgram: Vertex program
:type vertexProgram: string
:arg fragmentProgram: Fragment program
:type fragmentProgram: string
.. method:: setUniform1f(name, fx)
Set a uniform with 1 float value.
:arg name: the uniform name
:type name: string
:arg fx: Uniform value
:type fx: float
.. method:: setUniform1i(name, ix)
Set a uniform with an integer value.
:arg name: the uniform name
:type name: string
:arg ix: the uniform value
:type ix: integer
.. method:: setUniform2f(name, fx, fy)
Set a uniform with 2 float values
:arg name: the uniform name
:type name: string
:arg fx: first float value
:type fx: float
:arg fy: second float value
:type fy: float
.. method:: setUniform2i(name, ix, iy)
Set a uniform with 2 integer values
:arg name: the uniform name
:type name: string
:arg ix: first integer value
:type ix: integer
:arg iy: second integer value
:type iy: integer
.. method:: setUniform3f(name, fx, fy, fz)
Set a uniform with 3 float values.
:arg name: the uniform name
:type name: string
:arg fx: first float value
:type fx: float
:arg fy: second float value
:type fy: float
:arg fz: third float value
:type fz: float
.. method:: setUniform3i(name, ix, iy, iz)
Set a uniform with 3 integer values
:arg name: the uniform name
:type name: string
:arg ix: first integer value
:type ix: integer
:arg iy: second integer value
:type iy: integer
:arg iz: third integer value
:type iz: integer
.. method:: setUniform4f(name, fx, fy, fz, fw)
Set a uniform with 4 float values.
:arg name: the uniform name
:type name: string
:arg fx: first float value
:type fx: float
:arg fy: second float value
:type fy: float
:arg fz: third float value
:type fz: float
:arg fw: fourth float value
:type fw: float
.. method:: setUniform4i(name, ix, iy, iz, iw)
Set a uniform with 4 integer values
:arg name: the uniform name
:type name: string
:arg ix: first integer value
:type ix: integer
:arg iy: second integer value
:type iy: integer
:arg iz: third integer value
:type iz: integer
:arg iw: fourth integer value
:type iw: integer
.. method:: setUniformDef(name, type)
Define a new uniform
:arg name: the uniform name
:type name: string
:arg type: uniform type
:type type: UNI_NONE, UNI_INT, UNI_FLOAT, UNI_INT2, UNI_FLOAT2, UNI_INT3, UNI_FLOAT3, UNI_INT4, UNI_FLOAT4, UNI_MAT3, UNI_MAT4, UNI_MAX
.. method:: setUniformMatrix3(name, mat, transpose)
Set a uniform with a 3x3 matrix value
:arg name: the uniform name
:type name: string
:arg mat: A 3x3 matrix [[f, f, f], [f, f, f], [f, f, f]]
:type mat: 3x3 matrix
:arg transpose: set to True to transpose the matrix
:type transpose: boolean
.. method:: setUniformMatrix4(name, mat, transpose)
Set a uniform with a 4x4 matrix value
:arg name: the uniform name
:type name: string
:arg mat: A 4x4 matrix [[f, f, f, f], [f, f, f, f], [f, f, f, f], [f, f, f, f]]
:type mat: 4x4 matrix
:arg transpose: set to True to transpose the matrix
:type transpose: boolean
.. method:: setUniformiv(name, iList)
Set a uniform with a list of integer values
:arg name: the uniform name
:type name: string
:arg iList: a list (2, 3 or 4 elements) of integer values
:type iList: list[integer]
.. method:: validate()
Validate the shader object.
.. class:: BL_ShapeActionActuator(SCA_IActuator)
ShapeAction Actuators apply an shape action to an mesh object.
.. attribute:: action
The name of the action to set as the current shape action.
:type: string
.. attribute:: frameStart
Specifies the starting frame of the shape animation.
:type: float
.. attribute:: frameEnd
Specifies the ending frame of the shape animation.
:type: float
.. attribute:: blendIn
Specifies the number of frames of animation to generate when making transitions between actions.
:type: float
.. attribute:: priority
Sets the priority of this actuator. Actuators will lower priority numbers will override actuators with higher numbers.
:type: integer
.. attribute:: frame
Sets the current frame for the animation.
:type: float
.. attribute:: propName
Sets the property to be used in FromProp playback mode.
:type: string
.. attribute:: blendTime
Sets the internal frame timer. This property must be in the range from 0.0 to blendin.
:type: float
.. attribute:: mode
The operation mode of the actuator. Can be one of :ref:`these constants<shape-action-actuator>`.
:type: integer
.. attribute:: framePropName
The name of the property that is set to the current frame number.
:type: string
.. class:: CListValue(CPropValue)
This is a list like object used in the game engine internally that behaves similar to a python list in most ways.
As well as the normal index lookup (``val= clist[i]``), CListValue supports string lookups (``val= scene.objects["Cube"]``)
Other operations such as ``len(clist)``, ``list(clist)``, ``clist[0:10]`` are also supported.
.. method:: append(val)
Add an item to the list (like pythons append)
.. warning::
Appending values to the list can cause crashes when the list is used internally by the game engine.
.. method:: count(val)
Count the number of instances of a value in the list.
:return: number of instances
:rtype: integer
.. method:: index(val)
Return the index of a value in the list.
:return: The index of the value in the list.
:rtype: integer
.. method:: reverse()
Reverse the order of the list.
.. method:: get(key, default=None)
Return the value matching key, or the default value if its not found.
:return: The key value or a default.
.. method:: from_id(id)
This is a funtion especially for the game engine to return a value with a spesific id.
Since object names are not always unique, the id of an object can be used to get an object from the CValueList.
Example:
.. code-block:: python
myObID=id(gameObject)
ob= scene.objects.from_id(myObID)
Where ``myObID`` is an int or long from the id function.
This has the advantage that you can store the id in places you could not store a gameObject.
.. warning::
The id is derived from a memory location and will be different each time the game engine starts.
.. class:: KX_BlenderMaterial(PyObjectPlus)
KX_BlenderMaterial
.. method:: getShader()
Returns the material's shader.
:return: the material's shader
:rtype: :class:`BL_Shader`
.. method:: setBlending(src, dest)
Set the pixel color arithmetic functions.
:arg src: Specifies how the red, green, blue, and alpha source blending factors are computed.
:type src: Value in...
* GL_ZERO,
* GL_ONE,
* GL_SRC_COLOR,
* GL_ONE_MINUS_SRC_COLOR,
* GL_DST_COLOR,
* GL_ONE_MINUS_DST_COLOR,
* GL_SRC_ALPHA,
* GL_ONE_MINUS_SRC_ALPHA,
* GL_DST_ALPHA,
* GL_ONE_MINUS_DST_ALPHA,
* GL_SRC_ALPHA_SATURATE
:arg dest: Specifies how the red, green, blue, and alpha destination blending factors are computed.
:type dest: Value in...
* GL_ZERO
* GL_ONE
* GL_SRC_COLOR
* GL_ONE_MINUS_SRC_COLOR
* GL_DST_COLOR
* GL_ONE_MINUS_DST_COLOR
* GL_SRC_ALPHA
* GL_ONE_MINUS_SRC_ALPHA
* GL_DST_ALPHA
* GL_ONE_MINUS_DST_ALPHA
* GL_SRC_ALPHA_SATURATE
.. method:: getMaterialIndex()
Returns the material's index.
:return: the material's index
:rtype: integer
.. class:: KX_CameraActuator(SCA_IActuator)
Applies changes to a camera.
.. attribute:: damping
strength of of the camera following movement.
:type: float
.. attribute:: min
minimum distance to the target object maintained by the actuator.
:type: float
.. attribute:: max
maximum distance to stay from the target object.
:type: float
.. attribute:: height
height to stay above the target object.
:type: float
.. attribute:: useXY
axis this actuator is tracking, True=X, False=Y.
:type: boolean
.. attribute:: object
the object this actuator tracks.
:type: :class:`KX_GameObject` or None
.. class:: KX_ConstraintActuator(SCA_IActuator)
A constraint actuator limits the position, rotation, distance or orientation of an object.
.. attribute:: damp
Time constant of the constraint expressed in frame (not use by Force field constraint).
:type: integer
.. attribute:: rotDamp
Time constant for the rotation expressed in frame (only for the distance constraint), 0 = use damp for rotation as well.
:type: integer
.. attribute:: direction
The reference direction in world coordinate for the orientation constraint.
:type: 3-tuple of float: (x, y, z)
.. attribute:: option
Binary combination of :ref:`these constants <constraint-actuator-option>`
:type: integer
.. attribute:: time
activation time of the actuator. The actuator disables itself after this many frame. If set to 0, the actuator is not limited in time.
:type: integer
.. attribute:: propName
the name of the property or material for the ray detection of the distance constraint.
:type: string
.. attribute:: min
The lower bound of the constraint. For the rotation and orientation constraint, it represents radiant.
:type: float
.. attribute:: distance
the target distance of the distance constraint.
:type: float
.. attribute:: max
the upper bound of the constraint. For rotation and orientation constraints, it represents radiant.
:type: float
.. attribute:: rayLength
the length of the ray of the distance constraint.
:type: float
.. attribute:: limit
type of constraint. Use one of the :ref:`these constants <constraint-actuator-limit>`
:type: integer.
.. class:: KX_ConstraintWrapper(PyObjectPlus)
KX_ConstraintWrapper
.. method:: getConstraintId(val)
Returns the contraint's ID
:return: the constraint's ID
:rtype: integer
.. class:: KX_GameActuator(SCA_IActuator)
The game actuator loads a new .blend file, restarts the current .blend file or quits the game.
.. attribute:: fileName
the new .blend file to load.
:type: string
.. attribute:: mode
The mode of this actuator. Can be on of :ref:`these constants <game-actuator>`
:type: Int
.. class:: KX_GameObject(SCA_IObject)
All game objects are derived from this class.
Properties assigned to game objects are accessible as attributes of this class.
.. note::
Calling ANY method or attribute on an object that has been removed from a scene will raise a SystemError, if an object may have been removed since last accessing it use the :data:`invalid` attribute to check.
.. attribute:: name
The object's name. (read-only).
:type: string
.. attribute:: mass
The object's mass
:type: float
.. note::
The object must have a physics controller for the mass to be applied, otherwise the mass value will be returned as 0.0.
.. attribute:: linVelocityMin
Enforces the object keeps moving at a minimum velocity.
:type: float
.. note::
Applies to dynamic and rigid body objects only.
.. note::
A value of 0.0 disables this option.
.. note::
While objects are stationary the minimum velocity will not be applied.
.. attribute:: linVelocityMax
Clamp the maximum linear velocity to prevent objects moving beyond a set speed.
:type: float
.. note::
Applies to dynamic and rigid body objects only.
.. note::
A value of 0.0 disables this option (rather then setting it stationary).
.. attribute:: localInertia
the object's inertia vector in local coordinates. Read only.
:type: list [ix, iy, iz]
.. attribute:: parent
The object's parent object. (read-only).
:type: :class:`KX_GameObject` or None
.. attribute:: visible
visibility flag.
:type: boolean
.. note::
Game logic will still run for invisible objects.
.. attribute:: color
The object color of the object. [r, g, b, a]
:type: :class:`mathutils.Vector`
.. attribute:: occlusion
occlusion capability flag.
:type: boolean
.. attribute:: position
The object's position. [x, y, z] On write: local position, on read: world position
.. deprecated:: use :data:`localPosition` and :data:`worldPosition`.
:type: :class:`mathurils.Vector`
.. attribute:: orientation
The object's orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector. On write: local orientation, on read: world orientation
.. deprecated:: use :data:`localOrientation` and :data:`worldOrientation`.
:type: :class:`mathutils.Matrix`
.. attribute:: scaling
The object's scaling factor. [sx, sy, sz] On write: local scaling, on read: world scaling
.. deprecated:: use :data:`localScale` and :data:`worldScale`.
:type: :class:`mathutils.Vector`
.. attribute:: localOrientation
The object's local orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
:type: :class:`mathutils.Matrix`
.. attribute:: worldOrientation
The object's world orientation. 3x3 Matrix.
:type: :class:`mathutils.Matrix`
.. attribute:: localScale
The object's local scaling factor. [sx, sy, sz]
:type: :class:`mathutils.Vector`
.. attribute:: worldScale
The object's world scaling factor. [sx, sy, sz]
:type: :class:`mathutils.Vector`
.. attribute:: localPosition
The object's local position. [x, y, z]
:type: :class:`mathutils.Vector`
.. attribute:: worldPosition
The object's world position. [x, y, z]
:type: :class:`mathutils.Vector`
.. attribute:: localTransform
The object's local space transform matrix. 4x4 Matrix.
:type: :class:`mathutils.Matrix`
.. attribute:: worldTransform
The object's world space transform matrix. 4x4 Matrix.
:type: :class:`mathutils.Matrix`
.. attribute:: localLinearVelocity
The object's local linear velocity. [x, y, z]
:type: :class:`mathutils.Vector`
.. attribute:: worldLinearVelocity
The object's world linear velocity. [x, y, z]
:type: :class:`mathutils.Vector`
.. attribute:: localAngularVelocity
The object's local angular velocity. [x, y, z]
:type: :class:`mathutils.Vector`
.. attribute:: worldAngularVelocity
The object's world angular velocity. [x, y, z]
:type: :class:`mathutils.Vector`
.. attribute:: timeOffset
adjust the slowparent delay at runtime.
:type: float
.. attribute:: state
the game object's state bitmask, using the first 30 bits, one bit must always be set.
:type: int
.. attribute:: meshes
a list meshes for this object.
:type: list of :class:`KX_MeshProxy`
.. note::
Most objects use only 1 mesh.
.. note::
Changes to this list will not update the KX_GameObject.
.. attribute:: sensors
a sequence of :class:`SCA_ISensor` objects with string/index lookups and iterator support.
:type: list
.. note::
This attribute is experemental and may be removed (but probably wont be).
.. note::
Changes to this list will not update the KX_GameObject.
.. attribute:: controllers
a sequence of :class:`SCA_IController` objects with string/index lookups and iterator support.
:type: list of :class:`SCA_ISensor`
.. note::
This attribute is experemental and may be removed (but probably wont be).
.. note::
Changes to this list will not update the KX_GameObject.
.. attribute:: actuators
a list of :class:`SCA_IActuator` with string/index lookups and iterator support.
:type: list
.. note::
This attribute is experemental and may be removed (but probably wont be).
.. note::
Changes to this list will not update the KX_GameObject.
.. attribute:: attrDict
get the objects internal python attribute dictionary for direct (faster) access.
:type: dict
.. attribute:: children
direct children of this object, (read-only).
:type: :class:`CListValue` of :class:`KX_GameObject`'s
.. attribute:: childrenRecursive
all children of this object including childrens children, (read-only).
:type: :class:`CListValue` of :class:`KX_GameObject`'s
.. method:: endObject()
Delete this object, can be used in place of the EndObject Actuator.
The actual removal of the object from the scene is delayed.
.. method:: replaceMesh(mesh, useDisplayMesh=True, usePhysicsMesh=False)
Replace the mesh of this object with a new mesh. This works the same was as the actuator.
:arg mesh: mesh to replace or the meshes name.
:type mesh: :class:`MeshProxy` or string
:arg useDisplayMesh: when enabled the display mesh will be replaced (optional argument).
:type useDisplayMesh: boolean
:arg usePhysicsMesh: when enabled the physics mesh will be replaced (optional argument).
:type usePhysicsMesh: boolean
.. method:: setVisible(visible, recursive)
Sets the game object's visible flag.
:arg visible: the visible state to set.
:type visible: boolean
:arg recursive: optional argument to set all childrens visibility flag too.
:type recursive: boolean
.. method:: setOcclusion(occlusion, recursive)
Sets the game object's occlusion capability.
:arg occlusion: the state to set the occlusion to.
:type occlusion: boolean
:arg recursive: optional argument to set all childrens occlusion flag too.
:type recursive: boolean
.. method:: alignAxisToVect(vect, axis=2, factor=1.0)
Aligns any of the game object's axis along the given vector.
:arg vect: a vector to align the axis.
:type vect: 3D vector
:arg axis: The axis you want to align
* 0: X axis
* 1: Y axis
* 2: Z axis
:type axis: integer
:arg factor: Only rotate a feaction of the distance to the target vector (0.0 - 1.0)
:type factor: float
.. method:: getAxisVect(vect)
Returns the axis vector rotates by the objects worldspace orientation.
This is the equivalent of multiplying the vector by the orientation matrix.
:arg vect: a vector to align the axis.
:type vect: 3D Vector
:return: The vector in relation to the objects rotation.
:rtype: 3d vector.
.. method:: applyMovement(movement, local=False)
Sets the game object's movement.
:arg movement: movement vector.
:type movement: 3D Vector
:arg local:
* False: you get the "global" movement ie: relative to world orientation.
* True: you get the "local" movement ie: relative to object orientation.
:arg local: boolean
.. method:: applyRotation(rotation, local=False)
Sets the game object's rotation.
:arg rotation: rotation vector.
:type rotation: 3D Vector
:arg local:
* False: you get the "global" rotation ie: relative to world orientation.
* True: you get the "local" rotation ie: relative to object orientation.
:arg local: boolean
.. method:: applyForce(force, local=False)
Sets the game object's force.
This requires a dynamic object.
:arg force: force vector.
:type force: 3D Vector
:arg local:
* False: you get the "global" force ie: relative to world orientation.
* True: you get the "local" force ie: relative to object orientation.
:type local: boolean
.. method:: applyTorque(torque, local=False)
Sets the game object's torque.
This requires a dynamic object.
:arg torque: torque vector.
:type torque: 3D Vector
:arg local:
* False: you get the "global" torque ie: relative to world orientation.
* True: you get the "local" torque ie: relative to object orientation.
:type local: boolean
.. method:: getLinearVelocity(local=False)
Gets the game object's linear velocity.
This method returns the game object's velocity through it's centre of mass, ie no angular velocity component.
:arg local:
* False: you get the "global" velocity ie: relative to world orientation.
* True: you get the "local" velocity ie: relative to object orientation.
:type local: boolean
:return: the object's linear velocity.
:rtype: list [vx, vy, vz]
.. method:: setLinearVelocity(velocity, local=False)
Sets the game object's linear velocity.
This method sets game object's velocity through it's centre of mass,
ie no angular velocity component.
This requires a dynamic object.
:arg velocity: linear velocity vector.
:type velocity: 3D Vector
:arg local:
* False: you get the "global" velocity ie: relative to world orientation.
* True: you get the "local" velocity ie: relative to object orientation.
:type local: boolean
.. method:: getAngularVelocity(local=False)
Gets the game object's angular velocity.
:arg local:
* False: you get the "global" velocity ie: relative to world orientation.
* True: you get the "local" velocity ie: relative to object orientation.
:type local: boolean
:return: the object's angular velocity.
:rtype: list [vx, vy, vz]
.. method:: setAngularVelocity(velocity, local=False)
Sets the game object's angular velocity.
This requires a dynamic object.
:arg velocity: angular velocity vector.
:type velocity: boolean
:arg local:
* False: you get the "global" velocity ie: relative to world orientation.
* True: you get the "local" velocity ie: relative to object orientation.
.. method:: getVelocity(point=(0, 0, 0))
Gets the game object's velocity at the specified point.
Gets the game object's velocity at the specified point, including angular
components.
:arg point: optional point to return the velocity for, in local coordinates.
:type point: 3D Vector
:return: the velocity at the specified point.
:rtype: list [vx, vy, vz]
.. method:: getReactionForce()
Gets the game object's reaction force.
The reaction force is the force applied to this object over the last simulation timestep.
This also includes impulses, eg from collisions.
:return: the reaction force of this object.
:rtype: list [fx, fy, fz]
.. note::
This is not implimented at the moment.
.. method:: applyImpulse(point, impulse)
Applies an impulse to the game object.
This will apply the specified impulse to the game object at the specified point.
If point != position, applyImpulse will also change the object's angular momentum.
Otherwise, only linear momentum will change.
:arg point: the point to apply the impulse to (in world coordinates)
:type point: the point to apply the impulse to (in world coordinates)
.. method:: suspendDynamics()
Suspends physics for this object.
.. method:: restoreDynamics()
Resumes physics for this object.
.. note::
The objects linear velocity will be applied from when the dynamics were suspended.
.. method:: enableRigidBody()
Enables rigid body physics for this object.
Rigid body physics allows the object to roll on collisions.
.. note::
This is not working with bullet physics yet.
.. method:: disableRigidBody()
Disables rigid body physics for this object.
.. note::
This is not working with bullet physics yet. The angular is removed but rigid body physics can still rotate it later.
.. method:: setParent(parent, compound=True, ghost=True)
Sets this object's parent.
Control the shape status with the optional compound and ghost parameters:
In that case you can control if it should be ghost or not:
:arg parent: new parent object.
:type parent: :class:`KX_GameObject`
:arg compound: whether the shape should be added to the parent compound shape.
* True: the object shape should be added to the parent compound shape.
* False: the object should keep its individual shape.
:type compound: boolean
:arg ghost: whether the object should be ghost while parented.
* True: if the object should be made ghost while parented.
* False: if the object should be solid while parented.
:type ghost: boolean
.. note::
If the object type is sensor, it stays ghost regardless of ghost parameter
.. method:: removeParent()
Removes this objects parent.
.. method:: getPhysicsId()
Returns the user data object associated with this game object's physics controller.
.. method:: getPropertyNames()
Gets a list of all property names.
:return: All property names for this object.
:rtype: list
.. method:: getDistanceTo(other)
:arg other: a point or another :class:`KX_GameObject` to measure the distance to.
:type other: :class:`KX_GameObject` or list [x, y, z]
:return: distance to another object or point.
:rtype: float
.. method:: getVectTo(other)
Returns the vector and the distance to another object or point.
The vector is normalized unless the distance is 0, in which a zero length vector is returned.
:arg other: a point or another :class:`KX_GameObject` to get the vector and distance to.
:type other: :class:`KX_GameObject` or list [x, y, z]
:return: (distance, globalVector(3), localVector(3))
:rtype: 3-tuple (float, 3-tuple (x, y, z), 3-tuple (x, y, z))
.. method:: rayCastTo(other, dist, prop)
Look towards another point/object and find first object hit within dist that matches prop.
The ray is always casted from the center of the object, ignoring the object itself.
The ray is casted towards the center of another object or an explicit [x, y, z] point.
Use rayCast() if you need to retrieve the hit point
:arg other: [x, y, z] or object towards which the ray is casted
:type other: :class:`KX_GameObject` or 3-tuple
:arg dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
:type dist: float
:arg prop: property name that object must have; can be omitted => detect any object
:type prop: string
:return: the first object hit or None if no object or object does not match prop
:rtype: :class:`KX_GameObject`
.. method:: rayCast(objto, objfrom, dist, prop, face, xray, poly)
Look from a point/object to another point/object and find first object hit within dist that matches prop.
if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None, None, None) if no hit.
if poly is 1, returns a 4-tuple with in addition a :class:`KX_PolyProxy` as 4th element.
if poly is 2, returns a 5-tuple with in addition a 2D vector with the UV mapping of the hit point as 5th element.
.. code-block:: python
# shoot along the axis gun-gunAim (gunAim should be collision-free)
obj, point, normal = gun.rayCast(gunAim, None, 50)
if obj:
# do something
pass
The face paremeter determines the orientation of the normal.
* 0 => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
* 1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow.
* prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
* prop off, xray on : idem.
* prop on, xray off: return closest hit if it matches prop, no hit otherwise.
* prop on, xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
The :class:`KX_PolyProxy` 4th element of the return tuple when poly=1 allows to retrieve information on the polygon hit by the ray.
If there is no hit or the hit object is not a static mesh, None is returned as 4th element.
The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects.
:arg objto: [x, y, z] or object to which the ray is casted
:type objto: :class:`KX_GameObject` or 3-tuple
:arg objfrom: [x, y, z] or object from which the ray is casted; None or omitted => use self object center
:type objfrom: :class:`KX_GameObject` or 3-tuple or None
:arg dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to to
:type dist: float
:arg prop: property name that object must have; can be omitted or "" => detect any object
:type prop: string
:arg face: normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin
:type face: integer
:arg xray: X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object
:type xray: integer
:arg poly: polygon option: 0, 1 or 2 to return a 3-, 4- or 5-tuple with information on the face hit.
* 0 or omitted: return value is a 3-tuple (object, hitpoint, hitnormal) or (None, None, None) if no hit
* 1: return value is a 4-tuple and the 4th element is a :class:`KX_PolyProxy` or None if no hit or the object doesn't use a mesh collision shape.
* 2: return value is a 5-tuple and the 5th element is a 2-tuple (u, v) with the UV mapping of the hit point or None if no hit, or the object doesn't use a mesh collision shape, or doesn't have a UV mapping.
:type poly: integer
:return: (object, hitpoint, hitnormal) or (object, hitpoint, hitnormal, polygon) or (object, hitpoint, hitnormal, polygon, hituv).
* object, hitpoint and hitnormal are None if no hit.
* polygon is valid only if the object is valid and is a static object, a dynamic object using mesh collision shape or a soft body object, otherwise it is None
* hituv is valid only if polygon is valid and the object has a UV mapping, otherwise it is None
:rtype:
* 3-tuple (:class:`KX_GameObject`, 3-tuple (x, y, z), 3-tuple (nx, ny, nz))
* or 4-tuple (:class:`KX_GameObject`, 3-tuple (x, y, z), 3-tuple (nx, ny, nz), :class:`PolyProxy`)
* or 5-tuple (:class:`KX_GameObject`, 3-tuple (x, y, z), 3-tuple (nx, ny, nz), :class:`PolyProxy`, 2-tuple (u, v))
.. note::
The ray ignores the object on which the method is called. It is casted from/to object center or explicit [x, y, z] points.
.. method:: setCollisionMargin(margin)
Set the objects collision margin.
:arg margin: the collision margin distance in blender units.
:type margin: float
.. note::
If this object has no physics controller (a physics ID of zero), this function will raise RuntimeError.
.. method:: sendMessage(subject, body="", to="")
Sends a message.
:arg subject: The subject of the message
:type subject: string
:arg body: The body of the message (optional)
:type body: string
:arg to: The name of the object to send the message to (optional)
:type to: string
.. method:: reinstancePhysicsMesh(gameObject, meshObject)
Updates the physics system with the changed mesh.
If no arguments are given the physics mesh will be re-created from the first mesh assigned to the game object.
:arg gameObject: optional argument, set the physics shape from this gameObjets mesh.
:type gameObject: string, :class:`KX_GameObject` or None
:arg meshObject: optional argument, set the physics shape from this mesh.
:type meshObject: string, :class:`MeshProxy` or None
:return: True if reinstance succeeded, False if it failed.
:rtype: boolean
.. note::
If this object has instances the other instances will be updated too.
.. note::
The gameObject argument has an advantage that it can convert from a mesh with modifiers applied (such as subsurf).
.. warning::
Only triangle mesh type objects are supported currently (not convex hull)
.. warning::
If the object is a part of a combound object it will fail (parent or child)
.. warning::
Rebuilding the physics mesh can be slow, running many times per second will give a performance hit.
.. method:: get(key, default=None)
Return the value matching key, or the default value if its not found.
:return: The key value or a default.
.. method:: playAction(name, start_frame, end_frame, layer=0, priority=0, blendin=0, play_mode=ACT_MODE_PLAY, layer_weight=0.0, ipo_flags=0, speed=1.0)
Plays an action.
:arg name: the name of the action
:type name: string
:arg start: the start frame of the action
:type start: float
:arg end: the end frame of the action
:type end: float
:arg layer: the layer the action will play in (actions in different layers are added/blended together)
:type layer: integer
:arg priority: only play this action if there isn't an action currently playing in this layer with a higher (lower number) priority
:type priority: integer
:arg blendin: the amount of blending between this animation and the previous one on this layer
:type blendin: float
:arg play_mode: the play mode
:type play_mode: KX_ACTION_MODE_PLAY, KX_ACTION_MODE_LOOP, or KX_ACTION_MODE_PING_PONG
:arg layer_weight: how much of the previous layer to use for blending (0 = add)
:type layer_weight: float
:arg ipo_flags: flags for the old IPO behaviors (force, etc)
:type ipo_flags: int bitfield
:arg speed: the playback speed of the action as a factor (1.0 = normal speed, 2.0 = 2x speed, etc)
:type speed: float
.. method:: stopAction(layer=0)
Stop playing the action on the given layer.
:arg layer: The layer to stop playing.
:type layer: integer
.. method:: getActionFrame(layer=0)
Gets the current frame of the action playing in the supplied layer.
:arg layer: The layer that you want to get the frame from.
:type layer: integer
:return: The current frame of the action
:rtype: float
.. method:: setActionFrame(frame, layer=0)
Set the current frame of the action playing in the supplied layer.
:arg layer: The layer where you want to set the frame
:type layer: integer
:arg frame: The frame to set the action to
:type frame: float
.. method:: isPlayingAction(layer=0)
Checks to see if there is an action playing in the given layer.
:arg layer: The layer to check for a playing action.
:type layer: integer
:return: Whether or not the action is playing
:rtype: boolean
.. class:: KX_IpoActuator(SCA_IActuator)
IPO actuator activates an animation.
.. attribute:: frameStart
Start frame.
:type: float
.. attribute:: frameEnd
End frame.
:type: float
.. attribute:: propName
Use this property to define the Ipo position.
:type: string
.. attribute:: framePropName
Assign this property this action current frame number.
:type: string
.. attribute:: mode
Play mode for the ipo. Can be on of :ref:`these constants <ipo-actuator>`
:type: integer
.. attribute:: useIpoAsForce
Apply Ipo as a global or local force depending on the local option (dynamic objects only).
:type: boolean
.. attribute:: useIpoAdd
Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag.
:type: boolean
.. attribute:: useIpoLocal
Let the ipo acts in local coordinates, used in Force and Add mode.
:type: boolean
.. attribute:: useChildren
Update IPO on all children Objects as well.
:type: boolean
.. class:: KX_LightObject(KX_GameObject)
A Light object.
.. code-block:: python
# Turn on a red alert light.
import bge
co = bge.logic.getCurrentController()
light = co.owner
light.energy = 1.0
light.colour = [1.0, 0.0, 0.0]
.. data:: SPOT
A spot light source. See attribute :data:`type`
.. data:: SUN
A point light source with no attenuation. See attribute :data:`type`
.. data:: NORMAL
A point light source. See attribute :data:`type`
.. attribute:: type
The type of light - must be SPOT, SUN or NORMAL
.. attribute:: layer
The layer mask that this light affects object on.
:type: bitfield
.. attribute:: energy
The brightness of this light.
:type: float
.. attribute:: distance
The maximum distance this light can illuminate. (SPOT and NORMAL lights only).
:type: float
.. attribute:: colour
The colour of this light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
:type: list [r, g, b]
.. attribute:: color
Synonym for colour.
.. attribute:: lin_attenuation
The linear component of this light's attenuation. (SPOT and NORMAL lights only).
:type: float
.. attribute:: quad_attenuation
The quadratic component of this light's attenuation (SPOT and NORMAL lights only).
:type: float
.. attribute:: spotsize
The cone angle of the spot light, in degrees (SPOT lights only).
:type: float in [0 - 180].
.. attribute:: spotblend
Specifies the intensity distribution of the spot light (SPOT lights only).
:type: float in [0 - 1]
.. note::
Higher values result in a more focused light source.
.. class:: KX_MeshProxy(SCA_IObject)
A mesh object.
You can only change the vertex properties of a mesh object, not the mesh topology.
To use mesh objects effectively, you should know a bit about how the game engine handles them.
#. Mesh Objects are converted from Blender at scene load.
#. The Converter groups polygons by Material. This means they can be sent to the renderer efficiently. A material holds:
#. The texture.
#. The Blender material.
#. The Tile properties
#. The face properties - (From the "Texture Face" panel)
#. Transparency & z sorting
#. Light layer
#. Polygon shape (triangle/quad)
#. Game Object
#. Vertices will be split by face if necessary. Vertices can only be shared between faces if:
#. They are at the same position
#. UV coordinates are the same
#. Their normals are the same (both polygons are "Set Smooth")
#. They are the same colour, for example: a cube has 24 vertices: 6 faces with 4 vertices per face.
The correct method of iterating over every :class:`KX_VertexProxy` in a game object
.. code-block:: python
from bge import logic
cont = logic.getCurrentController()
object = cont.owner
for mesh in object.meshes:
for material in mesh.materials:
for v_index in range(mesh.getVertexArrayLength(mat)):
vertex = mesh.getVertex(mat, v_index)
# Do something with vertex here...
# ... eg: colour the vertex red.
vertex.colour = [1.0, 0.0, 0.0, 1.0]
.. attribute:: materials
:type: list of :class:`KX_BlenderMaterial` or :class:`KX_PolygonMaterial` types
.. attribute:: numPolygons
:type: integer
.. attribute:: numMaterials
:type: integer
.. method:: getNumMaterials()
:return: number of materials associated with this object
:rtype: integer
.. method:: getMaterialName(matid)
Gets the name of the specified material.
:arg matid: the specified material.
:type matid: integer
:return: the attached material name.
:rtype: string
.. method:: getTextureName(matid)
Gets the name of the specified material's texture.
:arg matid: the specified material
:type matid: integer
:return: the attached material's texture name.
:rtype: string
.. method:: getVertexArrayLength(matid)
Gets the length of the vertex array associated with the specified material.
There is one vertex array for each material.
:arg matid: the specified material
:type matid: integer
:return: the number of verticies in the vertex array.
:rtype: integer
.. method:: getVertex(matid, index)
Gets the specified vertex from the mesh object.
:arg matid: the specified material
:type matid: integer
:arg index: the index into the vertex array.
:type index: integer
:return: a vertex object.
:rtype: :class:`KX_VertexProxy`
.. method:: getNumPolygons()
:return: The number of polygon in the mesh.
:rtype: integer
.. method:: getPolygon(index)
Gets the specified polygon from the mesh.
:arg index: polygon number
:type index: integer
:return: a polygon object.
:rtype: :class:`PolyProxy`
.. class:: SCA_MouseSensor(SCA_ISensor)
Mouse Sensor logic brick.
.. attribute:: position
current [x, y] coordinates of the mouse, in frame coordinates (pixels).
:type: [integer, interger]
.. attribute:: mode
sensor mode.
:type: integer
* KX_MOUSESENSORMODE_LEFTBUTTON(1)
* KX_MOUSESENSORMODE_MIDDLEBUTTON(2)
* KX_MOUSESENSORMODE_RIGHTBUTTON(3)
* KX_MOUSESENSORMODE_WHEELUP(4)
* KX_MOUSESENSORMODE_WHEELDOWN(5)
* KX_MOUSESENSORMODE_MOVEMENT(6)
.. method:: getButtonStatus(button)
Get the mouse button status.
:arg button: The code that represents the key you want to get the state of, use one of :ref:`these constants<mouse-keys>`
:type button: int
:return: The state of the given key, can be one of :ref:`these constants<input-status>`
:rtype: int
.. class:: KX_MouseFocusSensor(SCA_MouseSensor)
The mouse focus sensor detects when the mouse is over the current game object.
The mouse focus sensor works by transforming the mouse coordinates from 2d device
space to 3d space then raycasting away from the camera.
.. attribute:: raySource
The worldspace source of the ray (the view position).
:type: list (vector of 3 floats)
.. attribute:: rayTarget
The worldspace target of the ray.
:type: list (vector of 3 floats)
.. attribute:: rayDirection
The :data:`rayTarget` - :class:`raySource` normalized.
:type: list (normalized vector of 3 floats)
.. attribute:: hitObject
the last object the mouse was over.
:type: :class:`KX_GameObject` or None
.. attribute:: hitPosition
The worldspace position of the ray intersecton.
:type: list (vector of 3 floats)
.. attribute:: hitNormal
the worldspace normal from the face at point of intersection.
:type: list (normalized vector of 3 floats)
.. attribute:: hitUV
the UV coordinates at the point of intersection.
:type: list (vector of 2 floats)
If the object has no UV mapping, it returns [0, 0].
The UV coordinates are not normalized, they can be < 0 or > 1 depending on the UV mapping.
.. attribute:: usePulseFocus
When enabled, moving the mouse over a different object generates a pulse. (only used when the 'Mouse Over Any' sensor option is set).
:type: boolean
.. class:: KX_TouchSensor(SCA_ISensor)
Touch sensor detects collisions between objects.
.. attribute:: propName
The property or material to collide with.
:type: string
.. attribute:: useMaterial
Determines if the sensor is looking for a property or material. KX_True = Find material; KX_False = Find property.
:type: boolean
.. attribute:: usePulseCollision
When enabled, changes to the set of colliding objects generate a pulse.
:type: boolean
.. attribute:: hitObject
The last collided object. (read-only).
:type: :class:`KX_GameObject` or None
.. attribute:: hitObjectList
A list of colliding objects. (read-only).
:type: :class:`CListValue` of :class:`KX_GameObject`
.. class:: KX_NearSensor(KX_TouchSensor)
A near sensor is a specialised form of touch sensor.
.. attribute:: distance
The near sensor activates when an object is within this distance.
:type: float
.. attribute:: resetDistance
The near sensor deactivates when the object exceeds this distance.
:type: float
.. class:: KX_NetworkMessageActuator(SCA_IActuator)
Message Actuator
.. attribute:: propName
Messages will only be sent to objects with the given property name.
:type: string
.. attribute:: subject
The subject field of the message.
:type: string
.. attribute:: body
The body of the message.
:type: string
.. attribute:: usePropBody
Send a property instead of a regular body message.
:type: boolean
.. class:: KX_NetworkMessageSensor(SCA_ISensor)
The Message Sensor logic brick.
Currently only loopback (local) networks are supported.
.. attribute:: subject
The subject the sensor is looking for.
:type: string
.. attribute:: frameMessageCount
The number of messages received since the last frame. (read-only).
:type: integer
.. attribute:: subjects
The list of message subjects received. (read-only).
:type: list of strings
.. attribute:: bodies
The list of message bodies received. (read-only).
:type: list of strings
.. class:: KX_ObjectActuator(SCA_IActuator)
The object actuator ("Motion Actuator") applies force, torque, displacement, angular displacement,
velocity, or angular velocity to an object.
Servo control allows to regulate force to achieve a certain speed target.
.. attribute:: force
The force applied by the actuator.
:type: list [x, y, z]
.. attribute:: useLocalForce
A flag specifying if the force is local.
:type: boolean
.. attribute:: torque
The torque applied by the actuator.
:type: list [x, y, z]
.. attribute:: useLocalTorque
A flag specifying if the torque is local.
:type: boolean
.. attribute:: dLoc
The displacement vector applied by the actuator.
:type: list [x, y, z]
.. attribute:: useLocalDLoc
A flag specifying if the dLoc is local.
:type: boolean
.. attribute:: dRot
The angular displacement vector applied by the actuator
:type: list [x, y, z]
.. note::
Since the displacement is applied every frame, you must adjust the displacement based on the frame rate, or you game experience will depend on the player's computer speed.
.. attribute:: useLocalDRot
A flag specifying if the dRot is local.
:type: boolean
.. attribute:: linV
The linear velocity applied by the actuator.
:type: list [x, y, z]
.. attribute:: useLocalLinV
A flag specifying if the linear velocity is local.
:type: boolean
.. note::
This is the target speed for servo controllers.
.. attribute:: angV
The angular velocity applied by the actuator.
:type: list [x, y, z]
.. attribute:: useLocalAngV
A flag specifying if the angular velocity is local.
:type: boolean
.. attribute:: damping
The damping parameter of the servo controller.
:type: short
.. attribute:: forceLimitX
The min/max force limit along the X axis and activates or deactivates the limits in the servo controller.
:type: list [min(float), max(float), bool]
.. attribute:: forceLimitY
The min/max force limit along the Y axis and activates or deactivates the limits in the servo controller.
:type: list [min(float), max(float), bool]
.. attribute:: forceLimitZ
The min/max force limit along the Z axis and activates or deactivates the limits in the servo controller.
:type: list [min(float), max(float), bool]
.. attribute:: pid
The PID coefficients of the servo controller.
:type: list of floats [proportional, integral, derivate]
.. attribute:: reference
The object that is used as reference to compute the velocity for the servo controller.
:type: :class:`KX_GameObject` or None
.. class:: KX_ParentActuator(SCA_IActuator)
The parent actuator can set or remove an objects parent object.
.. attribute:: object
the object this actuator sets the parent too.
:type: :class:`KX_GameObject` or None
.. attribute:: mode
The mode of this actuator.
:type: integer from 0 to 1.
.. attribute:: compound
Whether the object shape should be added to the parent compound shape when parenting.
Effective only if the parent is already a compound shape.
:type: boolean
.. attribute:: ghost
Whether the object should be made ghost when parenting
Effective only if the shape is not added to the parent compound shape.
:type: boolean
.. class:: KX_PhysicsObjectWrapper(PyObjectPlus)
KX_PhysicsObjectWrapper
.. method:: setActive(active)
Set the object to be active.
:arg active: set to True to be active
:type active: boolean
.. method:: setAngularVelocity(x, y, z, local)
Set the angular velocity of the object.
:arg x: angular velocity for the x-axis
:type x: float
:arg y: angular velocity for the y-axis
:type y: float
:arg z: angular velocity for the z-axis
:type z: float
:arg local: set to True for local axis
:type local: boolean
.. method:: setLinearVelocity(x, y, z, local)
Set the linear velocity of the object.
:arg x: linear velocity for the x-axis
:type x: float
:arg y: linear velocity for the y-axis
:type y: float
:arg z: linear velocity for the z-axis
:type z: float
:arg local: set to True for local axis
:type local: boolean
.. class:: KX_PolyProxy(SCA_IObject)
A polygon holds the index of the vertex forming the poylgon.
Note:
The polygon attributes are read-only, you need to retrieve the vertex proxy if you want
to change the vertex settings.
.. attribute:: matname
The name of polygon material, empty if no material.
:type: string
.. attribute:: material
The material of the polygon.
:type: :class:`KX_PolygonMaterial` or :class:`KX_BlenderMaterial`
.. attribute:: texture
The texture name of the polygon.
:type: string
.. attribute:: matid
The material index of the polygon, use this to retrieve vertex proxy from mesh proxy.
:type: integer
.. attribute:: v1
vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy.
:type: integer
.. attribute:: v2
vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy.
:type: integer
.. attribute:: v3
vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy.
:type: integer
.. attribute:: v4
Vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
Use this to retrieve vertex proxy from mesh proxy.
:type: integer
.. attribute:: visible
visible state of the polygon: 1=visible, 0=invisible.
:type: integer
.. attribute:: collide
collide state of the polygon: 1=receives collision, 0=collision free.
:type: integer
.. method:: getMaterialName()
Returns the polygon material name with MA prefix
:return: material name
:rtype: string
.. method:: getMaterial()
:return: The polygon material
:rtype: :class:`KX_PolygonMaterial` or :class:`KX_BlenderMaterial`
.. method:: getTextureName()
:return: The texture name
:rtype: string
.. method:: getMaterialIndex()
Returns the material bucket index of the polygon.
This index and the ones returned by getVertexIndex() are needed to retrieve the vertex proxy from :class:`MeshProxy`.
:return: the material index in the mesh
:rtype: integer
.. method:: getNumVertex()
Returns the number of vertex of the polygon.
:return: number of vertex, 3 or 4.
:rtype: integer
.. method:: isVisible()
Returns whether the polygon is visible or not
:return: 0=invisible, 1=visible
:rtype: boolean
.. method:: isCollider()
Returns whether the polygon is receives collision or not
:return: 0=collision free, 1=receives collision
:rtype: integer
.. method:: getVertexIndex(vertex)
Returns the mesh vertex index of a polygon vertex
This index and the one returned by getMaterialIndex() are needed to retrieve the vertex proxy from :class:`MeshProxy`.
:arg vertex: index of the vertex in the polygon: 0->3
:arg vertex: integer
:return: mesh vertex index
:rtype: integer
.. method:: getMesh()
Returns a mesh proxy
:return: mesh proxy
:rtype: :class:`MeshProxy`
.. class:: KX_PolygonMaterial(PyObjectPlus)
This is the interface to materials in the game engine.
Materials define the render state to be applied to mesh objects.
.. warning::
Some of the methods/variables are CObjects. If you mix these up, you will crash blender.
.. code-block:: python
from bge import logic
vertex_shader = """
void main(void)
{
// original vertex position, no changes
gl_Position = ftransform();
// coordinate of the 1st texture channel
gl_TexCoord[0] = gl_MultiTexCoord0;
// coordinate of the 2nd texture channel
gl_TexCoord[1] = gl_MultiTexCoord1;
}
"""
fragment_shader ="""
uniform sampler2D color_0;
uniform sampler2D color_1;
uniform float factor;
void main(void)
{
vec4 color_0 = texture2D(color_0, gl_TexCoord[0].st);
vec4 color_1 = texture2D(color_1, gl_TexCoord[1].st);
gl_FragColor = mix(color_0, color_1, factor);
}
"""
object = logic.getCurrentController().owner
object = cont.owner
for mesh in object.meshes:
for material in mesh.materials:
shader = material.getShader()
if shader != None:
if not shader.isValid():
shader.setSource(vertex_shader, fragment_shader, True)
# get the first texture channel of the material
shader.setSampler('color_0', 0)
# get the second texture channel of the material
shader.setSampler('color_1', 1)
# pass another uniform to the shader
shader.setUniform1f('factor', 0.3)
.. attribute:: texture
Texture name.
:type: string (read-only)
.. attribute:: gl_texture
OpenGL texture handle (eg for glBindTexture(GL_TEXTURE_2D, gl_texture).
:type: integer (read-only)
.. attribute:: material
Material name.
:type: string (read-only)
.. attribute:: tface
Texture face properties.
:type: CObject (read-only)
.. attribute:: tile
Texture is tiling.
:type: boolean
.. attribute:: tilexrep
Number of tile repetitions in x direction.
:type: integer
.. attribute:: tileyrep
Number of tile repetitions in y direction.
:type: integer
.. attribute:: drawingmode
Drawing mode for the material.
- 2 (drawingmode & 4) Textured
- 4 (drawingmode & 16) Light
- 14 (drawingmode & 16384) 3d Polygon Text.
:type: bitfield
.. attribute:: transparent
This material is transparent. All meshes with this
material will be rendered after non transparent meshes from back
to front.
:type: boolean
.. attribute:: zsort
Transparent polygons in meshes with this material will be sorted back to
front before rendering.
Non-Transparent polygons will be sorted front to back before rendering.
:type: boolean
.. attribute:: lightlayer
Light layers this material affects.
:type: bitfield.
.. attribute:: triangle
Mesh data with this material is triangles. It's probably not safe to change this.
:type: boolean
.. attribute:: diffuse
The diffuse colour of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0].
:type: list [r, g, b]
.. attribute:: specular
The specular colour of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0].
:type: list [r, g, b]
.. attribute:: shininess
The shininess (specular exponent) of the material. 0.0 <= shininess <= 128.0.
:type: float
.. attribute:: specularity
The amount of specular of the material. 0.0 <= specularity <= 1.0.
:type: float
.. method:: updateTexture(tface, rasty)
Updates a realtime animation.
:arg tface: Texture face (eg mat.tface)
:type tface: CObject
:arg rasty: Rasterizer
:type rasty: CObject
.. method:: setTexture(tface)
Sets texture render state.
:arg tface: Texture face
:type tface: CObject
.. code-block:: python
mat.setTexture(mat.tface)
.. method:: activate(rasty, cachingInfo)
Sets material parameters for this object for rendering.
Material Parameters set:
#. Texture
#. Backface culling
#. Line drawing
#. Specular Colour
#. Shininess
#. Diffuse Colour
#. Polygon Offset.
:arg rasty: Rasterizer instance.
:type rasty: CObject
:arg cachingInfo: Material cache instance.
:type cachingInfo: CObject
.. method:: setCustomMaterial(material)
Sets the material state setup object.
Using this method, you can extend or completely replace the gameengine material
to do your own advanced multipass effects.
Use this method to register your material class. Instead of the normal material,
your class's activate method will be called just before rendering the mesh.
This should setup the texture, material, and any other state you would like.
It should return True to render the mesh, or False if you are finished. You should
clean up any state Blender does not set before returning False.
Activate Method Definition:
.. code-block:: python
def activate(self, rasty, cachingInfo, material):
:arg material: The material object.
:type material: instance
.. code-block:: python
class PyMaterial:
def __init__(self):
self.pass_no = -1
def activate(self, rasty, cachingInfo, material):
# Activate the material here.
#
# The activate method will be called until it returns False.
# Every time the activate method returns True the mesh will
# be rendered.
#
# rasty is a CObject for passing to material.updateTexture()
# and material.activate()
# cachingInfo is a CObject for passing to material.activate()
# material is the KX_PolygonMaterial instance this material
# was added to
# default material properties:
self.pass_no += 1
if self.pass_no == 0:
material.activate(rasty, cachingInfo)
# Return True to do this pass
return True
# clean up and return False to finish.
self.pass_no = -1
return False
# Create a new Python Material and pass it to the renderer.
mat.setCustomMaterial(PyMaterial())
.. class:: KX_RadarSensor(KX_NearSensor)
Radar sensor is a near sensor with a conical sensor object.
.. attribute:: coneOrigin
The origin of the cone with which to test. The origin is in the middle of the cone. (read-only).
:type: list of floats [x, y, z]
.. attribute:: coneTarget
The center of the bottom face of the cone with which to test. (read-only).
:type: list of floats [x, y, z]
.. attribute:: distance
The height of the cone with which to test.
:type: float
.. attribute:: angle
The angle of the cone (in degrees) with which to test.
:type: float from 0 to 360
.. attribute:: axis
The axis on which the radar cone is cast.
:type: integer from 0 to 5
KX_RADAR_AXIS_POS_X, KX_RADAR_AXIS_POS_Y, KX_RADAR_AXIS_POS_Z,
KX_RADAR_AXIS_NEG_X, KX_RADAR_AXIS_NEG_Y, KX_RADAR_AXIS_NEG_Z
.. method:: getConeHeight()
:return: The height of the cone with which to test.
:rtype: float
.. class:: KX_RaySensor(SCA_ISensor)
A ray sensor detects the first object in a given direction.
.. attribute:: propName
The property the ray is looking for.
:type: string
.. attribute:: range
The distance of the ray.
:type: float
.. attribute:: useMaterial
Whether or not to look for a material (false = property).
:type: boolean
.. attribute:: useXRay
Whether or not to use XRay.
:type: boolean
.. attribute:: hitObject
The game object that was hit by the ray. (read-only).
:type: :class:`KX_GameObject`
.. attribute:: hitPosition
The position (in worldcoordinates) where the object was hit by the ray. (read-only).
:type: list [x, y, z]
.. attribute:: hitNormal
The normal (in worldcoordinates) of the object at the location where the object was hit by the ray. (read-only).
:type: list [x, y, z]
.. attribute:: rayDirection
The direction from the ray (in worldcoordinates). (read-only).
:type: list [x, y, z]
.. attribute:: axis
The axis the ray is pointing on.
:type: integer from 0 to 5
* KX_RAY_AXIS_POS_X
* KX_RAY_AXIS_POS_Y
* KX_RAY_AXIS_POS_Z
* KX_RAY_AXIS_NEG_X
* KX_RAY_AXIS_NEG_Y
* KX_RAY_AXIS_NEG_Z
.. class:: KX_SCA_AddObjectActuator(SCA_IActuator)
Edit Object Actuator (in Add Object Mode)
.. warning::
An Add Object actuator will be ignored if at game start, the linked object doesn't exist (or is empty) or the linked object is in an active layer.
.. code-block:: none
Error: GameObject 'Name' has a AddObjectActuator 'ActuatorName' without object (in 'nonactive' layer)
.. attribute:: object
the object this actuator adds.
:type: :class:`KX_GameObject` or None
.. attribute:: objectLastCreated
the last added object from this actuator (read-only).
:type: :class:`KX_GameObject` or None
.. attribute:: time
the lifetime of added objects, in frames. Set to 0 to disable automatic deletion.
:type: integer
.. attribute:: linearVelocity
the initial linear velocity of added objects.
:type: list [vx, vy, vz]
.. attribute:: angularVelocity
the initial angular velocity of added objects.
:type: list [vx, vy, vz]
.. method:: instantAddObject()
adds the object without needing to calling SCA_PythonController.activate()
.. note:: Use objectLastCreated to get the newly created object.
.. class:: KX_SCA_DynamicActuator(SCA_IActuator)
Dynamic Actuator.
.. attribute:: mode
:type: integer
the type of operation of the actuator, 0-4
* KX_DYN_RESTORE_DYNAMICS(0)
* KX_DYN_DISABLE_DYNAMICS(1)
* KX_DYN_ENABLE_RIGID_BODY(2)
* KX_DYN_DISABLE_RIGID_BODY(3)
* KX_DYN_SET_MASS(4)
.. attribute:: mass
the mass value for the KX_DYN_SET_MASS operation.
:type: float
.. class:: KX_SCA_EndObjectActuator(SCA_IActuator)
Edit Object Actuator (in End Object mode)
This actuator has no python methods.
.. class:: KX_SCA_ReplaceMeshActuator(SCA_IActuator)
Edit Object actuator, in Replace Mesh mode.
.. warning::
Replace mesh actuators will be ignored if at game start, the named mesh doesn't exist.
This will generate a warning in the console
.. code-block:: none
Error: GameObject 'Name' ReplaceMeshActuator 'ActuatorName' without object
.. code-block:: python
# Level-of-detail
# Switch a game object's mesh based on its depth in the camera view.
# +----------+ +-----------+ +-------------------------------------+
# | Always +-----+ Python +-----+ Edit Object (Replace Mesh) LOD.Mesh |
# +----------+ +-----------+ +-------------------------------------+
from bge import logic
# List detail meshes here
# Mesh (name, near, far)
# Meshes overlap so that they don't 'pop' when on the edge of the distance.
meshes = ((".Hi", 0.0, -20.0),
(".Med", -15.0, -50.0),
(".Lo", -40.0, -100.0)
)
cont = logic.getCurrentController()
object = cont.owner
actuator = cont.actuators["LOD." + obj.name]
camera = logic.getCurrentScene().active_camera
def Depth(pos, plane):
return pos[0]*plane[0] + pos[1]*plane[1] + pos[2]*plane[2] + plane[3]
# Depth is negative and decreasing further from the camera
depth = Depth(object.position, camera.world_to_camera[2])
newmesh = None
curmesh = None
# Find the lowest detail mesh for depth
for mesh in meshes:
if depth < mesh[1] and depth > mesh[2]:
newmesh = mesh
if "ME" + object.name + mesh[0] == actuator.getMesh():
curmesh = mesh
if newmesh != None and "ME" + object.name + newmesh[0] != actuator.mesh:
# The mesh is a different mesh - switch it.
# Check the current mesh is not a better fit.
if curmesh == None or curmesh[1] < depth or curmesh[2] > depth:
actuator.mesh = object.name + newmesh[0]
cont.activate(actuator)
.. attribute:: mesh
:class:`MeshProxy` or the name of the mesh that will replace the current one.
Set to None to disable actuator.
:type: :class:`MeshProxy` or None if no mesh is set
.. attribute:: useDisplayMesh
when true the displayed mesh is replaced.
:type: boolean
.. attribute:: usePhysicsMesh
when true the physics mesh is replaced.
:type: boolean
.. method:: instantReplaceMesh()
Immediately replace mesh without delay.
.. class:: KX_Scene(PyObjectPlus)
An active scene that gives access to objects, cameras, lights and scene attributes.
The activity culling stuff is supposed to disable logic bricks when their owner gets too far
from the active camera. It was taken from some code lurking at the back of KX_Scene - who knows
what it does!
.. code-block:: python
from bge import logic
# get the scene
scene = logic.getCurrentScene()
# print all the objects in the scene
for object in scene.objects:
print(object.name)
# get an object named 'Cube'
object = scene.objects["Cube"]
# get the first object in the scene.
object = scene.objects[0]
.. code-block:: python
# Get the depth of an object in the camera view.
from bge import logic
object = logic.getCurrentController().owner
cam = logic.getCurrentScene().active_camera
# Depth is negative and decreasing further from the camera
depth = object.position[0]*cam.world_to_camera[2][0] + object.position[1]*cam.world_to_camera[2][1] + object.position[2]*cam.world_to_camera[2][2] + cam.world_to_camera[2][3]
@bug: All attributes are read only at the moment.
.. attribute:: name
The scene's name, (read-only).
:type: string
.. attribute:: objects
A list of objects in the scene, (read-only).
:type: :class:`CListValue` of :class:`KX_GameObject`
.. attribute:: objectsInactive
A list of objects on background layers (used for the addObject actuator), (read-only).
:type: :class:`CListValue` of :class:`KX_GameObject`
.. attribute:: lights
A list of lights in the scene, (read-only).
:type: :class:`CListValue` of :class:`KX_LightObject`
.. attribute:: cameras
A list of cameras in the scene, (read-only).
:type: :class:`CListValue` of :class:`KX_Camera`
.. attribute:: active_camera
The current active camera.
:type: :class:`KX_Camera`
.. note::
This can be set directly from python to avoid using the :class:`KX_SceneActuator`.
.. attribute:: suspended
True if the scene is suspended, (read-only).
:type: boolean
.. attribute:: activity_culling
True if the scene is activity culling.
:type: boolean
.. attribute:: activity_culling_radius
The distance outside which to do activity culling. Measured in manhattan distance.
:type: float
.. attribute:: dbvt_culling
True when Dynamic Bounding box Volume Tree is set (read-only).
:type: boolean
.. attribute:: pre_draw
A list of callables to be run before the render step.
:type: list
.. attribute:: post_draw
A list of callables to be run after the render step.
:type: list
.. method:: addObject(object, other, time=0)
Adds an object to the scene like the Add Object Actuator would.
:arg object: The object to add
:type object: :class:`KX_GameObject` or string
:arg other: The object's center to use when adding the object
:type other: :class:`KX_GameObject` or string
:arg time: The lifetime of the added object, in frames. A time of 0 means the object will last forever.
:type time: integer
:return: The newly added object.
:rtype: :class:`KX_GameObject`
.. method:: end()
Removes the scene from the game.
.. method:: restart()
Restarts the scene.
.. method:: replace(scene)
Replaces this scene with another one.
:arg scene: The name of the scene to replace this scene with.
:type scene: string
.. method:: suspend()
Suspends this scene.
.. method:: resume()
Resume this scene.
.. method:: get(key, default=None)
Return the value matching key, or the default value if its not found.
:return: The key value or a default.
.. class:: KX_SceneActuator(SCA_IActuator)
Scene Actuator logic brick.
.. warning::
Scene actuators that use a scene name will be ignored if at game start, the named scene doesn't exist or is empty
This will generate a warning in the console:
.. code-block:: none
Error: GameObject 'Name' has a SceneActuator 'ActuatorName' (SetScene) without scene
.. attribute:: scene
the name of the scene to change to/overlay/underlay/remove/suspend/resume.
:type: string
.. attribute:: camera
the camera to change to.
:type: :class:`KX_Camera` on read, string or :class:`KX_Camera` on write
.. note::
When setting the attribute, you can use either a :class:`KX_Camera` or the name of the camera.
.. attribute:: useRestart
Set flag to True to restart the sene.
:type: boolean
.. attribute:: mode
The mode of the actuator.
:type: integer from 0 to 5.
.. class:: KX_SoundActuator(SCA_IActuator)
Sound Actuator.
The :data:`startSound`, :data:`pauseSound` and :data:`stopSound` do not requirethe actuator to be activated - they act instantly provided that the actuator has been activated once at least.
.. attribute:: fileName
The filename of the sound this actuator plays.
:type: string
.. attribute:: volume
The volume (gain) of the sound.
:type: float
.. attribute:: pitch
The pitch of the sound.
:type: float
.. attribute:: rollOffFactor
The roll off factor. Rolloff defines the rate of attenuation as the sound gets further away.
:type: float
.. attribute:: looping
The loop mode of the actuator.
:type: integer
.. attribute:: position
The position of the sound as a list: [x, y, z].
:type: float array
.. attribute:: velocity
The velocity of the emitter as a list: [x, y, z]. The relative velocity to the observer determines the pitch. List of 3 floats: [x, y, z].
:type: float array
.. attribute:: orientation
The orientation of the sound. When setting the orientation you can also use quaternion [float, float, float, float] or euler angles [float, float, float].
:type: 3x3 matrix [[float]]
.. attribute:: mode
The operation mode of the actuator. Can be one of :ref:`these constants<logic-sound-actuator>`
:type: integer
.. class:: KX_StateActuator(SCA_IActuator)
State actuator changes the state mask of parent object.
.. attribute:: operation
Type of bit operation to be applied on object state mask.
You can use one of :ref:`these constants <state-actuator-operation>`
:type: integer
.. attribute:: mask
Value that defines the bits that will be modified by the operation.
The bits that are 1 in the mask will be updated in the object state.
The bits that are 0 are will be left unmodified expect for the Copy operation which copies the mask to the object state.
:type: integer
.. class:: KX_TrackToActuator(SCA_IActuator)
Edit Object actuator in Track To mode.
.. warning::
Track To Actuators will be ignored if at game start, the object to track to is invalid.
This will generate a warning in the console:
.. code-block:: none
GameObject 'Name' no object in EditObjectActuator 'ActuatorName'
.. attribute:: object
the object this actuator tracks.
:type: :class:`KX_GameObject` or None
.. attribute:: time
the time in frames with which to delay the tracking motion.
:type: integer
.. attribute:: use3D
the tracking motion to use 3D.
:type: boolean
.. class:: KX_VehicleWrapper(PyObjectPlus)
KX_VehicleWrapper
TODO - description
.. method:: addWheel(wheel, attachPos, attachDir, axleDir, suspensionRestLength, wheelRadius, hasSteering)
Add a wheel to the vehicle
:arg wheel: The object to use as a wheel.
:type wheel: :class:`KX_GameObject` or a KX_GameObject name
:arg attachPos: The position that this wheel will attach to.
:type attachPos: vector of 3 floats
:arg attachDir: The direction this wheel points.
:type attachDir: vector of 3 floats
:arg axleDir: The direction of this wheels axle.
:type axleDir: vector of 3 floats
:arg suspensionRestLength: TODO - Description
:type suspensionRestLength: float
:arg wheelRadius: The size of the wheel.
:type wheelRadius: float
.. method:: applyBraking(force, wheelIndex)
Apply a braking force to the specified wheel
:arg force: the brake force
:type force: float
:arg wheelIndex: index of the wheel where the force needs to be applied
:type wheelIndex: integer
.. method:: applyEngineForce(force, wheelIndex)
Apply an engine force to the specified wheel
:arg force: the engine force
:type force: float
:arg wheelIndex: index of the wheel where the force needs to be applied
:type wheelIndex: integer
.. method:: getConstraintId()
Get the constraint ID
:return: the constraint id
:rtype: integer
.. method:: getConstraintType()
Returns the constraint type.
:return: constraint type
:rtype: integer
.. method:: getNumWheels()
Returns the number of wheels.
:return: the number of wheels for this vehicle
:rtype: integer
.. method:: getWheelOrientationQuaternion(wheelIndex)
Returns the wheel orientation as a quaternion.
:arg wheelIndex: the wheel index
:type wheelIndex: integer
:return: TODO Description
:rtype: TODO - type should be quat as per method name but from the code it looks like a matrix
.. method:: getWheelPosition(wheelIndex)
Returns the position of the specified wheel
:arg wheelIndex: the wheel index
:type wheelIndex: integer
:return: position vector
:rtype: list[x, y, z]
.. method:: getWheelRotation(wheelIndex)
Returns the rotation of the specified wheel
:arg wheelIndex: the wheel index
:type wheelIndex: integer
:return: the wheel rotation
:rtype: float
.. method:: setRollInfluence(rollInfluece, wheelIndex)
Set the specified wheel's roll influence.
The higher the roll influence the more the vehicle will tend to roll over in corners.
:arg rollInfluece: the wheel roll influence
:type rollInfluece: float
:arg wheelIndex: the wheel index
:type wheelIndex: integer
.. method:: setSteeringValue(steering, wheelIndex)
Set the specified wheel's steering
:arg steering: the wheel steering
:type steering: float
:arg wheelIndex: the wheel index
:type wheelIndex: integer
.. method:: setSuspensionCompression(compression, wheelIndex)
Set the specified wheel's compression
:arg compression: the wheel compression
:type compression: float
:arg wheelIndex: the wheel index
:type wheelIndex: integer
.. method:: setSuspensionDamping(damping, wheelIndex)
Set the specified wheel's damping
:arg damping: the wheel damping
:type damping: float
:arg wheelIndex: the wheel index
:type wheelIndex: integer
.. method:: setSuspensionStiffness(stiffness, wheelIndex)
Set the specified wheel's stiffness
:arg stiffness: the wheel stiffness
:type stiffness: float
:arg wheelIndex: the wheel index
:type wheelIndex: integer
.. method:: setTyreFriction(friction, wheelIndex)
Set the specified wheel's tyre friction
:arg friction: the tyre friction
:type friction: float
:arg wheelIndex: the wheel index
:type wheelIndex: integer
.. class:: KX_VertexProxy(SCA_IObject)
A vertex holds position, UV, colour and normal information.
Note:
The physics simulation is NOT currently updated - physics will not respond
to changes in the vertex position.
.. attribute:: XYZ
The position of the vertex.
:type: list [x, y, z]
.. attribute:: UV
The texture coordinates of the vertex.
:type: list [u, v]
.. attribute:: normal
The normal of the vertex.
:type: list [nx, ny, nz]
.. attribute:: colour
The colour of the vertex.
:type: list [r, g, b, a]
Black = [0.0, 0.0, 0.0, 1.0], White = [1.0, 1.0, 1.0, 1.0]
.. attribute:: color
Synonym for colour.
.. attribute:: x
The x coordinate of the vertex.
:type: float
.. attribute:: y
The y coordinate of the vertex.
:type: float
.. attribute:: z
The z coordinate of the vertex.
:type: float
.. attribute:: u
The u texture coordinate of the vertex.
:type: float
.. attribute:: v
The v texture coordinate of the vertex.
:type: float
.. attribute:: u2
The second u texture coordinate of the vertex.
:type: float
.. attribute:: v2
The second v texture coordinate of the vertex.
:type: float
.. attribute:: r
The red component of the vertex colour. 0.0 <= r <= 1.0.
:type: float
.. attribute:: g
The green component of the vertex colour. 0.0 <= g <= 1.0.
:type: float
.. attribute:: b
The blue component of the vertex colour. 0.0 <= b <= 1.0.
:type: float
.. attribute:: a
The alpha component of the vertex colour. 0.0 <= a <= 1.0.
:type: float
.. method:: getXYZ()
Gets the position of this vertex.
:return: this vertexes position in local coordinates.
:rtype: list [x, y, z]
.. method:: setXYZ(pos)
Sets the position of this vertex.
:type: list [x, y, z]
:arg pos: the new position for this vertex in local coordinates.
.. method:: getUV()
Gets the UV (texture) coordinates of this vertex.
:return: this vertexes UV (texture) coordinates.
:rtype: list [u, v]
.. method:: setUV(uv)
Sets the UV (texture) coordinates of this vertex.
:type: list [u, v]
.. method:: getUV2()
Gets the 2nd UV (texture) coordinates of this vertex.
:return: this vertexes UV (texture) coordinates.
:rtype: list [u, v]
.. method:: setUV2(uv, unit)
Sets the 2nd UV (texture) coordinates of this vertex.
:type: list [u, v]
:arg unit: optional argument, FLAT==1, SECOND_UV==2, defaults to SECOND_UV
:arg unit: integer
.. method:: getRGBA()
Gets the colour of this vertex.
The colour is represented as four bytes packed into an integer value. The colour is
packed as RGBA.
Since Python offers no way to get each byte without shifting, you must use the struct module to
access colour in an machine independent way.
Because of this, it is suggested you use the r, g, b and a attributes or the colour attribute instead.
.. code-block:: python
import struct;
col = struct.unpack('4B', struct.pack('I', v.getRGBA()))
# col = (r, g, b, a)
# black = ( 0, 0, 0, 255)
# white = (255, 255, 255, 255)
:return: packed colour. 4 byte integer with one byte per colour channel in RGBA format.
:rtype: integer
.. method:: setRGBA(col)
Sets the colour of this vertex.
See getRGBA() for the format of col, and its relevant problems. Use the r, g, b and a attributes
or the colour attribute instead.
setRGBA() also accepts a four component list as argument col. The list represents the colour as [r, g, b, a]
with black = [0.0, 0.0, 0.0, 1.0] and white = [1.0, 1.0, 1.0, 1.0]
.. code-block:: python
v.setRGBA(0xff0000ff) # Red
v.setRGBA(0xff00ff00) # Green on little endian, transparent purple on big endian
v.setRGBA([1.0, 0.0, 0.0, 1.0]) # Red
v.setRGBA([0.0, 1.0, 0.0, 1.0]) # Green on all platforms.
:arg col: the new colour of this vertex in packed RGBA format.
:type col: integer or list [r, g, b, a]
.. method:: getNormal()
Gets the normal vector of this vertex.
:return: normalised normal vector.
:rtype: list [nx, ny, nz]
.. method:: setNormal(normal)
Sets the normal vector of this vertex.
:type: sequence of floats [r, g, b]
:arg normal: the new normal of this vertex.
.. class:: KX_VisibilityActuator(SCA_IActuator)
Visibility Actuator.
.. attribute:: visibility
whether the actuator makes its parent object visible or invisible.
:type: boolean
.. attribute:: useOcclusion
whether the actuator makes its parent object an occluder or not.
:type: boolean
.. attribute:: useRecursion
whether the visibility/occlusion should be propagated to all children of the object.
:type: boolean
.. class:: SCA_2DFilterActuator(SCA_IActuator)
Create, enable and disable 2D filters
The following properties don't have an immediate effect.
You must active the actuator to get the result.
The actuator is not persistent: it automatically stops itself after setting up the filter
but the filter remains active. To stop a filter you must activate the actuator with 'type'
set to :data:`~bge.logic.RAS_2DFILTER_DISABLED` or :data:`~bge.logic.RAS_2DFILTER_NOFILTER`.
.. attribute:: shaderText
shader source code for custom shader.
:type: string
.. attribute:: disableMotionBlur
action on motion blur: 0=enable, 1=disable.
:type: integer
.. attribute:: mode
Type of 2D filter, use one of :ref:`these constants <Two-D-FilterActuator-mode>`
:type: integer
.. attribute:: passNumber
order number of filter in the stack of 2D filters. Filters are executed in increasing order of passNb.
Only be one filter can be defined per passNb.
:type: integer (0-100)
.. attribute:: value
argument for motion blur filter.
:type: float (0.0-100.0)
.. class:: SCA_ANDController(SCA_IController)
An AND controller activates only when all linked sensors are activated.
There are no special python methods for this controller.
.. class:: SCA_ActuatorSensor(SCA_ISensor)
Actuator sensor detect change in actuator state of the parent object.
It generates a positive pulse if the corresponding actuator is activated
and a negative pulse if the actuator is deactivated.
.. attribute:: actuator
the name of the actuator that the sensor is monitoring.
:type: string
.. class:: SCA_AlwaysSensor(SCA_ISensor)
This sensor is always activated.
.. class:: SCA_DelaySensor(SCA_ISensor)
The Delay sensor generates positive and negative triggers at precise time,
expressed in number of frames. The delay parameter defines the length of the initial OFF period. A positive trigger is generated at the end of this period.
The duration parameter defines the length of the ON period following the OFF period.
There is a negative trigger at the end of the ON period. If duration is 0, the sensor stays ON and there is no negative trigger.
The sensor runs the OFF-ON cycle once unless the repeat option is set: the OFF-ON cycle repeats indefinately (or the OFF cycle if duration is 0).
Use :class:`SCA_ISensor.reset` at any time to restart sensor.
.. attribute:: delay
length of the initial OFF period as number of frame, 0 for immediate trigger.
:type: integer.
.. attribute:: duration
length of the ON period in number of frame after the initial OFF period.
If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
:type: integer
.. attribute:: repeat
1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
:type: integer
.. class:: SCA_JoystickSensor(SCA_ISensor)
This sensor detects player joystick events.
.. attribute:: axisValues
The state of the joysticks axis as a list of values :data:`numAxis` long. (read-only).
:type: list of ints.
Each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.
The first 2 values are used by most joysticks and gamepads for directional control. 3rd and 4th values are only on some joysticks and can be used for arbitary controls.
* left:[-32767, 0, ...]
* right:[32767, 0, ...]
* up:[0, -32767, ...]
* down:[0, 32767, ...]
.. attribute:: axisSingle
like :data:`axisValues` but returns a single axis value that is set by the sensor. (read-only).
:type: integer
.. note::
Only use this for "Single Axis" type sensors otherwise it will raise an error.
.. attribute:: hatValues
The state of the joysticks hats as a list of values :data:`numHats` long. (read-only).
:type: list of ints
Each spesifying the direction of the hat from 1 to 12, 0 when inactive.
Hat directions are as follows...
* 0:None
* 1:Up
* 2:Right
* 4:Down
* 8:Left
* 3:Up - Right
* 6:Down - Right
* 12:Down - Left
* 9:Up - Left
.. attribute:: hatSingle
Like :data:`hatValues` but returns a single hat direction value that is set by the sensor. (read-only).
:type: integer
.. attribute:: numAxis
The number of axes for the joystick at this index. (read-only).
:type: integer
.. attribute:: numButtons
The number of buttons for the joystick at this index. (read-only).
:type: integer
.. attribute:: numHats
The number of hats for the joystick at this index. (read-only).
:type: integer
.. attribute:: connected
True if a joystick is connected at this joysticks index. (read-only).
:type: boolean
.. attribute:: index
The joystick index to use (from 0 to 7). The first joystick is always 0.
:type: integer
.. attribute:: threshold
Axis threshold. Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
:type: integer
.. attribute:: button
The button index the sensor reacts to (first button = 0). When the "All Events" toggle is set, this option has no effect.
:type: integer
.. attribute:: axis
The axis this sensor reacts to, as a list of two values [axisIndex, axisDirection]
* axisIndex: the axis index to use when detecting axis movement, 1=primary directional control, 2=secondary directional control.
* axisDirection: 0=right, 1=up, 2=left, 3=down.
:type: [integer, integer]
.. attribute:: hat
The hat the sensor reacts to, as a list of two values: [hatIndex, hatDirection]
* hatIndex: the hat index to use when detecting hat movement, 1=primary hat, 2=secondary hat (4 max).
* hatDirection: 1-12.
:type: [integer, integer]
.. method:: getButtonActiveList()
:return: A list containing the indicies of the currently pressed buttons.
:rtype: list
.. method:: getButtonStatus(buttonIndex)
:arg buttonIndex: the button index, 0=first button
:type buttonIndex: integer
:return: The current pressed state of the specified button.
:rtype: boolean
.. class:: SCA_KeyboardSensor(SCA_ISensor)
A keyboard sensor detects player key presses.
See module :mod:`bge.keys` for keycode values.
.. attribute:: key
The key code this sensor is looking for.
:type: keycode from :mod:`bge.keys` module
.. attribute:: hold1
The key code for the first modifier this sensor is looking for.
:type: keycode from :mod:`bge.keys` module
.. attribute:: hold2
The key code for the second modifier this sensor is looking for.
:type: keycode from :mod:`bge.keys` module
.. attribute:: toggleProperty
The name of the property that indicates whether or not to log keystrokes as a string.
:type: string
.. attribute:: targetProperty
The name of the property that receives keystrokes in case in case a string is logged.
:type: string
.. attribute:: useAllKeys
Flag to determine whether or not to accept all keys.
:type: boolean
.. attribute:: events
a list of pressed keys that have either been pressed, or just released, or are active this frame. (read-only).
:type: list [[:ref:`keycode<keyboard-keys>`, :ref:`status<input-status>`], ...]
.. method:: getKeyStatus(keycode)
Get the status of a key.
:arg keycode: The code that represents the key you want to get the state of, use one of :ref:`these constants<keyboard-keys>`
:type keycode: integer
:return: The state of the given key, can be one of :ref:`these constants<input-status>`
:rtype: int
.. class:: SCA_NANDController(SCA_IController)
An NAND controller activates when all linked sensors are not active.
There are no special python methods for this controller.
.. class:: SCA_NORController(SCA_IController)
An NOR controller activates only when all linked sensors are de-activated.
There are no special python methods for this controller.
.. class:: SCA_ORController(SCA_IController)
An OR controller activates when any connected sensor activates.
There are no special python methods for this controller.
.. class:: SCA_PropertyActuator(SCA_IActuator)
Property Actuator
.. attribute:: propName
the property on which to operate.
:type: string
.. attribute:: value
the value with which the actuator operates.
:type: string
.. attribute:: mode
TODO - add constants to game logic dict!.
:type: integer
.. class:: SCA_PropertySensor(SCA_ISensor)
Activates when the game object property matches.
.. attribute:: mode
Type of check on the property. Can be one of :ref:`these constants <logic-property-sensor>`
:type: integer.
.. attribute:: propName
the property the sensor operates.
:type: string
.. attribute:: value
the value with which the sensor compares to the value of the property.
:type: string
.. attribute:: min
the minimum value of the range used to evaluate the property when in interval mode.
:type: string
.. attribute:: max
the maximum value of the range used to evaluate the property when in interval mode.
:type: string
.. class:: SCA_PythonController(SCA_IController)
A Python controller uses a Python script to activate it's actuators,
based on it's sensors.
.. attribute:: script
The value of this variable depends on the execution methid.
* When 'Script' execution mode is set this value contains the entire python script as a single string (not the script name as you might expect) which can be modified to run different scripts.
* When 'Module' execution mode is set this value will contain a single line string - module name and function "module.func" or "package.modile.func" where the module names are python textblocks or external scripts.
:type: string
.. note::
Once this is set the script name given for warnings will remain unchanged.
.. attribute:: mode
the execution mode for this controller (read-only).
* Script: 0, Execite the :data:`script` as a python code.
* Module: 1, Execite the :data:`script` as a module and function.
:type: integer
.. method:: activate(actuator)
Activates an actuator attached to this controller.
:arg actuator: The actuator to operate on.
:type actuator: actuator or the actuator name as a string
.. method:: deactivate(actuator)
Deactivates an actuator attached to this controller.
:arg actuator: The actuator to operate on.
:type actuator: actuator or the actuator name as a string
.. class:: SCA_RandomActuator(SCA_IActuator)
Random Actuator
.. attribute:: seed
Seed of the random number generator.
:type: integer.
Equal seeds produce equal series. If the seed is 0, the generator will produce the same value on every call.
.. attribute:: para1
the first parameter of the active distribution.
:type: float, read-only.
Refer to the documentation of the generator types for the meaning of this value.
.. attribute:: para2
the second parameter of the active distribution.
:type: float, read-only
Refer to the documentation of the generator types for the meaning of this value.
.. attribute:: distribution
Distribution type. (read-only). Can be one of :ref:`these constants <logic-random-distributions>`
:type: integer
.. attribute:: propName
the name of the property to set with the random value.
:type: string
If the generator and property types do not match, the assignment is ignored.
.. method:: setBoolConst(value)
Sets this generator to produce a constant boolean value.
:arg value: The value to return.
:type value: boolean
.. method:: setBoolUniform()
Sets this generator to produce a uniform boolean distribution.
The generator will generate True or False with 50% chance.
.. method:: setBoolBernouilli(value)
Sets this generator to produce a Bernouilli distribution.
:arg value: Specifies the proportion of False values to produce.
* 0.0: Always generate True
* 1.0: Always generate False
:type value: float
.. method:: setIntConst(value)
Sets this generator to always produce the given value.
:arg value: the value this generator produces.
:type value: integer
.. method:: setIntUniform(lower_bound, upper_bound)
Sets this generator to produce a random value between the given lower and
upper bounds (inclusive).
:type lower_bound: integer
:type upper_bound: integer
.. method:: setIntPoisson(value)
Generate a Poisson-distributed number.
This performs a series of Bernouilli tests with parameter value.
It returns the number of tries needed to achieve succes.
:type value: float
.. method:: setFloatConst(value)
Always generate the given value.
:type value: float
.. method:: setFloatUniform(lower_bound, upper_bound)
Generates a random float between lower_bound and upper_bound with a
uniform distribution.
:type lower_bound: float
:type upper_bound: float
.. method:: setFloatNormal(mean, standard_deviation)
Generates a random float from the given normal distribution.
:arg mean: The mean (average) value of the generated numbers
:type mean: float
:arg standard_deviation: The standard deviation of the generated numbers.
:type standard_deviation: float
.. method:: setFloatNegativeExponential(half_life)
Generate negative-exponentially distributed numbers.
The half-life 'time' is characterized by half_life.
:type half_life: float
.. class:: SCA_RandomSensor(SCA_ISensor)
This sensor activates randomly.
.. attribute:: lastDraw
The seed of the random number generator.
:type: integer
.. attribute:: seed
The seed of the random number generator.
:type: integer
.. method:: setSeed(seed)
Sets the seed of the random number generator.
If the seed is 0, the generator will produce the same value on every call.
:type seed: integer
.. method:: getSeed()
:return: The initial seed of the generator. Equal seeds produce equal random series.
:rtype: integer
.. method:: getLastDraw()
:return: The last random number generated.
:rtype: integer
.. class:: SCA_XNORController(SCA_IController)
An XNOR controller activates when all linked sensors are the same (activated or inative).
There are no special python methods for this controller.
.. class:: SCA_XORController(SCA_IController)
An XOR controller activates when there is the input is mixed, but not when all are on or off.
There are no special python methods for this controller.
.. class:: KX_Camera(KX_GameObject)
A Camera object.
.. data:: INSIDE
See :data:`sphereInsideFrustum` and :data:`boxInsideFrustum`
.. data:: INTERSECT
See :data:`sphereInsideFrustum` and :data:`boxInsideFrustum`
.. data:: OUTSIDE
See :data:`sphereInsideFrustum` and :data:`boxInsideFrustum`
.. attribute:: lens
The camera's lens value.
:type: float
.. attribute:: ortho_scale
The camera's view scale when in orthographic mode.
:type: float
.. attribute:: near
The camera's near clip distance.
:type: float
.. attribute:: far
The camera's far clip distance.
:type: float
.. attribute:: perspective
True if this camera has a perspective transform, False for an orthographic projection.
:type: boolean
.. attribute:: frustum_culling
True if this camera is frustum culling.
:type: boolean
.. attribute:: projection_matrix
This camera's 4x4 projection matrix.
:type: 4x4 Matrix [[float]]
.. attribute:: modelview_matrix
This camera's 4x4 model view matrix. (read-only).
:type: 4x4 Matrix [[float]]
.. note::
This matrix is regenerated every frame from the camera's position and orientation.
.. attribute:: camera_to_world
This camera's camera to world transform. (read-only).
:type: 4x4 Matrix [[float]]
.. note::
This matrix is regenerated every frame from the camera's position and orientation.
.. attribute:: world_to_camera
This camera's world to camera transform. (read-only).
:type: 4x4 Matrix [[float]]
.. note::
Regenerated every frame from the camera's position and orientation.
.. note::
This is camera_to_world inverted.
.. attribute:: useViewport
True when the camera is used as a viewport, set True to enable a viewport for this camera.
:type: boolean
.. method:: sphereInsideFrustum(centre, radius)
Tests the given sphere against the view frustum.
:arg centre: The centre of the sphere (in world coordinates.)
:type centre: list [x, y, z]
:arg radius: the radius of the sphere
:type radius: float
:return: :data:`~bge.types.KX_Camera.INSIDE`, :data:`~bge.types.KX_Camera.OUTSIDE` or :data:`~bge.types.KX_Camera.INTERSECT`
:rtype: integer
.. note::
When the camera is first initialized the result will be invalid because the projection matrix has not been set.
.. code-block:: python
from bge import logic
cont = logic.getCurrentController()
cam = cont.owner
# A sphere of radius 4.0 located at [x, y, z] = [1.0, 1.0, 1.0]
if (cam.sphereInsideFrustum([1.0, 1.0, 1.0], 4) != cam.OUTSIDE):
# Sphere is inside frustum !
# Do something useful !
else:
# Sphere is outside frustum
.. method:: boxInsideFrustum(box)
Tests the given box against the view frustum.
:arg box: Eight (8) corner points of the box (in world coordinates.)
:type box: list of lists
:return: :data:`~bge.types.KX_Camera.INSIDE`, :data:`~bge.types.KX_Camera.OUTSIDE` or :data:`~bge.types.KX_Camera.INTERSECT`
.. note::
When the camera is first initialized the result will be invalid because the projection matrix has not been set.
.. code-block:: python
from bge import logic
cont = logic.getCurrentController()
cam = cont.owner
# Box to test...
box = []
box.append([-1.0, -1.0, -1.0])
box.append([-1.0, -1.0, 1.0])
box.append([-1.0, 1.0, -1.0])
box.append([-1.0, 1.0, 1.0])
box.append([ 1.0, -1.0, -1.0])
box.append([ 1.0, -1.0, 1.0])
box.append([ 1.0, 1.0, -1.0])
box.append([ 1.0, 1.0, 1.0])
if (cam.boxInsideFrustum(box) != cam.OUTSIDE):
# Box is inside/intersects frustum !
# Do something useful !
else:
# Box is outside the frustum !
.. method:: pointInsideFrustum(point)
Tests the given point against the view frustum.
:arg point: The point to test (in world coordinates.)
:type point: 3D Vector
:return: True if the given point is inside this camera's viewing frustum.
:rtype: boolean
.. note::
When the camera is first initialized the result will be invalid because the projection matrix has not been set.
.. code-block:: python
from bge import logic
cont = logic.getCurrentController()
cam = cont.owner
# Test point [0.0, 0.0, 0.0]
if (cam.pointInsideFrustum([0.0, 0.0, 0.0])):
# Point is inside frustum !
# Do something useful !
else:
# Box is outside the frustum !
.. method:: getCameraToWorld()
Returns the camera-to-world transform.
:return: the camera-to-world transform matrix.
:rtype: matrix (4x4 list)
.. method:: getWorldToCamera()
Returns the world-to-camera transform.
This returns the inverse matrix of getCameraToWorld().
:return: the world-to-camera transform matrix.
:rtype: matrix (4x4 list)
.. method:: setOnTop()
Set this cameras viewport ontop of all other viewport.
.. method:: setViewport(left, bottom, right, top)
Sets the region of this viewport on the screen in pixels.
Use :data:`bge.render.getWindowHeight` and :data:`bge.render.getWindowWidth` to calculate values relative to the entire display.
:arg left: left pixel coordinate of this viewport
:type left: integer
:arg bottom: bottom pixel coordinate of this viewport
:type bottom: integer
:arg right: right pixel coordinate of this viewport
:type right: integer
:arg top: top pixel coordinate of this viewport
:type top: integer
.. method:: getScreenPosition(object)
Gets the position of an object projected on screen space.
.. code-block:: python
# For an object in the middle of the screen, coord = [0.5, 0.5]
coord = camera.getScreenPosition(object)
:arg object: object name or list [x, y, z]
:type object: :class:`KX_GameObject` or 3D Vector
:return: the object's position in screen coordinates.
:rtype: list [x, y]
.. method:: getScreenVect(x, y)
Gets the vector from the camera position in the screen coordinate direction.
:arg x: X Axis
:type x: float
:arg y: Y Axis
:type y: float
:rtype: 3D Vector
:return: The vector from screen coordinate.
.. code-block:: python
# Gets the vector of the camera front direction:
m_vect = camera.getScreenVect(0.5, 0.5)
.. method:: getScreenRay(x, y, dist=inf, property=None)
Look towards a screen coordinate (x, y) and find first object hit within dist that matches prop.
The ray is similar to KX_GameObject->rayCastTo.
:arg x: X Axis
:type x: float
:arg y: Y Axis
:type y: float
:arg dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
:type dist: float
:arg property: property name that object must have; can be omitted => detect any object
:type property: string
:rtype: :class:`KX_GameObject`
:return: the first object hit or None if no object or object does not match prop
.. code-block:: python
# Gets an object with a property "wall" in front of the camera within a distance of 100:
target = camera.getScreenRay(0.5, 0.5, 100, "wall")
.. class:: BL_ArmatureObject(KX_GameObject)
An armature object.
.. attribute:: constraints
The list of armature constraint defined on this armature.
Elements of the list can be accessed by index or string.
The key format for string access is '<bone_name>:<constraint_name>'.
:type: list of :class:`BL_ArmatureConstraint`
.. attribute:: channels
The list of armature channels.
Elements of the list can be accessed by index or name the bone.
:type: list of :class:`BL_ArmatureChannel`
.. method:: update()
Ensures that the armature will be updated on next graphic frame.
This action is unecessary if a KX_ArmatureActuator with mode run is active
or if an action is playing. Use this function in other cases. It must be called
on each frame to ensure that the armature is updated continously.
.. class:: BL_ArmatureActuator(SCA_IActuator)
Armature Actuators change constraint condition on armatures.
.. _armatureactuator-constants-type:
Constants related to :data:`~bge.types.BL_ArmatureActuator.type`
.. data:: KX_ACT_ARMATURE_RUN
Just make sure the armature will be updated on the next graphic frame. This is the only persistent mode of the actuator: it executes automatically once per frame until stopped by a controller
:value: 0
.. data:: KX_ACT_ARMATURE_ENABLE
Enable the constraint.
:value: 1
.. data:: KX_ACT_ARMATURE_DISABLE
Disable the constraint (runtime constraint values are not updated).
:value: 2
.. data:: KX_ACT_ARMATURE_SETTARGET
Change target and subtarget of constraint.
:value: 3
.. data:: KX_ACT_ARMATURE_SETWEIGHT
Change weight of (only for IK constraint).
:value: 4
.. attribute:: type
The type of action that the actuator executes when it is active.
Can be one of :ref:`these constants <armatureactuator-constants-type>`
:type: integer
.. attribute:: constraint
The constraint object this actuator is controlling.
:type: :class:`BL_ArmatureConstraint`
.. attribute:: target
The object that this actuator will set as primary target to the constraint it controls.
:type: :class:`KX_GameObject`
.. attribute:: subtarget
The object that this actuator will set as secondary target to the constraint it controls.
:type: :class:`KX_GameObject`.
.. note::
Currently, the only secondary target is the pole target for IK constraint.
.. attribute:: weight
The weight this actuator will set on the constraint it controls.
:type: float.
.. note::
Currently only the IK constraint has a weight. It must be a value between 0 and 1.
.. note::
A weight of 0 disables a constraint while still updating constraint runtime values (see :class:`BL_ArmatureConstraint`)
.. class:: KX_ArmatureSensor(SCA_ISensor)
Armature sensor detect conditions on armatures.
.. _armaturesensor-type:
Constants related to :data:`type`
.. data:: KX_ARMSENSOR_STATE_CHANGED
Detect that the constraint is changing state (active/inactive)
:value: 0
.. data:: KX_ARMSENSOR_LIN_ERROR_BELOW
Detect that the constraint linear error is above a threshold
:value: 1
.. data:: KX_ARMSENSOR_LIN_ERROR_ABOVE
Detect that the constraint linear error is below a threshold
:value: 2
.. data:: KX_ARMSENSOR_ROT_ERROR_BELOW
Detect that the constraint rotation error is above a threshold
:value: 3
.. data:: KX_ARMSENSOR_ROT_ERROR_ABOVE
Detect that the constraint rotation error is below a threshold
:value: 4
.. attribute:: type
The type of measurement that the sensor make when it is active.
Can be one of :ref:`these constants <armaturesensor-type>`
:type: integer.
.. attribute:: constraint
The constraint object this sensor is watching.
:type: :class:`BL_ArmatureConstraint`
.. attribute:: value
The threshold used in the comparison with the constraint error
The linear error is only updated on CopyPose/Distance IK constraint with iTaSC solver
The rotation error is only updated on CopyPose+rotation IK constraint with iTaSC solver
The linear error on CopyPose is always >= 0: it is the norm of the distance between the target and the bone
The rotation error on CopyPose is always >= 0: it is the norm of the equivalent rotation vector between the bone and the target orientations
The linear error on Distance can be positive if the distance between the bone and the target is greater than the desired distance, and negative if the distance is smaller.
:type: float
.. class:: BL_ArmatureConstraint(PyObjectPlus)
Proxy to Armature Constraint. Allows to change constraint on the fly.
Obtained through :class:`BL_ArmatureObject`.constraints.
.. note::
Not all armature constraints are supported in the GE.
.. _armatureconstraint-constants-type:
Constants related to :data:`type`
.. data:: CONSTRAINT_TYPE_TRACKTO
.. data:: CONSTRAINT_TYPE_KINEMATIC
.. data:: CONSTRAINT_TYPE_ROTLIKE
.. data:: CONSTRAINT_TYPE_LOCLIKE
.. data:: CONSTRAINT_TYPE_MINMAX
.. data:: CONSTRAINT_TYPE_SIZELIKE
.. data:: CONSTRAINT_TYPE_LOCKTRACK
.. data:: CONSTRAINT_TYPE_STRETCHTO
.. data:: CONSTRAINT_TYPE_CLAMPTO
.. data:: CONSTRAINT_TYPE_TRANSFORM
.. data:: CONSTRAINT_TYPE_DISTLIMIT
.. _armatureconstraint-constants-ik-type:
Constants related to :data:`ik_type`
.. data:: CONSTRAINT_IK_COPYPOSE
constraint is trying to match the position and eventually the rotation of the target.
:value: 0
.. data:: CONSTRAINT_IK_DISTANCE
Constraint is maintaining a certain distance to target subject to ik_mode
:value: 1
.. _armatureconstraint-constants-ik-flag:
Constants related to :data:`ik_flag`
.. data:: CONSTRAINT_IK_FLAG_TIP
Set when the constraint operates on the head of the bone and not the tail
:value: 1
.. data:: CONSTRAINT_IK_FLAG_ROT
Set when the constraint tries to match the orientation of the target
:value: 2
.. data:: CONSTRAINT_IK_FLAG_STRETCH
Set when the armature is allowed to stretch (only the bones with stretch factor > 0.0)
:value: 16
.. data:: CONSTRAINT_IK_FLAG_POS
Set when the constraint tries to match the position of the target.
:value: 32
.. _armatureconstraint-constants-ik-mode:
Constants related to :data:`ik_mode`
.. data:: CONSTRAINT_IK_MODE_INSIDE
The constraint tries to keep the bone within ik_dist of target
:value: 0
.. data:: CONSTRAINT_IK_MODE_OUTSIDE
The constraint tries to keep the bone outside ik_dist of the target
:value: 1
.. data:: CONSTRAINT_IK_MODE_ONSURFACE
The constraint tries to keep the bone exactly at ik_dist of the target.
:value: 2
.. attribute:: type
Type of constraint, (read-only).
Use one of :ref:`these constants<armatureconstraint-constants-type>`.
:type: integer, one of CONSTRAINT_TYPE_* constants
.. attribute:: name
Name of constraint constructed as <bone_name>:<constraint_name>. constraints list.
:type: string
This name is also the key subscript on :class:`BL_ArmatureObject`.
.. attribute:: enforce
fraction of constraint effect that is enforced. Between 0 and 1.
:type: float
.. attribute:: headtail
Position of target between head and tail of the target bone: 0=head, 1=tail.
:type: float.
.. note::
Only used if the target is a bone (i.e target object is an armature.
.. attribute:: lin_error
runtime linear error (in Blender units) on constraint at the current frame.
This is a runtime value updated on each frame by the IK solver. Only available on IK constraint and iTaSC solver.
:type: float
.. attribute:: rot_error
Runtime rotation error (in radiant) on constraint at the current frame.
:type: float.
This is a runtime value updated on each frame by the IK solver. Only available on IK constraint and iTaSC solver.
It is only set if the constraint has a rotation part, for example, a CopyPose+Rotation IK constraint.
.. attribute:: target
Primary target object for the constraint. The position of this object in the GE will be used as target for the constraint.
:type: :class:`KX_GameObject`.
.. attribute:: subtarget
Secondary target object for the constraint. The position of this object in the GE will be used as secondary target for the constraint.
:type: :class:`KX_GameObject`.
Currently this is only used for pole target on IK constraint.
.. attribute:: active
True if the constraint is active.
:type: boolean
.. note::
An inactive constraint does not update lin_error and rot_error.
.. attribute:: ik_weight
Weight of the IK constraint between 0 and 1.
Only defined for IK constraint.
:type: float
.. attribute:: ik_type
Type of IK constraint, (read-only).
Use one of :ref:`these constants<armatureconstraint-constants-ik-type>`.
:type: integer.
.. attribute:: ik_flag
Combination of IK constraint option flags, read-only.
Use one of :ref:`these constants<armatureconstraint-constants-ik-flag>`.
:type: integer
.. attribute:: ik_dist
Distance the constraint is trying to maintain with target, only used when ik_type=CONSTRAINT_IK_DISTANCE.
:type: float
.. attribute:: ik_mode
Use one of :ref:`these constants<armatureconstraint-constants-ik-mode>`.
Additional mode for IK constraint. Currently only used for Distance constraint:
:type: integer
.. class:: BL_ArmatureChannel(PyObjectPlus)
Proxy to armature pose channel. Allows to read and set armature pose.
The attributes are identical to RNA attributes, but mostly in read-only mode.
See :data:`rotation_mode`
.. data:: PCHAN_ROT_QUAT
.. data:: PCHAN_ROT_XYZ
.. data:: PCHAN_ROT_XZY
.. data:: PCHAN_ROT_YXZ
.. data:: PCHAN_ROT_YZX
.. data:: PCHAN_ROT_ZXY
.. data:: PCHAN_ROT_ZYX
.. attribute:: name
channel name (=bone name), read-only.
:type: string
.. attribute:: bone
return the bone object corresponding to this pose channel, read-only.
:type: :class:`BL_ArmatureBone`
.. attribute:: parent
return the parent channel object, None if root channel, read-only.
:type: :class:`BL_ArmatureChannel`
.. attribute:: has_ik
true if the bone is part of an active IK chain, read-only.
This flag is not set when an IK constraint is defined but not enabled (miss target information for example).
:type: boolean
.. attribute:: ik_dof_x
true if the bone is free to rotation in the X axis, read-only.
:type: boolean
.. attribute:: ik_dof_y
true if the bone is free to rotation in the Y axis, read-only.
:type: boolean
.. attribute:: ik_dof_z
true if the bone is free to rotation in the Z axis, read-only.
:type: boolean
.. attribute:: ik_limit_x
true if a limit is imposed on X rotation, read-only.
:type: boolean
.. attribute:: ik_limit_y
true if a limit is imposed on Y rotation, read-only.
:type: boolean
.. attribute:: ik_limit_z
true if a limit is imposed on Z rotation, read-only.
:type: boolean
.. attribute:: ik_rot_control
true if channel rotation should applied as IK constraint, read-only.
:type: boolean
.. attribute:: ik_lin_control
true if channel size should applied as IK constraint, read-only.
:type: boolean
.. attribute:: location
displacement of the bone head in armature local space, read-write.
:type: vector [X, Y, Z].
.. note::
You can only move a bone if it is unconnected to its parent. An action playing on the armature may change the value. An IK chain does not update this value, see joint_rotation.
.. note::
Changing this field has no immediate effect, the pose is updated when the armature is updated during the graphic render (see :data:`BL_ArmatureObject.update`).
.. attribute:: scale
scale of the bone relative to its parent, read-write.
:type: vector [sizeX, sizeY, sizeZ].
.. note::
An action playing on the armature may change the value. An IK chain does not update this value, see joint_rotation.
.. note::
Changing this field has no immediate effect, the pose is updated when the armature is updated during the graphic render (see :data:`BL_ArmatureObject.update`)
.. attribute:: rotation_quaternion
rotation of the bone relative to its parent expressed as a quaternion, read-write.
:type: vector [qr, qi, qj, qk].
.. note::
This field is only used if rotation_mode is 0. An action playing on the armature may change the value. An IK chain does not update this value, see joint_rotation.
.. note::
Changing this field has no immediate effect, the pose is updated when the armature is updated during the graphic render (see :data:`BL_ArmatureObject.update`)
.. attribute:: rotation_euler
rotation of the bone relative to its parent expressed as a set of euler angles, read-write.
:type: vector [X, Y, Z].
.. note::
This field is only used if rotation_mode is > 0. You must always pass the angles in [X, Y, Z] order; the order of applying the angles to the bone depends on rotation_mode. An action playing on the armature may change this field. An IK chain does not update this value, see joint_rotation.
.. note::
Changing this field has no immediate effect, the pose is updated when the armature is updated during the graphic render (see :data:`BL_ArmatureObject.update`)
.. attribute:: rotation_mode
Method of updating the bone rotation, read-write.
:type: integer
Use the following constants (euler mode are named as in Blender UI but the actual axis order is reversed).
* PCHAN_ROT_QUAT(0) : use quaternioin in rotation attribute to update bone rotation
* PCHAN_ROT_XYZ(1) : use euler_rotation and apply angles on bone's Z, Y, X axis successively
* PCHAN_ROT_XZY(2) : use euler_rotation and apply angles on bone's Y, Z, X axis successively
* PCHAN_ROT_YXZ(3) : use euler_rotation and apply angles on bone's Z, X, Y axis successively
* PCHAN_ROT_YZX(4) : use euler_rotation and apply angles on bone's X, Z, Y axis successively
* PCHAN_ROT_ZXY(5) : use euler_rotation and apply angles on bone's Y, X, Z axis successively
* PCHAN_ROT_ZYX(6) : use euler_rotation and apply angles on bone's X, Y, Z axis successively
.. attribute:: channel_matrix
pose matrix in bone space (deformation of the bone due to action, constraint, etc), Read-only.
This field is updated after the graphic render, it represents the current pose.
:type: matrix [4][4]
.. attribute:: pose_matrix
pose matrix in armature space, read-only,
This field is updated after the graphic render, it represents the current pose.
:type: matrix [4][4]
.. attribute:: pose_head
position of bone head in armature space, read-only.
:type: vector [x, y, z]
.. attribute:: pose_tail
position of bone tail in armature space, read-only.
:type: vector [x, y, z]
.. attribute:: ik_min_x
minimum value of X rotation in degree (<= 0) when X rotation is limited (see ik_limit_x), read-only.
:type: float
.. attribute:: ik_max_x
maximum value of X rotation in degree (>= 0) when X rotation is limited (see ik_limit_x), read-only.
:type: float
.. attribute:: ik_min_y
minimum value of Y rotation in degree (<= 0) when Y rotation is limited (see ik_limit_y), read-only.
:type: float
.. attribute:: ik_max_y
maximum value of Y rotation in degree (>= 0) when Y rotation is limited (see ik_limit_y), read-only.
:type: float
.. attribute:: ik_min_z
minimum value of Z rotation in degree (<= 0) when Z rotation is limited (see ik_limit_z), read-only.
:type: float
.. attribute:: ik_max_z
maximum value of Z rotation in degree (>= 0) when Z rotation is limited (see ik_limit_z), read-only.
:type: float
.. attribute:: ik_stiffness_x
bone rotation stiffness in X axis, read-only.
:type: float between 0 and 1
.. attribute:: ik_stiffness_y
bone rotation stiffness in Y axis, read-only.
:type: float between 0 and 1
.. attribute:: ik_stiffness_z
bone rotation stiffness in Z axis, read-only.
:type: float between 0 and 1
.. attribute:: ik_stretch
ratio of scale change that is allowed, 0=bone can't change size, read-only.
:type: float
.. attribute:: ik_rot_weight
weight of rotation constraint when ik_rot_control is set, read-write.
:type: float between 0 and 1
.. attribute:: ik_lin_weight
weight of size constraint when ik_lin_control is set, read-write.
:type: float between 0 and 1
.. attribute:: joint_rotation
Control bone rotation in term of joint angle (for robotic applications), read-write.
When writing to this attribute, you pass a [x, y, z] vector and an appropriate set of euler angles or quaternion is calculated according to the rotation_mode.
When you read this attribute, the current pose matrix is converted into a [x, y, z] vector representing the joint angles.
The value and the meaning of the x, y, z depends on the ik_dof_x/ik_dof_y/ik_dof_z attributes:
* 1DoF joint X, Y or Z: the corresponding x, y, or z value is used an a joint angle in radiant
* 2DoF joint X+Y or Z+Y: treated as 2 successive 1DoF joints: first X or Z, then Y. The x or z value is used as a joint angle in radiant along the X or Z axis, followed by a rotation along the new Y axis of y radiants.
* 2DoF joint X+Z: treated as a 2DoF joint with rotation axis on the X/Z plane. The x and z values are used as the coordinates of the rotation vector in the X/Z plane.
* 3DoF joint X+Y+Z: treated as a revolute joint. The [x, y, z] vector represents the equivalent rotation vector to bring the joint from the rest pose to the new pose.
:type: vector [x, y, z]
.. note::
The bone must be part of an IK chain if you want to set the ik_dof_x/ik_dof_y/ik_dof_z attributes via the UI, but this will interfere with this attribute since the IK solver will overwrite the pose. You can stay in control of the armature if you create an IK constraint but do not finalize it (e.g. don't set a target) the IK solver will not run but the IK panel will show up on the UI for each bone in the chain.
.. note::
[0, 0, 0] always corresponds to the rest pose.
.. note::
You must request the armature pose to update and wait for the next graphic frame to see the effect of setting this attribute (see :data:`BL_ArmatureObject.update`).
.. note::
You can read the result of the calculation in rotation or euler_rotation attributes after setting this attribute.
.. class:: BL_ArmatureBone(PyObjectPlus)
Proxy to Blender bone structure. All fields are read-only and comply to RNA names.
All space attribute correspond to the rest pose.
.. attribute:: name
bone name.
:type: string
.. attribute:: connected
true when the bone head is struck to the parent's tail.
:type: boolean
.. attribute:: hinge
true when bone doesn't inherit rotation or scale from parent bone.
:type: boolean
.. attribute:: inherit_scale
true when bone inherits scaling from parent bone.
:type: boolean
.. attribute:: bbone_segments
number of B-bone segments.
:type: integer
.. attribute:: roll
bone rotation around head-tail axis.
:type: float
.. attribute:: head
location of head end of the bone in parent bone space.
:type: vector [x, y, z]
.. attribute:: tail
location of head end of the bone in parent bone space.
:type: vector [x, y, z]
.. attribute:: length
bone length.
:type: float
.. attribute:: arm_head
location of head end of the bone in armature space.
:type: vector [x, y, z]
.. attribute:: arm_tail
location of tail end of the bone in armature space.
:type: vector [x, y, z]
.. attribute:: arm_mat
matrix of the bone head in armature space.
:type: matrix [4][4]
.. note::
This matrix has no scale part.
.. attribute:: bone_mat
rotation matrix of the bone in parent bone space.
:type: matrix [3][3]
.. attribute:: parent
parent bone, or None for root bone.
:type: :class:`BL_ArmatureBone`
.. attribute:: children
list of bone's children.
:type: list of :class:`BL_ArmatureBone`
|