Jump to content
  • Advertisement

Archived

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

SoaringTortoise

Caching Mesh output?

This topic is 5219 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, At the moment my game (DirectX8.0 based) is drawing a terrain that is made up of a vertex buffer for the terrain and then a bunch of meshes for decoration (walls, paving slabs, etc). The problem is that some of the meshes are extremely low polygon (<20 polys), but I''m obviously wasting a huge amount of time throwing these to the video card each frame. For example, if a simple scene contains 40 or so paving slabs then I''m using 40 draw calls (at least, more if the meshes have more than one texture) to put just 800 polys into the pipeline. Of course, each mesh is drawn with its own world transform, and that just adds to the performance hit. Ideally I would like all static meshes to be stored in VB''s so that I can simplify the rendering pipeline. My idea for this is to create a couple of VB''s (one for each texture?) and then ''cache'' the meshes into the VB''s during the map-load routine so that I can use a simple drawprim to render them instead of all the worldtransform/draw-subset mallarky. Does anyone have any ideas for how I can go about doing this? Specifically: 1) How can I transform a MESH (not the world) to get the vertices in the right location and orientation 2) How can I get the mesh vertex information (after tranformation) into a vertex buffer Thanks, ST

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by SoaringTortoise
1) How can I transform a MESH (not the world) to get the vertices in the right location and orientation


To use the hardware to transform your mesh, you need to set the world matrix. This will transform your mesh into world space.
quote:
Original post by SoaringTortoise
2) How can I get the mesh vertex information (after tranformation) into a vertex buffer


This is a better question. If you know that certain parts of your world will never change position, then you can optimize them a bit by transforming the vertices that make up the static objects of your world into world space when your app loads.

Pseudocode to do this follows:

void Init()
{
for( each model in your world )
{
load the model.
lock the model''s vertex buffer.
transform the vertices into world space (you can use the functions D3DXVec3TransformCoordArray, and D3DXVec3TransformNormalArray to help you).
store these vertices (either in the original vertex buffer or in some other vertex buffer).
Unlock the model''s vertex buffer.
}
}

Now when your code goes to render these static objects, you no longer have to worry about setting a world transform because all of the geometry is already in world space. Now you can draw all of your paving slabs in one DrawPrimitive call (if they''re using the same material properties, textures, etc...).

Hope this helps,
neneboricua

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!