Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- obverts = bpy.context.active_object.data.vertices
- vertString = ""
- vertString += "vertices = new Vector3[]\n{"
- for vertex in obverts:
- vertString += "\n\tnew Vector3 ("
- vertString += str(round(vertex.co[0],5))
- vertString += "f, "
- vertString += str(round(vertex.co[1],5))
- vertString += "f, "
- vertString += str(round(vertex.co[2],5))
- vertString += "f),"
- vertString = vertString.rstrip(',')
- vertString += "\n};"
- obtris = bpy.context.active_object.data.polygons
- triString = ""
- triString += "triangles = new int[]\n{"
- for tri in obtris:
- if len(tri.vertices) > 3:
- raise RuntimeError("You forgot to triangulate the mesh! Go into edit mode, select all, and hit CTRL+T")
- triString += "\n\t"
- triString += str(tri.vertices[0])
- triString += ", "
- triString += str(tri.vertices[1])
- triString += ", "
- triString += str(tri.vertices[2])
- triString += ","
- triString = triString.rstrip(',')
- triString += "\n};"
- file = open('D:\\Libraries\\Documents\\Unity Projects\\RESTOFPATH\\meshData.txt', 'w')
- file.write(vertString + "\n\n" + triString)
- print("Export Successful!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement