View Full Version : m15 question
Mike, I hope you can answer this as Petr is away this week as you know. I was wondering, if I tried to write a m15 importer, how would I use the vertex data to make it into a model? Do you know which type of equate Petr uses to build the polygons with tbgl_BeginPoly?
Which should I use? :
%GL_TRIANGLES
%GL_TRIANGLE_STRIP
%GL_QUADS
%GL_QUAD_STRIP
%GL_POLYGON
My Guess is polygon, but just wanted to make sure. I would be importing the model in opengl using either Delphi or c++, if that helps. THanks.
Michael Hartlef
18-06-2007, 12:21
The question between triangle/quad/polygon is ruled by the polygon stop flag in the M15 file format. Of course, you could dived it into triangles all the time, if you know the right algo.
In which format are you storing the datas for a model inside your delphi app? That should give you the answer anyway. If you plan on importing over file formats, then you might need several ways to store them or generally store them as triangles.
The strip versions are mostly used for speed reasons. But I don't have enough knowledge about this to tell you when to use strips and when not.
If you use polygons, then you are save, as they can easily have 3, 4, 5 sides.
My guess for TBGL is that Petr uses Polygons as a M15 model can have triangles and quads.
THanks Mike, just trying to understand these file formats better and thought if I could write an import of m15, it might be the easiest way to start to learn.
Thanks for the information!
Petr Schreiber
20-06-2007, 19:32
Hi kryton,
till version 0.2.0 of TBGL, all models were interpeted using %GL_POLYGON. This is general, but not very optimized way.
So ... TBGL now optimizes on run much better and chooses best %GL_* mode to render. I recommend to keep with 3 and 4 vertex polys, but you can still use polygons with no limit for vertices. But then we will fall in slower %GL_POLYGON.
Why is %GL_POLYGON slower ? Because TBGL has to close each poly in glBegin / glEnd pair, while %GL_QUADS and %GL_TRIANGLES can go as mini series inside one big glBegin / glEnd as long as they use same texture.
STRIP versions are really nice, but they are not usable in all cases ( mostly in very rare and specific cases ), so I don't use them ( except for TBGL primitives ) now.
Hope this answers your question :),
Petr
Thanks Petr, yes that explains it really well.
As I try to make the importer I am sure I will ask more questions.