Jump to content
  • Advertisement


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


Indexed Primitives and D3DXMeshes with VertexBuffers

This topic is 5295 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

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 this post

Link to post
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.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!