Skip to content

Instantly share code, notes, and snippets.

@philippTheCat
Created May 26, 2011 20:44
Show Gist options
  • Save philippTheCat/994035 to your computer and use it in GitHub Desktop.
Save philippTheCat/994035 to your computer and use it in GitHub Desktop.
class object:
faces = []
def __init__(self):
pass
def addFace(self,face):
self.faces.append(face)
def draw(self):
for i in self.faces:
i.draw()
class importer():
vertexes = []
faces = []
object = None
def __init__(self):
pass
def importObj(self,file):
objraw = open(file,"r")
for i in objraw:
self.__objParseLine(i[:-1])
obj = object()
for i in self.faces:
obj.addFace(i)
return obj
def __objParseLine(self,line):
linesplit = line.split(" ")
if linesplit[0] == "v":
curvertex = vertex(linesplit[1],linesplit[2],linesplit[3])
self.vertexes.append(curvertex)
elif linesplit[0] == "f":
curface = face()
print len(linesplit[1:]),linesplit[1:]
for i in linesplit[1:]:
curface.addVertex(self.vertexes[int(i)+1])
#curface.vertexes
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment