Multiple vertex buffers and index buffers

Started by
13 comments, last by nickwinters 20 years, 1 month ago
Yes that''s fine. That won''t cause you any problems.
Advertisement
Now I need to figure out how to use multiple meshes. Any sample code?

Thanks.

-Nick
It really depends on how you''re storing the meshes. The basic idea is something like this:

SetStreamSource(0, mesh1VB, 0, sizeof(...))
SetIndices( mesh1IB );
SetFVF(...);
SetTransform(D3DTS_WORLD, &matMesh1)
DrawIndexedPrimitive(....)

SetStreamSource(0, mesh2VB, 0, sizeof(...))
SetIndices( mesh2IB );
SetFVF(...);
SetTransform(D3DTS_WORLD, &matMesh2)
DrawIndexedPrimitive(....)

.
.
.

If you''re using .x files, this can be made a little easier but you get the idea. You use a different transformation matrix for each mesh in your world so you can move them around.

neneboricua
Doing multiple passes is by far the easiest way of doing it, just watch how many you do cus things will slow down if you start to do loads.

d3ddevice->Clear (gibble gabble)

d3ddevice->BeginScene()

//Draw Terrain
d3ddevice->SetIndices (indexbuffer(0))
d3ddevice->SetStreamSource (vertexbuffer(0), len(vertex))
d3ddevice->DrawIndexedPrimitive (gibble gabble) //Pass 1

//Draw Buildings
d3ddevice->SetIndices (indexbuffer(1))
d3ddevice->SetStreamSource (vertexbuffer(1), len(vertex))
d3ddevice->DrawIndexedPrimitive (gibble gabble) //Pass 2

d3ddevice->EndScene()

d3ddevice->Present (gibble gabble)

Of course the gibble gabble bits are the parameters I can''t remember.

What it does may not be strictly correct but of course it works and it''s easy to understand

Hope that helps

Matt
Doing multiple passes is by far the easiest way of doing it, just watch how many you do cus things will slow down if you start to do loads.

d3ddevice->Clear (gibble gabble)

d3ddevice->BeginScene()

//Draw Terrain
d3ddevice->;SetIndices (indexbuffer(0))
d3ddevice->;SetStreamSource (vertexbuffer(0), len(vertex))
d3ddevice->SetVertexFormat (D3DFVF_CUSTOMVERTEX0);
d3ddevice->;DrawIndexedPrimitive (gibble gabble) //Pass 1

//Draw Buildings
d3ddevice->;SetIndices (indexbuffer(1))
d3ddevice->;SetStreamSource (vertexbuffer(1), len(vertex))
d3ddevice->SetVertexFormat (D3DFVF_CUSTOMVERTEX1);
d3ddevice->;DrawIndexedPrimitive (gibble gabble) //Pass 2

d3ddevice->EndScene()

d3ddevice->Present (gibble gabble)

Of course the gibble gabble bits are the parameters I can''t remember.

What it does may not be strictly correct but of course it works and it''s easy to understand

Hope that helps

EDIT - Oops, sorry. Posted it anonomously and couldn''t edit it. Could a moderator delete the previous post please?
EDIT - Forgot the Vertex format.

This topic is closed to new replies.

Advertisement