Skip to content

Commit

Permalink
Fix #7, add totalVerts to MESH struct
Browse files Browse the repository at this point in the history
  • Loading branch information
ABelliqueux committed Jul 1, 2021
1 parent f31a71c commit 393d088
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions io_export_psx_tmesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ def linearToRGB(component):
# MESH

h.write("typedef struct MESH { \n"+
"\tint totalVerts;\n" +
"\tTMESH * tmesh;\n" +
"\tPRIM * index;\n" +
"\tTIM_IMAGE * tim; \n" +
Expand Down Expand Up @@ -1024,7 +1025,6 @@ def linearToRGB(component):
"\tCAMPATH * camPath;\n" +
"\tCAMANGLE ** camAngles;\n" +
"\tNODE * curNode;\n" +
"\tMESH * meshPlan; // This one is temporary\n" +
"\t} LEVEL;\n")

h.close()
Expand Down Expand Up @@ -1489,7 +1489,10 @@ def linearToRGB(component):

f.write("};\n\n")

# Write polygons index + type
# Write polygons index + type

# Keep track of total number of vertices in the mesh
totalVerts = 0

f.write( "PRIM " + fileName + "_model" + cleanName + "_index[] = {\n" )

Expand All @@ -1501,10 +1504,14 @@ def linearToRGB(component):

f.write( "\t" + str( poly.vertices[ 0 ] ) + "," + str( poly.vertices[ 1 ] ) + "," + str( poly.vertices[ 2 ] ) )

totalVerts += 3

if len(poly.vertices) > 3:

f.write("," + str(poly.vertices[3]) + ",8")


totalVerts += 1

else:

f.write(",0,4")
Expand Down Expand Up @@ -1850,11 +1857,14 @@ def linearToRGB(component):

# ~ f.write("NODE_DECLARATION\n")

f.write( "MESH " + fileName + "_mesh" + cleanName + " = {\n" )
f.write( "MESH " + fileName + "_mesh" + cleanName + " = {\n" +

"\t" + str(totalVerts) + ",\n" +

f.write("\t&" + fileName + "_model"+ cleanName +",\n")
"\t&" + fileName + "_model"+ cleanName +",\n" +

f.write("\t" + fileName + "_model" + cleanName + "_index,\n")
"\t" + fileName + "_model" + cleanName + "_index,\n"
)

if len(m.uv_textures) != 0:

Expand Down Expand Up @@ -1897,7 +1907,7 @@ def linearToRGB(component):

+ str(round(degrees(-bpy.data.objects[m.name].rotation_euler.z)/360 * 4096)) + ","

+ str(round(degrees(bpy.data.objects[m.name].rotation_euler.y)/360 * 4096)) + "},\n" +
+ str(round(degrees(bpy.data.objects[m.name].rotation_euler.y)/360 * 4096)) + ", 0},\n" +

"\t" + str( int( chkProp[ 'isRigidBody' ] ) ) + ", // isRigidBody\n" +

Expand Down Expand Up @@ -1937,9 +1947,9 @@ def linearToRGB(component):

"\t" + "subs_" + m.name + ",\n" +

"\t0" +
"\t0,\n" +

"\n};\n\n"
"};\n\n"
)

level_symbols.append( "MESH " + fileName + "_mesh" + cleanName )
Expand Down Expand Up @@ -2789,8 +2799,6 @@ def linearToRGB(component):
"\t(CAMANGLE **)&" + fileName + "_camAngles,\n" +

"\t&" + fileName + "_node" + CleanName(nodePtr) + ",\n" +

# ~ "\t&" + fileName + "_meshPlan\n" +

"};\n\n")

Expand Down

0 comments on commit 393d088

Please sign in to comment.