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
|
/*
* $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano, Michel Selten, Alex Mole,
* Alexander Szakaly, Campbell Barton, Ken Hughes
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "Material.h" /*This must come first*/
#include "DNA_oops_types.h"
#include "DNA_space_types.h"
#include "DNA_material_types.h"
#include "BKE_main.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_material.h"
#include "BKE_texture.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BSE_editipo.h"
#include "BIF_space.h"
#include "mydevice.h"
#include "constant.h"
#include "MTex.h"
#include "Texture.h"
#include "Ipo.h"
#include "gen_utils.h"
/*****************************************************************************/
/* Python BPy_Material defaults: */
/*****************************************************************************/
/* Material MIN, MAX values */
#define EXPP_MAT_ADD_MIN 0.0f
#define EXPP_MAT_ADD_MAX 1.0f
#define EXPP_MAT_ALPHA_MIN 0.0f
#define EXPP_MAT_ALPHA_MAX 1.0f
#define EXPP_MAT_AMB_MIN 0.0f
#define EXPP_MAT_AMB_MAX 1.0f
#define EXPP_MAT_COL_MIN 0.0f /* min/max for all ... */
#define EXPP_MAT_COL_MAX 1.0f /* ... color triplets */
#define EXPP_MAT_EMIT_MIN 0.0f
#define EXPP_MAT_EMIT_MAX 1.0f
#define EXPP_MAT_REF_MIN 0.0f
#define EXPP_MAT_REF_MAX 1.0f
#define EXPP_MAT_SPEC_MIN 0.0f
#define EXPP_MAT_SPEC_MAX 2.0f
#define EXPP_MAT_SPECTRA_MIN 0.0f
#define EXPP_MAT_SPECTRA_MAX 1.0f
/* Shader specific settings */
#define EXPP_MAT_ROUGHNESS_MIN 0.0f
#define EXPP_MAT_ROUGHNESS_MAX 3.140f
#define EXPP_MAT_SPECSIZE_MIN 0.0f
#define EXPP_MAT_SPECSIZE_MAX 1.530f
#define EXPP_MAT_DIFFUSESIZE_MIN 0.0f
#define EXPP_MAT_DIFFUSESIZE_MAX 3.140f
#define EXPP_MAT_SPECSMOOTH_MIN 0.0f
#define EXPP_MAT_SPECSMOOTH_MAX 1.0f
#define EXPP_MAT_DIFFUSESMOOTH_MIN 0.0f
#define EXPP_MAT_DIFFUSESMOOTH_MAX 1.0f
#define EXPP_MAT_DIFFUSE_DARKNESS_MIN 0.0f
#define EXPP_MAT_DIFFUSE_DARKNESS_MAX 2.0f
#define EXPP_MAT_REFRACINDEX_MIN 1.0f
#define EXPP_MAT_REFRACINDEX_MAX 10.0f
#define EXPP_MAT_RMS_MIN 0.0f
#define EXPP_MAT_RMS_MAX 0.4f
/* End shader settings */
#define EXPP_MAT_ZOFFS_MIN 0.0
#define EXPP_MAT_ZOFFS_MAX 10.0
#define EXPP_MAT_HALOSIZE_MIN 0.0
#define EXPP_MAT_HALOSIZE_MAX 100.0
#define EXPP_MAT_FLARESIZE_MIN 0.1f
#define EXPP_MAT_FLARESIZE_MAX 25.0
#define EXPP_MAT_FLAREBOOST_MIN 0.1f
#define EXPP_MAT_FLAREBOOST_MAX 10.0
#define EXPP_MAT_SUBSIZE_MIN 0.1f
#define EXPP_MAT_SUBSIZE_MAX 25.0
#define EXPP_MAT_HARD_MIN 1
#define EXPP_MAT_HARD_MAX 255 /* 127 with MODE HALO ON */
#define EXPP_MAT_HALOSEED_MIN 1
#define EXPP_MAT_HALOSEED_MAX 255
#define EXPP_MAT_NFLARES_MIN 1
#define EXPP_MAT_NFLARES_MAX 32
#define EXPP_MAT_FLARESEED_MIN 1
#define EXPP_MAT_FLARESEED_MAX 255
#define EXPP_MAT_NSTARS_MIN 3
#define EXPP_MAT_NSTARS_MAX 50
#define EXPP_MAT_NLINES_MIN 0
#define EXPP_MAT_NLINES_MAX 250
#define EXPP_MAT_NRINGS_MIN 0
#define EXPP_MAT_NRINGS_MAX 24
#define EXPP_MAT_RAYMIRR_MIN 0.0
#define EXPP_MAT_RAYMIRR_MAX 1.0
#define EXPP_MAT_MIRRDEPTH_MIN 0
#define EXPP_MAT_MIRRDEPTH_MAX 10
#define EXPP_MAT_FRESNELMIRR_MIN 0.0
#define EXPP_MAT_FRESNELMIRR_MAX 5.0
#define EXPP_MAT_FRESNELMIRRFAC_MIN 1.0
#define EXPP_MAT_FRESNELMIRRFAC_MAX 5.0
#define EXPP_MAT_FILTER_MIN 0.0
#define EXPP_MAT_FILTER_MAX 1.0
#define EXPP_MAT_TRANSLUCENCY_MIN 0.0
#define EXPP_MAT_TRANSLUCENCY_MAX 1.0
#define EXPP_MAT_ZOFFS_MIN 0.0
#define EXPP_MAT_ZOFFS_MAX 10.0
#define EXPP_MAT_IOR_MIN 1.0
#define EXPP_MAT_IOR_MAX 3.0
#define EXPP_MAT_TRANSDEPTH_MIN 0
#define EXPP_MAT_TRANSDEPTH_MAX 10
#define EXPP_MAT_FRESNELTRANS_MIN 0.0
#define EXPP_MAT_FRESNELTRANS_MAX 5.0
#define EXPP_MAT_FRESNELTRANSFAC_MIN 1.0
#define EXPP_MAT_FRESNELTRANSFAC_MAX 5.0
#define EXPP_MAT_SPECTRANS_MIN 0.0
#define EXPP_MAT_SPECTRANS_MAX 1.0
#define EXPP_MAT_MIRRTRANSADD_MIN 0.0
#define EXPP_MAT_MIRRTRANSADD_MAX 1.0
/* closure values for getColorComponent()/setColorComponent() */
#define EXPP_MAT_COMP_R 0
#define EXPP_MAT_COMP_G 1
#define EXPP_MAT_COMP_B 2
#define EXPP_MAT_COMP_SPECR 3
#define EXPP_MAT_COMP_SPECG 4
#define EXPP_MAT_COMP_SPECB 5
#define EXPP_MAT_COMP_MIRR 6
#define EXPP_MAT_COMP_MIRG 7
#define EXPP_MAT_COMP_MIRB 8
#define IPOKEY_RGB 0
#define IPOKEY_ALPHA 1
#define IPOKEY_HALOSIZE 2
#define IPOKEY_MODE 3
#define IPOKEY_ALLCOLOR 10
#define IPOKEY_ALLMIRROR 14
#define IPOKEY_OFS 12
#define IPOKEY_SIZE 13
#define IPOKEY_ALLMAPPING 11
/*****************************************************************************/
/* Python API function prototypes for the Material module. */
/*****************************************************************************/
static PyObject *M_Material_New( PyObject * self, PyObject * args,
PyObject * keywords );
static PyObject *M_Material_Get( PyObject * self, PyObject * args );
/* Not exposed nor used */
Material *GetMaterialByName( char *name );
/*****************************************************************************/
/* The following string definitions are used for documentation strings. In */
/* Python these will be written to the console when doing a */
/* Blender.Material.__doc__ */
/*****************************************************************************/
static char M_Material_doc[] = "The Blender Material module";
static char M_Material_New_doc[] =
"(name) - return a new material called 'name'\n\
() - return a new material called 'Mat'";
static char M_Material_Get_doc[] =
"(name) - return the material called 'name', None if not found.\n\
() - return a list of all materials in the current scene.";
/*****************************************************************************/
/* Python method structure definition for Blender.Material module: */
/*****************************************************************************/
struct PyMethodDef M_Material_methods[] = {
{"New", ( PyCFunction ) M_Material_New, METH_VARARGS | METH_KEYWORDS,
M_Material_New_doc},
{"Get", M_Material_Get, METH_VARARGS, M_Material_Get_doc},
{"get", M_Material_Get, METH_VARARGS, M_Material_Get_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Function: M_Material_New */
/* Python equivalent: Blender.Material.New */
/*****************************************************************************/
static PyObject *M_Material_New( PyObject * self, PyObject * args,
PyObject * keywords )
{
char *name = "Mat";
static char *kwlist[] = { "name", NULL };
BPy_Material *pymat; /* for Material Data object wrapper in Python */
Material *blmat; /* for actual Material Data we create in Blender */
char buf[21];
if( !PyArg_ParseTupleAndKeywords
( args, keywords, "|s", kwlist, &name ) )
return ( EXPP_ReturnPyObjError
( PyExc_AttributeError,
"expected string or nothing as argument" ) );
if( strcmp( name, "Mat" ) != 0 ) /* use gave us a name ? */
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
blmat = add_material( name ); /* first create the Material Data in Blender */
if( blmat ) /* now create the wrapper obj in Python */
pymat = ( BPy_Material * ) Material_CreatePyObject( blmat );
else
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create Material Data in Blender" ) );
blmat->id.us = 0; /* was incref'ed by add_material() above */
if( pymat == NULL )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create Material Data object" ) );
return ( PyObject * ) pymat;
}
/*****************************************************************************/
/* Function: M_Material_Get */
/* Python equivalent: Blender.Material.Get */
/* Description: Receives a string and returns the material whose */
/* name matches the string. If no argument is */
/* passed in, a list with all materials in the */
/* current scene is returned. */
/*****************************************************************************/
static PyObject *M_Material_Get( PyObject * self, PyObject * args )
{
char *name = NULL;
Material *mat_iter;
if( !PyArg_ParseTuple( args, "|s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument (or nothing)" ) );
mat_iter = G.main->mat.first;
if( name ) { /* (name) - Search material by name */
BPy_Material *wanted_mat = NULL;
while( mat_iter ) {
if( strcmp( name, mat_iter->id.name + 2 ) == 0 ) {
wanted_mat =
( BPy_Material * )
Material_CreatePyObject( mat_iter );
break;
}
mat_iter = mat_iter->id.next;
}
if( wanted_mat == NULL ) { /* Requested material doesn't exist */
char error_msg[64];
PyOS_snprintf( error_msg, sizeof( error_msg ),
"Material \"%s\" not found", name );
return EXPP_ReturnPyObjError( PyExc_NameError,
error_msg );
}
return ( PyObject * ) wanted_mat;
}
else { /* () - return a list with all materials in the scene */
int index = 0;
PyObject *matlist, *pyobj;
matlist = PyList_New( BLI_countlist( &( G.main->mat ) ) );
if( !matlist )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyList" ) );
while( mat_iter ) {
pyobj = Material_CreatePyObject( mat_iter );
if( !pyobj )
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create PyObject" ) );
PyList_SET_ITEM( matlist, index, pyobj );
mat_iter = mat_iter->id.next;
index++;
}
return matlist;
}
}
static PyObject *Material_ModesDict( void )
{
PyObject *Modes = PyConstant_New( );
if( Modes ) {
BPy_constant *c = ( BPy_constant * ) Modes;
PyConstant_Insert(c, "TRACEABLE", PyInt_FromLong(MA_TRACEBLE));
PyConstant_Insert(c, "SHADOW", PyInt_FromLong(MA_SHADOW));
PyConstant_Insert(c, "SHADELESS", PyInt_FromLong(MA_SHLESS));
PyConstant_Insert(c, "WIRE", PyInt_FromLong(MA_WIRE));
PyConstant_Insert(c, "VCOL_LIGHT", PyInt_FromLong(MA_VERTEXCOL));
PyConstant_Insert(c, "HALO", PyInt_FromLong(MA_HALO));
PyConstant_Insert(c, "ZTRANSP", PyInt_FromLong(MA_ZTRA));
PyConstant_Insert(c, "VCOL_PAINT", PyInt_FromLong(MA_VERTEXCOLP));
PyConstant_Insert(c, "ZINVERT", PyInt_FromLong(MA_ZINV));
PyConstant_Insert(c, "HALORINGS", PyInt_FromLong(MA_HALO_RINGS));
PyConstant_Insert(c, "ENV", PyInt_FromLong(MA_ENV));
PyConstant_Insert(c, "HALOLINES", PyInt_FromLong(MA_HALO_LINES));
PyConstant_Insert(c, "ONLYSHADOW", PyInt_FromLong(MA_ONLYSHADOW));
PyConstant_Insert(c, "HALOXALPHA", PyInt_FromLong(MA_HALO_XALPHA));
PyConstant_Insert(c, "HALOSTAR", PyInt_FromLong(MA_STAR));
PyConstant_Insert(c, "TEXFACE", PyInt_FromLong(MA_FACETEXTURE));
PyConstant_Insert(c, "HALOTEX", PyInt_FromLong(MA_HALOTEX));
PyConstant_Insert(c, "HALOPUNO", PyInt_FromLong(MA_HALOPUNO));
PyConstant_Insert(c, "NOMIST", PyInt_FromLong(MA_NOMIST));
PyConstant_Insert(c, "HALOSHADE", PyInt_FromLong(MA_HALO_SHADE));
PyConstant_Insert(c, "HALOFLARE", PyInt_FromLong(MA_HALO_FLARE));
PyConstant_Insert(c, "RADIO", PyInt_FromLong(MA_RADIO));
PyConstant_Insert(c, "RAYMIRROR", PyInt_FromLong(MA_RAYMIRROR));
PyConstant_Insert(c, "ZTRA", PyInt_FromLong(MA_ZTRA));
PyConstant_Insert(c, "RAYTRANSP", PyInt_FromLong(MA_RAYTRANSP));
}
return Modes;
}
static PyObject *Material_ShadersDict( void )
{
PyObject *Shaders = PyConstant_New( );
if( Shaders ) {
BPy_constant *c = ( BPy_constant * ) Shaders;
PyConstant_Insert(c, "DIFFUSE_LAMBERT", PyInt_FromLong(MA_DIFF_LAMBERT));
PyConstant_Insert(c, "DIFFUSE_ORENNAYAR", PyInt_FromLong(MA_DIFF_ORENNAYAR));
PyConstant_Insert(c, "DIFFUSE_TOON", PyInt_FromLong(MA_DIFF_TOON));
PyConstant_Insert(c, "DIFFUSE_MINNAERT", PyInt_FromLong(MA_DIFF_MINNAERT));
PyConstant_Insert(c, "SPEC_COOKTORR", PyInt_FromLong(MA_SPEC_COOKTORR));
PyConstant_Insert(c, "SPEC_PHONG", PyInt_FromLong(MA_SPEC_PHONG));
PyConstant_Insert(c, "SPEC_BLINN", PyInt_FromLong(MA_SPEC_BLINN));
PyConstant_Insert(c, "SPEC_TOON", PyInt_FromLong(MA_SPEC_TOON));
PyConstant_Insert(c, "SPEC_WARDISO", PyInt_FromLong(MA_SPEC_WARDISO));
}
return Shaders;
}
/*****************************************************************************/
/* Function: Material_Init */
/*****************************************************************************/
PyObject *Material_Init( void )
{
PyObject *submodule, *Modes, *Shaders;
if( PyType_Ready( &Material_Type ) < 0)
return NULL;
Modes = Material_ModesDict( );
Shaders = Material_ShadersDict( );
submodule = Py_InitModule3( "Blender.Material",
M_Material_methods, M_Material_doc );
if( Modes )
PyModule_AddObject( submodule, "Modes", Modes );
if( Shaders )
PyModule_AddObject( submodule, "Shaders", Shaders );
PyModule_AddIntConstant( submodule, "RGB", IPOKEY_RGB );
PyModule_AddIntConstant( submodule, "ALPHA", IPOKEY_ALPHA );
PyModule_AddIntConstant( submodule, "HALOSIZE", IPOKEY_HALOSIZE );
PyModule_AddIntConstant( submodule, "MODE", IPOKEY_MODE );
PyModule_AddIntConstant( submodule, "ALLCOLOR", IPOKEY_ALLCOLOR );
PyModule_AddIntConstant( submodule, "ALLMIRROR", IPOKEY_ALLMIRROR );
PyModule_AddIntConstant( submodule, "OFS", IPOKEY_OFS );
PyModule_AddIntConstant( submodule, "SIZE", IPOKEY_SIZE );
PyModule_AddIntConstant( submodule, "ALLMAPPING", IPOKEY_ALLMAPPING );
return ( submodule );
}
/***************************/
/*** The Material PyType ***/
/***************************/
static PyObject *Matr_oldsetAdd( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetAlpha( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetAmb( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetEmit( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetFilter( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetFlareBoost( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetFlareSeed( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetFlareSize( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetFresnelMirr( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetFresnelMirrFac( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetFresnelTrans( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetFresnelTransFac( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetHaloSeed( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetHaloSize( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetHardness( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetIOR( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetName( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetNFlares( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetNLines( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetNRings( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetNStars( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetRayMirr( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetMirrDepth( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetRef( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetSpec( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetSpecTransp( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetSubSize( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetTransDepth( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetZOffset( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetMode( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetIpo( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetRGBCol( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetSpecCol( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetSpecShader( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetMirCol( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetDiffuseShader( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetRoughness( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetSpecSize( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetDiffuseSize( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetSpecSmooth( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetDiffuseSmooth( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetDiffuseDarkness( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetRefracIndex( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetRms( BPy_Material * self, PyObject * args );
static PyObject *Matr_oldsetTranslucency( BPy_Material * self, PyObject * args );
;
static int Material_setIpo( BPy_Material * self, PyObject * value );
static int Material_setName( BPy_Material * self, PyObject * value );
static int Material_setMode( BPy_Material * self, PyObject * value );
static int Material_setRGBCol( BPy_Material * self, PyObject * value );
static int Material_setSpecCol( BPy_Material * self, PyObject * value );
static int Material_setMirCol( BPy_Material * self, PyObject * value );
static int Material_setColorComponent( BPy_Material * self, PyObject * value,
void * closure );
static int Material_setAmb( BPy_Material * self, PyObject * value );
static int Material_setEmit( BPy_Material * self, PyObject * value );
static int Material_setSpecTransp( BPy_Material * self, PyObject * value );
static int Material_setAlpha( BPy_Material * self, PyObject * value );
static int Material_setRef( BPy_Material * self, PyObject * value );
static int Material_setSpec( BPy_Material * self, PyObject * value );
static int Material_setZOffset( BPy_Material * self, PyObject * value );
static int Material_setAdd( BPy_Material * self, PyObject * value );
static int Material_setHaloSize( BPy_Material * self, PyObject * value );
static int Material_setFlareSize( BPy_Material * self, PyObject * value );
static int Material_setFlareBoost( BPy_Material * self, PyObject * value );
static int Material_setSubSize( BPy_Material * self, PyObject * value );
static int Material_setHaloSeed( BPy_Material * self, PyObject * value );
static int Material_setFlareSeed( BPy_Material * self, PyObject * value );
static int Material_setHardness( BPy_Material * self, PyObject * value );
static int Material_setNFlares( BPy_Material * self, PyObject * value );
static int Material_setNStars( BPy_Material * self, PyObject * value );
static int Material_setNLines( BPy_Material * self, PyObject * value );
static int Material_setNRings( BPy_Material * self, PyObject * value );
static int Material_setRayMirr( BPy_Material * self, PyObject * value );
static int Material_setMirrDepth( BPy_Material * self, PyObject * value );
static int Material_setFresnelMirr( BPy_Material * self, PyObject * value );
static int Material_setFresnelMirrFac( BPy_Material * self, PyObject * value );
static int Material_setIOR( BPy_Material * self, PyObject * value );
static int Material_setTransDepth( BPy_Material * self, PyObject * value );
static int Material_setFresnelTrans( BPy_Material * self, PyObject * value );
static int Material_setFresnelTransFac( BPy_Material * self, PyObject * value );
static int Material_setOopsLoc ( BPy_Material * self, PyObject * value );
static int Material_setOopsSel ( BPy_Material * self, PyObject * value );
static int Material_setSpecShader( BPy_Material * self, PyObject * value );
static int Material_setDiffuseShader( BPy_Material * self, PyObject * value );
static int Material_setRoughness( BPy_Material * self, PyObject * value );
static int Material_setSpecSize( BPy_Material * self, PyObject * value );
static int Material_setDiffuseSize( BPy_Material * self, PyObject * value );
static int Material_setSpecSmooth( BPy_Material * self, PyObject * value );
static int Material_setDiffuseSmooth( BPy_Material * self, PyObject * value );
static int Material_setDiffuseDarkness( BPy_Material * self, PyObject * value );
static int Material_setRefracIndex( BPy_Material * self, PyObject * value );
static int Material_setRms( BPy_Material * self, PyObject * value );
static int Material_setFilter( BPy_Material * self, PyObject * value );
static int Material_setTranslucency( BPy_Material * self, PyObject * value );
static PyObject *Material_getColorComponent( BPy_Material * self,
void * closure );
static PyObject *Material_getOopsLoc( BPy_Material * self );
static PyObject *Material_getOopsSel( BPy_Material * self );
static PyObject *Material_getUsers( BPy_Material * self );
/*****************************************************************************/
/* Python BPy_Material methods declarations: */
/*****************************************************************************/
static PyObject *Material_getIpo( BPy_Material * self );
static PyObject *Material_getName( BPy_Material * self );
static PyObject *Material_getMode( BPy_Material * self );
static PyObject *Material_getRGBCol( BPy_Material * self );
/*static PyObject *Material_getAmbCol(BPy_Material *self);*/
static PyObject *Material_getSpecCol( BPy_Material * self );
static PyObject *Material_getMirCol( BPy_Material * self );
static PyObject *Material_getAmb( BPy_Material * self );
static PyObject *Material_getEmit( BPy_Material * self );
static PyObject *Material_getAlpha( BPy_Material * self );
static PyObject *Material_getRef( BPy_Material * self );
static PyObject *Material_getSpec( BPy_Material * self );
static PyObject *Material_getSpecTransp( BPy_Material * self );
static PyObject *Material_getAdd( BPy_Material * self );
static PyObject *Material_getZOffset( BPy_Material * self );
static PyObject *Material_getHaloSize( BPy_Material * self );
static PyObject *Material_getHaloSeed( BPy_Material * self );
static PyObject *Material_getFlareSize( BPy_Material * self );
static PyObject *Material_getFlareSeed( BPy_Material * self );
static PyObject *Material_getFlareBoost( BPy_Material * self );
static PyObject *Material_getSubSize( BPy_Material * self );
static PyObject *Material_getHardness( BPy_Material * self );
static PyObject *Material_getNFlares( BPy_Material * self );
static PyObject *Material_getNStars( BPy_Material * self );
static PyObject *Material_getNLines( BPy_Material * self );
static PyObject *Material_getNRings( BPy_Material * self );
/* Shader settings */
static PyObject *Material_getSpecShader( BPy_Material * self );
static PyObject *Material_getDiffuseShader( BPy_Material * self );
static PyObject *Material_getRoughness( BPy_Material * self );
static PyObject *Material_getSpecSize( BPy_Material * self );
static PyObject *Material_getDiffuseSize( BPy_Material * self );
static PyObject *Material_getSpecSmooth( BPy_Material * self );
static PyObject *Material_getDiffuseSmooth( BPy_Material * self );
static PyObject *Material_getDiffuseDarkness( BPy_Material * self );
static PyObject *Material_getRefracIndex( BPy_Material * self );
static PyObject *Material_getRms( BPy_Material * self );
static PyObject *Material_getRayMirr( BPy_Material * self );
static PyObject *Material_getMirrDepth( BPy_Material * self );
static PyObject *Material_getFresnelMirr( BPy_Material * self );
static PyObject *Material_getFresnelMirrFac( BPy_Material * self );
static PyObject *Material_getIOR( BPy_Material * self );
static PyObject *Material_getTransDepth( BPy_Material * self );
static PyObject *Material_getFresnelTrans( BPy_Material * self );
static PyObject *Material_getFresnelTransFac( BPy_Material * self );
static PyObject *Material_getFilter( BPy_Material * self );
static PyObject *Material_getTranslucency( BPy_Material * self );
static PyObject *Material_getTextures( BPy_Material * self );
static PyObject *Material_clearIpo( BPy_Material * self );
static PyObject *Material_setTexture( BPy_Material * self, PyObject * args );
static PyObject *Material_clearTexture( BPy_Material * self, PyObject * args );
static PyObject *Material_getScriptLinks(BPy_Material *self, PyObject * args );
static PyObject *Material_addScriptLink(BPy_Material * self, PyObject * args );
static PyObject *Material_clearScriptLinks(BPy_Material *self, PyObject *args);
static PyObject *Material_insertIpoKey( BPy_Material * self, PyObject * args );
/*****************************************************************************/
/* Python BPy_Material methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Material_methods[] = {
/* name, method, flags, doc */
{"getName", ( PyCFunction ) Material_getName, METH_NOARGS,
"() - Return Material's name"},
{"getIpo", ( PyCFunction ) Material_getIpo, METH_NOARGS,
"() - Return Material's ipo or None if not found"},
{"getMode", ( PyCFunction ) Material_getMode, METH_NOARGS,
"() - Return Material's mode flags"},
{"getRGBCol", ( PyCFunction ) Material_getRGBCol, METH_NOARGS,
"() - Return Material's rgb color triplet"},
/* {"getAmbCol", (PyCFunction)Material_getAmbCol, METH_NOARGS,
"() - Return Material's ambient color"},*/
{"getSpecCol", ( PyCFunction ) Material_getSpecCol, METH_NOARGS,
"() - Return Material's specular color"},
{"getMirCol", ( PyCFunction ) Material_getMirCol, METH_NOARGS,
"() - Return Material's mirror color"},
{"getAmb", ( PyCFunction ) Material_getAmb, METH_NOARGS,
"() - Return Material's ambient color blend factor"},
{"getEmit", ( PyCFunction ) Material_getEmit, METH_NOARGS,
"() - Return Material's emitting light intensity"},
{"getAlpha", ( PyCFunction ) Material_getAlpha, METH_NOARGS,
"() - Return Material's alpha (transparency) value"},
{"getRef", ( PyCFunction ) Material_getRef, METH_NOARGS,
"() - Return Material's reflectivity"},
{"getSpec", ( PyCFunction ) Material_getSpec, METH_NOARGS,
"() - Return Material's specularity"},
/* Shader specific settings */
{"getSpecShader", ( PyCFunction ) Material_getSpecShader, METH_NOARGS,
"() - Returns Material's specular shader" },
{"getDiffuseShader", ( PyCFunction ) Material_getDiffuseShader, METH_NOARGS,
"() - Returns Material's diffuse shader" },
{"getRoughness", ( PyCFunction ) Material_getRoughness, METH_NOARGS,
"() - Returns Material's Roughness (applies to the \"Oren Nayar\" Diffuse Shader only)" },
{"getSpecSize", ( PyCFunction ) Material_getSpecSize, METH_NOARGS,
"() - Returns Material's size of specular area (applies to the \"Toon\" Specular Shader only)" },
{"getDiffuseSize", ( PyCFunction ) Material_getDiffuseSize, METH_NOARGS,
"() - Returns Material's size of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
{"getSpecSmooth", ( PyCFunction ) Material_getSpecSmooth, METH_NOARGS,
"() - Returns Material's smoothing of specular area (applies to the \"Toon\" Diffuse Shader only)" },
{"getDiffuseSmooth", ( PyCFunction ) Material_getDiffuseSmooth, METH_NOARGS,
"() - Returns Material's smoothing of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
{"getDiffuseDarkness", ( PyCFunction ) Material_getDiffuseDarkness, METH_NOARGS,
"() - Returns Material's diffuse darkness (applies to the \"Minnaert\" Diffuse Shader only)" },
{"getRefracIndex", ( PyCFunction ) Material_getRefracIndex, METH_NOARGS,
"() - Returns Material's Index of Refraction (applies to the \"Blinn\" Specular Shader only)" },
{"getRms", ( PyCFunction ) Material_getRms, METH_NOARGS,
"() - Returns Material's standard deviation of surface slope (applies to the \"WardIso\" Specular Shader only)" },
/* End shader settings */
{"getSpecTransp", ( PyCFunction ) Material_getSpecTransp, METH_NOARGS,
"() - Return Material's specular transparency"},
{"getAdd", ( PyCFunction ) Material_getAdd, METH_NOARGS,
"() - Return Material's glow factor"},
{"getZOffset", ( PyCFunction ) Material_getZOffset, METH_NOARGS,
"() - Return Material's artificial offset for faces"},
{"getHaloSize", ( PyCFunction ) Material_getHaloSize, METH_NOARGS,
"() - Return Material's halo size"},
{"getHaloSeed", ( PyCFunction ) Material_getHaloSeed, METH_NOARGS,
"() - Return Material's seed for random ring dimension and line "
"location in halos"},
{"getFlareSize", ( PyCFunction ) Material_getFlareSize, METH_NOARGS,
"() - Return Material's (flare size)/(halo size) factor"},
{"getFlareSeed", ( PyCFunction ) Material_getFlareSeed, METH_NOARGS,
"() - Return Material's flare offset in the seed table"},
{"getFlareBoost", ( PyCFunction ) Material_getFlareBoost, METH_NOARGS,
"() - Return Material's flare boost"},
{"getSubSize", ( PyCFunction ) Material_getSubSize, METH_NOARGS,
"() - Return Material's dimension of subflare, dots and circles"},
{"getHardness", ( PyCFunction ) Material_getHardness, METH_NOARGS,
"() - Return Material's specular hardness"},
{"getNFlares", ( PyCFunction ) Material_getNFlares, METH_NOARGS,
"() - Return Material's number of flares in halo"},
{"getNStars", ( PyCFunction ) Material_getNStars, METH_NOARGS,
"() - Return Material's number of points in the halo stars"},
{"getNLines", ( PyCFunction ) Material_getNLines, METH_NOARGS,
"() - Return Material's number of lines in halo"},
{"getNRings", ( PyCFunction ) Material_getNRings, METH_NOARGS,
"() - Return Material's number of rings in halo"},
{"getRayMirr", ( PyCFunction ) Material_getRayMirr, METH_NOARGS,
"() - Return mount mirror"},
{"getMirrDepth", ( PyCFunction ) Material_getMirrDepth, METH_NOARGS,
"() - Return amount mirror depth"},
{"getFresnelMirr", ( PyCFunction ) Material_getFresnelMirr, METH_NOARGS,
"() - Return fresnel power for refractions"},
{"getFresnelMirrFac", ( PyCFunction ) Material_getFresnelMirrFac, METH_NOARGS,
"() - Return fresnel power for refractions factor"},
{"getFilter", ( PyCFunction ) Material_getFilter, METH_NOARGS,
"() - Return the amount of filtering when transparent raytrace is enabled"},
{"getTranslucency", ( PyCFunction ) Material_getTranslucency, METH_NOARGS,
"() - Return the Translucency, the amount of diffuse shading of the back side"},
{"getIOR", ( PyCFunction ) Material_getIOR, METH_NOARGS,
"() - Return IOR"},
{"getTransDepth", ( PyCFunction ) Material_getTransDepth, METH_NOARGS,
"() - Return amount inter-refractions"},
{"getFresnelTrans", ( PyCFunction ) Material_getFresnelTrans, METH_NOARGS,
"() - Return fresnel power for refractions"},
{"getFresnelTransFac", ( PyCFunction ) Material_getFresnelTransFac, METH_NOARGS,
"() - Return fresnel power for refractions factor"},
{"getTextures", ( PyCFunction ) Material_getTextures, METH_NOARGS,
"() - Return Material's texture list as a tuple"},
{"setName", ( PyCFunction ) Matr_oldsetName, METH_VARARGS,
"(s) - Change Material's name"},
{"setIpo", ( PyCFunction ) Matr_oldsetIpo, METH_VARARGS,
"(Blender Ipo) - Change Material's Ipo"},
{"clearIpo", ( PyCFunction ) Material_clearIpo, METH_NOARGS,
"(Blender Ipo) - Unlink Ipo from this Material"},
{"insertIpoKey", ( PyCFunction ) Material_insertIpoKey, METH_VARARGS,
"(Material Ipo Constant) - Insert IPO Key at current frame"},
{"setMode", ( PyCFunction ) Matr_oldsetMode, METH_VARARGS,
"([s[,s]]) - Set Material's mode flag(s)"},
{"setRGBCol", ( PyCFunction ) Matr_oldsetRGBCol, METH_VARARGS,
"(f,f,f or [f,f,f]) - Set Material's rgb color triplet"},
/* {"setAmbCol", (PyCFunction)Matr_oldsetAmbCol, METH_VARARGS,
"(f,f,f or [f,f,f]) - Set Material's ambient color"},*/
{"setSpecCol", ( PyCFunction ) Matr_oldsetSpecCol, METH_VARARGS,
"(f,f,f or [f,f,f]) - Set Material's specular color"},
/* Shader spesific settings */
{"setSpecShader", ( PyCFunction ) Matr_oldsetSpecShader, METH_VARARGS,
"(i) - Set the Material's specular shader" },
{"setDiffuseShader", ( PyCFunction ) Matr_oldsetDiffuseShader, METH_VARARGS,
"(i) - Set the Material's diffuse shader" },
{"setRoughness", ( PyCFunction ) Matr_oldsetRoughness, METH_VARARGS,
"(f) - Set the Material's Roughness (applies to the \"Oren Nayar\" Diffuse Shader only)" },
{"setSpecSize", ( PyCFunction ) Matr_oldsetSpecSize, METH_VARARGS,
"(f) - Set the Material's size of specular area (applies to the \"Toon\" Specular Shader only)" },
{"setDiffuseSize", ( PyCFunction ) Matr_oldsetDiffuseSize, METH_VARARGS,
"(f) - Set the Material's size of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
{"setSpecSmooth", ( PyCFunction ) Matr_oldsetSpecSmooth, METH_VARARGS,
"(f) - Set the Material's smoothing of specular area (applies to the \"Toon\" Specular Shader only)" },
{"setDiffuseSmooth", ( PyCFunction ) Matr_oldsetDiffuseSmooth, METH_VARARGS,
"(f) - Set the Material's smoothing of diffuse area (applies to the \"Toon\" Diffuse Shader only)" },
{"setDiffuseDarkness", ( PyCFunction ) Matr_oldsetDiffuseDarkness, METH_VARARGS,
"(f) - Set the Material's diffuse darkness (applies to the \"Minnaert\" Diffuse Shader only)" },
{"setRefracIndex", ( PyCFunction ) Matr_oldsetRefracIndex, METH_VARARGS,
"(f) - Set the Material's Index of Refraction (applies to the \"Blinn\" Specular Shader only)" },
{"setRms", ( PyCFunction ) Matr_oldsetRms, METH_VARARGS,
"(f) - Set the Material's standard deviation of surface slope (applies to the \"WardIso\" Specular Shader only)" },
/* End shader settings */
{"setMirCol", ( PyCFunction ) Matr_oldsetMirCol, METH_VARARGS,
"(f,f,f or [f,f,f]) - Set Material's mirror color"},
{"setAmb", ( PyCFunction ) Matr_oldsetAmb, METH_VARARGS,
"(f) - Set how much the Material's color is affected"
" by \nthe global ambient colors - [0.0, 1.0]"},
{"setEmit", ( PyCFunction ) Matr_oldsetEmit, METH_VARARGS,
"(f) - Set Material's emitting light intensity - [0.0, 1.0]"},
{"setAlpha", ( PyCFunction ) Matr_oldsetAlpha, METH_VARARGS,
"(f) - Set Material's alpha (transparency) - [0.0, 1.0]"},
{"setRef", ( PyCFunction ) Matr_oldsetRef, METH_VARARGS,
"(f) - Set Material's reflectivity - [0.0, 1.0]"},
{"setSpec", ( PyCFunction ) Matr_oldsetSpec, METH_VARARGS,
"(f) - Set Material's specularity - [0.0, 2.0]"},
{"setSpecTransp", ( PyCFunction ) Matr_oldsetSpecTransp, METH_VARARGS,
"(f) - Set Material's specular transparency - [0.0, 1.0]"},
{"setAdd", ( PyCFunction ) Matr_oldsetAdd, METH_VARARGS,
"(f) - Set Material's glow factor - [0.0, 1.0]"},
{"setZOffset", ( PyCFunction ) Matr_oldsetZOffset, METH_VARARGS,
"(f) - Set Material's artificial offset - [0.0, 10.0]"},
{"setHaloSize", ( PyCFunction ) Matr_oldsetHaloSize, METH_VARARGS,
"(f) - Set Material's halo size - [0.0, 100.0]"},
{"setHaloSeed", ( PyCFunction ) Matr_oldsetHaloSeed, METH_VARARGS,
"(i) - Set Material's halo seed - [0, 255]"},
{"setFlareSize", ( PyCFunction ) Matr_oldsetFlareSize, METH_VARARGS,
"(f) - Set Material's factor: (flare size)/(halo size) - [0.1, 25.0]"},
{"setFlareSeed", ( PyCFunction ) Matr_oldsetFlareSeed, METH_VARARGS,
"(i) - Set Material's flare seed - [0, 255]"},
{"setFlareBoost", ( PyCFunction ) Matr_oldsetFlareBoost, METH_VARARGS,
"(f) - Set Material's flare boost - [0.1, 10.0]"},
{"setSubSize", ( PyCFunction ) Matr_oldsetSubSize, METH_VARARGS,
"(f) - Set Material's dimension of subflare,"
" dots and circles - [0.1, 25.0]"},
{"setHardness", ( PyCFunction ) Matr_oldsetHardness, METH_VARARGS,
"(i) - Set Material's hardness - [1, 255 (127 if halo mode is ON)]"},
{"setNFlares", ( PyCFunction ) Matr_oldsetNFlares, METH_VARARGS,
"(i) - Set Material's number of flares in halo - [1, 32]"},
{"setNStars", ( PyCFunction ) Matr_oldsetNStars, METH_VARARGS,
"(i) - Set Material's number of stars in halo - [3, 50]"},
{"setNLines", ( PyCFunction ) Matr_oldsetNLines, METH_VARARGS,
"(i) - Set Material's number of lines in halo - [0, 250]"},
{"setNRings", ( PyCFunction ) Matr_oldsetNRings, METH_VARARGS,
"(i) - Set Material's number of rings in halo - [0, 24]"},
{"setRayMirr", ( PyCFunction ) Matr_oldsetRayMirr, METH_VARARGS,
"(f) - Set amount mirror - [0.0, 1.0]"},
{"setMirrDepth", ( PyCFunction ) Matr_oldsetMirrDepth, METH_VARARGS,
"(i) - Set amount inter-reflections - [0, 10]"},
{"setFresnelMirr", ( PyCFunction ) Matr_oldsetFresnelMirr, METH_VARARGS,
"(f) - Set fresnel power for mirror - [0.0, 5.0]"},
{"setFresnelMirrFac", ( PyCFunction ) Matr_oldsetFresnelMirrFac, METH_VARARGS,
"(f) - Set blend fac for mirror fresnel - [1.0, 5.0]"},
{"setFilter", ( PyCFunction ) Matr_oldsetFilter, METH_VARARGS,
"(f) - Set the amount of filtering when transparent raytrace is enabled"},
{"setTranslucency", ( PyCFunction ) Matr_oldsetTranslucency, METH_VARARGS,
"(f) - Set the Translucency, the amount of diffuse shading of the back side"},
{"setIOR", ( PyCFunction ) Matr_oldsetIOR, METH_VARARGS,
"(f) - Set IOR - [1.0, 3.0]"},
{"setTransDepth", ( PyCFunction ) Matr_oldsetTransDepth, METH_VARARGS,
"(i) - Set amount inter-refractions - [0, 10]"},
{"setFresnelTrans", ( PyCFunction ) Matr_oldsetFresnelTrans, METH_VARARGS,
"(f) - Set fresnel power for refractions - [0.0, 5.0]"},
{"setFresnelTransFac", ( PyCFunction ) Matr_oldsetFresnelTransFac, METH_VARARGS,
"(f) - Set fresnel power for refractions factor- [0.0, 5.0]"},
{"setTexture", ( PyCFunction ) Material_setTexture, METH_VARARGS,
"(n,tex,texco=0,mapto=0) - Set numbered texture to tex"},
{"clearTexture", ( PyCFunction ) Material_clearTexture, METH_VARARGS,
"(n) - Remove texture from numbered slot"},
{"getScriptLinks", ( PyCFunction ) Material_getScriptLinks,
METH_VARARGS,
"(eventname) - Get a list of this material's scriptlinks (Text names) "
"of the given type\n"
"(eventname) - string: FrameChanged, Redraw or Render."},
{"addScriptLink", ( PyCFunction ) Material_addScriptLink, METH_VARARGS,
"(text, evt) - Add a new material scriptlink.\n"
"(text) - string: an existing Blender Text name;\n"
"(evt) string: FrameChanged, Redraw or Render."},
{"clearScriptLinks", ( PyCFunction ) Material_clearScriptLinks, METH_VARARGS,
"() - Delete all scriptlinks from this material.\n"
"([s1<,s2,s3...>]) - Delete specified scriptlinks from this material."},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef BPy_Material_getseters[] = {
{"add",
(getter)Material_getAdd, (setter)Material_setAdd,
"Strength of the add effect",
NULL},
{"alpha",
(getter)Material_getAlpha, (setter)Material_setAlpha,
"Alpha setting ",
NULL},
{"amb",
(getter)Material_getAmb, (setter)Material_setAmb,
"Amount of global ambient color material receives",
NULL},
{"diffuseDarkness",
(getter)Material_getDiffuseDarkness, (setter)Material_setDiffuseDarkness,
"Material's diffuse darkness (\"Minnaert\" diffuse shader only)",
NULL},
{"diffuseShader",
(getter)Material_getDiffuseShader, (setter)Material_setDiffuseShader,
"Diffuse shader type",
NULL},
{"diffuseSize",
(getter)Material_getDiffuseSize, (setter)Material_setDiffuseSize,
"Material's diffuse area size (\"Toon\" diffuse shader only)",
NULL},
{"diffuseSmooth",
(getter)Material_getDiffuseSmooth, (setter)Material_setDiffuseSmooth,
"Material's diffuse area smoothing (\"Toon\" diffuse shader only)",
NULL},
{"emit",
(getter)Material_getEmit, (setter)Material_setEmit,
"Amount of light the material emits",
NULL},
{"filter",
(getter)Material_getFilter, (setter)Material_setFilter,
"Amount of filtering when transparent raytrace is enabled",
NULL},
{"flareBoost",
(getter)Material_getFlareBoost, (setter)Material_setFlareBoost,
"Flare's extra strength",
NULL},
{"flareSeed",
(getter)Material_getFlareSeed, (setter)Material_setFlareSeed,
"Offset in the flare seed table",
NULL},
{"flareSize",
(getter)Material_getFlareSize, (setter)Material_setFlareSize,
"Ratio of flare size to halo size",
NULL},
{"fresnelDepth",
(getter)Material_getFresnelMirr, (setter)Material_setFresnelMirr,
"Power of Fresnel for mirror reflection",
NULL},
{"fresnelDepthFac",
(getter)Material_getFresnelMirrFac, (setter)Material_setFresnelMirrFac,
"Blending factor for Fresnel mirror",
NULL},
{"fresnelTrans",
(getter)Material_getFresnelTrans, (setter)Material_setFresnelTrans,
"Power of Fresnel for transparency",
NULL},
{"fresnelTransFac",
(getter)Material_getFresnelTransFac, (setter)Material_setFresnelTransFac,
"Blending factor for Fresnel transparency",
NULL},
{"haloSeed",
(getter)Material_getHaloSeed, (setter)Material_setHaloSeed,
"Randomizes halo ring dimension and line location",
NULL},
{"haloSize",
(getter)Material_getHaloSize, (setter)Material_setHaloSize,
"Dimension of the halo",
NULL},
{"hard",
(getter)Material_getHardness, (setter)Material_setHardness,
"Specularity hardness",
NULL},
{"IOR",
(getter)Material_getIOR, (setter)Material_setIOR,
"Angular index of refraction for raytrace",
NULL},
{"ipo",
(getter)Material_getIpo, (setter)Material_setIpo,
"Material Ipo data",
NULL},
{"mirCol",
(getter)Material_getMirCol, (setter)Material_setMirCol,
"Mirror RGB color triplet",
NULL},
{"mirR",
(getter)Material_getColorComponent, (setter)Material_setColorComponent,
"Mirror color red component",
(void *) EXPP_MAT_COMP_MIRR },
{"mirG",
(getter)Material_getColorComponent, (setter)Material_setColorComponent,
"Mirror color green component",
(void *) EXPP_MAT_COMP_MIRG },
{"mirB",
(getter)Material_getColorComponent, (setter)Material_setColorComponent,
"Mirror color blue component",
(void *) EXPP_MAT_COMP_MIRB },
{"mode",
(getter)Material_getMode, (setter)Material_setMode,
"Material mode bitmask",
NULL},
{"name",
(getter)Material_getName, (setter)Material_setName,
"Material data name",
NULL},
{"nFlares",
(getter)Material_getNFlares, (setter)Material_setNFlares,
"Number of subflares with halo",
NULL},
{"nLines",
(getter)Material_getNLines, (setter)Material_setNLines,
"Number of star-shaped lines with halo",
NULL},
{"nRings",
(getter)Material_getNRings, (setter)Material_setNRings,
"Number of rings with halo",
NULL},
{"nStars",
(getter)Material_getNStars, (setter)Material_setNStars,
"Number of star points with halo",
NULL},
{"oopsLoc",
(getter)Material_getOopsLoc, (setter)Material_setOopsLoc,
"Material OOPs location",
NULL},
{"oopsSel",
(getter)Material_getOopsSel, (setter)Material_setOopsSel,
"Material OOPs selection flag",
NULL},
{"rayMirr",
(getter)Material_getRayMirr, (setter)Material_setRayMirr,
"Mirror reflection amount for raytrace",
NULL},
{"rayMirrDepth",
(getter)Material_getMirrDepth, (setter)Material_setMirrDepth,
"Amount of raytrace inter-reflections",
NULL},
{"ref",
(getter)Material_getRef, (setter)Material_setRef,
"Amount of reflections (for shader)",
NULL},
{"refracIndex",
(getter)Material_getRefracIndex, (setter)Material_setRefracIndex,
"Material's Index of Refraction (applies to the \"Blinn\" Specular Shader only",
NULL},
{"rgbCol",
(getter)Material_getRGBCol, (setter)Material_setRGBCol,
"Diffuse RGB color triplet",
NULL},
{"rms",
(getter)Material_getRms, (setter)Material_setRms,
"Material's surface slope standard deviation (\"WardIso\" specular shader only)",
NULL},
{"roughness",
(getter)Material_getRoughness, (setter)Material_setRoughness,
"Material's roughness (\"Oren Nayar\" diffuse shader only)",
NULL},
{"spec",
(getter)Material_getSpec, (setter)Material_setSpec,
"Degree of specularity",
NULL},
{"specCol",
(getter)Material_getSpecCol, (setter)Material_setSpecCol,
"Specular RGB color triplet",
NULL},
{"specR",
(getter)Material_getColorComponent, (setter)Material_setColorComponent,
"Specular color red component",
(void *) EXPP_MAT_COMP_SPECR },
{"specG",
(getter)Material_getColorComponent, (setter)Material_setColorComponent,
"Specular color green component",
(void *) EXPP_MAT_COMP_SPECG },
{"specB",
(getter)Material_getColorComponent, (setter)Material_setColorComponent,
"Specular color blue component",
(void *) EXPP_MAT_COMP_SPECB },
{"specTransp",
(getter)Material_getSpecTransp, (setter)Material_setSpecTransp,
"Makes specular areas opaque on transparent materials",
NULL},
{"specShader",
(getter)Material_getSpecShader, (setter)Material_setSpecShader,
"Specular shader type",
NULL},
{"specSize",
(getter)Material_getSpecSize, (setter)Material_setSpecSize,
"Material's specular area size (\"Toon\" specular shader only)",
NULL},
{"specSmooth",
(getter)Material_getSpecSmooth, (setter)Material_setSpecSmooth,
"Sets the smoothness of specular toon area",
NULL},
{"subSize",
(getter)Material_getSubSize, (setter)Material_setSubSize,
"Dimension of subflares, dots and circles",
NULL},
{"transDepth",
(getter)Material_getTransDepth, (setter)Material_setTransDepth,
"Amount of refractions for raytrace",
NULL},
{"translucency",
(getter)Material_getTranslucency, (setter)Material_setTranslucency,
"Amount of diffuse shading of the back side",
NULL},
{"zOffset",
(getter)Material_getZOffset, (setter)Material_setZOffset,
"Artificial offset in the Z buffer (for Ztransp option)",
NULL},
{"R",
(getter)Material_getColorComponent, (setter)Material_setColorComponent,
"Diffuse color red component",
(void *) EXPP_MAT_COMP_R },
{"G",
(getter)Material_getColorComponent, (setter)Material_setColorComponent,
"Diffuse color green component",
(void *) EXPP_MAT_COMP_G },
{"B",
(getter)Material_getColorComponent, (setter)Material_setColorComponent,
"Diffuse color blue component",
(void *) EXPP_MAT_COMP_B },
{"users",
(getter)Material_getUsers, (setter)NULL,
"Number of material users",
NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
/*****************************************************************************/
/* Python Material_Type callback function prototypes: */
/*****************************************************************************/
static void Material_dealloc( BPy_Material * self );
static PyObject *Material_repr( BPy_Material * self );
/*****************************************************************************/
/* Python Material_Type structure definition: */
/*****************************************************************************/
PyTypeObject Material_Type = {
PyObject_HEAD_INIT( NULL ) /* required py macro */
0, /* ob_size */
/* For printing, in format "<module>.<name>" */
"Blender Material", /* char *tp_name; */
sizeof( BPy_Material ), /* int tp_basicsize; */
0, /* tp_itemsize; For allocation */
/* Methods to implement standard operations */
( destructor ) Material_dealloc,/* destructor tp_dealloc; */
NULL, /* printfunc tp_print; */
NULL, /* getattrfunc tp_getattr; */
NULL, /* setattrfunc tp_setattr; */
NULL, /* cmpfunc tp_compare; */
( reprfunc ) Material_repr, /* reprfunc tp_repr; */
/* Method suites for standard classes */
NULL, /* PyNumberMethods *tp_as_number; */
NULL, /* PySequenceMethods *tp_as_sequence; */
NULL, /* PyMappingMethods *tp_as_mapping; */
/* More standard operations (here for binary compatibility) */
NULL, /* hashfunc tp_hash; */
NULL, /* ternaryfunc tp_call; */
NULL, /* reprfunc tp_str; */
NULL, /* getattrofunc tp_getattro; */
NULL, /* setattrofunc tp_setattro; */
/* Functions to access object as input/output buffer */
NULL, /* PyBufferProcs *tp_as_buffer; */
/*** Flags to define presence of optional/expanded features ***/
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
NULL, /* char *tp_doc; Documentation string */
/*** Assigned meaning in release 2.0 ***/
/* call function for all accessible objects */
NULL, /* traverseproc tp_traverse; */
/* delete references to contained objects */
NULL, /* inquiry tp_clear; */
/*** Assigned meaning in release 2.1 ***/
/*** rich comparisons ***/
NULL, /* richcmpfunc tp_richcompare; */
/*** weak reference enabler ***/
0, /* long tp_weaklistoffset; */
/*** Added in release 2.2 ***/
/* Iterators */
NULL, /* getiterfunc tp_iter; */
NULL, /* iternextfunc tp_iternext; */
/*** Attribute descriptor and subclassing stuff ***/
BPy_Material_methods, /* struct PyMethodDef *tp_methods; */
NULL, /* struct PyMemberDef *tp_members; */
BPy_Material_getseters, /* struct PyGetSetDef *tp_getset; */
NULL, /* struct _typeobject *tp_base; */
NULL, /* PyObject *tp_dict; */
NULL, /* descrgetfunc tp_descr_get; */
NULL, /* descrsetfunc tp_descr_set; */
0, /* long tp_dictoffset; */
NULL, /* initproc tp_init; */
NULL, /* allocfunc tp_alloc; */
NULL, /* newfunc tp_new; */
/* Low-level free-memory routine */
NULL, /* freefunc tp_free; */
/* For PyObject_IS_GC */
NULL, /* inquiry tp_is_gc; */
NULL, /* PyObject *tp_bases; */
/* method resolution order */
NULL, /* PyObject *tp_mro; */
NULL, /* PyObject *tp_cache; */
NULL, /* PyObject *tp_subclasses; */
NULL, /* PyObject *tp_weaklist; */
NULL
};
/*****************************************************************************/
/* Function: Material_dealloc */
/* Description: This is a callback function for the BPy_Material type. It is */
/* the destructor function. */
/*****************************************************************************/
static void Material_dealloc( BPy_Material * self )
{
Py_DECREF( self->col );
Py_DECREF( self->amb );
Py_DECREF( self->spec );
Py_DECREF( self->mir );
PyObject_DEL( self );
}
/*****************************************************************************/
/* Function: Material_CreatePyObject */
/* Description: Create a new BPy_Material from an existing */
/* Blender material structure. */
/*****************************************************************************/
PyObject *Material_CreatePyObject( struct Material *mat )
{
BPy_Material *pymat;
float *col[3], *amb[3], *spec[3], *mir[3];
pymat = ( BPy_Material * ) PyObject_NEW( BPy_Material,
&Material_Type );
if( !pymat )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create BPy_Material object" );
pymat->material = mat;
col[0] = &mat->r;
col[1] = &mat->g;
col[2] = &mat->b;
amb[0] = &mat->ambr;
amb[1] = &mat->ambg;
amb[2] = &mat->ambb;
spec[0] = &mat->specr;
spec[1] = &mat->specg;
spec[2] = &mat->specb;
mir[0] = &mat->mirr;
mir[1] = &mat->mirg;
mir[2] = &mat->mirb;
pymat->col = ( BPy_rgbTuple * ) rgbTuple_New( col );
pymat->amb = ( BPy_rgbTuple * ) rgbTuple_New( amb );
pymat->spec = ( BPy_rgbTuple * ) rgbTuple_New( spec );
pymat->mir = ( BPy_rgbTuple * ) rgbTuple_New( mir );
return ( PyObject * ) pymat;
}
/*****************************************************************************/
/* Function: Material_CheckPyObject */
/* Description: This function returns true when the given PyObject is of the */
/* type Material. Otherwise it will return false. */
/*****************************************************************************/
int Material_CheckPyObject( PyObject * pyobj )
{
return ( pyobj->ob_type == &Material_Type );
}
/*****************************************************************************/
/* Function: Material_FromPyObject */
/* Description: This function returns the Blender material from the given */
/* PyObject. */
/*****************************************************************************/
Material *Material_FromPyObject( PyObject * pyobj )
{
return ( ( BPy_Material * ) pyobj )->material;
}
/*****************************************************************************/
/* Description: Returns the object with the name specified by the argument */
/* name. Note that the calling function has to remove the first */
/* two characters of the object name. These two characters */
/* specify the type of the object (OB, ME, WO, ...) */
/* The function will return NULL when no object with the given */
/* name is found. */
/*****************************************************************************/
Material *GetMaterialByName( char *name )
{
Material *mat_iter;
mat_iter = G.main->mat.first;
while( mat_iter ) {
if( StringEqual( name, GetIdName( &( mat_iter->id ) ) ) ) {
return ( mat_iter );
}
mat_iter = mat_iter->id.next;
}
/* There is no material with the given name */
return ( NULL );
}
/*****************************************************************************/
/* Python BPy_Material methods: */
/*****************************************************************************/
static PyObject *Material_getIpo( BPy_Material * self )
{
Ipo *ipo = self->material->ipo;
if( !ipo ) {
Py_INCREF( Py_None );
return Py_None;
}
return Ipo_CreatePyObject( ipo );
}
static PyObject *Material_getName( BPy_Material * self )
{
PyObject *attr = PyString_FromString( self->material->id.name + 2 );
if( attr )
return attr;
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.name attribute" ) );
}
static PyObject *Material_getMode( BPy_Material * self )
{
PyObject *attr = PyInt_FromLong( ( long ) self->material->mode );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.Mode attribute" );
}
static PyObject *Material_getRGBCol( BPy_Material * self )
{
return rgbTuple_getCol( self->col );
}
/*
static PyObject *Material_getAmbCol(BPy_Material *self)
{
return rgbTuple_getCol(self->amb);
}
*/
static PyObject *Material_getSpecCol( BPy_Material * self )
{
return rgbTuple_getCol( self->spec );
}
static PyObject *Material_getMirCol( BPy_Material * self )
{
return rgbTuple_getCol( self->mir );
}
static PyObject *Material_getSpecShader( BPy_Material * self )
{
PyObject *attr = PyInt_FromLong( ( long ) self->material->spec_shader );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.specShader attribute" );
}
static PyObject *Material_getDiffuseShader( BPy_Material * self )
{
PyObject *attr = PyInt_FromLong( ( long ) self->material->diff_shader );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.diffuseShader attribute" );
}
static PyObject *Material_getRoughness( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->roughness );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.roughness attribute" );
}
static PyObject *Material_getSpecSize( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->param[2] );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.specSize attribute" );
}
static PyObject *Material_getDiffuseSize( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->param[0] );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.diffuseSize attribute" );
}
static PyObject *Material_getSpecSmooth( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->param[3] );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.specSmooth attribute" );
}
static PyObject *Material_getDiffuseSmooth( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->param[1] );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.diffuseSmooth( attribute" );
}
static PyObject *Material_getDiffuseDarkness( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->darkness );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.diffuseDarkness attribute" );
}
static PyObject *Material_getRefracIndex( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->refrac );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.refracIndex attribute" );
}
static PyObject *Material_getRms( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->rms );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.rms attribute" );
}
static PyObject *Material_getAmb( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->amb );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.amb attribute" );
}
static PyObject *Material_getEmit( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->emit );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.emit attribute" );
}
static PyObject *Material_getAlpha( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->alpha );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.alpha attribute" );
}
static PyObject *Material_getRef( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->ref );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.ref attribute" );
}
static PyObject *Material_getSpec( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->spec );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.spec attribute" );
}
static PyObject *Material_getSpecTransp( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->spectra );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.specTransp attribute" );
}
static PyObject *Material_getAdd( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->add );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.add attribute" );
}
static PyObject *Material_getZOffset( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->zoffs );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.zOffset attribute" );
}
static PyObject *Material_getHaloSize( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->hasize );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.haloSize attribute" );
}
static PyObject *Material_getFlareSize( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->flaresize );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.flareSize attribute" );
}
static PyObject *Material_getFlareBoost( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->flareboost );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.flareBoost attribute" );
}
static PyObject *Material_getSubSize( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->subsize );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.subSize attribute" );
}
static PyObject *Material_getHaloSeed( BPy_Material * self )
{
PyObject *attr = PyInt_FromLong( ( long ) self->material->seed1 );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.haloSeed attribute" );
}
static PyObject *Material_getFlareSeed( BPy_Material * self )
{
PyObject *attr = PyInt_FromLong( ( long ) self->material->seed2 );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.flareSeed attribute" );
}
static PyObject *Material_getHardness( BPy_Material * self )
{
PyObject *attr = PyInt_FromLong( ( long ) self->material->har );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.hard attribute" );
}
static PyObject *Material_getNFlares( BPy_Material * self )
{
PyObject *attr = PyInt_FromLong( ( long ) self->material->flarec );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.nFlares attribute" );
}
static PyObject *Material_getNStars( BPy_Material * self )
{
PyObject *attr = PyInt_FromLong( ( long ) self->material->starc );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.nStars attribute" );
}
static PyObject *Material_getNLines( BPy_Material * self )
{
PyObject *attr = PyInt_FromLong( ( long ) self->material->linec );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.nLines attribute" );
}
static PyObject *Material_getNRings( BPy_Material * self )
{
PyObject *attr = PyInt_FromLong( ( long ) self->material->ringc );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.nRings attribute" );
}
static PyObject *Material_getRayMirr( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->ray_mirror );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.rayMirr attribute" );
}
static PyObject *Material_getMirrDepth( BPy_Material * self )
{
PyObject *attr = PyInt_FromLong( ( long ) self->material->ray_depth );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.rayMirrDepth attribute" );
}
static PyObject *Material_getFresnelMirr( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->fresnel_mir );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.fresnelDepth attribute" );
}
static PyObject *Material_getFresnelMirrFac( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->fresnel_mir_i );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.fresnelDepthFac attribute" );
}
static PyObject *Material_getFilter( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->filter );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.filter attribute" );
}
static PyObject *Material_getTranslucency( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->translucency );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.translucency attribute" );
}
static PyObject *Material_getIOR( BPy_Material * self )
{
PyObject *attr = PyFloat_FromDouble( ( double ) self->material->ang );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.IOR attribute" );
}
static PyObject *Material_getTransDepth( BPy_Material * self )
{
PyObject *attr =
PyInt_FromLong( ( long ) self->material->ray_depth_tra );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.transDepth attribute" );
}
static PyObject *Material_getFresnelTrans( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->fresnel_tra );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.fresnelTrans attribute" );
}
static PyObject *Material_getFresnelTransFac( BPy_Material * self )
{
PyObject *attr =
PyFloat_FromDouble( ( double ) self->material->fresnel_tra_i );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Material.fresnelTransFac attribute" );
}
static PyObject *Material_getTextures( BPy_Material * self )
{
int i;
struct MTex *mtex;
PyObject *t[MAX_MTEX];
PyObject *tuple;
/* build a texture list */
for( i = 0; i < MAX_MTEX; ++i ) {
mtex = self->material->mtex[i];
if( mtex ) {
t[i] = MTex_CreatePyObject( mtex );
} else {
Py_INCREF( Py_None );
t[i] = Py_None;
}
}
/* turn the array into a tuple */
tuple = Py_BuildValue( "NNNNNNNNNN", t[0], t[1], t[2], t[3],
t[4], t[5], t[6], t[7], t[8], t[9] );
if( !tuple )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"Material_getTextures: couldn't create PyTuple" );
return tuple;
}
/*
* this should accept a Py_None argument and just delete the Ipo link
* (as Lamp_clearIpo() does)
*/
static int Material_setIpo( BPy_Material * self, PyObject * value )
{
Ipo *ipo = NULL;
Ipo *oldipo = self->material->ipo;
ID *id;
/* if parameter is not None, check for valid Ipo */
if ( value != Py_None ) {
if ( !Ipo_CheckPyObject( value ) )
return EXPP_ReturnIntError( PyExc_RuntimeError,
"expected an Ipo object" );
ipo = Ipo_FromPyObject( value );
if( !ipo )
return EXPP_ReturnIntError( PyExc_RuntimeError,
"null ipo!" );
if( ipo->blocktype != ID_MA )
return EXPP_ReturnIntError( PyExc_TypeError,
"Ipo is not a material data Ipo" );
}
/* if already linked to Ipo, delete link */
if ( oldipo ) {
id = &oldipo->id;
if( id->us > 0 )
id->us--;
}
/* assign new Ipo and increment user count, or set to NULL if deleting */
self->material->ipo = ipo;
if ( ipo ) {
id = &ipo->id;
id->us++;
}
return 0;
}
/*
* Material_insertIpoKey( key )
* inserts Material IPO key at current frame
*/
static PyObject *Material_insertIpoKey( BPy_Material * self, PyObject * args )
{
int key = 0, map;
if( !PyArg_ParseTuple( args, "i", &( key ) ) )
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected int argument" ) );
map = texchannel_to_adrcode(self->material->texact);
if(key==IPOKEY_RGB || key==IPOKEY_ALLCOLOR) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_R);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_G);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_B);
}
if(key==IPOKEY_ALPHA || key==IPOKEY_ALLCOLOR) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_ALPHA);
}
if(key==IPOKEY_HALOSIZE || key==IPOKEY_ALLCOLOR) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_HASIZE);
}
if(key==IPOKEY_MODE || key==IPOKEY_ALLCOLOR) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_MODE);
}
if(key==IPOKEY_ALLCOLOR) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_R);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_G);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_B);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_REF);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_EMIT);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_AMB);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_HARD);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_MODE);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_TRANSLU);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_ADD);
}
if(key==IPOKEY_ALLMIRROR) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_RAYM);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESMIR);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESMIRI);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESTRA);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESTRAI);
}
if(key==IPOKEY_OFS || key==IPOKEY_ALLMAPPING) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_X);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_Y);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_Z);
}
if(key==IPOKEY_SIZE || key==IPOKEY_ALLMAPPING) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_X);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_Y);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_Z);
}
if(key==IPOKEY_ALLMAPPING) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_R);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_G);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_B);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_DVAR);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_COLF);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_NORF);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_VARF);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_DISP);
}
allspace(REMAKEIPO, 0);
EXPP_allqueue(REDRAWIPO, 0);
EXPP_allqueue(REDRAWVIEW3D, 0);
EXPP_allqueue(REDRAWACTION, 0);
EXPP_allqueue(REDRAWNLA, 0);
return EXPP_incr_ret( Py_None );
}
static int Material_setName( BPy_Material * self, PyObject * value )
{
char *name;
char buf[21];
name = PyString_AsString ( value );
if( !name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
rename_id( &self->material->id, buf );
return 0;
}
static int Material_setMode( BPy_Material * self, PyObject * value )
{
int param;
int bitmask = MA_TRACEBLE
| MA_SHADOW
| MA_SHLESS
| MA_WIRE
| MA_VERTEXCOL
| MA_VERTEXCOLP
| MA_HALO
| MA_ZTRA
| MA_ZINV
| MA_HALO_RINGS
| MA_HALO_LINES
| MA_ONLYSHADOW
| MA_HALO_XALPHA
| MA_STAR
| MA_FACETEXTURE
| MA_HALOTEX
| MA_HALOPUNO
| MA_NOMIST
| MA_HALO_SHADE
| MA_HALO_FLARE
| MA_RADIO
| MA_RAYMIRROR
| MA_ZTRA
| MA_RAYTRANSP
| MA_ONLYSHADOW
| MA_NOMIST
| MA_ENV;
if( !PyInt_CheckExact ( value ) ) {
char errstr[128];
sprintf ( errstr , "expected int bitmask of 0x%08x", bitmask );
return EXPP_ReturnIntError( PyExc_TypeError, errstr );
}
param = PyInt_AS_LONG ( value );
if ( ( param & bitmask ) != param )
return EXPP_ReturnIntError( PyExc_ValueError,
"invalid bit(s) set in mask" );
self->material->mode = param;
return 0;
}
static int Material_setRGBCol( BPy_Material * self, PyObject * value )
{
return rgbTuple_setCol( self->col, value );
}
/*
static PyObject *Material_setAmbCol (BPy_Material *self, PyObject * value )
{
return rgbTuple_setCol(self->amb, value);
}
*/
static int Material_setSpecCol( BPy_Material * self, PyObject * value )
{
return rgbTuple_setCol( self->spec, value );
}
static int Material_setMirCol( BPy_Material * self, PyObject * value )
{
return rgbTuple_setCol( self->mir, value );
}
static int Material_setColorComponent( BPy_Material * self, PyObject * value,
void * closure )
{
float param;
if( !PyNumber_Check ( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected float argument in [0.0,1.0]" );
param = (float)PyFloat_AsDouble( value );
param = EXPP_ClampFloat( param, EXPP_MAT_COL_MIN, EXPP_MAT_COL_MAX );
switch ( (int)closure ) {
case EXPP_MAT_COMP_R:
self->material->r = param;
return 0;
case EXPP_MAT_COMP_G:
self->material->g = param;
return 0;
case EXPP_MAT_COMP_B:
self->material->b = param;
return 0;
case EXPP_MAT_COMP_SPECR:
self->material->specr = param;
return 0;
case EXPP_MAT_COMP_SPECG:
self->material->specg = param;
return 0;
case EXPP_MAT_COMP_SPECB:
self->material->specb = param;
return 0;
case EXPP_MAT_COMP_MIRR:
self->material->mirr = param;
return 0;
case EXPP_MAT_COMP_MIRG:
self->material->mirg = param;
return 0;
case EXPP_MAT_COMP_MIRB:
self->material->mirb = param;
return 0;
}
return EXPP_ReturnIntError( PyExc_RuntimeError,
"unknown color component specified" );
}
static int Material_setAmb( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->amb,
EXPP_MAT_AMB_MIN,
EXPP_MAT_AMB_MAX );
}
static int Material_setEmit( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->emit,
EXPP_MAT_EMIT_MIN,
EXPP_MAT_EMIT_MAX );
}
static int Material_setSpecTransp( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->spectra,
EXPP_MAT_SPECTRA_MIN,
EXPP_MAT_SPECTRA_MAX );
}
static int Material_setAlpha( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->alpha,
EXPP_MAT_ALPHA_MIN,
EXPP_MAT_ALPHA_MAX );
}
static int Material_setRef( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->ref,
EXPP_MAT_REF_MIN,
EXPP_MAT_REF_MAX );
}
static int Material_setSpec( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->spec,
EXPP_MAT_SPEC_MIN,
EXPP_MAT_SPEC_MAX );
}
static int Material_setZOffset( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->zoffs,
EXPP_MAT_ZOFFS_MIN,
EXPP_MAT_ZOFFS_MAX );
}
static int Material_setAdd( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->add,
EXPP_MAT_ADD_MIN,
EXPP_MAT_ADD_MAX );
}
static int Material_setHaloSize( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->hasize,
EXPP_MAT_HALOSIZE_MIN,
EXPP_MAT_HALOSIZE_MAX );
}
static int Material_setFlareSize( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->flaresize,
EXPP_MAT_FLARESIZE_MIN,
EXPP_MAT_FLARESIZE_MAX );
}
static int Material_setFlareBoost( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->flareboost,
EXPP_MAT_FLAREBOOST_MIN,
EXPP_MAT_FLAREBOOST_MAX );
}
static int Material_setSubSize( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->subsize,
EXPP_MAT_SUBSIZE_MIN,
EXPP_MAT_SUBSIZE_MAX );
}
static int Material_setHaloSeed( BPy_Material * self, PyObject * value )
{
return EXPP_setIValueClamped ( value, &self->material->seed1,
EXPP_MAT_HALOSEED_MIN,
EXPP_MAT_HALOSEED_MAX, 'b' );
}
static int Material_setFlareSeed( BPy_Material * self, PyObject * value )
{
return EXPP_setIValueClamped ( value, &self->material->seed2,
EXPP_MAT_FLARESEED_MIN,
EXPP_MAT_FLARESEED_MAX, 'b' );
}
static int Material_setHardness( BPy_Material * self, PyObject * value )
{
return EXPP_setIValueClamped ( value, &self->material->har,
EXPP_MAT_HARD_MIN,
EXPP_MAT_HARD_MAX, 'h' );
}
static int Material_setNFlares( BPy_Material * self, PyObject * value )
{
return EXPP_setIValueClamped ( value, &self->material->flarec,
EXPP_MAT_NFLARES_MIN,
EXPP_MAT_NFLARES_MAX, 'h' );
}
static int Material_setNStars( BPy_Material * self, PyObject * value )
{
return EXPP_setIValueClamped ( value, &self->material->starc,
EXPP_MAT_NSTARS_MIN,
EXPP_MAT_NSTARS_MAX, 'h' );
}
static int Material_setNLines( BPy_Material * self, PyObject * value )
{
return EXPP_setIValueClamped ( value, &self->material->linec,
EXPP_MAT_NLINES_MIN,
EXPP_MAT_NLINES_MAX, 'h' );
}
static int Material_setNRings( BPy_Material * self, PyObject * value )
{
return EXPP_setIValueClamped ( value, &self->material->ringc,
EXPP_MAT_NRINGS_MIN,
EXPP_MAT_NRINGS_MAX, 'h' );
}
static int Material_setRayMirr( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->ray_mirror,
EXPP_MAT_RAYMIRR_MIN,
EXPP_MAT_RAYMIRR_MAX );
}
static int Material_setMirrDepth( BPy_Material * self, PyObject * value )
{
return EXPP_setIValueClamped ( value, &self->material->ray_depth,
EXPP_MAT_MIRRDEPTH_MIN,
EXPP_MAT_MIRRDEPTH_MAX, 'h' );
}
static int Material_setFresnelMirr( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->fresnel_mir,
EXPP_MAT_FRESNELMIRR_MIN,
EXPP_MAT_FRESNELMIRR_MAX );
}
static int Material_setFresnelMirrFac( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->fresnel_mir_i,
EXPP_MAT_FRESNELMIRRFAC_MIN,
EXPP_MAT_FRESNELMIRRFAC_MAX );
}
static int Material_setIOR( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->ang,
EXPP_MAT_IOR_MIN,
EXPP_MAT_IOR_MAX );
}
static int Material_setTransDepth( BPy_Material * self, PyObject * value )
{
return EXPP_setIValueClamped ( value, &self->material->ray_depth_tra,
EXPP_MAT_TRANSDEPTH_MIN,
EXPP_MAT_TRANSDEPTH_MAX, 'h' );
}
static int Material_setFresnelTrans( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->fresnel_tra,
EXPP_MAT_FRESNELTRANS_MIN,
EXPP_MAT_FRESNELTRANS_MAX );
}
static int Material_setFresnelTransFac( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->fresnel_tra_i,
EXPP_MAT_FRESNELTRANSFAC_MIN,
EXPP_MAT_FRESNELTRANSFAC_MAX );
}
static int Material_setSpecShader( BPy_Material * self, PyObject * value )
{
return EXPP_setIValueRange( value, &self->material->spec_shader,
MA_SPEC_COOKTORR,
MA_SPEC_WARDISO, 'h' );
}
static int Material_setDiffuseShader( BPy_Material * self, PyObject * value )
{
return EXPP_setIValueRange( value, &self->material->diff_shader,
MA_DIFF_LAMBERT,
MA_DIFF_MINNAERT, 'h' );
}
static int Material_setRoughness( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->roughness,
EXPP_MAT_ROUGHNESS_MIN,
EXPP_MAT_ROUGHNESS_MAX );
}
static int Material_setSpecSize( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->param[2],
EXPP_MAT_SPECSIZE_MIN,
EXPP_MAT_SPECSIZE_MAX );
}
static int Material_setDiffuseSize( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->param[0],
EXPP_MAT_DIFFUSESIZE_MIN,
EXPP_MAT_DIFFUSESIZE_MAX );
}
static int Material_setSpecSmooth( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->param[3],
EXPP_MAT_SPECSMOOTH_MIN,
EXPP_MAT_SPECSMOOTH_MAX );
}
static int Material_setDiffuseSmooth( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->param[1],
EXPP_MAT_DIFFUSESMOOTH_MIN,
EXPP_MAT_DIFFUSESMOOTH_MAX );
}
static int Material_setDiffuseDarkness( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->darkness,
EXPP_MAT_DIFFUSE_DARKNESS_MIN,
EXPP_MAT_DIFFUSE_DARKNESS_MAX );
}
static int Material_setRefracIndex( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->refrac,
EXPP_MAT_REFRACINDEX_MIN,
EXPP_MAT_REFRACINDEX_MAX );
}
static int Material_setRms( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->rms,
EXPP_MAT_RMS_MIN,
EXPP_MAT_RMS_MAX );
}
static int Material_setFilter( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->filter,
EXPP_MAT_FILTER_MIN,
EXPP_MAT_FILTER_MAX );
}
static int Material_setTranslucency( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->translucency,
EXPP_MAT_TRANSLUCENCY_MIN,
EXPP_MAT_TRANSLUCENCY_MAX );
}
static PyObject *Material_setTexture( BPy_Material * self, PyObject * args )
{
int texnum;
PyObject *pytex;
Tex *bltex;
int texco = TEXCO_ORCO, mapto = MAP_COL;
if( !PyArg_ParseTuple( args, "iO!|ii", &texnum, &Texture_Type, &pytex,
&texco, &mapto ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int in [0,9] and Texture" );
if( ( texnum < 0 ) || ( texnum >= MAX_MTEX ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int in [0,9] and Texture" );
bltex = Texture_FromPyObject( pytex );
if( !self->material->mtex[texnum] ) {
/* there isn't an mtex for this slot so we need to make one */
self->material->mtex[texnum] = add_mtex( );
} else {
/* we already had a texture here so deal with the old one first */
self->material->mtex[texnum]->tex->id.us--;
}
self->material->mtex[texnum]->tex = bltex;
id_us_plus( &bltex->id );
self->material->mtex[texnum]->texco = (short)texco;
self->material->mtex[texnum]->mapto = (short)mapto;
Py_INCREF( Py_None );
return Py_None;
}
static PyObject *Material_clearTexture( BPy_Material * self, PyObject * args )
{
int texnum;
struct MTex *mtex;
if( !PyArg_ParseTuple( args, "i", &texnum ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int in [0,9]" );
if( ( texnum < 0 ) || ( texnum >= MAX_MTEX ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int in [0,9]" );
mtex = self->material->mtex[texnum];
if( mtex ) {
if( mtex->tex )
mtex->tex->id.us--;
MEM_freeN( mtex );
self->material->mtex[texnum] = NULL;
}
Py_INCREF( Py_None );
return Py_None;
}
/* mat.addScriptLink */
static PyObject *Material_addScriptLink( BPy_Material * self, PyObject * args )
{
Material *mat = self->material;
ScriptLink *slink = NULL;
slink = &( mat )->scriptlink;
return EXPP_addScriptLink( slink, args, 0 );
}
/* mat.clearScriptLinks */
static PyObject *Material_clearScriptLinks(BPy_Material *self, PyObject *args )
{
Material *mat = self->material;
ScriptLink *slink = NULL;
slink = &( mat )->scriptlink;
return EXPP_clearScriptLinks( slink, args );
}
/* mat.getScriptLinks */
static PyObject *Material_getScriptLinks( BPy_Material * self,
PyObject * args )
{
Material *mat = self->material;
ScriptLink *slink = NULL;
PyObject *ret = NULL;
slink = &( mat )->scriptlink;
/* can't this just return? EXP_getScriptLinks() returns a PyObject*
* or NULL anyway */
ret = EXPP_getScriptLinks( slink, args, 0 );
if( ret )
return ret;
else
return NULL;
}
/*****************************************************************************/
/* Function: Material_repr */
/* Description: This is a callback function for the BPy_Material type. It */
/* builds a meaninful string to represent material objects. */
/*****************************************************************************/
static PyObject *Material_repr( BPy_Material * self )
{
return PyString_FromFormat( "[Material \"%s\"]",
self->material->id.name + 2 );
}
/*****************************************************************************/
/* These functions are used in NMesh.c and Object.c */
/*****************************************************************************/
PyObject *EXPP_PyList_fromMaterialList( Material ** matlist, int len, int all )
{
PyObject *list;
int i;
list = PyList_New( 0 );
if( !matlist )
return list;
for( i = 0; i < len; i++ ) {
Material *mat = matlist[i];
PyObject *ob;
if( mat ) {
ob = Material_CreatePyObject( mat );
PyList_Append( list, ob );
Py_DECREF( ob ); /* because Append increfs */
} else if( all ) { /* return NULL mats (empty slots) as Py_None */
PyList_Append( list, Py_None );
}
}
return list;
}
Material **EXPP_newMaterialList_fromPyList( PyObject * list )
{
int i, len;
BPy_Material *pymat = 0;
Material *mat;
Material **matlist;
len = PySequence_Length( list );
if( len > 16 )
len = 16;
else if( len <= 0 )
return NULL;
matlist = EXPP_newMaterialList( len );
for( i = 0; i < len; i++ ) {
pymat = ( BPy_Material * ) PySequence_GetItem( list, i );
if( Material_CheckPyObject( ( PyObject * ) pymat ) ) {
mat = pymat->material;
matlist[i] = mat;
} else if( ( PyObject * ) pymat == Py_None ) {
matlist[i] = NULL;
} else { /* error; illegal type in material list */
Py_DECREF( pymat );
MEM_freeN( matlist );
return NULL;
}
Py_DECREF( pymat );
}
return matlist;
}
Material **EXPP_newMaterialList( int len )
{
Material **matlist =
( Material ** ) MEM_mallocN( len * sizeof( Material * ),
"MaterialList" );
return matlist;
}
int EXPP_releaseMaterialList( Material ** matlist, int len )
{
int i;
Material *mat;
if( ( len < 0 ) || ( len > MAXMAT ) ) {
printf( "illegal matindex!\n" );
return 0;
}
for( i = 0; i < len; i++ ) {
mat = matlist[i];
if( mat ) {
if( ( ( ID * ) mat )->us > 0 )
( ( ID * ) mat )->us--;
else
printf( "FATAL: material usage=0: %s",
( ( ID * ) mat )->name );
}
}
MEM_freeN( matlist );
return 1;
}
/** expands pointer array of length 'oldsize' to length 'newsize'.
* A pointer to the (void *) array must be passed as first argument
* The array pointer content can be NULL, in this case a new array of length
* 'newsize' is created.
*/
static int expandPtrArray( void **p, int oldsize, int newsize )
{
void *newarray;
if( newsize < oldsize ) {
return 0;
}
newarray = MEM_callocN( sizeof( void * ) * newsize, "PtrArray" );
if( *p ) {
memcpy( newarray, *p, sizeof( void * ) * oldsize );
MEM_freeN( *p );
}
*p = newarray;
return 1;
}
int EXPP_synchronizeMaterialLists( Object * object )
{
Material ***p_dataMaterials = give_matarar( object );
short *nmaterials = give_totcolp( object );
int result = 0;
if( object->totcol > *nmaterials ) {
/* More object mats than data mats */
result = expandPtrArray( ( void * ) p_dataMaterials,
*nmaterials, object->totcol );
*nmaterials = object->totcol;
} else {
if( object->totcol < *nmaterials ) {
/* More data mats than object mats */
result = expandPtrArray( ( void * ) &object->mat,
object->totcol, *nmaterials );
object->totcol = (char)*nmaterials;
}
} /* else no synchronization needed, they are of equal length */
return result; /* 1 if changed, 0 otherwise */
}
void EXPP_incr_mats_us( Material ** matlist, int len )
{
int i;
Material *mat;
if( len <= 0 )
return;
for( i = 0; i < len; i++ ) {
mat = matlist[i];
if( mat )
mat->id.us++;
}
return;
}
static PyObject *Material_getColorComponent( BPy_Material * self,
void * closure )
{
PyObject *attr = NULL;
switch ( (int)closure ) {
case EXPP_MAT_COMP_R:
attr = PyFloat_FromDouble( ( double ) self->material->r );
break;
case EXPP_MAT_COMP_G:
attr = PyFloat_FromDouble( ( double ) self->material->g );
break;
case EXPP_MAT_COMP_B:
attr = PyFloat_FromDouble( ( double ) self->material->b );
break;
case EXPP_MAT_COMP_SPECR:
attr = PyFloat_FromDouble( ( double ) self->material->specr );
break;
case EXPP_MAT_COMP_SPECG:
attr = PyFloat_FromDouble( ( double ) self->material->specg );
break;
case EXPP_MAT_COMP_SPECB:
attr = PyFloat_FromDouble( ( double ) self->material->specb );
break;
case EXPP_MAT_COMP_MIRR:
attr = PyFloat_FromDouble( ( double ) self->material->mirr );
break;
case EXPP_MAT_COMP_MIRG:
attr = PyFloat_FromDouble( ( double ) self->material->mirg );
break;
case EXPP_MAT_COMP_MIRB:
attr = PyFloat_FromDouble( ( double ) self->material->mirb );
break;
default:
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"unknown color component specified" );
}
if( !attr )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"PyFloat_FromDouble() failed" );
return attr;
}
static PyObject *Material_getOopsLoc ( BPy_Material * self )
{
if( G.soops ) {
Oops *oops = G.soops->oops.first;
while( oops ) {
if( oops->type == ID_MA && (Material *)oops->id == self->material )
return Py_BuildValue( "ff", oops->x, oops->y );
oops = oops->next;
}
}
Py_INCREF( Py_None );
return Py_None;
}
static PyObject *Material_getOopsSel ( BPy_Material * self )
{
if( G.soops ) {
Oops *oops= G.soops->oops.first;
while( oops ) {
if( oops->type == ID_MA
&& (Material *)oops->id == self->material ) {
if( oops->flag & SELECT )
return EXPP_incr_ret_True();
else
return EXPP_incr_ret_False();
}
oops = oops->next;
}
}
Py_INCREF( Py_None );
return Py_None;
}
static int Material_setOopsLoc ( BPy_Material * self, PyObject * value )
{
if( G.soops ) {
Oops *oops= G.soops->oops.first;
while( oops ) {
if( oops->type == ID_MA ) {
if ( (Material *)oops->id == self->material ) {
if ( PyArg_ParseTuple( value, "ff", &(oops->x),&(oops->y)))
return 0;
else
return EXPP_ReturnIntError( PyExc_AttributeError,
"expected two floats as arguments" );
}
}
oops = oops->next;
}
return EXPP_ReturnIntError( PyExc_RuntimeError,
"couldn't find oopsLoc data for material" );
}
return 0;
}
static int Material_setOopsSel ( BPy_Material * self, PyObject * value )
{
int param;
if( !PyInt_CheckExact ( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected an integer, 0 or 1" );
param = PyInt_AS_LONG ( value );
if( param < 0 || param > 1 )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected an integer, 0 or 1" );
if( G.soops ) {
Oops *oops = G.soops->oops.first;
while( oops ) {
if( oops->type==ID_MA ) {
if( (Material *)oops->id == self->material ) {
if( !param )
oops->flag &= ~SELECT;
else
oops->flag |= SELECT;
return 0;
}
}
oops= oops->next;
}
}
return 0;
}
static PyObject *Material_getUsers( BPy_Material * self )
{
return PyInt_FromLong( self->material->id.us );
}
/* #####DEPRECATED###### */
static PyObject *Matr_oldsetAdd( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setAdd );
}
static PyObject *Matr_oldsetAlpha( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setAlpha );
}
static PyObject *Matr_oldsetAmb( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setAmb );
}
static PyObject *Matr_oldsetDiffuseDarkness( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setDiffuseDarkness );
}
static PyObject *Matr_oldsetDiffuseShader( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setDiffuseShader );
}
static PyObject *Matr_oldsetDiffuseSize( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setDiffuseSize );
}
static PyObject *Matr_oldsetDiffuseSmooth( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setDiffuseSmooth );
}
static PyObject *Matr_oldsetEmit( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setEmit );
}
static PyObject *Matr_oldsetFilter( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFilter );
}
static PyObject *Matr_oldsetFlareBoost( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFlareBoost );
}
static PyObject *Matr_oldsetFlareSeed( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFlareSeed );
}
static PyObject *Matr_oldsetFlareSize( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFlareSize );
}
static PyObject *Matr_oldsetFresnelMirr( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFresnelMirr );
}
static PyObject *Matr_oldsetFresnelMirrFac( BPy_Material * self,
PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFresnelMirrFac );
}
static PyObject *Matr_oldsetFresnelTrans( BPy_Material * self,
PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFresnelTrans );
}
static PyObject *Matr_oldsetFresnelTransFac( BPy_Material * self,
PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setFresnelTransFac );
}
static PyObject *Matr_oldsetHaloSeed( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setHaloSeed );
}
static PyObject *Matr_oldsetHaloSize( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setHaloSize );
}
static PyObject *Matr_oldsetHardness( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setHardness );
}
static PyObject *Matr_oldsetIOR( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setIOR );
}
static PyObject *Matr_oldsetName( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setName );
}
static PyObject *Matr_oldsetNFlares( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setNFlares );
}
static PyObject *Matr_oldsetNLines( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setNLines );
}
static PyObject *Matr_oldsetNRings( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setNRings );
}
static PyObject *Matr_oldsetNStars( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setNStars );
}
static PyObject *Matr_oldsetRayMirr( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setRayMirr );
}
static PyObject *Matr_oldsetRoughness( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setRoughness );
}
static PyObject *Matr_oldsetMirrDepth( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setMirrDepth );
}
static PyObject *Matr_oldsetRef( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setRef );
}
static PyObject *Matr_oldsetRefracIndex( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setRefracIndex );
}
static PyObject *Matr_oldsetRms( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setRms );
}
static PyObject *Matr_oldsetSpec( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setSpec );
}
static PyObject *Matr_oldsetSpecShader( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setSpecShader );
}
static PyObject *Matr_oldsetSpecSize( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setSpecSize );
}
static PyObject *Matr_oldsetSpecSmooth( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setSpecSmooth );
}
static PyObject *Matr_oldsetSpecTransp( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setSpecTransp );
}
static PyObject *Matr_oldsetSubSize( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setSubSize );
}
static PyObject *Matr_oldsetTranslucency( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setTranslucency );
}
static PyObject *Matr_oldsetTransDepth( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setTransDepth );
}
static PyObject *Matr_oldsetZOffset( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setZOffset );
}
static PyObject *Matr_oldsetRGBCol( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setRGBCol );
}
static PyObject *Matr_oldsetSpecCol( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setSpecCol );
}
static PyObject *Matr_oldsetMirCol( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setMirCol );
}
/* Possible modes are traceable, shadow, shadeless, wire, vcolLight,
* vcolPaint, halo, ztransp, zinvert, haloRings, env, haloLines,
* onlyShadow, xalpha, star, faceTexture, haloTex, haloPuno, noMist,
* haloShaded, haloFlare */
static PyObject *Matr_oldsetMode( BPy_Material * self, PyObject * args )
{
unsigned int i, flag = 0, ok = 0;
PyObject *value, *error;
char *m[28] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL
};
static int bitmask = MA_TRACEBLE
| MA_SHADOW
| MA_SHLESS
| MA_WIRE
| MA_VERTEXCOL
| MA_VERTEXCOLP
| MA_HALO
| MA_ZTRA
| MA_ZINV
| MA_HALO_RINGS
| MA_HALO_LINES
| MA_ONLYSHADOW
| MA_HALO_XALPHA
| MA_STAR
| MA_FACETEXTURE
| MA_HALOTEX
| MA_HALOPUNO
| MA_NOMIST
| MA_HALO_SHADE
| MA_HALO_FLARE
| MA_RADIO
| MA_RAYMIRROR
| MA_ZTRA
| MA_RAYTRANSP
| MA_ONLYSHADOW
| MA_NOMIST
| MA_ENV;
/*
* check for a single integer argument; do a quick check for now
* that the value is not larger than double the highest flag bit
*/
if ( (PySequence_Size( args ) == 1)
&& PyInt_Check ( PyTuple_GET_ITEM ( args , 0 ) )
&& PyArg_ParseTuple( args, "i", &flag )
&& (flag & bitmask) == flag ) {
ok = 1;
/*
* check for either an empty argument list, or up to 28 strings
*/
} else if( PyArg_ParseTuple( args, "|ssssssssssssssssssssssssssss",
&m[0], &m[1], &m[2], &m[3], &m[4], &m[5], &m[6],
&m[7], &m[8], &m[9], &m[10], &m[11], &m[12],
&m[13], &m[14], &m[15], &m[16], &m[17], &m[18],
&m[19], &m[20], &m[21], &m[22], &m[23], &m[24],
&m[25], &m[26], &m[27] ) ) {
for( i = 0; i < 28; i++ ) {
if( m[i] == NULL )
break;
if( strcmp( m[i], "Traceable" ) == 0 )
flag |= MA_TRACEBLE;
else if( strcmp( m[i], "Shadow" ) == 0 )
flag |= MA_SHADOW;
else if( strcmp( m[i], "Shadeless" ) == 0 )
flag |= MA_SHLESS;
else if( strcmp( m[i], "Wire" ) == 0 )
flag |= MA_WIRE;
else if( strcmp( m[i], "VColLight" ) == 0 )
flag |= MA_VERTEXCOL;
else if( strcmp( m[i], "VColPaint" ) == 0 )
flag |= MA_VERTEXCOLP;
else if( strcmp( m[i], "Halo" ) == 0 )
flag |= MA_HALO;
else if( strcmp( m[i], "ZTransp" ) == 0 )
flag |= MA_ZTRA;
else if( strcmp( m[i], "ZInvert" ) == 0 )
flag |= MA_ZINV;
else if( strcmp( m[i], "HaloRings" ) == 0 )
flag |= MA_HALO_RINGS;
else if( strcmp( m[i], "HaloLines" ) == 0 )
flag |= MA_HALO_LINES;
else if( strcmp( m[i], "OnlyShadow" ) == 0 )
flag |= MA_ONLYSHADOW;
else if( strcmp( m[i], "HaloXAlpha" ) == 0 )
flag |= MA_HALO_XALPHA;
else if( strcmp( m[i], "HaloStar" ) == 0 )
flag |= MA_STAR;
else if( strcmp( m[i], "TexFace" ) == 0 )
flag |= MA_FACETEXTURE;
else if( strcmp( m[i], "HaloTex" ) == 0 )
flag |= MA_HALOTEX;
else if( strcmp( m[i], "HaloPuno" ) == 0 )
flag |= MA_HALOPUNO;
else if( strcmp( m[i], "NoMist" ) == 0 )
flag |= MA_NOMIST;
else if( strcmp( m[i], "HaloShaded" ) == 0 )
flag |= MA_HALO_SHADE;
else if( strcmp( m[i], "HaloFlare" ) == 0 )
flag |= MA_HALO_FLARE;
else if( strcmp( m[i], "Radio" ) == 0 )
flag |= MA_RADIO;
/* ** Mirror ** */
else if( strcmp( m[i], "RayMirr" ) == 0 )
flag |= MA_RAYMIRROR;
else if( strcmp( m[i], "ZTransp" ) == 0 )
flag |= MA_ZTRA;
else if( strcmp( m[i], "RayTransp" ) == 0 )
flag |= MA_RAYTRANSP;
else if( strcmp( m[i], "OnlyShadow" ) == 0 )
flag |= MA_ONLYSHADOW;
else if( strcmp( m[i], "NoMist" ) == 0 )
flag |= MA_NOMIST;
else if( strcmp( m[i], "Env" ) == 0 )
flag |= MA_ENV;
else
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"unknown Material mode argument" ) );
}
ok = 1;
}
/* if neither input method worked, then throw an exception */
if ( ok == 0 )
return ( EXPP_ReturnPyObjError
( PyExc_AttributeError,
"expected nothing, an integer or up to 22 string argument(s)" ) );
/* build tuple, call wrapper */
value = Py_BuildValue( "(i)", flag );
error = EXPP_setterWrapper( (void *)self, value, (setter)Material_setMode );
Py_DECREF ( value );
return error;
}
static PyObject *Matr_oldsetIpo( BPy_Material * self, PyObject * args )
{
return EXPP_setterWrapper( (void *)self, args, (setter)Material_setIpo );
}
/*
* clearIpo() returns True/False depending on whether material has an Ipo
*/
static PyObject *Material_clearIpo( BPy_Material * self )
{
/* if Ipo defined, delete it and return true */
if( self->material->ipo ) {
PyObject *value = Py_BuildValue( "(O)", Py_None );
EXPP_setterWrapper( (void *)self, value, (setter)Material_setIpo );
Py_DECREF ( value );
return EXPP_incr_ret_True();
}
return EXPP_incr_ret_False(); /* no ipo found */
}
|