Jump to content
• Advertisement

Terrain drawing question (list vs strip vs.. mesh..)

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

Well, I'm startin my first 3d project thingamajig to learn this stuff.. and I'm drawing a terrain thing. If I get upwards of 25k triangles, things start getting too slow. I store an array of vertices and slope vectors so I can have stuff bouncin around the terrain fairly realistically etc. Right now I use a triangle strip, and draw the terrain one strip at a time with successive calls to DIP. I do this cuz I can't figure out how to put the whole darn terrain into one strip or fan.. Should I just use a huge list of triangles then?? That'd be a lot of indices, but hopefully for a performance gain. Another idea was to use a flat mesh, then fill in Y values, vertice normals for lighting, and my slope vectors, as they do in the d3d billboard example. Maybe meshes are optimized and can draw faster as well? Then there's this thing called "BSP" or even "scene graph" that I frankly don't want to get into at this time.. So any tips would be handy and helpful! Thanks!

Share this post

Share on other sites
Advertisement
Yeah you should most definetly batch a bunch of triangle lists together and draw them in one go. And don't think scene management has to be difficult. It can be, but in this case it can be pretty easy. Just look into a thing called quadtrees, and that should be enough for your terrain rendering.

The basic idea is to divide a flat plane into 4 nodes, and divide each nodeinto 4 more pieces and etc... You end up with a hierchical list of small nodes (a tree of nodes, each node with 4 children). Check each node against the view frustum (which by the was is a very simple process) and add all the triangles in that node to a list, when you've traveresed the entire hierarchy, draw all the triangles in the list you created. This will not only give you a performace boost, but will aloow for much more larger terrains.

Share this post

Share on other sites
Thanks for the reply! I think I was lumping such a quadtree into the BSP category in my mind.. but I think I could handle that :P You'll have to tell me how to batch the triangle lists though.. Thanks again!

Share this post

Share on other sites
Quote:
 Original post by n0obThanks for the reply! I think I was lumping such a quadtree into the BSP category in my mind.. but I think I could handle that :P You'll have to tell me how to batch the triangle lists though.. Thanks again!

Well, each node would have a list of indices that the node contains. As you traverse the tree - determining which nodes to draw and which to not, you concatenate all the lists of the drawable nodes. You end up with one big list of indices that index into the vertex buffer. Then you DrawIndexedPrimitive on all those suckers.

so roughly speaking, something like:

void build_list( list& ilist, node* n ){  if( n )  {    if( n->is_leaf() && is_in_view_frustum( n ) )    {      ilist.add( n->get_index_list() )    }    else    {      build_list( ilist, n->get_child_1() );      build_list( ilist, n->get_child_2() );      build_list( ilist, n->get_child_3() );      build_list( ilist, n->get_child_4() );    }  }}

Share this post

Share on other sites
So, it will be a triangle list then?  Blart, I guess you said that already lol [/edit] And I create the index buffer each loop I guess... Is there a nifty D3DX function for testing if something is in the view frustum? It seems that there should be, but I can't find anything in the help :/ Thanks again!

Share this post

Share on other sites
Hey woot I found an article on this very thing >_<
http://www.flipcode.com/articles/article_frustumculling.shtml

Share this post

Share on other sites

• Advertisement
• Advertisement

• Popular Contributors

1. 1
2. 2
3. 3
frob
12
4. 4
5. 5
• Advertisement

• 13
• 14
• 65
• 14
• 15
• Forum Statistics

• Total Topics
632130
• Total Posts
3004286

×

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!