Skip to main content
GameDev.net gamedev.net
🔒 Locked

Quad Tree

Started by steg Nov 6, 2004 at 8:31 AM 3 replies 400+ views
Original Post
steg
steg
Hi all, Say for simplicity sake I have a terrain of 4x4 quads (yes very small), now to start doing the quad tree I partition this into 4 quarters (shown with asterisks: ) : |/|/|*|/|/| |/|/|*|/|/| ******** |/|/|*|/|/| |/|/|*|/|/| Thus I now have 4 patches as such or to put it another way, 1 root node with 4 leaf nodes : Root leaf leaf leaf leaf Is this the right way of going about this ? Obviously I need to do the bounding box for each leaf. Thanks, Steve
If it isn't working, take a bath, have a think and try again...
steg
steg
Ok as nobody has answered as yet, something else I need to ask, as I store my bounding coordinates for each patch/node, do I also need to store a pointer to which index this references within my vertex buffer or do I store vertex information within the actual quad tree node ? At the moment I have a huge vertex buffer with all the terrain vertices in, I can draw from here if I know the index to start to draw from.

Sorry to sound stupid.

Steve
If it isn't working, take a bath, have a think and try again...
JohnBolton
JohnBolton
Quote:
Original post by steg
... Is this the right way of going about this ? ...

Yes. That is how the basic quadtree works -- each node is split into 4 equal sections, which are also nodes.
Quote:
Original post by steg
... do I also need to store a pointer to which index this references within my vertex buffer or do I store vertex information within the actual quad tree node ? ...

Without describing what you are trying to do and how your algorithm works, it is impossible for anyone to give a meaningful reply.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
pammatt
pammatt
Not sure if this is helpful or not but here you go. I store only references to patches in my quadtree.

I use one big vertex buffer (depending on the terrain size, but I am currently only targeting smaller terrains (257x257 - 1025x1025) so the one big vertex buffer is fine.

Each patch stores a start vertex. By doing this, I can re-use the index buffer for every patch.

Since the quadtree only stores references to patches, I traverse the quadtree, determine which patches are visible, and tell those patches to render themselves.
steg
steg
Thanks all,

I am wanting to use the quad tree for terrain rendering, I am going to put in geomipmapping firstly and then quad tree after. I was thinking of using one big vertex buffer and several index buffers ( one for each LOD ), then store the start positions in the trees node.

Regards,
Steve
If it isn't working, take a bath, have a think and try again...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.