3 OBJ are wavefront object files. These are quite common and can be exported from a lot of 3D tools.
4 Only vertex information is read from the OBJ file, information about textures and normals is ignored.
6 http://en.wikipedia.org/wiki/Wavefront_.obj_file
8 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
11 from Cura.util import printableObject
13 def loadScene(filename):
14 obj = printableObject.printableObject(filename)
20 f = open(filename, "r")
26 vertexList.append([float(parts[1]), float(parts[2]), float(parts[3])])
28 parts = map(lambda p: p.split('/')[0], parts)
29 for idx in xrange(1, len(parts)-2):
30 faceList.append([int(parts[1]), int(parts[idx+1]), int(parts[idx+2])])
33 m._prepareFaceCount(len(faceList))
38 if i < 0 or i >= len(vertexList):
40 if j < 0 or j >= len(vertexList):
42 if k < 0 or k >= len(vertexList):
44 m._addFace(vertexList[i][0], vertexList[i][1], vertexList[i][2], vertexList[j][0], vertexList[j][1], vertexList[j][2], vertexList[k][0], vertexList[k][1], vertexList[k][2])
46 obj._postProcessAfterLoad()