1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/small3dlib.git synced 2024-11-23 20:59:58 +01:00

Update obj tool

This commit is contained in:
Miloslav Číž 2019-06-06 16:38:29 +02:00
parent c9bcb0ace5
commit 289487ceea

View file

@ -90,8 +90,8 @@ for line in objFile:
# print the result: # print the result:
def arrayString(name, array, components, scales, align, short, dataType): def arrayString(name, array, components, scales, align, short, dataType, sizeStr):
result = "const " + dataType + " " + name + "[] = {\n" result = "const " + dataType + " " + name + "[" + sizeStr + "] = {\n"
if COMPACT: if COMPACT:
lineLen = 0 lineLen = 0
@ -153,12 +153,17 @@ if GUARDS:
print("#ifndef " + NAME.upper() + "_MODEL_H") print("#ifndef " + NAME.upper() + "_MODEL_H")
print("#define " + NAME.upper() + "_MODEL_H\n") print("#define " + NAME.upper() + "_MODEL_H\n")
print(arrayString(NAME + "Vertices",vertices,3,[VERTEX_SCALE],5,False,"S3L_Unit")) print("#define " + NAME.upper() + "_VERTEX_COUNT " + str(len(vertices)))
print(arrayString(NAME + "TriangleIndices",triangles,3,[1],5,True,"S3L_Index")) print(arrayString(NAME + "Vertices",vertices,3,[VERTEX_SCALE],5,False,"S3L_Unit",NAME.upper() + "_VERTEX_COUNT * 3"))
print("#define " + NAME.upper() + "_TRIANGLE_COUNT " + str(len(triangles)))
print(arrayString(NAME + "TriangleIndices",triangles,3,[1],5,True,"S3L_Index",NAME.upper() + "_TRIANGLE_COUNT * 3"))
if INDEXED_UVS: if INDEXED_UVS:
print(arrayString(NAME + "UVs",uvs,2,[U_SCALE,V_SCALE],5,False,"S3L_Unit")) print("#define " + NAME.upper() + "_UV_COUNT " + str(len(uvs)))
print(arrayString(NAME + "UVIndices",triangleUVs,3,[1],5,True,"S3L_Index")) print(arrayString(NAME + "UVs",uvs,2,[U_SCALE,V_SCALE],5,False,"S3L_Unit",NAME.upper() + "_UV_COUNT * 2"))
print("#define " + NAME.upper() + "_UV_INDEX_COUNT " + str(len(triangleUVs)))
print(arrayString(NAME + "UVIndices",triangleUVs,3,[1],5,True,"S3L_Index",NAME.upper() + "_UV_INDEX_COUNT * 3"))
else: else:
uvs2 = [] uvs2 = []
for item in triangleUVs: for item in triangleUVs:
@ -170,21 +175,22 @@ else:
uvs[item[2]][0], uvs[item[2]][0],
uvs[item[2]][1]]) uvs[item[2]][1]])
print(arrayString(NAME + "TriangleUVs",uvs2,6,[U_SCALE,V_SCALE],5,False,"S3L_Unit")) print("#define " + NAME.upper() + "_DIRECT_UV_COUNT " + str(len(uvs2)))
print(arrayString(NAME + "DirectUVs",uvs2,6,[U_SCALE,V_SCALE],5,False,"S3L_Unit",NAME.upper() + "_DIRECT_UV_COUNT * 6"))
print("S3L_Model3D " + NAME + "Model = ") print("S3L_Model3D " + NAME + "Model = ")
if COMPACT: if COMPACT:
print("{.vertices=" + print("{.vertices=" +
NAME + "Vertices,.vertexCount=" + str(len(vertices)) + NAME + "Vertices,.vertexCount=" + str(len(vertices)) +
",.triangles=" + NAME + "TriangleIndices,\n.triangleCount=" + ",.triangles=" + NAME.upper() + "TriangleIndices,\n.triangleCount=" +
str(len(triangles)) + "};"); str(len(triangles)) + "};");
else: else:
print("{") print("{")
print(" .vertices = " + NAME + "Vertices,") print(" .vertices = " + NAME + "Vertices,")
print(" .vertexCount = " + str(len(vertices)) + ",") print(" .vertexCount = " + NAME.upper() + "_VERTEX_COUNT,")
print(" .triangles = " + NAME + "TriangleIndices,") print(" .triangles = " + NAME + "TriangleIndices,")
print(" .triangleCount = " + str(len(triangles))) print(" .triangleCount = " + NAME.upper() + "_TRIANGLE_COUNT")
print("};") print("};")
if GUARDS: if GUARDS: