Class AbstractSceneGraph

java.lang.Object
gaiasky.scenegraph.AbstractSceneGraph
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, ISceneGraph
Direct Known Subclasses:
SceneGraph

public abstract class AbstractSceneGraph
extends java.lang.Object
implements ISceneGraph
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected boolean hasOctree
    Does it contain an octree
    protected boolean hasStarGroup
    Does it contain a star group
    protected com.badlogic.gdx.utils.ObjectMap<java.lang.Integer,​IPosition> hipMap
    Map from integer to position with all Hipparcos stars, for the constellations
    protected int[] objectsPerThread
    Number of objects per thread
    SceneGraphNode root
    The root of the tree
    protected com.badlogic.gdx.utils.ObjectMap<java.lang.String,​SceneGraphNode> stringToNode
    Quick lookup map.
  • Constructor Summary

    Constructors
    Constructor Description
    AbstractSceneGraph()  
  • Method Summary

    Modifier and Type Method Description
    void addNodeAuxiliaryInfo​(SceneGraphNode node)
    Updates the string to node map and the star map if necessary.
    protected void addToIndex​(SceneGraphNode node, com.badlogic.gdx.utils.ObjectMap<java.lang.String,​SceneGraphNode> map)  
    boolean containsNode​(java.lang.String name)
    Whether this scene graphs contains a node with the given name
    void dispose()  
    IFocus findFocus​(java.lang.String name)  
    com.badlogic.gdx.utils.Array<IFocus> getFocusableObjects()  
    int getNObjects()  
    SceneGraphNode getNode​(java.lang.String name)
    Returns the node with the given name, or null if it does not exist.
    com.badlogic.gdx.utils.Array<SceneGraphNode> getNodes()  
    double[] getObjectPosition​(java.lang.String name, double[] out)
    Gets the current position of the object identified by the given name.
    SceneGraphNode getRoot()  
    int getSize()  
    com.badlogic.gdx.utils.ObjectMap<java.lang.Integer,​IPosition> getStarMap()
    Gets a star map: HIP -> IPosition It only contains the stars with HIP number
    void initialize​(com.badlogic.gdx.utils.Array<SceneGraphNode> nodes, ITimeFrameProvider time, boolean hasOctree, boolean hasStarGroup)
    Builds the scene graph using the given nodes.
    void insert​(SceneGraphNode node, boolean addToIndex)
    Inserts a node
    void matchingFocusableNodes​(java.lang.String name, com.badlogic.gdx.utils.Array<java.lang.String> results)
    Returns focusable nodes matching the given string, to a maximum of 10
    void matchingFocusableNodes​(java.lang.String name, com.badlogic.gdx.utils.Array<java.lang.String> results, int maxResults)
    Returns focusable nodes matching the given string, to a maximum of maxResults
    void remove​(SceneGraphNode node, boolean removeFromIndex)
    Removes a node
    void removeNodeAuxiliaryInfo​(SceneGraphNode node)
    Removes the info of the node from the aux lists.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface gaiasky.scenegraph.ISceneGraph

    update
  • Field Details

    • root

      public SceneGraphNode root
      The root of the tree
    • stringToNode

      protected com.badlogic.gdx.utils.ObjectMap<java.lang.String,​SceneGraphNode> stringToNode
      Quick lookup map. Name to node.
    • hipMap

      protected com.badlogic.gdx.utils.ObjectMap<java.lang.Integer,​IPosition> hipMap
      Map from integer to position with all Hipparcos stars, for the constellations
    • objectsPerThread

      protected int[] objectsPerThread
      Number of objects per thread
    • hasOctree

      protected boolean hasOctree
      Does it contain an octree
    • hasStarGroup

      protected boolean hasStarGroup
      Does it contain a star group
  • Constructor Details

    • AbstractSceneGraph

      public AbstractSceneGraph()
  • Method Details

    • initialize

      public void initialize​(com.badlogic.gdx.utils.Array<SceneGraphNode> nodes, ITimeFrameProvider time, boolean hasOctree, boolean hasStarGroup)
      Builds the scene graph using the given nodes.
      Specified by:
      initialize in interface ISceneGraph
      Parameters:
      nodes - The list of nodes
      time - The time provider
      hasOctree - Whether the list of nodes contains an octree
      hasStarGroup - Whether the list contains a star group
    • insert

      public void insert​(SceneGraphNode node, boolean addToIndex)
      Description copied from interface: ISceneGraph
      Inserts a node
      Specified by:
      insert in interface ISceneGraph
      Parameters:
      node - The node to add
      addToIndex - Whether to add the ids of this node to the index
    • remove

      public void remove​(SceneGraphNode node, boolean removeFromIndex)
      Description copied from interface: ISceneGraph
      Removes a node
      Specified by:
      remove in interface ISceneGraph
      Parameters:
      node - The node to remove
      removeFromIndex - Whether to remove the ids of this node from the index
    • addToIndex

      protected void addToIndex​(SceneGraphNode node, com.badlogic.gdx.utils.ObjectMap<java.lang.String,​SceneGraphNode> map)
    • addNodeAuxiliaryInfo

      public void addNodeAuxiliaryInfo​(SceneGraphNode node)
      Description copied from interface: ISceneGraph
      Updates the string to node map and the star map if necessary.
      Specified by:
      addNodeAuxiliaryInfo in interface ISceneGraph
      Parameters:
      node - The node to add
    • removeNodeAuxiliaryInfo

      public void removeNodeAuxiliaryInfo​(SceneGraphNode node)
      Description copied from interface: ISceneGraph
      Removes the info of the node from the aux lists.
      Specified by:
      removeNodeAuxiliaryInfo in interface ISceneGraph
      Parameters:
      node - The node to remove
    • matchingFocusableNodes

      public void matchingFocusableNodes​(java.lang.String name, com.badlogic.gdx.utils.Array<java.lang.String> results)
      Description copied from interface: ISceneGraph
      Returns focusable nodes matching the given string, to a maximum of 10
      Specified by:
      matchingFocusableNodes in interface ISceneGraph
      Parameters:
      name - The name
      results - The results
    • matchingFocusableNodes

      public void matchingFocusableNodes​(java.lang.String name, com.badlogic.gdx.utils.Array<java.lang.String> results, int maxResults)
      Description copied from interface: ISceneGraph
      Returns focusable nodes matching the given string, to a maximum of maxResults
      Specified by:
      matchingFocusableNodes in interface ISceneGraph
      Parameters:
      name - The name
      results - The results
      maxResults - The maximum number of results
    • containsNode

      public boolean containsNode​(java.lang.String name)
      Description copied from interface: ISceneGraph
      Whether this scene graphs contains a node with the given name
      Specified by:
      containsNode in interface ISceneGraph
      Parameters:
      name - The name
      Returns:
      True if this scene graph contains the node, false otherwise
    • getNode

      public SceneGraphNode getNode​(java.lang.String name)
      Description copied from interface: ISceneGraph
      Returns the node with the given name, or null if it does not exist.
      Specified by:
      getNode in interface ISceneGraph
      Parameters:
      name - The name of the node.
      Returns:
      The node with the name.
    • getNodes

      public com.badlogic.gdx.utils.Array<SceneGraphNode> getNodes()
      Specified by:
      getNodes in interface ISceneGraph
    • getFocusableObjects

      public com.badlogic.gdx.utils.Array<IFocus> getFocusableObjects()
      Specified by:
      getFocusableObjects in interface ISceneGraph
    • findFocus

      public IFocus findFocus​(java.lang.String name)
      Specified by:
      findFocus in interface ISceneGraph
    • getSize

      public int getSize()
      Specified by:
      getSize in interface ISceneGraph
    • dispose

      public void dispose()
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
    • getRoot

      public SceneGraphNode getRoot()
      Specified by:
      getRoot in interface ISceneGraph
    • getStarMap

      public com.badlogic.gdx.utils.ObjectMap<java.lang.Integer,​IPosition> getStarMap()
      Description copied from interface: ISceneGraph
      Gets a star map: HIP -> IPosition It only contains the stars with HIP number
      Specified by:
      getStarMap in interface ISceneGraph
      Returns:
      The HIP star map
    • getNObjects

      public int getNObjects()
    • getObjectPosition

      public double[] getObjectPosition​(java.lang.String name, double[] out)
      Description copied from interface: ISceneGraph
      Gets the current position of the object identified by the given name. The given position is in the internal reference system and corrects stars for proper motions and other objects for their specific motions as well.
      Specified by:
      getObjectPosition in interface ISceneGraph
      Parameters:
      name - The name of the object
      out - The out double array
      Returns:
      The out double array if the object exists, has a position and out has 3 or more slots. Null otherwise.