Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
vertices, faces = [], []
for line in open("teapot.obj"):
if line.strip(): # not an empty line
line = line.split()
if line[0] == "v": # is a vertex? In the form "v x y z [...]" where x y z are float
vertices.append(map(float, line[1:])[:3]) # we want first three axis
elif line[0] == "f": # is a face? In the form "f v1[/t1/...] v2[...] ... vN[...]
faces.append(map((lambda x: int(x.split("/")[0])), line[1:])) # we only want vertex index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment