mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 02:11:19 +00:00
Break out the skin/material setup code.
This commit is contained in:
parent
41213f2c30
commit
de24fa99a8
1 changed files with 13 additions and 11 deletions
|
@ -219,17 +219,9 @@ def load_skins(mdl):
|
|||
else:
|
||||
load_skin (mdl.skins[i], "%s_%d" % (mdl.name, i))
|
||||
|
||||
def import_mdl(operator, context, filepath):
|
||||
mdl = load_mdl(filepath)
|
||||
|
||||
bpy.context.user_preferences.edit.use_global_undo = False
|
||||
|
||||
faces, uvs = make_faces (mdl)
|
||||
verts = make_verts (mdl, 0)
|
||||
def setup_skins (mdl, mesh, uvs):
|
||||
load_skins (mdl)
|
||||
img = mdl.images[0] # use the first skin for now
|
||||
mesh = bpy.data.meshes.new(mdl.name)
|
||||
mesh.from_pydata(verts, [], faces)
|
||||
uvlay = mesh.uv_textures.new(mdl.name)
|
||||
for i, f in enumerate(uvlay.data):
|
||||
mdl_uv = uvs[i]
|
||||
|
@ -249,13 +241,23 @@ def import_mdl(operator, context, filepath):
|
|||
ts.texture = tex
|
||||
ts.use_map_alpha = True
|
||||
ts.texture_coords = 'UV'
|
||||
mesh.update()
|
||||
object_data_add(context, mesh, operator=None)
|
||||
act = bpy.context.active_object
|
||||
if not act.material_slots:
|
||||
bpy.ops.object.material_slot_add()
|
||||
act.material_slots[0].material = mat
|
||||
|
||||
def import_mdl(operator, context, filepath):
|
||||
bpy.context.user_preferences.edit.use_global_undo = False
|
||||
|
||||
mdl = load_mdl(filepath)
|
||||
faces, uvs = make_faces (mdl)
|
||||
verts = make_verts (mdl, 0)
|
||||
mesh = bpy.data.meshes.new(mdl.name)
|
||||
mesh.from_pydata(verts, [], faces)
|
||||
object_data_add(context, mesh, operator=None)
|
||||
setup_skins (mdl, mesh, uvs)
|
||||
mesh.update()
|
||||
|
||||
bpy.context.user_preferences.edit.use_global_undo = True
|
||||
return 'FINISHED'
|
||||
|
||||
|
|
Loading…
Reference in a new issue