Skip to content

Commit

Permalink
[Blender] Fix vertex-winding between Blender and Warzone2100
Browse files Browse the repository at this point in the history
  • Loading branch information
CupnPlateGames authored and past-due committed Mar 1, 2024
1 parent 032b719 commit 4f78fe6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
16 changes: 9 additions & 7 deletions tools/blender/2.9x/pie_addon/pie_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,17 @@ def adjustToIntUv(num):
'{uvx1} {uvy1} {uvx2} {uvy2} '
'{uvx3} {uvy3}').format(
type=200,
# Normals in Blender and in game are flipped
# Import and export in opposite order to flip them
v1=face.verts[0].index,
v2=face.verts[1].index,
v3=face.verts[2].index,
v2=face.verts[2].index,
v3=face.verts[1].index,
uvx1=uvx1,
uvy1=uvy1,
uvx2=uvx2,
uvy2=uvy2,
uvx3=uvx3,
uvy3=uvy3,
uvx2=uvx3,
uvy2=uvy3,
uvx3=uvx2,
uvy3=uvy2,
)

# if child.pie_object_prop.exportNormal is True:
Expand Down Expand Up @@ -456,4 +458,4 @@ def formSpaces(num, spaces):

pieFile.write('\n')

pieFile.close()
pieFile.close()
12 changes: 7 additions & 5 deletions tools/blender/2.9x/pie_addon/pie_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ def pie_generateBlenderObjects(self, pieParse, pieName):
pie_polygons = []

for p in level['POLYGONS']:
pie_polygons.append((p[2], p[3], p[4]))
# Normals in Blender and in game are flipped
# Import and export in opposite order to flip them
pie_polygons.append((p[2], p[4], p[3]))
mesh.from_pydata(pie_points, [], pie_polygons)

animatedPolygons = []
Expand All @@ -205,12 +207,12 @@ def pie_generateBlenderObjects(self, pieParse, pieName):

if pieParse['PIE'] == '3':
uvData[L + 0].uv = ((p[5 + m], -p[6 + m] + 1))
uvData[L + 1].uv = ((p[7 + m], -p[8 + m] + 1))
uvData[L + 2].uv = ((p[9 + m], -p[10 + m] + 1))
uvData[L + 1].uv = ((p[9 + m], -p[10 + m] + 1))
uvData[L + 2].uv = ((p[7 + m], -p[8 + m] + 1))
elif pieParse['PIE'] == '2':
uvData[L + 0].uv = ((p[5 + m] / n, (-p[6 + m] / n) + 1))
uvData[L + 1].uv = ((p[7 + m] / n, (-p[8 + m] / n) + 1))
uvData[L + 2].uv = ((p[9 + m] / n, (-p[10 + m] / n) + 1))
uvData[L + 1].uv = ((p[9 + m] / n, (-p[10 + m] / n) + 1))
uvData[L + 2].uv = ((p[7 + m] / n, (-p[8 + m] / n) + 1))

bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bm = bmesh.from_edit_mesh(mesh)
Expand Down

0 comments on commit 4f78fe6

Please sign in to comment.