Advertisement Jump to content


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


HOW: Determining Drawing Primitive types

This topic is 6333 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well I''m making some progress in my attempt to learn the basics of 3D programming. I can create instances of objects and move them around and everything. My question is, and I''m afraid this is Direct3D-centric, how do I figure out what primitives (strips, fans, sets) I am using to draw an object? See, Direct3D has a helper mesh object that has a DrawSubset() method which I use to draw the mesh. What about objects I create on my own? Will they ALWAYS be triangle strips, fans or sets? How do I, in my model or mesh, determine what calls I should be making for drawing an object? Do I have an array of vertices that store vertex data but also store primitive transitions? This obviously isn''t just a Direct3D issue - OpenGL has different triangle primitives as well. I can''t image this is hard coded; the data has to come from model loading, but can someone shed some light on this? - Sphet

Share this post

Link to post
Share on other sites
Who else than you knows how your data is arranged..
It's quite simple: you have vertex data for a vertex buffer and indices to theses vertices in your index buffer. Now it's up to you to fill the index buffer, you can arrange these indices in a way that they match the available primitive types.

Whenever possible, favor strips or fans over sets as the latter needs three times more data. Unfortunately your model data might come as a triangle set, and it's a non trivial task to convert them to triangle strips. Nvidia has a tool for this task on their page.

You might encounter the problem that using triangle stripes does not allow for all shapes (e.g. rendering 2 separate surfaces with one vertex buffer shot). The solution is to include som "degenerate" vertices that lead to nothing rendered and hence allow for placing your magic pencil at a new position.

- thomas

Edited by - Renus on September 11, 2001 4:52:16 AM

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
I believe ID3DXBaseMesh uses triangle list as its primitive. So unless you are filling your own vertex buffer and render them using DrawPrimitive() you''ll have to stick with using triangle list for D3DXMesh.

Usually models are exported from a modelling software (like 3d s max, maya, lightwave, milkshape, etc) to a certain file format. Some capable of exporting models to various primitives types (strips, fan, etc) but mostly export to triangle list..

Share this post

Link to post
Share on other sites
This confused me alot too when i first started programming 3d, and its not DX specific. OpenGL has triangle fans, strips, index arrays also (it also has compiled display lists, which DX doesn''t )

Basically, you pick whatever primitive your model comes in. If you are rendering a Quake MD2 file, you''ll probably use triangles. If you are doing terrain, you might want to use triangle strips. If you are doing a skydome, you do a triangle fan for the very top, and then a bunch of triangle strips for each of the lower levels.

You''ll get the hang of it with experience. Try to pick whichever format your model naturally comes in.

Keep in mind that strips and fans are signifigantly faster than other methods. There are utilities to redo your models in terms of strips and fans ( However, don''t go crazy with this right now. After you game is mostly done, that is the time to start worrying about performance optimizations like converting all your models to triangle strips. Don''t optimize too early. You''ll waste your time.

So in summary, use whatever primitive your model naturally comes in, with preference for strips/fans. (but don''t force it, until your whole game is almost done)

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!