Class LODCubeSphere.Quadtree
java.lang.Object
gaiasky.render.gdx.procgen.LODCubeSphere.Quadtree
- Enclosing class:
LODCubeSphere
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 Summary
ConstructorsConstructorDescriptionQuadtree(LODCubeSphere parent, int depth, double[] p0, double[] p1, double[] p2, double[] p3) -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildMesh(int N, float radius) Build a mesh for this quadtree node with an NxN grid of vertices.voidinitialize(int depth) Spawns cells in this node down to the given level, fully.booleanisLeaf()Check if this node has any children or if it is a leaf node.voidSubdivide the current quadtree into 4 children.voidundivide()Remove the children of this node, making it into a leaf node.
-
Constructor Details
-
Quadtree
public Quadtree(LODCubeSphere parent, int depth, double[] p0, double[] p1, double[] p2, double[] p3) -
Quadtree
public Quadtree(LODCubeSphere parent, int depth, Vector3D p0, Vector3D p1, Vector3D p2, Vector3D p3)
-
-
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 ofCubeSphereCreator.This method uses the parent
LODCubeSphere.builderto add geometry. CallLODCubeSphere.begin(int)before, andLODCubeSphere.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.
-