Sign in to follow this  
d1223m

another octree question

Recommended Posts

hi, im trying to make a level exporter. my plan is to make an octree with all the polygon data stored in the leaf nodes. so far so good. iv got this working with simple glVertex calls. next im thinking i should put all the vertex/texcoord data into a vertex array ( and then VBO ). so i can store an array of vertex index's for each polygon instead of the actual vertex. now iv read a lot about state changes being bad. at the moment i have a material id for each polygon. this is where i start to get confused. should i go thru my octree collecting polygons to draw without actually drawing them, sort them by the material and then draw them? perhaps sorting that many faces would be bad. as i said, i get confused here as whats best. any help much appreciated dunk

Share this post


Link to post
Share on other sites
What I've done is create an array of 'all' triangles in the gameworld. These are sorted first on material and secondairy on octnode. In my culling structure (which might be an octtree but is a combination of an octtree and a POV structure) I have stored references to the elements of the array.

Each frame I find the visible triangles (using the culling structure) and mark the visible triangles in the array with the current framenumber.

Then I loop through the array finding a 'batch' of triangles with the same material (because of the sorting they are allways next to each other) and set the material and then draw the batch.

It is actually a bit more complex than this because I do not really store the triangles but I use indexbuffers.

Cheers

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