35
35
def save (self , context , filepath = "" ,
36
36
use_version = '6' ,
37
37
use_selection = False ,
38
- use_vertex_colors = True ,
39
38
use_apply_modifiers = True ,
40
39
use_armature = True ,
40
+ use_vertex_colors = True ,
41
+ use_vertex_colors_alpha = False ,
41
42
use_vertex_cleanup = False ,
42
43
use_armature_pose = False ,
43
44
use_frame_start = 1 ,
@@ -77,9 +78,10 @@ def save(self, context, filepath="",
77
78
result = _write (self , context , filepath ,
78
79
use_version ,
79
80
use_selection ,
80
- use_vertex_colors ,
81
81
use_apply_modifiers ,
82
82
use_armature ,
83
+ use_vertex_colors ,
84
+ use_vertex_colors_alpha ,
83
85
use_vertex_cleanup ,
84
86
use_armature_pose ,
85
87
use_weight_min ,
@@ -117,9 +119,10 @@ def save(self, context, filepath="",
117
119
result = _write (self , context , filepath_frame ,
118
120
use_version ,
119
121
use_selection ,
120
- use_vertex_colors ,
121
122
use_apply_modifiers ,
122
123
use_armature ,
124
+ use_vertex_colors ,
125
+ use_vertex_colors_alpha ,
123
126
use_vertex_cleanup ,
124
127
use_armature_pose ,
125
128
use_weight_min ,
@@ -143,9 +146,10 @@ def save(self, context, filepath="",
143
146
def _write (self , context , filepath ,
144
147
use_version ,
145
148
use_selection ,
146
- use_vertex_colors ,
147
149
use_apply_modifiers ,
148
150
use_armature ,
151
+ use_vertex_colors ,
152
+ use_vertex_colors_alpha ,
149
153
use_vertex_cleanup ,
150
154
use_armature_pose ,
151
155
use_weight_min ,
@@ -568,7 +572,14 @@ def _write(self, context, filepath,
568
572
else :
569
573
c = col .color4
570
574
571
- file .write ("COLOR %.6f %.6f %.6f 1.000000\n " % (c [0 ], c [1 ], c [2 ]))
575
+ if use_vertex_colors_alpha :
576
+
577
+ # Turn RGB into grayscale by calculating average value
578
+ file .write ("COLOR 1.000000 1.000000 1.000000 %.6f\n " % ((c [0 ] + c [1 ] + c [2 ]) / 3 ))
579
+
580
+ else :
581
+ file .write ("COLOR %.6f %.6f %.6f 1.000000\n " % (c [0 ], c [1 ], c [2 ]))
582
+
572
583
else :
573
584
file .write ("COLOR 1.000000 1.000000 1.000000 1.000000\n " )
574
585
0 commit comments