Skip to content

Instantly share code, notes, and snippets.

@williame
Created September 21, 2014 16:19
Show Gist options
  • Save williame/5799b75baf6bff3137ba to your computer and use it in GitHub Desktop.
Save williame/5799b75baf6bff3137ba to your computer and use it in GitHub Desktop.
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