Gracefully handle missing textures.

The texinfo still gets a material, but just an untextured one. The idea is
such textures can be fixed up at a later date.
This commit is contained in:
Bill Currie 2012-09-11 14:57:24 +09:00
parent 41004fd7c2
commit 54832740c8

View file

@ -64,23 +64,32 @@ def load_material(tx):
mat.diffuse_color = (1, 1, 1)
mat.specular_intensity = 0
mat.use_raytrace = False
tex = bpy.data.textures.new(tx.name, 'IMAGE')
tex.extension = 'REPEAT'
tex.use_preview_alpha = True
tex.image = tx.image
mat.texture_slots.add()
ts = mat.texture_slots[0]
ts.texture = tex
ts.use_map_alpha = True
ts.texture_coords = 'UV'
if tx.image:
tex = bpy.data.textures.new(tx.name, 'IMAGE')
tex.extension = 'REPEAT'
tex.use_preview_alpha = True
tex.image = tx.image
mat.texture_slots.add()
ts = mat.texture_slots[0]
ts.texture = tex
ts.use_map_alpha = True
ts.texture_coords = 'UV'
return mat
def load_textures(texdefs, wads):
for tx in texdefs:
if hasattr(tx, "miptex"):
continue
tx.miptex = wads[0].getData(tx.name)
tx.image = load_image(tx)
try:
tx.miptex = wads[0].getData(tx.name)
tx.image = load_image(tx)
except KeyError:
class MT:
def __init__(self, x, y):
self.width = x
self.height = y
tx.miptex = MT(64,64)
tx.image = None
tx.material = load_material(tx)
def build_uvs(verts, faces, texdefs):