-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathutils.py
More file actions
1083 lines (933 loc) · 31.2 KB
/
utils.py
File metadata and controls
1083 lines (933 loc) · 31.2 KB
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
'''
V-Ray/Blender 2.5
http://vray.cgdo.ru
Time-stamp: "Thursday, 11 August 2011 [03:20]"
Author: Andrey M. Izrantsev (aka bdancer)
E-Mail: izrantsev@cgdo.ru
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.
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, see <http://www.gnu.org/licenses/>.
All Rights Reserved. V-Ray(R) is a registered trademark of Chaos Software.
'''
''' Python modules '''
import filecmp
import math
import os
import platform
import random
import shutil
import string
import struct
import socket
import subprocess
import sys
import time
import tempfile
import getpass
''' Blender modules '''
import bpy
import mathutils
''' vb modules '''
from vb25.plugins import *
PLATFORM= sys.platform
HOSTNAME= socket.gethostname()
PURE_PROCEDURAL= (
'TexDirt',
'TexEdges',
'TexFalloff',
)
COLOR_TABLE= {
'22500': (0.3764,0.5432,1.0000),
'34800': (0.3361,0.5095,1.0000),
'8300': (0.7319,0.7938,1.0000),
'10100': (0.5978,0.7069,1.0000),
'7300': (0.8591,0.8704,1.0000),
'15200': (0.4460,0.5982,1.0000),
'21400': (0.3830,0.5486,1.0000),
'28100': (0.3527,0.5235,1.0000),
'8800': (0.6856,0.7645,1.0000),
'39100': (0.3290,0.5033,1.0000),
'8900': (0.6773,0.7593,1.0000),
'19400': (0.3975,0.5603,1.0000),
'32300': (0.3413,0.5139,1.0000),
'12700': (0.4982,0.6371,1.0000),
'10200': (0.5925,0.7033,1.0000),
'24300': (0.3673,0.5357,1.0000),
'22000': (0.3793,0.5456,1.0000),
'1700': (1.0000,0.1912,0.0000),
'13600': (0.4762,0.6209,1.0000),
'5300': (1.0000,0.8167,0.6937),
'27400': (0.3550,0.5255,1.0000),
'19300': (0.3984,0.5610,1.0000),
'10800': (0.5637,0.6836,1.0000),
'30100': (0.3468,0.5186,1.0000),
'21100': (0.3850,0.5502,1.0000),
'8600': (0.7030,0.7757,1.0000),
'39400': (0.3286,0.5030,1.0000),
'36200': (0.3336,0.5073,1.0000),
'16700': (0.4249,0.5819,1.0000),
'15100': (0.4477,0.5994,1.0000),
'28400': (0.3517,0.5227,1.0000),
'30600': (0.3455,0.5174,1.0000),
'24900': (0.3646,0.5335,1.0000),
'27300': (0.3553,0.5257,1.0000),
'1400': (1.0000,0.1303,0.0000),
'5000': (1.0000,0.7792,0.6180),
'13900': (0.4698,0.6161,1.0000),
'34500': (0.3367,0.5100,1.0000),
'10700': (0.5681,0.6866,1.0000),
'31000': (0.3444,0.5166,1.0000),
'27900': (0.3533,0.5241,1.0000),
'15400': (0.4429,0.5958,1.0000),
'18100': (0.4093,0.5697,1.0000),
'16400': (0.4287,0.5848,1.0000),
'7900': (0.7762,0.8211,1.0000),
'21200': (0.3843,0.5496,1.0000),
'35900': (0.3341,0.5077,1.0000),
'11000': (0.5551,0.6776,1.0000),
'7700': (0.8014,0.8363,1.0000),
'6500': (1.0000,0.9445,0.9853),
'36100': (0.3338,0.5074,1.0000),
'31300': (0.3437,0.5159,1.0000),
'3800': (1.0000,0.6028,0.3207),
'4100': (1.0000,0.6511,0.3927),
'1900': (1.0000,0.2272,0.0000),
'38500': (0.3299,0.5041,1.0000),
'13200': (0.4854,0.6277,1.0000),
'5700': (1.0000,0.8630,0.7933),
'27000': (0.3564,0.5266,1.0000),
'37000': (0.3322,0.5061,1.0000),
'22300': (0.3776,0.5441,1.0000),
'6200': (1.0000,0.9156,0.9147),
'25900': (0.3605,0.5300,1.0000),
'32400': (0.3411,0.5137,1.0000),
'16100': (0.4327,0.5879,1.0000),
'33600': (0.3385,0.5115,1.0000),
'6800': (0.9488,0.9219,1.0000),
'25300': (0.3629,0.5321,1.0000),
'20000': (0.3928,0.5565,1.0000),
'7000': (0.9102,0.9000,1.0000),
'37700': (0.3311,0.5052,1.0000),
'3200': (1.0000,0.4970,0.1879),
'23800': (0.3696,0.5376,1.0000),
'32900': (0.3400,0.5128,1.0000),
'25400': (0.3625,0.5317,1.0000),
'18700': (0.4036,0.5652,1.0000),
'33500': (0.3387,0.5117,1.0000),
'35400': (0.3350,0.5085,1.0000),
'13500': (0.4785,0.6226,1.0000),
'26800': (0.3571,0.5272,1.0000),
'29400': (0.3487,0.5202,1.0000),
'11400': (0.5394,0.6666,1.0000),
'6100': (1.0000,0.9055,0.8907),
'34200': (0.3373,0.5105,1.0000),
'17500': (0.4156,0.5746,1.0000),
'20700': (0.3877,0.5524,1.0000),
'23500': (0.3711,0.5389,1.0000),
'19800': (0.3943,0.5577,1.0000),
'4500': (1.0000,0.7111,0.4919),
'3700': (1.0000,0.5860,0.2974),
'30800': (0.3450,0.5170,1.0000),
'38100': (0.3305,0.5046,1.0000),
'14400': (0.4599,0.6087,1.0000),
'21800': (0.3805,0.5466,1.0000),
'29100': (0.3496,0.5209,1.0000),
'31600': (0.3430,0.5153,1.0000),
'26100': (0.3597,0.5294,1.0000),
'23200': (0.3726,0.5401,1.0000),
'1300': (1.0000,0.1085,0.0000),
'9200': (0.6543,0.7444,1.0000),
'35700': (0.3345,0.5080,1.0000),
'11300': (0.5432,0.6693,1.0000),
'17000': (0.4212,0.5791,1.0000),
'12400': (0.5066,0.6432,1.0000),
'2400': (1.0000,0.3364,0.0501),
'36800': (0.3326,0.5064,1.0000),
'14100': (0.4657,0.6131,1.0000),
'35200': (0.3354,0.5088,1.0000),
'20900': (0.3863,0.5513,1.0000),
'26400': (0.3586,0.5284,1.0000),
'29200': (0.3493,0.5207,1.0000),
'9700': (0.6208,0.7224,1.0000),
'18800': (0.4027,0.5644,1.0000),
'9900': (0.6089,0.7144,1.0000),
'39700': (0.3281,0.5026,1.0000),
'11900': (0.5220,0.6542,1.0000),
'12300': (0.5095,0.6453,1.0000),
'33000': (0.3398,0.5126,1.0000),
'24700': (0.3655,0.5342,1.0000),
'36500': (0.3331,0.5068,1.0000),
'2900': (1.0000,0.4394,0.1297),
'19200': (0.3992,0.5616,1.0000),
'37900': (0.3308,0.5049,1.0000),
'12900': (0.4929,0.6332,1.0000),
'39800': (0.3280,0.5025,1.0000),
'17900': (0.4113,0.5713,1.0000),
'14200': (0.4638,0.6116,1.0000),
'22400': (0.3770,0.5437,1.0000),
'3300': (1.0000,0.5155,0.2087),
'21500': (0.3824,0.5481,1.0000),
'2300': (1.0000,0.3149,0.0373),
'34900': (0.3359,0.5093,1.0000),
'31900': (0.3423,0.5147,1.0000),
'19700': (0.3951,0.5584,1.0000),
'39000': (0.3291,0.5035,1.0000),
'36600': (0.3329,0.5067,1.0000),
'30700': (0.3452,0.5172,1.0000),
'24800': (0.3650,0.5338,1.0000),
'8200': (0.7423,0.8002,1.0000),
'24200': (0.3677,0.5361,1.0000),
'22700': (0.3753,0.5423,1.0000),
'32000': (0.3420,0.5145,1.0000),
'27500': (0.3546,0.5252,1.0000),
'5400': (1.0000,0.8286,0.7187),
'12000': (0.5187,0.6519,1.0000),
'28000': (0.3530,0.5238,1.0000),
'17300': (0.4178,0.5763,1.0000),
'30200': (0.3465,0.5183,1.0000),
'10900': (0.5593,0.6806,1.0000),
'1000': (1.0000,0.0401,0.0000),
'8500': (0.7123,0.7815,1.0000),
'10300': (0.5873,0.6998,1.0000),
'15000': (0.4493,0.6007,1.0000),
'21600': (0.3817,0.5476,1.0000),
'28700': (0.3508,0.5219,1.0000),
'16800': (0.4236,0.5809,1.0000),
'36300': (0.3334,0.5071,1.0000),
'39300': (0.3287,0.5031,1.0000),
'1500': (1.0000,0.1515,0.0000),
'9400': (0.6402,0.7352,1.0000),
'10400': (0.5823,0.6964,1.0000),
'22200': (0.3781,0.5446,1.0000),
'22800': (0.3748,0.5419,1.0000),
'21300': (0.3836,0.5491,1.0000),
'5100': (1.0000,0.7919,0.6433),
'34600': (0.3365,0.5098,1.0000),
'13800': (0.4719,0.6177,1.0000),
'19100': (0.4001,0.5623,1.0000),
'35800': (0.3343,0.5079,1.0000),
'7400': (0.8437,0.8614,1.0000),
'3900': (1.0000,0.6193,0.3444),
'15700': (0.4384,0.5923,1.0000),
'32600': (0.3407,0.5133,1.0000),
'16500': (0.4274,0.5838,1.0000),
'23300': (0.3721,0.5397,1.0000),
'30400': (0.3460,0.5179,1.0000),
'37300': (0.3317,0.5057,1.0000),
'27100': (0.3560,0.5263,1.0000),
'4000': (1.0000,0.6354,0.3684),
'14800': (0.4527,0.6033,1.0000),
'32500': (0.3409,0.5135,1.0000),
'5800': (1.0000,0.8740,0.8179),
'13100': (0.4879,0.6295,1.0000),
'16200': (0.4313,0.5869,1.0000),
'25000': (0.3642,0.5331,1.0000),
'18300': (0.4074,0.5681,1.0000),
'7100': (0.8923,0.8897,1.0000),
'33900': (0.3379,0.5110,1.0000),
'23900': (0.3692,0.5372,1.0000),
'20300': (0.3905,0.5547,1.0000),
'29800': (0.3476,0.5192,1.0000),
'37600': (0.3313,0.5053,1.0000),
'4300': (1.0000,0.6817,0.4419),
'15900': (0.4355,0.5901,1.0000),
'21900': (0.3799,0.5461,1.0000),
'34000': (0.3377,0.5108,1.0000),
'13400': (0.4807,0.6243,1.0000),
'27600': (0.3543,0.5249,1.0000),
'25500': (0.3621,0.5314,1.0000),
'5500': (1.0000,0.8403,0.7437),
'6000': (1.0000,0.8952,0.8666),
'4900': (1.0000,0.7661,0.5928),
'26700': (0.3575,0.5275,1.0000),
'34300': (0.3371,0.5103,1.0000),
'11700': (0.5287,0.6590,1.0000),
'29500': (0.3485,0.5200,1.0000),
'31200': (0.3439,0.5161,1.0000),
'20600': (0.3884,0.5529,1.0000),
'23600': (0.3706,0.5384,1.0000),
'2700': (1.0000,0.3992,0.0950),
'28900': (0.3502,0.5214,1.0000),
'3400': (1.0000,0.5336,0.2301),
'37500': (0.3314,0.5054,1.0000),
'38800': (0.3294,0.5037,1.0000),
'30900': (0.3447,0.5168,1.0000),
'17400': (0.4167,0.5755,1.0000),
'14500': (0.4581,0.6073,1.0000),
'4400': (1.0000,0.6966,0.4668),
'31500': (0.3432,0.5155,1.0000),
'26000': (0.3601,0.5297,1.0000),
'29600': (0.3482,0.5197,1.0000),
'38200': (0.3303,0.5045,1.0000),
'35600': (0.3346,0.5082,1.0000),
'11800': (0.5253,0.6566,1.0000),
'11200': (0.5470,0.6720,1.0000),
'17700': (0.4134,0.5729,1.0000),
'6700': (0.9696,0.9336,1.0000),
'20500': (0.3891,0.5535,1.0000),
'9300': (0.6471,0.7397,1.0000),
'12500': (0.5037,0.6411,1.0000),
'24100': (0.3682,0.5365,1.0000),
'36900': (0.3324,0.5063,1.0000),
'18400': (0.4064,0.5674,1.0000),
'33400': (0.3389,0.5119,1.0000),
'19600': (0.3959,0.5590,1.0000),
'38700': (0.3296,0.5038,1.0000),
'9000': (0.6693,0.7541,1.0000),
'14600': (0.4563,0.6060,1.0000),
'39600': (0.3283,0.5027,1.0000),
'29300': (0.3490,0.5204,1.0000),
'26300': (0.3589,0.5288,1.0000),
'33300': (0.3391,0.5120,1.0000),
'25600': (0.3617,0.5310,1.0000),
'24600': (0.3659,0.5346,1.0000),
'18900': (0.4018,0.5637,1.0000),
'19500': (0.3967,0.5596,1.0000),
'37800': (0.3309,0.5050,1.0000),
'17200': (0.4189,0.5772,1.0000),
'30300': (0.3463,0.5181,1.0000),
'22900': (0.3742,0.5414,1.0000),
'14300': (0.4618,0.6102,1.0000),
'3000': (1.0000,0.4589,0.1483),
'2800': (1.0000,0.4195,0.1119),
'2200': (1.0000,0.2930,0.0257),
'31800': (0.3425,0.5149,1.0000),
'39900': (0.3279,0.5024,1.0000),
'8100': (0.7531,0.8069,1.0000),
'30000': (0.3471,0.5188,1.0000),
'9500': (0.6335,0.7308,1.0000),
'32100': (0.3418,0.5143,1.0000),
'28300': (0.3520,0.5230,1.0000),
'12100': (0.5156,0.6497,1.0000),
'24500': (0.3664,0.5349,1.0000),
'36700': (0.3327,0.5066,1.0000),
'23000': (0.3737,0.5410,1.0000),
'1100': (1.0000,0.0631,0.0000),
'35100': (0.3356,0.5090,1.0000),
'2100': (1.0000,0.2709,0.0153),
'20800': (0.3870,0.5518,1.0000),
'10000': (0.6033,0.7106,1.0000),
'22600': (0.3759,0.5428,1.0000),
'21700': (0.3811,0.5471,1.0000),
'8400': (0.7219,0.7875,1.0000),
'36000': (0.3339,0.5076,1.0000),
'16900': (0.4224,0.5800,1.0000),
'39200': (0.3288,0.5032,1.0000),
'7200': (0.8753,0.8799,1.0000),
'15300': (0.4445,0.5970,1.0000),
'28600': (0.3511,0.5222,1.0000),
'22100': (0.3787,0.5451,1.0000),
'14900': (0.4510,0.6020,1.0000),
'32200': (0.3416,0.5141,1.0000),
'5200': (1.0000,0.8044,0.6685),
'34700': (0.3363,0.5096,1.0000),
'12600': (0.5009,0.6391,1.0000),
'10500': (0.5774,0.6930,1.0000),
'1600': (1.0000,0.1718,0.0000),
'13700': (0.4740,0.6193,1.0000),
'7500': (0.8289,0.8527,1.0000),
'19000': (0.4009,0.5630,1.0000),
'15600': (0.4398,0.5935,1.0000),
'32700': (0.3404,0.5132,1.0000),
'16600': (0.4261,0.5829,1.0000),
'21000': (0.3856,0.5507,1.0000),
'38600': (0.3297,0.5040,1.0000),
'28500': (0.3514,0.5225,1.0000),
'27800': (0.3536,0.5243,1.0000),
'39500': (0.3284,0.5028,1.0000),
'4700': (1.0000,0.7392,0.5422),
'40000': (0.3277,0.5022,1.0000),
'5900': (1.0000,0.8847,0.8424),
'13000': (0.4904,0.6314,1.0000),
'30500': (0.3457,0.5177,1.0000),
'27200': (0.3557,0.5260,1.0000),
'37200': (0.3319,0.5058,1.0000),
'7800': (0.7885,0.8285,1.0000),
'34400': (0.3369,0.5101,1.0000),
'33800': (0.3381,0.5112,1.0000),
'16300': (0.4300,0.5859,1.0000),
'15500': (0.4413,0.5946,1.0000),
'18000': (0.4103,0.5705,1.0000),
'25100': (0.3637,0.5328,1.0000),
'20200': (0.3913,0.5553,1.0000),
'17800': (0.4124,0.5721,1.0000),
'11100': (0.5510,0.6748,1.0000),
'7600': (0.8149,0.8443,1.0000),
'29900': (0.3473,0.5190,1.0000),
'8700': (0.6941,0.7700,1.0000),
'37100': (0.3321,0.5060,1.0000),
'34100': (0.3375,0.5106,1.0000),
'31400': (0.3435,0.5157,1.0000),
'27700': (0.3540,0.5246,1.0000),
'5600': (1.0000,0.8518,0.7686),
'25200': (0.3633,0.5324,1.0000),
'6900': (0.9290,0.9107,1.0000),
'4200': (1.0000,0.6666,0.4172),
'4800': (1.0000,0.7528,0.5675),
'26600': (0.3578,0.5278,1.0000),
'38400': (0.3300,0.5042,1.0000),
'13300': (0.4831,0.6260,1.0000),
'10600': (0.5727,0.6898,1.0000),
'31100': (0.3442,0.5164,1.0000),
'11600': (0.5322,0.6615,1.0000),
'25800': (0.3609,0.5304,1.0000),
'6300': (1.0000,0.9254,0.9384),
'2600': (1.0000,0.3786,0.0790),
'28800': (0.3505,0.5217,1.0000),
'23700': (0.3701,0.5380,1.0000),
'20100': (0.3920,0.5559,1.0000),
'32800': (0.3402,0.5130,1.0000),
'3500': (1.0000,0.5515,0.2520),
'37400': (0.3316,0.5056,1.0000),
'38300': (0.3302,0.5044,1.0000),
'26900': (0.3567,0.5269,1.0000),
'33200': (0.3393,0.5122,1.0000),
'18600': (0.4045,0.5659,1.0000),
'25700': (0.3613,0.5307,1.0000),
'38900': (0.3293,0.5036,1.0000),
'6600': (0.9917,0.9458,1.0000),
'20400': (0.3898,0.5541,1.0000),
'23400': (0.3716,0.5393,1.0000),
'35500': (0.3348,0.5084,1.0000),
'24000': (0.3687,0.5368,1.0000),
'11500': (0.5357,0.6640,1.0000),
'29700': (0.3479,0.5195,1.0000),
'18500': (0.4055,0.5666,1.0000),
'16000': (0.4341,0.5890,1.0000),
'33700': (0.3383,0.5113,1.0000),
'15800': (0.4369,0.5912,1.0000),
'3600': (1.0000,0.5689,0.2745),
'17600': (0.4145,0.5738,1.0000),
'14700': (0.4545,0.6046,1.0000),
'19900': (0.3935,0.5571,1.0000),
'4600': (1.0000,0.7253,0.5170),
'29000': (0.3499,0.5212,1.0000),
'31700': (0.3427,0.5151,1.0000),
'26200': (0.3593,0.5291,1.0000),
'1800': (1.0000,0.2097,0.0000),
'38000': (0.3306,0.5048,1.0000),
'17100': (0.4201,0.5781,1.0000),
'23100': (0.3732,0.5405,1.0000),
'1200': (1.0000,0.0860,0.0000),
'9100': (0.6617,0.7492,1.0000),
'3100': (1.0000,0.4781,0.1677),
'2500': (1.0000,0.3577,0.0640),
'9600': (0.6271,0.7265,1.0000),
'14000': (0.4677,0.6146,1.0000),
'35300': (0.3352,0.5087,1.0000),
'18200': (0.4083,0.5689,1.0000),
'12800': (0.4955,0.6351,1.0000),
'26500': (0.3582,0.5281,1.0000),
'8000': (0.7644,0.8139,1.0000),
'6400': (1.0000,0.9351,0.9619),
'33100': (0.3396,0.5124,1.0000),
'36400': (0.3332,0.5070,1.0000),
'24400': (0.3668,0.5353,1.0000),
'9800': (0.6148,0.7183,1.0000),
'35000': (0.3357,0.5091,1.0000),
'2000': (1.0000,0.2484,0.0061),
'12200': (0.5125,0.6474,1.0000),
'28200': (0.3524,0.5232,1.0000),
}
ARCH= platform.architecture()[0]
TEX_TYPES= ('IMAGE', 'VRAY')
GEOM_TYPES= ('MESH', 'CURVE', 'SURFACE', 'META', 'FONT')
none_matrix= mathutils.Matrix(((0.0,0.0,0.0,0.0),(0.0,0.0,0.0,0.0),(0.0,0.0,0.0,0.0),(0.0,0.0,0.0,0.0)))
def get_username():
if PLATFORM == 'win32':
return "standalone"
else:
return getpass.getuser()
# Colorize sting on Linux
def color(text, color=None):
if not color or not PLATFORM == 'linux2':
return text
if color == 'green':
return "\033[0;32m%s\033[0m" % text
elif color == 'red':
return "\033[0;31m%s\033[0m" % text
elif color == 'yellow':
return "\033[0;33m%s\033[0m" % text
elif color == 'magenta':
return "\033[0;35m%s\033[0m" % text
else:
return text
# Log message
def debug(scene, message, newline= True, cr= True, error= False):
# sys.stdout.write("[%s] V-Ray/Blender: %s%s%s" % (
# time.strftime("%Y/%b/%d|%H:%m:%S"),
# color("Error! ", 'red') if error else '',
# message,
# '\n' if newline else '\r' if cr else '')
# )
sys.stdout.write("%s: %s%s%s" % (
color("V-Ray/Blender", 'green'),
color("Error! ", 'red') if error else '',
message,
'\n' if newline else '\r' if cr else '')
)
if not newline:
sys.stdout.flush()
# Prints dictionary
def print_dict(scene, title, params, spacing= 2):
debug(scene, "%s:" % title)
for key in sorted(params.keys()):
if type(params[key]) == dict:
spacing*= 2
print_dict(scene, key, params[key], spacing)
spacing/= 2
elif type(params[key]) in (list,tuple):
debug(scene, "%s%s" % (''.join([' ']*spacing), color(key, 'yellow')))
for item in params[key]:
debug(scene, ''.join([' ']*spacing*2) + str(item))
else:
debug(scene, "%s%s: %s" % (''.join([' ']*spacing), color(key, 'yellow'), params[key]))
# Property
def p(t):
if type(t) is bool:
return "%i"%(t)
elif type(t) is int:
return "%i"%(t)
elif type(t) is float:
return "%.6f"%(t)
elif type(t) is mathutils.Vector:
return "Vector(%.3f,%.3f,%.3f)"%(t.x,t.y,t.z)
elif type(t) is mathutils.Color:
return "Color(%.3f,%.3f,%.3f)"%(t.r,t.g,t.b)
elif type(t) is str:
if t == "True":
return "1"
elif t == "False":
return "0"
else:
return t
else:
return "%s"%(t)
# Animated property
def a(scene, t):
if scene.vray.exporter.animation:
return "interpolate((%i,%s))" % (scene.frame_current, p(t))
else:
return p(t)
# Transform matrix string
def transform(m):
return "Transform(Matrix(Vector(%f, %f, %f),Vector(%f, %f, %f),Vector(%f, %f, %f)),Vector(%f, %f, %f))" % (m[0][0], m[1][0], m[2][0], m[0][1], m[1][1], m[2][1], m[0][2], m[1][2], m[2][2], m[0][3], m[1][3], m[2][3])
# Clean string from forbidden chars
def clean_string(s):
s= s.replace("+", "p")
s= s.replace("-", "m")
for i in range(len(s)):
c= s[i]
if not ((c >= 'A' and c <= 'Z') or (c >= 'a' and c <= 'z') or (c >= '0' and c <= '9')):
s= s.replace(c, "_")
return s
# The most powerfull unique name generator =)
def get_random_string():
return ''.join([random.choice(string.ascii_letters) for x in range(16)])
# Append to list only if item not already in list
def append_unique(array, item):
if item in array:
return False
array.append(item)
return True
# V-Ray uses UV indexes, Blender uses UV names
# Here we store UV name->index map
def get_uv_layer_id(uv_layers, uv_layer_name):
if not uv_layer_name:
return 1
return uv_layers[uv_layer_name] if uv_layer_name in uv_layers else 1
def get_uv_layers_map(sce):
uv_layers= {}
uv_id= 1
for ma in bpy.data.materials:
for slot in ma.texture_slots:
if slot and slot.texture:
if slot.texture.vray.texture_coords == 'UV':
if slot.uv_layer and slot.uv_layer not in uv_layers:
uv_layers[slot.uv_layer]= uv_id
uv_id+= 1
if sce.vray.exporter.debug:
for uv_layer in uv_layers:
print_dict(sce, "UV layer name map", uv_layers)
return uv_layers
# Generate visibility list for "Hide From View"
def get_visibility_lists(camera):
VRayCamera= camera.data.vray
visibility= {
'all': [],
'camera': [],
'gi': [],
'reflect': [],
'refract': [],
'shadows': [],
}
if VRayCamera.hide_from_view:
for hide_type in visibility:
if getattr(VRayCamera, 'hf_%s' % hide_type):
if getattr(VRayCamera, 'hf_%s_auto' % hide_type):
visibility[hide_type]= generate_object_list(group_names_string= 'hf_%s' % camera.name)
else:
visibility[hide_type]= generate_object_list(getattr(VRayCamera, 'hf_%s_objects' % hide_type), getattr(VRayCamera, 'hf_%s_groups' % hide_type))
return visibility
# Generate list objects from ';' separated object and group strings
def generate_object_list(object_names_string= None, group_names_string= None):
object_list= []
if object_names_string:
ob_names= object_names_string.split(';')
for ob_name in ob_names:
if ob_name in bpy.data.objects:
object_list.append(bpy.data.objects[ob_name])
if group_names_string:
gr_names= group_names_string.split(';')
for gr_name in gr_names:
if gr_name in bpy.data.groups:
object_list.extend(bpy.data.groups[gr_name].objects)
return object_list
# Get object used as ORCO projection
def get_orco_object(scene, ob, VRayTexture):
if VRayTexture.object:
texture_object= get_data_by_name(scene, 'objects', VRayTexture.object)
if texture_object:
return texture_object
return ob
# Naming
# def get_name(data, bus):
# name= data.name
# if bus['object']['particle'].get('name'):
# name= "%s_%s" % (bus['object']['particle']['name'], name)
# if bus['object']['dupli'].get('name'):
# name= "%s_%s" % (bus['object']['dupli']['name'], name)
# if issubclass(type(data), bpy.types.Lamp):
# name= 'LA'+name
# elif issubclass(type(data), bpy.types.Texture):
# name= 'TE'+name
# elif type(data) == bpy.types.Material:
# name= 'MA'+name
# else:
# name= 'OB'+name
# if data.library:
# name+= "%s%s" % ('LI', get_filename(data.library.filepath))
# return clean_string(name)
def get_name(ob, prefix= None):
if not ob:
return None
name= ob.name
if prefix:
name= prefix+name
if ob.library:
name+= "%s%s" % ('LI', get_filename(ob.library.filepath).replace('.blend',''))
return clean_string(name)
# Get node name
def get_node_name(node_tree, node):
return "%s%s" % (get_name(node_tree, prefix='NT'),
clean_string(node.name))
# Find node connected to socket
def connected_node(node_tree, node_socket):
for node in node_tree.links:
if node.to_socket == node_socket:
return node.from_node
return None
# Get node_tree Output
def get_output_node(node_tree, output_node_name= None):
for node in node_tree.nodes:
if node.type == 'OUTPUT':
if output_node_name is not None:
if output_node_name == node.name:
return node
else:
return node
return None
# Get data by name
def get_data_by_name(sce, data_type, name):
if data_type == 'objects':
if name in sce.objects:
return sce.objects[name]
elif data_type in ('textures','materials','meshes'):
data_ptr= getattr(bpy.data, data_type)
if name in data_ptr:
return data_ptr[name]
return None
# Get file name
def get_filename(filepath):
return os.path.basename(bpy.path.abspath(filepath))
# Create directory
def create_dir(directory):
if not os.path.exists(directory):
debug(None, "Creating directory \"%s\"... " % directory, newline= False, cr= False)
try:
os.mkdir(directory)
sys.stdout.write("%s\n" % (color("done", 'yellow')))
except OSError:
directory= tempfile.gettempdir()
sys.stdout.write("%s\n" % (color("Fail!", 'red')))
debug(None, "Using default exporting path: %s" % directory)
return directory
def create_dir_from_filepath(filepath):
file_path, file_name= os.path.split(bpy.path.abspath(filepath))
file_path= create_dir(file_path)
return os.path.join(file_path, file_name)
# Get full filepath
# Also copies file to DR shared folder
def get_full_filepath(bus, ob, filepath):
def rel_path(filepath):
if filepath[:2] == "//":
return True
else:
return False
scene= bus['scene']
VRayDR= scene.vray.VRayDR
# If object is linked and path is relative
# we need to find correct absolute path
if ob.library and rel_path(filepath):
lib_path= os.path.dirname(bpy.path.abspath(ob.library.filepath))
filepath= os.path.normpath(os.path.join(lib_path,filepath[2:]))
# Full absolute file path
src_file= os.path.normpath(bpy.path.abspath(filepath))
if not VRayDR.on:
return src_file
# File name
src_filename= os.path.basename(src_file)
# DR shared directory
dest_path= bus['filenames']['DR']['dest_dir']
# If shared directory is not set
# just return absolute file path
if not dest_path:
return src_file
file_type= os.path.splitext(src_file)[1]
component_subdir= ""
if file_type.lower() in ('ies','lens'):
component_subdir= "misc"
elif file_type.lower() == "vrmesh":
component_subdir= "proxy"
else:
component_subdir= "textures"
if component_subdir:
dest_path= create_dir(os.path.join(dest_path, component_subdir))
# Copy file to the shared directory
dest_file= os.path.join(dest_path, src_filename)
if os.path.isfile(src_file):
if os.path.exists(dest_file):
# Copy only if the file was changed
if not filecmp.cmp(dest_file, src_file):
debug(scene, "Copying \"%s\" to \"%s\""% (color(src_filename, 'magenta'), dest_path))
shutil.copyfile(src_file, dest_file)
else:
debug(scene, "File \"%s\" exists and not modified."% (color(src_filename, 'magenta')))
else:
debug(scene, "Copying \"%s\" to \"%s\"" % (color(src_filename, 'magenta'), dest_path))
shutil.copyfile(src_file, dest_file)
else:
debug(scene, "\"%s\" is not a file!" % (src_file), error= True)
return src_file
if VRayDR.type == 'WW' or 'UW':
return "//%s/%s/%s/%s/%s"%(HOSTNAME,
VRayDR.share_name,
bus['filenames']['DR']['sub_dir'], component_subdir, src_filename)
return bus['filenames']['DR']['prefix'] + os.sep + component_subdir + os.sep + src_filename
# True if object on active layer
def object_on_visible_layers(sce,ob):
for l in range(20):
if ob.layers[l] and sce.layers[l]:
return True
return False
# True if object is visible
def object_visible(bus, ob):
scene= bus['scene']
VRayScene= scene.vray
VRayExporter= VRayScene.exporter
SettingsOptions= VRayScene.SettingsOptions
if VRayExporter.active_layers:
if not object_on_visible_layers(scene,ob):
if ob.type == 'LAMP':
if not SettingsOptions.light_doHiddenLights:
return False
if not SettingsOptions.geom_doHidden:
return False
if ob.hide_render:
if ob.type == 'LAMP':
if not SettingsOptions.light_doHiddenLights:
return False
if not SettingsOptions.geom_doHidden:
return False
return True
# Distance between 2 objects
def get_distance(ob1, ob2):
p1= ob1.matrix_world[3]
p2= ob2.matrix_world[3]
vec= p1 - p2
return vec.length
# VRayProxy Creator call
def proxy_creator(hq_filepath, vrmesh_filepath, append= False):
proxycreator_bin= "proxycreator"
if PLATFORM == 'linux2':
proxycreator_bin+= "_linux"
elif PLATFORM == 'win32':
proxycreator_bin+= "_win"
else:
proxycreator_bin+= "_mac"
if PLATFORM == 'win32':
proxycreator_bin+= ".exe"
elif PLATFORM == 'linux2':
proxycreator_bin+= ARCH[:-3]
vray_exporter_path= get_vray_exporter_path()
if vray_exporter_path:
proxycreator_bin= os.path.join(vray_exporter_path, "bin", proxycreator_bin)
if os.path.exists(proxycreator_bin):
debug(None, "Proxy Creator: %s" % (proxycreator_bin))
cmd= []
cmd.append(proxycreator_bin)
if append:
cmd.append('--append')
cmd.append(hq_filepath)
cmd.append(vrmesh_filepath)
proc= subprocess.call(cmd)
else:
debug(None, "Proxy Creator not found!", error= True)
# Returns path to vb25 folder
def get_vray_exporter_path():
for vb_path in bpy.utils.script_paths(os.path.join('startup','vb25')):
if vb_path:
return vb_path
return ""
# Detects V-Ray Standalone installation
def get_vray_standalone_path(sce):
VRayExporter= sce.vray.exporter
vray_bin= "vray"
if PLATFORM == 'win32':
vray_bin+= ".exe"
def get_env_paths(var):
split_char= ':'
if PLATFORM == 'win32':
split_char= ';'
env_var= os.getenv(var)
if env_var:
return env_var.replace('\"','').split(split_char)
return []
def find_vray_binary(paths):
if paths:
for p in paths:
if p:
vray_path= os.path.join(p,vray_bin)
if os.path.exists(vray_path):
if VRayExporter.debug:
debug(sce, "V-Ray found in: %s" % (vray_path))
return vray_path
return None
if not VRayExporter.detect_vray and VRayExporter.vray_binary:
return bpy.path.abspath(VRayExporter.vray_binary)
vray_standalone_paths= get_env_paths('VRAY_PATH')
if vray_standalone_paths:
vray_standalone= find_vray_binary(vray_standalone_paths)
if vray_standalone:
return vray_standalone
for var in os.environ:
if var.startswith('VRAY_FOR_MAYA'):
if var.find('MAIN') != -1:
debug(sce, "Searching in: %s" % (var))
vray_maya= find_vray_binary([os.path.join(path, 'bin') for path in get_env_paths(var)])
if vray_maya:
debug(sce, "V-Ray found in: %s" % (vray_maya))
return vray_maya
debug(sce, "V-Ray not found! Trying to start \"%s\" command from $PATH..." % (vray_bin), True)
return vray_bin
# Inits directories / files
def init_files(bus):
scene= bus['scene']
VRayScene= scene.vray
VRayExporter= VRayScene.exporter
VRayDR= VRayScene.VRayDR
SettingsOutput= VRayScene.SettingsOutput
(blendfile_path, blendfile_name)= os.path.split(bpy.data.filepath)
# Blend-file name without extension
blendfile_name= os.path.basename(bpy.data.filepath)[:-6] if bpy.data.filepath else "default"
# Default export directory is system's %TMP%
default_dir= tempfile.gettempdir()
# Export and output directory
export_filepath= os.path.join(default_dir, "vrayblender_"+get_username())
export_filename= "scene"
output_filepath= default_dir
if bpy.data.filepath:
if SettingsOutput.img_dir:
output_filepath= bpy.path.abspath(SettingsOutput.img_dir)
if VRayExporter.output == 'USER':
if VRayExporter.output_dir:
export_filepath= bpy.path.abspath(VRayExporter.output_dir)
elif VRayExporter.output == 'SCENE':
export_filepath= blendfile_path
if VRayExporter.output_unique:
export_filename= blendfile_name
if VRayDR.on:
export_filename= blendfile_name