View Full Version : Quake Models

11-26-2000, 10:08 AM
My engine supports md2 loading and animating, I'm trying to convert my engine to triangle strips and I got a question:
The vertices in the md2 format doesn't seem to be organized in a way that you could easly find the triangle strips so I have to find all the connected vertices myself. Why isn't it saved in the first place as triangle strips - does quake engine computes this every run also?

11-26-2000, 03:18 PM
IIRC there is info about strips in the file . have a lok at the milkshake website for a md2 loader source code also one of mark kilguard's demo's on the nvidia site uses strips.
BTW not 100% sure about the accuracely of this but i know it is possible :O)

[This message has been edited by zed (edited 11-28-2000).]

11-27-2000, 11:20 AM
You can generate strips out of any triangle
mesh with a fairly trivial (but slow)
algorithm and some careful coding.

Generating some "optimal" set of strips is
substantially (and I mean MUCH) harder.

Here's the algorithm:

1. un-mark all triangles
2. pick an un-marked triangle and append it to a new strip; if there is none, goto 8.; make the new strip the current strip; make this triangle the current triangle
3. mark the current triangle
4. find the next un-marked triangle which shares the two last vertexes of the current triangle; if none, goto 7.
5. make that next triangle the current triangle, and append its third vertex to the strip
6. goto 3.
7. remember the current strip; goto 2.
8. congratulations, you're done!

Also, you may need some re-ordering logic
for vertexes to find triangle matches in all
the places there are any (steps 4 & 5).
Remember to preserve winding order (and that
tristrips flip-flop the winding order
compared to the base triangles).

Ideally, because of the O(n2) nature of this
algorithm, you'd want to run this in a
"compiler" step, not while actually loading
the mesh. Perhaps you can cache the tristrip
version in some other file, and re-use that
when the user re-loads the same mesh?

Now, if someone has a good way of generating
bone & skin data out of an animated md2 mesh,
I'd be *REALLY* interested in hearing about
it :-)

[This message has been edited by bgl (edited 11-27-2000).]

11-27-2000, 03:09 PM
The triangles in Quake2 MD2 files are already in strip or fan order. You only need to convert the triangle fans to strips.

11-27-2000, 10:44 PM
Are there any documents on Quake's mod file format?