Class LODCubeSphere.Quadtree

java.lang.Object
gaiasky.render.gdx.procgen.LODCubeSphere.Quadtree
Enclosing class:
LODCubeSphere

public static class LODCubeSphere.Quadtree extends Object

A quadtree, which parts 2D space into 4 parts on subdivision.

Each quadtree has 4 vertices (p_i) and the given indices for the children:

    p0              p1
      ┌──────┬──────┐
      │      │      │
      │  0   │  1   │
      │      │      │
      ├──────┼──────┤
      │      │      │
      │  2   │  3   │
      │      │      │
      └──────┴──────┘
    p2              p3
  • Constructor Details

  • Method Details

    • initialize

      public void initialize(int depth)
      Spawns cells in this node down to the given level, fully.
      Parameters:
      depth - The depth to initialize.
    • isLeaf

      public boolean isLeaf()
      Check if this node has any children or if it is a leaf node.
      Returns:
      True if the node has no children.
    • subdivide

      public void subdivide()
      Subdivide the current quadtree into 4 children. This operation only succeeds if this is a leaf node. Otherwise, the node is already subdivided and nothing happens.
    • undivide

      public void undivide()
      Remove the children of this node, making it into a leaf node.
    • buildMesh

      public void buildMesh(int N, float radius)
      Build a mesh for this quadtree node with an NxN grid of vertices.

      Each vertex position is bilinearly interpolated within the quad's bounds on the cube face, then mapped to the sphere via map(Vector3D). Normals, UV coordinates (spherical projection), tangents (westward/U direction), and binormals (southward/V direction) are computed from the mapped position, matching the conventions of CubeSphereCreator.

      This method uses the parent LODCubeSphere.builder to add geometry. Call LODCubeSphere.begin(int) before, and LODCubeSphere.end() after building all visible leaf nodes.

      Parameters:
      N - The number of subdivisions per edge (N > 0). Produces an NxN grid of quads.
      radius - The radius of the sphere.