bugfix: Wasn't creating materials for a mesh, and the material indexes it was already generating were wrong.

master
TigerKat 4 years ago
parent 03f9bf8a14
commit 8603399f19

@ -2,7 +2,7 @@
bl_info = {
"name": "City of Heroes (.geo)",
"author": "TigerKat",
"version": (0, 2, 8),
"version": (0, 2, 9),
"blender": (2, 80, 0),
"location": "File > Import/Export,",
"description": "City of Heroes (.geo)",

@ -947,6 +947,7 @@ class Model:
v = GeoVertex(coord, normal, uv, weights)
geomesh.getGeoVertexIndexNew(v)
texture_indexes = []
#print("Geo.tex_idx: %s Geo.geo.header_texnames: %s" % (self.tex_idx, self.geo.header_texnames))
for t in self.tex_idx:
texture_indexes += [geomesh.getTextureIndex(self.geo.header_texnames[t[0]])] * t[1]
#print("len(self.verts): %s" % (len(self.verts), ))

@ -73,7 +73,11 @@ class GeoMesh:
self.geovertex.append(gv)
return index
def getTextureIndex(self, name):
if isinstance(name, int):
#Convenience, assume ints are from a previous look up.
return name
index = self.textures_map.get(name, len(self.textures))
#print("GeoMesh.getTextureIndex(%s): %s" % (name, index))
if index == len(self.textures):
self.textures_map[name] = index
self.textures.append(name)

@ -44,6 +44,15 @@ def convert_model(geo_model, mesh_data, obj, scale):
indices = [i for face in geomesh.face for i in import_fix_winding(face.vert_indexes)]
texture_indices = [face.texture_index for face in geomesh.face]
#Create materials for textures.
mesh_data.materials.clear()
#print("geomesh.textures: %s" % (geomesh.textures,))
for i, tex_name in enumerate(geomesh.textures):
#if isinstance(tex_name, int):
# continue
#print("tex_name: %s" % tex_name)
mesh_data.materials.append(bpy.data.materials.new(tex_name.decode("utf-8")))
mesh_data.vertices.add(len(geomesh.geovertex))
mesh_data.loops.add(len(indices))
mesh_data.polygons.add(len(geomesh.face))

Loading…
Cancel
Save