Skip to content

Instantly share code, notes, and snippets.

/stellar.py
Created Jun 10, 2013

Embed
What would you like to do?
test
def mesh_append_face( obj, bm, vertex_list, uv_list, texture_name ):
# add vertices and uvs before creating the new face
for vert in vertex_list:
bm.verts.new((*vert))
bm.faces.new( ( bm.verts[i] for i in range( -len( vertex_list ), 0)) )
# add uvs to the new face
uv_layer = bm.loops.layers.uv.verify()
bm.faces.layers.tex.verify()
face = bm.faces[-1]
for i, loop in enumerate(face.loops):
loop[uv_layer].uv = uv_list[i]
# assign material
try:
material_names = [ m.name for m in obj.data.materials ]
material_id = material_names.index(texture_name)
except ValueError:
obj.data.materials.append(bpy.data.materials[texture_name])
material_id = len(obj.data.materials) - 1
face.material_index = material_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.