mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 02:11:19 +00:00
Fix import and export for blender 2.63
Blender 2.63 should be out in a few days. Nice to get this ready ahead of time.
This commit is contained in:
parent
d3af0b2357
commit
fd9b8f7b4a
2 changed files with 12 additions and 11 deletions
|
@ -32,7 +32,7 @@ def check_faces(mesh):
|
|||
#quad to tri conversion will not be done automatically.
|
||||
faces_ok = True
|
||||
save_select = []
|
||||
for f in mesh.faces:
|
||||
for f in mesh.polygons:
|
||||
save_select.append(f.select)
|
||||
f.select = False
|
||||
if len(f.vertices) > 3:
|
||||
|
@ -42,7 +42,7 @@ def check_faces(mesh):
|
|||
mesh.update()
|
||||
return False
|
||||
#reset selection to what it was before the check.
|
||||
for f, s in map(lambda x, y: (x, y), mesh.faces, save_select):
|
||||
for f, s in map(lambda x, y: (x, y), mesh.polygons, save_select):
|
||||
f.select = s
|
||||
mesh.update()
|
||||
return True
|
||||
|
@ -94,14 +94,15 @@ def build_tris(mesh):
|
|||
# the layout. However, there seems to be nothing in the mdl format
|
||||
# preventing the use of duplicate 3d vertices to allow complete freedom
|
||||
# of the UV layout.
|
||||
uvfaces = mesh.uv_textures[0].data
|
||||
uvfaces = mesh.uv_loop_layers[0].data
|
||||
stverts = []
|
||||
tris = []
|
||||
vertmap = [] # map mdl vert num to blender vert num (for 3d verts)
|
||||
uvdict = {}
|
||||
for face, uvface in map(lambda a,b: (a,b), mesh.faces, uvfaces):
|
||||
for face in mesh.polygons:
|
||||
fv = list(face.vertices)
|
||||
uv = list(uvface.uv)
|
||||
uv = uvfaces[face.loop_start:face.loop_start + face.loop_total]
|
||||
uv = list(map(lambda a: a.uv, uv))
|
||||
# blender's and quake's vertex order seem to be opposed
|
||||
fv.reverse()
|
||||
uv.reverse()
|
||||
|
|
|
@ -100,13 +100,13 @@ def setup_skins (mdl, uvs):
|
|||
load_skins (mdl)
|
||||
img = mdl.images[0] # use the first skin for now
|
||||
uvlay = mdl.mesh.uv_textures.new(mdl.name)
|
||||
for i, f in enumerate(uvlay.data):
|
||||
uvloop = mdl.mesh.uv_loop_layers[0]
|
||||
for i, texpoly in enumerate(uvlay.data):
|
||||
poly = mdl.mesh.polygons[i]
|
||||
mdl_uv = uvs[i]
|
||||
for j, uv in enumerate(f.uv):
|
||||
uv[0], uv[1] = mdl_uv[j]
|
||||
f.image = img
|
||||
if hasattr(f, "use_image"): # for older blender
|
||||
f.use_image = True
|
||||
texpoly.image = img
|
||||
for j,k in enumerate(poly.loop_indices):
|
||||
uvloop.data[k].uv = mdl_uv[j]
|
||||
mat = bpy.data.materials.new(mdl.name)
|
||||
mat.diffuse_color = (1,1,1)
|
||||
mat.use_raytrace = False
|
||||
|
|
Loading…
Reference in a new issue