Jump to content
  • Advertisement

Archived

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

Big Boy Rees

Index Buffers??

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

Um, could someone give me a quick run down of what index buffers are? (referring to D3D 3dDevice) Im trying to load multiple meshes at different locations scaled to different sizes in vb 6.0 Though the only way I can do it is make an array of the D3Ddevice.. (I''m using sdk Tutorial 6 codeing) Which looping through every matrix setup and render causes alot of flashing. I just need to know yes or no, are index buffers used for 1 device to load multiple meshes.

Share this post


Link to post
Share on other sites
Advertisement
Index buffers hold indices into the array of vertices for a mesh. For example suppose you wanted to describe a cube with a straight vertex buffer. The vertex buffer would have 3 vertices for each triangle of the cube and there are 12 triangles in the cube. This gives you a total of 36 vertices.

Now using an index buffer we can reduce the number of vertices in the vertex buffer. How many vertices make up a cube? Well, there are 8 vertices in the cube but some are reused for multiple triangles. So how do we save memory by defining our vertices only once. The answer is index buffers. Index buffers are indicees into the vertex buffer. So say the first triangle of the cube is the first three vertices in the vertex buffer. This would mean your first three indices in the index buffer would be 0, 1, 2; which means this triangle is defined by the 1st, 2nd, and 3rd points in the vertex buffer.

Like I said before this is done to save space. If you only save indices which are shorts then you are saving space rather than storing the same vertices in the vertex buffer. Now, getting back to what you were asking, each mesh would most probably have it''s own vertex and index buffer. This is probably a good way to start out until you get used to using indexed vertex buffers.

Hope this helps.
-dizzy

Share this post


Link to post
Share on other sites
Now, I dont do d3d with VB.
So, just out of curiosity - what the hell is causing the flashing? Drawing multiple mesches at different locations should not cause any flash.


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share this post


Link to post
Share on other sites
Oh.. I think the flashings just cause I am setting the view matrix for 10 different 3d devices, then rendering them all. So as it renders each I get to see a mesh, then that dissapears and the next one appears. I really have no idea how to create lots of meshes in the same device without them all being affected by world transforms.

I can use a world matrix to scale, rotate, translate ..etc

And all my meshes are made at 0,0,0 in 3ds max R2

So translating works fine expcept it moves everything and I dont want that...

Share this post


Link to post
Share on other sites
You''re supposed to use a single D3DDevice for all your work, until you close that app you''re creating, that is...

Making sure your first transformation only affects the matching object should be done about like so: (Now I''m offering C-like pseudocode, I don''t know how the DX API works in VB)

Loop
set necessary render states

BeginScene()
Clear screen
SetTransform(World, FirstObjectMatrix)
FirstObject->RenderTransformed

SetTransform(World, SecondObjectMatrix)
SecondObject->RenderTransformed

...

EndScene()


Hope this helps.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!