Order of Vertices in a mesh object

Hello,

It's been a while since I played with Blender - kinda got wrapped up in life, and other projects ;)  I've recently started learning OpenGL, and while I'm a total newbie there, too, I thought it would be cool to start putting together an exporter for my existing models, and toy with them using OpenGL.  For starters, all I'm really concerned with is the geometry.  Materials, texture maps, that sort of thing - I fully gather there's no exact 1:1 correspondence between blender and raw OpenGL, and I'll kinda tackle one problem at a time.  For right now, all I'm really wondering is, when you iterate through the vertices in a Mesh object, what order are those in?  Just the order they were created, or would it correspond to GL_QUADS, GL_TRIANGLE_STRIPS, or something along those lines?  It also seems initially feasible to iterate through the faces, and render them as GL_POLYGONS, though I haven't really tested that theory yet.  I also understand that there's been some success with using lib3ds, and the 3DS export script for Blender, but I'd kinda prefer to take the 'roll your own' approach, because it would help with comprehending OpenGL itself.  Given my n00bishness, it's entirely possible I'm asking the wrong question here, but any pointers, references to documentation I wasn't able to find, anything along those lines would be extremely helpful, thanks :)

If you just plain iterate through a mesh’s vertexes, i.e.


for v in me.verts:
     # do something

they come out in the order they are added to the mesh.

If you iterate through the vertexes of a face, however, they come out either in clockwise or counterclockwise fashion (can’t recall which, shouldn’t be too hard to figure out ;)) that should be suitable for use with OpenGL.

As for pointers, I’d just start playing around with the OpenGL redbook open, perhaps the NeHe tutorials on gamedev, and theBlender python API (you know python right, if not add the python reference ;)).

Thanks a lot for the reply. At least in terms of the current experiment, if you will, it looks like iterating the faces is going to be the best approach. From what I can see, there are going to be some restrictions on the mesh topology for that to work properly, but they appear to be the sorts of things that are just good practice anyway, and I don’t think my existing models, other than my very, very early efforts are going to present much of a problem. I’ve been poring over Nehe as I’ve been playing around, I dig how they’ve got sample code for just about any platform you might be fiddling around with. I hadn’t, for some reason, actually picked up the red book, though I’d seen a few billion references to it - somehow it just never lit up on my radar, so I’ve been reading over that while I’m supposed to be working. :smiley: I’m curious how this method is going to perform - something about it seems inefficient, but as I play around with OpenGL, I continue to be amazed at how much you can throw at a decent GPU, so it may be workable :smiley: Thanks again for the resources / reply. It was most helpful.