Skip to content
Snippets Groups Projects
Commit ffee4ae8 authored by Halvor's avatar Halvor
Browse files

Rewrote exporter to flip uvs on the "v-axis", as openGL reads textures that way

parent bf326c11
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -4,7 +4,13 @@ import bmesh
# input
scale = 1
#Just comment out the one not in use
workdir = "../assets/models/"
# workdir = "C:/Users/Halvor/CMakeBuilds/621c328c-e411-0639-97bb-a40cd0883fa6/build/x64-Debug/assets/models/"
material = "INSERTMATERIALNAMEHERE"
shader = "INSERTSHADERNAMEHERE"
# @doc https://blender.stackexchange.com/questions/45698/triangulate-mesh-in-python - 21.04.2018
def triangulate(obj):
......@@ -32,8 +38,8 @@ def writeVertices(outfile, vertices, uvs):
vc.normal[0],
vc.normal[1],
vc.normal[2],
uvs.get(vc.index, [0,0])[0],
uvs.get(vc.index, [0,0])[1],
(uvs.get(vc.index, [0,0])[0]),
(1-uvs.get(vc.index, [0,0])[1]),
255, 255, 255, 255))
......@@ -68,7 +74,7 @@ if __name__ == "__main__":
uvDict = {}
loops = mesh.loops
active_layer = mesh.uv_layers.active
active_layer = mesh.uv_layers[0]
if active_layer:
uv_layer = mesh.uv_layers.active.data
......@@ -82,17 +88,17 @@ if __name__ == "__main__":
print("Active name:", active_object.name)
print("Vertexcount: ", len(vertices))
print("TriangleCount: ", len(polygons))
print("Outputfile:", active_object.name+".yml")
print("Outputfile:", workdir + active_object.name+".yml")
outfile = open(active_object.name+".yml", "w")
outfile = open(workdir + active_object.name+".yml", "w")
writeVertices(outfile, vertices, uvDict)
outfile.write("\n")
outfile.write("meshes: 1\n");
outfile.write("mesh: blendermesh\n")
outfile.write("material: default\n")
outfile.write("shader: default\n")
outfile.write("material: " + material + "\n")
outfile.write("shader: " + shader +"\n")
writeTriangles(outfile, polygons)
outfile.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment