Skip to main content
gamedev.net
🔒 Locked

Index count

Started by Bimble Bob Feb 15, 2007 at 11:47 AM 3 replies 850+ views
Original Post
Bimble Bob
Bimble Bob
OK Given that I have a list of X vertices and I can add 3 vertices to this list at one time how can I calculate the number of indices and how should I store them? I know I'm being a bit vague but I can't think of anything else relevant to say. [Edited by - Dom_152 on February 16, 2007 10:30:19 AM]
It's not a bug... it's a feature!
xycsoscyx
xycsoscyx
It actually depends on a lot of things. The number of indices will always be directly related to the types of primitives you are renderng (while the number of vertices will not be constant). If you are using triangle lists, the number of indices will always be (NumFaces * 3), if you are using triangle fans, the number of indices will always be (NumFaces + 2), etc.

The whole point of using indices is that your vertex count is no longer directly linked to the number of faces being rendered. Adding three vertices doesn't really mean anything if you're using vertices (as just adding vertices doesn't add to the number of primitives until you actually index them).
Bimble Bob
Bimble Bob
So as I'm using Triangle lists what point is there in me using indices? Should I consider using fans instead?
It's not a bug... it's a feature!
Lord_Evil
Lord_Evil
Indices provide a way to reduce memory consumption and bandwidth requirements and to optimize transformations. The idea is to share vertices between faces, so that your vertex count is independent from your face count. You then only have to send a set of vertices, tranform them once (if caching occurs inside the driver) and build arbitrary numbers of triangles by indexing those vertices.

Using triangle strips or fans is considered the faster alternative. At least it would use less memory. A 10 by 10 terrain patch built of individual triangles (triangle list) has 600 indices, the same patch built with connected triangle strips (introducing some degenerated triangles to get the connection) has 238 indices, i.e. 362 indices less!

The problem comes when building strips or fans from your triangle lists. This is not always as trivial as building a strip for a patch of terrain.

If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
Bimble Bob
Bimble Bob
Am I right in assuming that 3D model formats such as .X or .3DS will contain index data within them? At the moment I have a std::vector array of void pointer which contains the vertices. The vertices are grouped by the material they use hence the use of the vector. The vertices are just structures with XYZ and colour and texture depending on the vertex type. So can I work out index data from my list of vertices or will I have to rely on the model file to give me that info?

[Edited by - Dom_152 on February 16, 2007 10:27:22 AM]
It's not a bug... it's a feature!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.