Skip to content
Snippets Groups Projects
Commit b113287a authored by Campbell Barton's avatar Campbell Barton
Browse files

VRML: export vertex colors by default and fallback to material colors.

parent 0fee27b5
No related branches found
No related tags found
No related merge requests found
...@@ -70,9 +70,8 @@ class ExportVRML(bpy.types.Operator, ExportHelper): ...@@ -70,9 +70,8 @@ class ExportVRML(bpy.types.Operator, ExportHelper):
color_type = EnumProperty( color_type = EnumProperty(
name='Color', name='Color',
items=( items=(
('MATERIAL', "Material Color", ""), ('VERTEX', "Vertex Color", ""),
('VERTEX', "Vertex Color", "")), ('MATERIAL', "Material Color", "")),
default='MATERIAL',
) )
use_uv = BoolProperty( use_uv = BoolProperty(
name="Texture/UVs", name="Texture/UVs",
......
...@@ -206,16 +206,16 @@ def save_object(fw, global_matrix, ...@@ -206,16 +206,16 @@ def save_object(fw, global_matrix,
if use_color: if use_color:
if color_type == 'VERTEX': if color_type == 'VERTEX':
if bm.loops.layers.color.active is None: if bm.loops.layers.color.active is None:
use_color = False # fallback to material
elif color_type == 'MATERIAL': color_type = 'MATERIAL'
if color_type == 'MATERIAL':
if not me.materials: if not me.materials:
use_color = False use_color = False
else: else:
material_colors = [ material_colors = [
"%.2f %.2f %.2f " % (m.diffuse_color[:] if m else (1.0, 1.0, 1.0)) "%.2f %.2f %.2f " % (m.diffuse_color[:] if m else (1.0, 1.0, 1.0))
for m in me.materials] for m in me.materials]
else: assert(color_type in {'VERTEX', 'MATERIAL'})
assert(0)
if use_uv: if use_uv:
if bm.loops.layers.uv.active is None: if bm.loops.layers.uv.active is None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment