Class SVTQuadtree<T>

java.lang.Object
gaiasky.util.svt.SVTQuadtree<T>

public class SVTQuadtree<T> extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Auxiliary object to store additional data.
    int
    Depth of the tree, e.g., the deepest level, in [0,n].
    com.badlogic.gdx.utils.LongMap<SVTQuadtreeNode<T>>[]
    Each tile is identified by its level and its UV.
    final int
     
    final String
    Name of the tree.
    int
    The total number of tiles in the tree.
    Root node(s) of the tree.
    final int
    Size in pixels of each tile.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SVTQuadtree(String name, int tileSize, int rootPositions)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(int level, int col, int row)
     
    int[]
    getColRow(int level, double u, double v)
    Gets the column and row at the given level (with [0,0] being at the top-left) from the UV texture coordinates, with the origin at the bottom-left.
    int[]
    getColRow(int level, double u, double v, int[] colRow)
     
    long
    getKey(int level, int col, int row)
     
    long
     
    int[]
    Get the resolution of this SVT at the most-detailed level.
    getTile(int level, int col, int row)
    Gets a tile in the tree given its level, column and row.
    getTileFromUV(int level, double u, double v)
    Gets a tile given a level and texture coordinates in UV.
    long
    getUTileCount(int level)
     
    double[]
    getUV(int level, int col, int row)
    Gets the UV texture coordinates from the given column, row and level.
    double[]
    getUV(int level, int col, int row, double[] uv)
     
    long
    getVTileCount(int level)
     
    void
    insert(int level, int col, int row, T object)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_LEVEL

      public final int MAX_LEVEL
      See Also:
    • name

      public final String name
      Name of the tree.
    • tileSize

      public final int tileSize
      Size in pixels of each tile. Tiles are square, so width and height are equal. The tile size is a power of two, capping at 1024. One of 8, 16, 32, 64, 128, 256, 512 or 1024.
    • numTiles

      public int numTiles
      The total number of tiles in the tree.
    • depth

      public int depth
      Depth of the tree, e.g., the deepest level, in [0,n].
    • root

      public SVTQuadtreeNode<T>[] root
      Root node(s) of the tree.
    • levels

      public com.badlogic.gdx.utils.LongMap<SVTQuadtreeNode<T>>[] levels
      Each tile is identified by its level and its UV. Here we can access tiles directly.
    • aux

      public Object aux
      Auxiliary object to store additional data.
  • Constructor Details

    • SVTQuadtree

      public SVTQuadtree(String name, int tileSize, int rootPositions)
  • Method Details

    • insert

      public void insert(int level, int col, int row, T object)
    • getTile

      public SVTQuadtreeNode<T> getTile(int level, int col, int row)
      Gets a tile in the tree given its level, column and row.
      Parameters:
      level - The level.
      col - The column.
      row - The row.
      Returns:
      The tile with the given level, column and row, if it exists.
    • getTileFromUV

      public SVTQuadtreeNode<T> getTileFromUV(int level, double u, double v)
      Gets a tile given a level and texture coordinates in UV.
      Parameters:
      level - The level.
      u - The U texture coordinate in [0,1].
      v - The V texture coordinate in [0,1].
      Returns:
      The tile at the given level and UV.
    • getUTileCount

      public long getUTileCount(int level)
    • getVTileCount

      public long getVTileCount(int level)
    • getColRow

      public int[] getColRow(int level, double u, double v)
      Gets the column and row at the given level (with [0,0] being at the top-left) from the UV texture coordinates, with the origin at the bottom-left.
      Parameters:
      level - The level.
      u - The U coordinate.
      v - The V coordinate.
      Returns:
      The column and row, with the origin at the top-left.
    • getColRow

      public int[] getColRow(int level, double u, double v, int[] colRow)
    • getUV

      public double[] getUV(int level, int col, int row)
      Gets the UV texture coordinates from the given column, row and level. The UV coordinates start have the origin at the bottom-left, while the column and row have the origin at the top-left.
      Parameters:
      level - The level.
      col - The column.
      row - The row.
      Returns:
      The UV coordinates.
    • getUV

      public double[] getUV(int level, int col, int row, double[] uv)
    • contains

      public boolean contains(int level, int col, int row)
    • getKey

      public long getKey(int level, int col, int row)
    • getKey

      public long getKey(SVTQuadtreeNode<T> tile)
    • getResolution

      public int[] getResolution()
      Get the resolution of this SVT at the most-detailed level.
      Returns:
      The resolution at the most detailed level.