Sign in to follow this  
sipickles

Accessing data in a vertex buffer, thru an index buffer

Recommended Posts

Hello, My terrain engine uses one big heightmapped vertex buffer. This is then 'sectorized' in the index buffer, to create concurrent block of indices referring to one sector of terrain. I need to find the heightest point of each sector tho. During the vertex buffer sector, the sectors have not been created, so it can't be stored then. Ideally, I'd be able to check the height of each vertex referred to be a particular index in the indexbuffer as it is being built.... Then the greatest one for each sector can be stored! How would I go about this? Thanks Simon

Share this post


Link to post
Share on other sites
Something like:


Lock_Vertex_Buffer
For( Each Sector )
{
Current_Maximum = -99999
Lock_Sector_Index_Buffer
For( Each Index In Buffer )
{
if( VertexBuffer( index ).height > Current_Maximum )
Current_Maximum = VertexBuffer( Index )
}
This_Sector.Maximum_Height = Current_Maximum
}


Given that your vertex buffer contains the height data you're going to have to use the index data to look up the information... the rest should fall into a fairly simple algorithm such as the one I typed out above.

Obviously the one above isn't gonna be particularly quick for a large data-set, but for a pre-process/load-time function it shouldn't matter too much.

hth
Jack

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this