• ### Announcements

#### Archived

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

# Games, Vertex Buffers and Objects

## Recommended Posts

evolutional    1393

##### Share on other sites
RhoneRanger    100
Your question is quite simple, and you are on the right track. If you set the stream source, fvf, and indices, you can dran an indexed primitive as many times as you want!

pseudocode

Device->SetStreamSource(ModelBuffer);Device->SetFVF(ModelFVF);Device->SetIndices(ModelIndices);for(int i=0;i < NumMatrices; i++){   SetMatrix(ModelMatrix [ i ] );   Device->DrawIndexedPrimitive(TRIANGLELIST);}

EDIT: Stupid HTML

[edited by - RhoneRanger on July 7, 2003 12:39:55 PM]

##### Share on other sites
evolutional    1393
Thanks...

... so instead of creating a "standard" VB to display all the objects in my world I''d go:

[Pseudocode]

Create a normal VB for this

DISPLAY:
Number of models = 100
Create an index buffer of 100 * Size of model VB
Populate the index buffer with copies of the model VB (note: all models will be in the same position/rot/etc)
Then do as you say...
For each model that needs to be displayed
...apply relevant matrices
... draw

##### Share on other sites
Sort of but not really. You don''t need to create all those VB''s. Just create one, then prior to rendering each unit set the world transform rotation, translation and scale matrix to position the model you want to render. I could be wrong here, but I think that rendering models from VB''s is exactly the same as rendering Meshes in this respect. Feel free to search the forum for help on the matrix set up.

##### Share on other sites
evolutional    1393
In this example take model to be the same as mesh as in my engine a model is a collection of meshes that are all rendered in turn (and each mesh has it's own separate VB).

What I was thinking was:

For each scene, work out how many meshes are on show, allocate a large vertexbuffer to accomodate all the vertices...
... populate this with copies of the mesh VBs, rotating and translating each one in turn until you get to the end...
...Then display.

I guess I could (for optimisation) allocate the vertex buffer and only reallocate it if a mesh is removed/added to the scene.

Oh and I'm fine with world translation/rotation matrices (I think).

is my thinking on track? It seems logical to me

[edited by - downgraded on July 7, 2003 6:26:42 PM]