Wednesday, July 16, 2008

Extracting Vertices

The parser turns out to be even easier to use than I expected.  The attached python script will give all the vertices in order to be passed to OpenGL for rendering model zero (the static portion of the map).  This is of course a very dumb way to render the map, not taking any advantage of BSPs and visibility information, but it should do for a test render.  I hope to get a test render working in the next couple of days, but it may take a while given my general lack of OpenGL experience.




def get_vertices_from_model(ibsp, model):
vertices = []
face = ibsp.models[model].face
nfaces = ibsp.models[model].nfaces
for f in range(face, face+nfaces):
type = ibsp.faces[f].type
if type not in [1,3]:
continue
vertex = ibsp.faces[f].vertex
meshvert = ibsp.faces[f].meshvert
nmeshverts = ibsp.faces[f].nmeshverts
for m in range(meshvert, meshvert+nmeshverts):
vertices.append(ibsp.vertices[vertex + ibsp.meshverts[m]])
return vertices

No comments: