#### Archived

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

# Indexed Primitives and D3DXMeshes with VertexBuffers

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

## Recommended Posts

Hi, I followed the Directx 9 SDK tutorials ages ago and now ive come back to the vertex buffer parts i dont understand. What i want to do, create a cube with each side being a certain density of triangles and each side capable of having its own tecture. Dont get me wrong i am nifty with meshes, but the problem that arises is now that i understand that in order to have one vertex buffer holding a whole cube, and then be able to render each face separately, i need to drawindexed primitves. I want to be able to rotate the enitire cube about any axis and for the cube to be scaleable. It is clear that having separate VB''s for the faces is slow but also very complicated to keep the faces together when transforming and rotating them. I havent figured out how to index the vertices stored in the mesh vertex buffer. Can anyone help please? ACE

##### Share on other sites
Suppose you have 6 vertex buffers, each with 100 vertices. Suppose you have indices for these 6 vertex buffers, where the indices go between 0 and 99 (i e, your list might look like: 0, 1, 3, 3, 1, 2, 3, 2, 5, 5, 2, 4, ...)

You can turn this into one vertex buffer and six different lists by concatenating the data for each buffer. The index list for each is adjusted based on where in the vertex buffer the data ends up. Face 0 is not adjusted, Face 1 has all its indices adjusted by 100 (so it''s 100, 101, 103, 103, 101, 102, ...); face 2 has all its indices adjusted by 200 and so forth.

I don''t understand why scaling/rotating these things would get messy. You do all your scaling, translation and rotation using the WORLD matrix; the actual data doesn''t change. Just set up the matrix you want. If you want the same matrix for multiple buffers, just set the same world matrix for each of them.

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633654
• Total Posts
3013170
×