Jump to content
  • Advertisement
Sign in to follow this  

Some help using quadtrees

This topic is 4724 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 am implementing a game that uses a heightmap for terrain. the heighmap is made up of independant quads(not strips). I want to use a quadtree to limit how much of the terrain is being drawn which im pretty sure they are good for. Now I have the basic priciple for building the quadtree down but im wondering what data I should store in quadtree. I have come to think of two options. Option 1 seems pretty easy to implement and that is directly storign vertex,normal and texcoords in the quadtree leaves and building an array of each from the leaves in view and just draw them with glDrawArrays. This seems pretty straightforward. Option 2 would be too store all my vertice/normal/texcoords in either an interleaved or seperate arrays and just index them in the quadtree and draw them with glDrawElements thus alleviating an extra copy in building the array to draw in option1. Seems harder to implement and im wondering if this is alot better than option one, or only marginally. Maybe im missing something tottaly and this istn a good idea? Any advice would be appreciated. Another question I have it how should I store other static objects that arent terrain? and how should I handle the moving objects, though I only plan for a few at this point I'd like to make this somewhat flexible. Edit: I moved this from the begginers forum. I removed the original post.

Share this post


Link to post
Share on other sites
Advertisement
Hi

What you seem to be implementing is a scene manager.
I would suggest you to think in terms of representing the scene data as part of sectors. You should divide the entire world into sectors which can be represented as quads. You can then build a quad tree and represent all the objects which come into this quad sector, So for each sector/quad check what scene objects are in the current sector...and then store it as a quad tree.
E.g. you have a terrain and some trees in your scene. Divide the entire world into different sectors/quads and then build the quad tree by filling in the information of what objects are in which sector. In this manner you should be able to build a scene manager to get a good result. I used it to represent my scene long time ago. I would suggect you also take a look at ROAM terrain generation. It is best for terrain generation and rendering.

Share this post


Link to post
Share on other sites
Forget ROAM, it is obsolete for most cases. Check out Chunked LOD. It uses a quad tree, but it has meshes in all the nodes, not just the leaves. The non-leaf nodes contain lower resolution meshes. Basically the algorithm works like this: Start at the root node. If the node is far enough away or it is a leaf, you draw it, otherwise you do this for each of its sub-nodes. Frustum culling can be easily included, too.

Share this post


Link to post
Share on other sites
All I really wanted was to do frustrum culling. Im just wondering if its esier better to use index buffer or just build an array of vertices from the quadtree... I guess ill just try both :D

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!