Browse Source

Export ALL THE UVs!

pull/6/head
Adam Johnson 11 years ago
parent
commit
6ac720d0d5
  1. 30
      korman/exporter/mesh.py

30
korman/exporter/mesh.py

@ -153,12 +153,14 @@ class MeshConverter:
data = geodata[tessface.material_index] data = geodata[tessface.material_index]
face_verts = [] face_verts = []
# Convert to per-material indices
for j in tessface.vertices:
# Unpack the UV coordinates from each UV Texture layer # Unpack the UV coordinates from each UV Texture layer
# NOTE: Blender has no third (W) coordinate # NOTE: Blender has no third (W) coordinate
uvws = [(uvtex.data[j].uv.x, uvtex.data[j].uv.y) for uvtex in mesh.uv_layers] tessface_uvws = [uvtex.data[i].uv for uvtex in mesh.tessface_uv_textures]
print(tessface_uvws)
# Convert to per-material indices
for j, vertex in enumerate(tessface.vertices):
uvws = tuple([uvw[j] for uvw in tessface_uvws])
# Grab VCols (TODO--defaulting to white for now) # Grab VCols (TODO--defaulting to white for now)
# This will be finalized once the vertex color light code baking is in # This will be finalized once the vertex color light code baking is in
color = (255, 255, 255, 255) color = (255, 255, 255, 255)
@ -166,17 +168,17 @@ class MeshConverter:
# Now, we'll index into the vertex dict using the per-face elements :( # Now, we'll index into the vertex dict using the per-face elements :(
# We're using tuples because lists are not hashable. The many mathutils and PyHSPlasma # We're using tuples because lists are not hashable. The many mathutils and PyHSPlasma
# types are not either, and it's entirely too much work to fool with all that. # types are not either, and it's entirely too much work to fool with all that.
coluv = (color, tuple(uvws)) coluv = (color, uvws)
if coluv not in data.blender2gs[j]: if coluv not in data.blender2gs[vertex]:
source = mesh.vertices[j] source = mesh.vertices[vertex]
vertex = plGeometrySpan.TempVertex() geoVertex = plGeometrySpan.TempVertex()
vertex.position = utils.vector3(source.co) geoVertex.position = utils.vector3(source.co)
vertex.normal = utils.vector3(source.normal) geoVertex.normal = utils.vector3(source.normal)
vertex.color = hsColor32(*color) geoVertex.color = hsColor32(*color)
vertex.uvs = [hsVector3(uv[0], 1.0-uv[1], 0.0) for uv in uvws] geoVertex.uvs = [hsVector3(uv[0], uv[1], 0.0) for uv in uvws]
data.blender2gs[j][coluv] = len(data.vertices) data.blender2gs[vertex][coluv] = len(data.vertices)
data.vertices.append(vertex) data.vertices.append(geoVertex)
face_verts.append(data.blender2gs[j][coluv]) face_verts.append(data.blender2gs[vertex][coluv])
# Convert to triangles, if need be... # Convert to triangles, if need be...
if len(face_verts) == 3: if len(face_verts) == 3:

Loading…
Cancel
Save