From 27c54ac83579cfee0783cbabafa2721eb9279ad9 Mon Sep 17 00:00:00 2001 From: Michael Schnabel Date: Tue, 11 Feb 2020 09:57:37 +0100 Subject: [PATCH] material creation refactoring --- io_mesh_w3d/common/utils/material_import.py | 2 ++ io_mesh_w3d/common/utils/mesh_import.py | 34 +++++---------------- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/io_mesh_w3d/common/utils/material_import.py b/io_mesh_w3d/common/utils/material_import.py index 3c19ce97..0e073744 100644 --- a/io_mesh_w3d/common/utils/material_import.py +++ b/io_mesh_w3d/common/utils/material_import.py @@ -14,6 +14,8 @@ ########################################################################## def create_vertex_materials(context, struct, mesh, triangles, prelit_type=None): + if struct is None: + return materials = [] principleds = [] for vertMat in struct.vert_materials: diff --git a/io_mesh_w3d/common/utils/mesh_import.py b/io_mesh_w3d/common/utils/mesh_import.py index 41d453ce..b9d2facd 100644 --- a/io_mesh_w3d/common/utils/mesh_import.py +++ b/io_mesh_w3d/common/utils/mesh_import.py @@ -28,33 +28,13 @@ def create_mesh(context, mesh_struct, hierarchy, coll): if mesh_struct.is_hidden(): mesh_ob.hide_set(True) - # vertex material stuff - if mesh_struct.vert_materials: - create_vertex_materials(context, mesh_struct, mesh, triangles) - - if mesh_struct.prelit_unlit is not None: - print('create prelit unlit') - prelit = mesh_struct.prelit_unlit - create_vertex_materials(context, prelit, mesh, triangles, prelit_type='PRELIT_UNLIT') - - if mesh_struct.prelit_vertex is not None: - print('create prelit vertex') - prelit = mesh_struct.prelit_vertex - create_vertex_materials(context, prelit, mesh, triangles, prelit_type='PRELIT_VERTEX') - - if mesh_struct.prelit_lightmap_multi_pass is not None: - print('create prelit lightmap multi pass') - prelit = mesh_struct.prelit_lightmap_multi_pass - create_vertex_materials(context, prelit, mesh, triangles, prelit_type='PRELIT_LIGHTMAP_MULTI_PASS') - - if mesh_struct.prelit_lightmap_multi_texture is not None: - print('create prelit lightmap multi texture') - prelit = mesh_struct.prelit_lightmap_multi_texture - create_vertex_materials(context, prelit, mesh, triangles, prelit_type='PRELIT_LIGHTMAP_MULTI_TEXTURE') - - # shader material stuff - if mesh_struct.shader_materials: - create_shader_materials(context, mesh_struct, mesh, triangles) + create_shader_materials(context, mesh_struct, mesh, triangles) + + create_vertex_materials(context, mesh_struct, mesh, triangles) + create_vertex_materials(context, mesh_struct.prelit_unlit, mesh, triangles, prelit_type='PRELIT_UNLIT') + create_vertex_materials(context, mesh_struct.prelit_vertex, mesh, triangles, prelit_type='PRELIT_VERTEX') + create_vertex_materials(context, mesh_struct.prelit_lightmap_multi_pass, mesh, triangles, prelit_type='PRELIT_LIGHTMAP_MULTI_PASS') + create_vertex_materials(context, mesh_struct.prelit_lightmap_multi_texture, mesh, triangles, prelit_type='PRELIT_LIGHTMAP_MULTI_TEXTURE') def rig_mesh(mesh_struct, hierarchy, rig, sub_object=None):