Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

4

Quadtree Terrain

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

In order to make a quadtree terrain engine, I must make sure that no neighboring cells differ by more than one level of detail. But how would I keep track of a cell''s neighbors? Right now each cell has a pointer to its parent and its four children (a child is NULL if it doesn''t exist.)

Share this post


Link to post
Share on other sites
Advertisement
shh -

take the tree, decide how far down you want to traverse. Call
this number d.


_ _ _ _ _ _ _ _
| |_|_| |
| |_|o|_ _|
| | | |
|_ _ _ _|_ _|_ _|
| | |
| | |
| | |
|_ _ _ _| _ _ _ |



we have that the first level is node ( 1,0 )

and for lower levels:
2: (0,0)
3: (1,1)

(2^2*1,2^2*0)+(2^1*(0,0))+(2^0*1,2^0*1)=
(4,0) + (0,0)+(1,1)
= (5,1)

This is the array element.

To express it in more general terms:
matrxElem = ( 2^(d-1) * level1 ) + ( 2^(d-2)*level2 ) +...+(2^(d-n)*leveln )

{ using vector addition and the fact that 2^0 = 1

Dave




----------------------------------------------------------
code projects are like relationship's

Edit 1 and 2: tree diagram messed up.
Edit 3: Said 2^3 by accident

[edited by - ray_intellect on February 28, 2004 6:50:02 PM]

[edited by - ray_intellect on February 28, 2004 6:51:17 PM]

[edited by - ray_intellect on February 28, 2004 7:03:22 PM]

Share this post


Link to post
Share on other sites
Thank you so much!

I was trying to do this for the past two weeks without any success and your algorithm worked so well!

Share this post


Link to post
Share on other sites

  • 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!