Class TerrainNode


  • public class TerrainNode
    extends Object
    Class that represents one node of the terrain quadtree
    Author:
    Darius Dinger
    • Constructor Detail

      • TerrainNode

        public TerrainNode​(TerrainNode parent,
                           TerrainNode.Direction dir,
                           javax.vecmath.Vector2f position,
                           float size,
                           int lod,
                           Terrain terrain)
        Creates a new terrain node and sets its position, size and lod
        Parameters:
        parent - Parent node of this node
        dir - Id of the quad in the parent quad
        position - Position of the node in world space (x,z)
        size - Size / horizontal scale of this terrain node (squared)
        lod - Lod level of this node
        terrain - Parent terrain instance, this node belongs to
    • Method Detail

      • getNeighboursGeTop

        public TerrainNode getNeighboursGeTop()
        Gets the greater or equal top neighbour node
        returns null if its root node or neighbour is smaller
        Returns:
        Top neighbour node or null
      • getNeighboursGeBottom

        public TerrainNode getNeighboursGeBottom()
        Gets the greater or equal bottom neighbour node
        returns null if its root node or neighbour is smaller
        Returns:
        Bottom neighbour node or null
      • getNeighboursGeLeft

        public TerrainNode getNeighboursGeLeft()
        Gets the greater or equal left neighbour node
        returns null if its root node or neighbour is smaller
        Returns:
        Left neighbour node or null
      • getNeighboursGeRight

        public TerrainNode getNeighboursGeRight()
        Gets the greater or equal right neighbour node
        returns null if its root node or neighbour is smaller
        Returns:
        Right neighbour node or null
      • isLeaf

        public boolean isLeaf()
        Is the node a leaf of the tree / has it children?
        Returns:
        Wether the node is a leaf
      • getChilds

        public TerrainNode[] getChilds()
        Gets all child nodes of this node.
        If the node is a leaf, the childs will be returned anyway.
        Returns:
        Child nodes of this node
      • getSize

        public float getSize()
        Getting the horizontal scaling/size of this terrain node (squared)
        Returns:
        Size of this node
      • getPosition

        public javax.vecmath.Vector2f getPosition()
        Getting the position/offset of this chunk relative to the terrain (0, 0) coordinate
        Returns:
        This terrain nodes position
      • getLod

        public int getLod()
        Getting the lod level of this specific node
        Returns:
        Lod level of this node
      • getParent

        public TerrainNode getParent()
        Returns:
        Parent node