Skip to content

Commit

Permalink
Merge pull request #2 from rizzntine/autopep8-patches
Browse files Browse the repository at this point in the history
Fixes by autopep8 action
  • Loading branch information
rizzntine authored Jan 28, 2024
2 parents 63bada3 + d123178 commit f53d467
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions io_mesh_w3d/common/utils/material_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

def create_vertex_material(context, principleds, structure, mesh, b_mesh, name, triangles, mesh_ob):

if len(structure.material_passes) == 1 and len(structure.textures) > 1: # condition for multiple materials per single mesh object
if len(structure.material_passes) == 1 and len(
structure.textures) > 1: # condition for multiple materials per single mesh object
# Create the same amount of materials as textures used for this mesh
source_mat = structure.vert_materials[0]
for texture in structure.textures:
Expand All @@ -29,7 +30,7 @@ def create_vertex_material(context, principleds, structure, mesh, b_mesh, name,
# Load textures
for tex_id, texture in enumerate(structure.textures):
texture = structure.textures[tex_id]
tex = find_texture(context, texture.file, texture.id)
tex = find_texture(context, texture.file, texture.id)
node_tree = mesh.materials[tex_id].node_tree
bsdf_node = node_tree.nodes.get('Principled BSDF')
texture_node = node_tree.nodes.new('ShaderNodeTexImage')
Expand All @@ -40,12 +41,12 @@ def create_vertex_material(context, principleds, structure, mesh, b_mesh, name,
links.new(texture_node.outputs['Alpha'], bsdf_node.inputs['Alpha'])

# Assign material to appropriate object faces
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.object.mode_set(mode='EDIT')
bm = bmesh.from_edit_mesh(mesh_ob.data)
bm.faces.ensure_lookup_table()
for i, face in enumerate(bm.faces):
bm.faces[i].material_index = structure.material_passes[0].tx_stages[0].tx_ids[0][i]
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.mode_set(mode='OBJECT')
else:
for vertMat in structure.vert_materials:
(material, principled) = create_material_from_vertex_material(name, vertMat)
Expand All @@ -69,8 +70,8 @@ def create_vertex_material(context, principleds, structure, mesh, b_mesh, name,
links = node_tree.links
links.new(texture_node.outputs['Color'], bsdf_node.inputs['Base Color'])
links.new(texture_node.outputs['Alpha'], bsdf_node.inputs['Alpha'])
#Iterate through all materials and set their blend mode to Alpha Clip for transparency

# Iterate through all materials and set their blend mode to Alpha Clip for transparency
for material in mesh.materials:
if material:
material.blend_method = 'CLIP'
Expand Down

0 comments on commit f53d467

Please sign in to comment.