Skip to main content
gamedev.net
🔒 Locked

Multiple Models

Started by Ksingh30 Apr 13, 2005 at 12:24 AM 5 replies 700+ views
Original Post
Ksingh30
Ksingh30
ok lets say im loading some model in .X format and Im using D3DXLoadMeshFromX(); ok once I load the mesh, how can I dsiplay that model sever times in different locations.
Psyian
Psyian


The simplest way is just set your world matrix, draw it, change your world matrix and draw it again.
Ksingh30
Ksingh30
well no I want it to be drawn several times at the same time. so for example if the mesh was a car. I want there to be 5 cars draw.
c t o a n
c t o a n
I'm not sure how you would render the same mesh 5 times using a single draw call, but if you draw the mesh 5 times using 5 different world matrices before Present'ing the device, you'll see 5 meshes.
Chris PergrossiMy Realm | "Good Morning, Dave"
Ksingh30
Ksingh30
I just realized that, Thank you
Supernat02
Supernat02
When you start to optimize your code, you may create a vertex buffer and/or index buffer that holds multiple objects. You would update the vertex buffer to hold all 5 meshes with the world matrices already applied to each vertex. Then you only have to call DrawPrimitive one time. This will most likely be faster than calling DrawPrimitive 5 times and using the world transform to move it. You would want to have the vertices translated only once if they are going to always persist at the same location in the world.
Chris ByersMicrosoft DirectX MVP - 2005
circlesoft
circlesoft
Quote:
Original post by Supernat02
When you start to optimize your code, you may create a vertex buffer and/or index buffer that holds multiple objects. You would update the vertex buffer to hold all 5 meshes with the world matrices already applied to each vertex. Then you only have to call DrawPrimitive one time. This will most likely be faster than calling DrawPrimitive 5 times and using the world transform to move it. You would want to have the vertices translated only once if they are going to always persist at the same location in the world.

If you aren't already familiar with it, this technique is referred to as batching. It's probably the most effective technique for combating the biggest performance-related drawback of graphics today: CPU-boundness because of Draw calls. Here is an awesome slidedeck on the issue.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.