Tuesday, September 29, 2009

Dealing with quadtrees 2: Points

Continuing to make a quadtree. Next step is to understand the splitting process. In simple words I need to split a parent quad on to 4 small quads with proper coordinate for each vertex of the each child node.

LOD

To understand the concept I took a very simple quad with coordinates from (0;0;0) to (1;1;0). It’s frame and numbers are black on the screenshot. It has 4 points:

  • Point 0 - (0;0;0)
  • Point 1 - (0;1;0)
  • Point 2 - (1;0;0)
  • Point 3 - (1;1;0)

Because of jME tutorial page about drawing vertices has algorithm, that draws quad as two triangles exactly the same way (coordinates) as I mentioned before (like from point 0 to 3) I used the same concept here, but later on I have found that in my draft papers I have mistaken X coordinate with Y. That gave me that the point #1 is under point #0, but in reality it point #1 should be from the right from point #0. But actualy that was not important :)

As it can be seen from the picture, 4 child quads are numbered the same way as points (although as I have mentioned that isn't quite right, but it works), and in the table I wrote coordinates for each point of each child just as I see them.

coords

No comments:

Post a Comment