Jump to content
  • Advertisement
Sign in to follow this  
noatom

How would you approach this?

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

I need to load heightmap data and split it into meshes.

 

If each mesh can contain x vertices and y indices,how would you go about extracting the right vertices and calculating the indices?

Share this post


Link to post
Share on other sites
Advertisement

first, you may want to create your meshes base on texture used. i actually use 4 interleaved meshes per 300x300 ground mesh chunk, one for each ground texture used.

 

then, you want to start going through the list of triangles formed by your heghtmap data, and for each one that uses the texture of the mesh your're creating, add it to the vb and ib.  when the vb and ib fill up, switch to the next vb and ib. repeat for all triangles that use the texture in question. so the basic algo is:

 

for each texture

     {

     for each triangle that uses the texture

             {

             add to vb and ib

             if vb and ib full

                    {

                    next vb and ib

                    }

            }

     }

 

the result will be 1 or more sets of vb's and ib's for each texture used.

 

if you want to put them all in one big vb and  ib, and then bind that once, then bind a texture, draw a range of indices, then bind a new texture and draw a second range, you don't need to sort on texture:

 

     for each triangle

             {

             add to vb and ib

             if vb and ib full

                    {

                    next vb and ib

                    }

            }

Edited by Norman Barrows

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!