Skip to content

Commit

Permalink
Revert "stopgap implementation of second uv layer, see issue #8"
Browse files Browse the repository at this point in the history
This breaks exports, reverting until I figure out what I missed.

This reverts commit dfee9ee.
  • Loading branch information
shakesoda committed Apr 4, 2019
1 parent dfee9ee commit af16c0f
Showing 1 changed file with 6 additions and 32 deletions.
38 changes: 6 additions & 32 deletions blender-2.80/exm_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
bl_info = {
"name": "Export Excessive Model (.exm/.iqm)",
"author": "Lee Salzman, Colby Klein",
"version": (2019, 4, 4),
"version": (2018, 12, 5),
"blender": (2, 80, 0),
"location": "File > Export > Excessive Model",
"description": "Export to the Excessive Model format (.exm/.iqm)",
Expand All @@ -38,12 +38,7 @@
IQM_BLENDINDEXES = 4
IQM_BLENDWEIGHTS = 5
IQM_COLOR = 6
IQM_CUSTOM = 0x10

# NB: this is INTENTIONALLY UNDOCUMENTED AND UNFINISHED.
# it's outside of spec, index subject to change! please give feedback on issue
# #8 if you use this feature.
EXM_TEXCOORD2 = IQM_CUSTOM + 0x10
# IQM_CUSTOM = 0x10

# IQM_BYTE = 0
IQM_UBYTE = 1
Expand All @@ -69,12 +64,11 @@
MAXVCACHE = 32

class Vertex:
def __init__(self, index, coord, normal, uv, weights, color, uv2 = None):
def __init__(self, index, coord, normal, uv, weights, color):
self.index = index
self.coord = coord
self.normal = normal
self.uv = uv
self.uv2 = uv2
self.weights = weights
self.color = color

Expand Down Expand Up @@ -127,7 +121,7 @@ def __hash__(self):
return self.index

def __eq__(self, v):
return self.coord == v.coord and self.normal == v.normal and self.uv == v.uv and self.weights == v.weights and self.color == v.color and self.uv2 == v.uv2
return self.coord == v.coord and self.normal == v.normal and self.uv == v.uv and self.weights == v.weights and self.color == v.color


class Mesh:
Expand Down Expand Up @@ -513,13 +507,9 @@ def writeVerts(self, file, offset):
file.write(IQM_VERTEXARRAY.pack(IQM_BLENDWEIGHTS, 0, IQM_UBYTE, 4, offset))
offset += self.numverts * struct.calcsize('<4B')
hascolors = any(mesh.verts and mesh.verts[0].color for mesh in self.meshes)
hasuv2 = any(mesh.verts and mesh.verts[0].uv2 for mesh in self.meshes)
if hascolors:
file.write(IQM_VERTEXARRAY.pack(IQM_COLOR, 0, IQM_UBYTE, 4, offset))
offset += self.numverts * struct.calcsize('<4B')
if hasuv2:
file.write(IQM_VERTEXARRAY.pack(EXM_TEXCOORD2, 0, IQM_FLOAT, 2, offset))
offset += self.numverts * struct.calcsize('<2f')

for mesh in self.meshes:
for v in mesh.verts:
Expand Down Expand Up @@ -547,10 +537,6 @@ def writeVerts(self, file, offset):
file.write(struct.pack('<4B', v.color[0], v.color[1], v.color[2], v.color[3]))
else:
file.write(struct.pack('<4B', 0, 0, 0, 255))
if hasuv2:
for mesh in self.meshes:
for v in mesh.verts:
file.write(struct.pack('<2f', *v.uv2))

def calcNeighbors(self):
edges = {}
Expand Down Expand Up @@ -931,13 +917,9 @@ def collectMeshes(context, bones, scale, matfun, usemodifiers = True, useskel =
groups = obj.vertex_groups

uvfaces = None
lightuvfaces = None
for uv_layer in data.uv_layers:
if uv_layer.active:
uvfaces = uv_layer.data
else:
lightuvfaces = uv_layer.data
if uvfaces and lightuvfaces:
break

colors = None
Expand Down Expand Up @@ -997,13 +979,6 @@ def collectMeshes(context, bones, scale, matfun, usemodifiers = True, useskel =
else:
vertuv = mathutils.Vector((0.0, 0.0))

# flip V axis of texture space
if lightuvfaces:
uv2 = lightuvfaces[loop_index].uv
vertuv2 = mathutils.Vector((uv2[0], 1.0 - uv2[1]))
else:
vertuv2 = mathutils.Vector((0.0, 0.0))

if colors:
vertcol = colors[loop_index].color
vertcol = (int(round(vertcol[0] * 255.0)), int(round(vertcol[1] * 255.0)), int(round(vertcol[2] * 255.0)), 255)
Expand All @@ -1029,13 +1004,13 @@ def collectMeshes(context, bones, scale, matfun, usemodifiers = True, useskel =

if not tri.use_smooth:
vertindex = len(verts)
vertkey = Vertex(vertindex, vertco, vertno, vertuv, vertweights, vertcol, vertuv2)
vertkey = Vertex(vertindex, vertco, vertno, vertuv, vertweights, vertcol)
vertkey.normalizeWeights()
mesh.verts.append(vertkey)
faceverts.append(vertkey)
continue

vertkey = Vertex(v.index, vertco, vertno, vertuv, vertweights, vertcol, vertuv2)
vertkey = Vertex(v.index, vertco, vertno, vertuv, vertweights, vertcol)
vertkey.normalizeWeights()
if not verts[v.index]:
verts[v.index] = vertkey
Expand Down Expand Up @@ -1307,7 +1282,6 @@ def execute(self, context):

global_matrix = axis_conversion(to_up="Z", to_forward="Y").to_4x4()
exm_meta = ""
# disabled in git due to unspecified nature.
# exm_meta = getJSON(context, self.properties.filepath, global_matrix)

exportIQM(context, self.properties.filepath, self.properties.usemesh, self.properties.usemodifiers, self.properties.useskel, self.properties.usebbox, self.properties.usecol, self.properties.meshopt, matfun, derigify, self.properties.boneorder, flipyz, reversewinding, exm_meta, self.properties.selected_only)
Expand Down

0 comments on commit af16c0f

Please sign in to comment.