Archived

This topic is now archived and is closed to further replies.

Doener

MilkShape3D Export with Triangle-Strips

Recommended Posts

Ok, I've written a loader for MilkShape3D's ms3d Format, and can render it correctly, but it isn't very fast since all data are seperate triangles. Can anyone help me in writing a Export Plug-In that writes a file which consists of triangle-strips instead of seperate triangles? I can't seem to find a way to convert from triangles to triangle-strips. What's the trick? Or does anyone know a good tutorial? Or a paper on the topic? Edited by - Doener on January 10, 2002 10:23:38 AM Edited by - Doener on January 10, 2002 10:41:40 AM

Share this post


Link to post
Share on other sites
I''m in exactly the same position (except I export to my own format).

The best I can think of is to create a seperate app to optimise the models into strips/fans. It''s just a bit of triangle picking and grouping but it''s not the best solution.

Another idea I had was to name the meshes in milk to a fixed protocol, such as "FAN_meshname". But I would have to make the decision that this mesh can be created by a tri-fan, and the exporter would have to find a way of arranging the data correctly. (for you, you''re loader could do the sorting, but then it would happen at run-time, every time).

Cheers

Matt



Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Organizing arbitrary triangles into efficient triangle strips is an NP complete problem, I believe. This is why your video card and drivers don''t strip triangles for you.

Share this post


Link to post
Share on other sites
Maybe my questions wasn''t that clear.
I actually want to create an export-plugin that uses its own dataformat.
I know that the driver/GPU doesn''t perform the optimizations for me, why else should I try to optimize it myself?
My problem is to find a way to create the triangle-strips/fans from the seperate triangles. Since MD2 files use triangle-strips/fans there has to be a way to do it, since MilkShape has a MD2-Export-PlugIn.

I hope now my problem is more visible

Share this post


Link to post
Share on other sites
Ask on the milkshape forum about how Mete made the md2 exporter, but I have a suspicion it's not as complex (or optimal) as you think it is.

There is going to be some element of manual labour in optimising these models.


Edited by - 3dmodelman on January 10, 2002 11:14:09 AM

Share this post


Link to post
Share on other sites
There is a good article on the subject here:

http://www.codercorner.com/Strips.htm

It comes with source code. nVidia has also released the code to their NVTriStrip library, which you can get from their Developer Relations site:

http://developer.nvidia.com/view.asp?IO=nvtristrip_v1_1

Before investing too much time, you should realize that you probably won''t see big gains, and things may actually get slower, since each strip must be built from triangles with the same material. In real-world use, this usually leads to lots of small strips, which translates into lots of DrawPrimitive calls (if you''re using Direct3D.) You''d probably be better off just using indexed triangle lists, which are fairly simple to generate (MS3D may even store its triangles that way, I don''t really know.) Then, reorder your vertex/index buffers to optimize your DP calls (again assuming you''re using D3D.)

Hope that helps.

Share this post


Link to post
Share on other sites
Thanks for the links, I''ll check them out later, but I''m pretty sure they''ll help me.

For that speed aspect, I think I''ll gain performance, I don''t know anything about D3D but with OpenGL I can assign different materials to each vertex in the triangle strip (as I remember, I''m a bit rusty ;-) ), so I should be able to gain some performance, why else should ID have chosen triangle strips? Only thing I can''t change each vertex is the actual texture, but when I use just a single texture that shouldn''t be any problem, since I can change the texture coords.

Share this post


Link to post
Share on other sites
Mainly what I was trying to say is that stripping is a fair amount of work to implement, and you might not see the gains you expect. Instead, you might want to focus on changing the way you do your rendering, ie. use vertex arrays and/or VAR instead of using glVertex3f/glTexCoord2f/glNormal3f for each vertex. Indexed lists will get you very acceptable performance, and require signifigantly less time to generate and use. Once again, this is from my experience, and may not be applicable in your case. Since Milkshape is designed for modelling fairly low-poly objects, you probably won''t be running across bandwidth issues, which is one of the two main benefits of strips. The other benefit is cache coherency, which you can also get by reordering your vertex and index buffers for indexed lists. A third possible benefit is reduced memory requirements. Anyway, in my opinion, the benefit probably isn''t worth the effort.

Share this post


Link to post
Share on other sites