feat: added the ability to render whole model

This commit is contained in:
2025-11-13 13:47:59 +01:00
parent f8ffb9c0b3
commit e370c1d0c3
6 changed files with 123 additions and 22 deletions

40
parseObj.py Normal file
View File

@@ -0,0 +1,40 @@
# Open the file in read mode
file = open("test.obj", "r")
# Read the entire content of the file
content = file.read().split("\n")
file.close()
startVerts = 0
verts = []
for index,line in enumerate(content):
if line[0] == 'o':
startVerts = index + 1
content = content[startVerts:]
break
for index,line in enumerate(content):
if "vn" in line:
endVerts = index
verts = content[:endVerts]
content = content[endVerts:]
break
startFaces = 0;
faces = []
for index,line in enumerate(content):
if line[0] == 'f':
startFaces = index
faces = content[startFaces:-1]
break
verts = ["vec3(" +",".join(vert.split(" ")[1:4]) + ")" for vert in verts]
faces = [ ",".join([str(int((d.split("/")[0])) - 1) for d in face.split(" ")[1:4]]) for face in faces]
out = "#include \"model.hpp\" \n const model testModel({" + ",".join(verts) +"},{" + ",".join(faces) + "});"
with open("testModel.hpp", "w") as f:
f.write(out)
print(out)
# Close the file