Class SceneGraphNode

java.lang.Object
gaiasky.scenegraph.SceneGraphNode
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, IStarContainer, IVisibilitySwitch, IPosition
Direct Known Subclasses:
Area, Axes, BillboardGroup, CelestialBody, Constellation, ConstellationBoundaries, CosmicRuler, FadeNode, Loc, MilkyWay, ShapeObject, StarCluster, StubModel, VertsObject

public class SceneGraphNode extends Object implements IStarContainer, IPosition, IVisibilitySwitch
An object in the scene graph. Serves as a top class which provides the basic functionality.
  • Field Details

    • ROOT_NAME

      public static final String ROOT_NAME
      See Also:
    • D31

      protected static TLV3D D31
    • D32

      protected static TLV3D D32
    • D33

      protected static TLV3D D33
    • D34

      protected static TLV3D D34
    • B31

      protected static TLV3B B31
    • B32

      protected static TLV3B B32
    • B33

      protected static TLV3B B33
    • B34

      protected static TLV3B B34
    • F31

      protected static TLV3 F31
    • F32

      protected static TLV3 F32
    • F33

      protected static TLV3 F33
    • F34

      protected static TLV3 F34
    • id

      public long id
      The internal identifier
    • parent

      public SceneGraphNode parent
      The parent entity.
    • children

      public com.badlogic.gdx.utils.Array<SceneGraphNode> children
      List of children entities.
    • translation

      public Vector3b translation
      Cumulative translation object. In contrast with the position, which contains the position relative to the parent, this contains the absolute position in the internal reference system.
    • localTransform

      public com.badlogic.gdx.math.Matrix4 localTransform
      Local transform matrix. Contains the transform matrix and the transformations that will be applied to this object and not to its children.
    • orientation

      public Matrix4d orientation
      This transform stores only the orientation of the object. For example in planets, it stores their orientation with respect to their equatorial plane, but not other transformations applied to the object such as the size or the rotation angle at the time.
    • names

      public String[] names
      The name(s) of the node, if any.
    • localizedNameIndex

      public int localizedNameIndex
      The index of the localized name in the names array.
    • parentName

      public String parentName
      The first name of the parent object.
    • numChildren

      public int numChildren
      The total number of descendants under this node.
    • computed

      public boolean computed
      Flag indicating whether the object has been computed in this step.
    • visible

      protected boolean visible
      Is this node visible?
    • forceLabel

      protected boolean forceLabel
      Force to render the label of this entity, bypassing the solid angle check
    • lastStateChangeTimeMs

      protected long lastStateChangeTimeMs
      Time of last visibility change in milliseconds
    • opacity

      public float opacity
      The ownOpacity value (alpha)
    • ct

      public ComponentTypes ct
      Component types, for managing visibility
    • pos

      public Vector3b pos
      Position of this entity in the local reference system. The units are Constants.U_TO_KM by default.
    • coordinates

      protected IBodyCoordinates coordinates
      Coordinates provider. Provides position coordinates depending on time.
    • posSph

      public Vector2d posSph
      Position in the equatorial system; ra, dec.
    • size

      public float size
      Size factor in internal units.
    • distToCamera

      public double distToCamera
      The distance to the camera from the focus center.
    • viewAngle

      public double viewAngle
      The view angle, in radians.
    • viewAngleApparent

      public double viewAngleApparent
      The view angle corrected with the field of view angle, in radians.
    • cc

      public float[] cc
      Base RGB color
    • labelcolor

      public float[] labelcolor
    • copy

      public boolean copy
      Is this just a copy?
    • octantId

      public Long octantId
      The id of the octant it belongs to, if any
    • octant

      public OctreeNode octant
      Its page
  • Constructor Details

  • Method Details

    • insert

      public static boolean insert(SceneGraphNode node, boolean addToIndex)
      Inserts the given node into the default scene graph, if it exists.
      Parameters:
      node - The node to insert
      addToIndex - Whether to add to the index
      Returns:
      True if it was inserted, false otherwise
    • add

      public final void add(SceneGraphNode... children)
      Adds the given SceneGraphNode list as children to this node.
      Parameters:
      children - The children nodes to add.
    • addChild

      public final void addChild(SceneGraphNode child, boolean updateAncestorCount)
      Adds a child to the given node and updates the number of children in this node and in all ancestors.
      Parameters:
      child - The child node to add.
      updateAncestorCount - Whether to update the ancestors number of children.
    • removeChild

      public final void removeChild(SceneGraphNode child, boolean updateAncestorCount)
      Removes the given child from this node, if it exists.
      Parameters:
      child - The child node to remove.
      updateAncestorCount - Whether to update the ancestors number of children.
    • addChild

      public final void addChild(SceneGraphNode child, boolean updateAncestorCount, int numChildren)
      Adds a child to the given node and updates the number of children in this node and in all ancestors.
      Parameters:
      child - The child node to add.
      updateAncestorCount - Whether to update the ancestors number of children.
      numChildren - The number of children this will hold.
    • add

      public void add(List<? extends SceneGraphNode> children)
      Adds the given list of children as child nodes.
      Parameters:
      children - The children nodes to add.
    • getChildByNameAndType

      public SceneGraphNode getChildByNameAndType(String name, Class<? extends SceneGraphNode> clazz)
    • getChildByName

      public SceneGraphNode getChildByName(String name)
    • getChildrenByType

      public com.badlogic.gdx.utils.Array<SceneGraphNode> getChildrenByType(Class<? extends SceneGraphNode> clazz, com.badlogic.gdx.utils.Array<SceneGraphNode> list)
    • getChildrenByComponentType

      public com.badlogic.gdx.utils.Array<SceneGraphNode> getChildrenByComponentType(ComponentTypes.ComponentType ct, com.badlogic.gdx.utils.Array<SceneGraphNode> list)
    • getNode

      public SceneGraphNode getNode(String name)
    • getNode

      public SceneGraphNode getNode(int id)
    • update

      public void update(ITimeFrameProvider time, Vector3b parentTransform, ICamera camera)
    • update

      public void update(ITimeFrameProvider time, Vector3b parentTransform, ICamera camera, float opacity)
    • updateLocal

      public void updateLocal(ITimeFrameProvider time, ICamera camera)
      Updates the transform matrix with the transformations that will apply to the children and the local transform matrix with the transformations that will apply only to this object.
    • addToRenderLists

      protected void addToRenderLists(ICamera camera)
      Adds this entity to the necessary render lists after the distance to the camera and the view angle have been determined.
    • updateLocalValues

      public void updateLocalValues(ITimeFrameProvider time, ICamera camera)
      This function updates all the local values before the localTransform is updated. Position, rotations and scale must be updated in here.
    • initialize

      public void initialize()
    • doneLoading

      public void doneLoading(com.badlogic.gdx.assets.AssetManager manager)
    • getPos

      public Vector3b getPos()
    • isCopy

      public boolean isCopy()
    • getPosition

      public Vector3d getPosition(Vector3d aux)
      Returns the position of this entity in the internal reference system.
      Parameters:
      aux - The vector where the result will be put.
      Returns:
      The aux vector with the position.
    • setNames

      public void setNames(String... names)
    • setName

      public void setName(String name)
      Specified by:
      setName in interface IVisibilitySwitch
    • updateLocalizedName

      public void updateLocalizedName()
    • updateLocalizedNameRecursive

      public void updateLocalizedNameRecursive()
      Recursively updates the localized names for this node and its children using the current Locale setting.
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface IVisibilitySwitch
    • setDescription

      public void setDescription(String description)
      Specified by:
      setDescription in interface IVisibilitySwitch
    • addName

      public int addName(String name)
      Adds a name to the list of names.
      Parameters:
      name - The name.
      Returns:
      The index of the added name.
    • setName

      public void setName(String name, int index)
      Sets the given index in the names list to the given name. If the index is out of bounds, nothing happens.
      Parameters:
      name - The new name.
      index - The index in the names list.
    • getNames

      public String[] getNames()
    • getName

      public String getName()
      Specified by:
      getName in interface IVisibilitySwitch
    • getLocalizedName

      public String getLocalizedName()
    • namesConcat

      public String namesConcat()
    • hasName

      public boolean hasName(String candidate)
    • hasName

      public boolean hasName(String candidate, boolean matchCase)
    • setId

      public void setId(Long id)
    • getId

      public long getId()
    • setParent

      public void setParent(String parentName)
    • dispose

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

      public void addFocusableObjects(com.badlogic.gdx.utils.Array<IFocus> list)
      Adds all the children that are focusable objects to the list.
    • addNodes

      public void addNodes(com.badlogic.gdx.utils.Array<SceneGraphNode> nodes)
    • setUp

      public void setUp(ISceneGraph sceneGraph)
    • setCt

      public void setCt(String ct)
    • setCt

      public void setCt(String[] cts)
    • getCt

      public ComponentTypes getCt()
    • getComponentType

      public ComponentTypes getComponentType()
    • hasCt

      public boolean hasCt(ComponentTypes.ComponentType ct)
      Specified by:
      hasCt in interface IVisibilitySwitch
    • getAggregatedChildren

      public int getAggregatedChildren()
      Gets the number of nodes contained in this node, including itself.
      Returns:
      The number of children of this node and its descendants.
    • getLineCopy

      public <T extends SceneGraphNode> T getLineCopy()
    • getSimpleCopy

      public <T extends SceneGraphNode> T getSimpleCopy()
      Gets a copy of this object but does not copy its parent or children.
      Returns:
      The copied object.
    • getRoot

      public SceneGraphNode getRoot()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • returnToPool

      public void returnToPool()
    • setComputedFlag

      public void setComputedFlag(com.badlogic.gdx.utils.Array<SceneGraphNode> nodes, boolean computed)
      Sets the computed flag of the list of nodes and their children to the given value.
      Parameters:
      nodes - List of nodes to set the flag to. May be null.
      computed - The computed value.
    • addToRender

      protected boolean addToRender(IRenderable renderable, SceneGraphRenderer.RenderGroup rg)
      Adds the given renderable to the given render group list.
      Parameters:
      renderable - The renderable to add.
      rg - The render group that identifies the renderable list.
      Returns:
      True if added, false otherwise.
    • removeFromRender

      protected boolean removeFromRender(IRenderable renderable, SceneGraphRenderer.RenderGroup rg)
      Removes the given renderable from the given render group list.
      Parameters:
      renderable - The renderable to remove.
      rg - The render group to remove from.
      Returns:
      True if removed, false otherwise.
    • isInRender

      protected boolean isInRender(IRenderable renderable, SceneGraphRenderer.RenderGroup rg)
    • isInRender

      protected boolean isInRender(IRenderable renderable, SceneGraphRenderer.RenderGroup... rgs)
    • getFirstStarAncestor

      public SceneGraphNode getFirstStarAncestor()
      Gets the first ancestor of this node that is of type Star.
      Returns:
      The first ancestor of type Star.
    • getStarCount

      public int getStarCount()
      Specified by:
      getStarCount in interface IStarContainer
    • getVelocity

      public Vector3d getVelocity()
      Specified by:
      getVelocity in interface IPosition
    • getOrientation

      public Matrix4d getOrientation()
    • isVisibilityOn

      public boolean isVisibilityOn()
    • getOpacity

      public float getOpacity()
    • getSceneGraphDepth

      public int getSceneGraphDepth()
    • addToIndex

      protected void addToIndex(Map<String,SceneGraphNode> map)
      Special actions to be taken for this object when adding to the index.
      Parameters:
      map - The index.
    • removeFromIndex

      protected void removeFromIndex(Map<String,SceneGraphNode> map)
      Special actions to be taken for this object when removing from the index. Must implement if addToIndex is implemented.
      Parameters:
      map - The index.
    • mustAddToIndex

      public boolean mustAddToIndex()
      Whether to add this node to the index.
      Returns:
      True if the node needs to be added to the index.
    • isValidPosition

      public boolean isValidPosition()
      Returns whether the current position is valid (usually, when there is no coordinates overflow).
    • getNext

      public IFocus getNext(ITimeFrameProvider time, ICamera camera, boolean force)
      Gets a copy of this entity which mimics its state in the next time step with position, orientation, etc.
      Returns:
      A copy of this entity in the next time step
    • getPredictedPosition

      public Vector3b getPredictedPosition(Vector3b out, ITimeFrameProvider time, ICamera camera, boolean force)
      Gets the position of this entity in the next time step in the internal reference system using the given time provider and the given camera.
      Parameters:
      out - The out vector where the result will be stored.
      time - The time frame provider.
      camera - The camera.
      force - Whether to force the computation if time is off.
      Returns:
      The aux vector for chaining.
    • mustUpdatePosition

      protected boolean mustUpdatePosition(ITimeFrameProvider time)
      Whether position must be recomputed for this entity. By default, only when time is on
      Parameters:
      time - The current time
      Returns:
      True if position should be recomputed for this entity
    • getAbsolutePosition

      public Vector3b getAbsolutePosition(Vector3b out)
      Returns the absolute position of this entity in the native coordinates (equatorial system) and internal units
      Parameters:
      out - Auxiliary vector to put the result in
      Returns:
      The vector with the position
    • getAbsolutePosition

      public Vector3b getAbsolutePosition(String name, Vector3b aux)
    • getAbsoluteOrientation

      public Matrix4d getAbsoluteOrientation(Matrix4d aux)
    • getRadius

      public double getRadius()
      Returns the radius in internal units
      Returns:
      The radius of the object, in internal units
    • getHeight

      public double getHeight(Vector3b camPos)
    • getHeight

      public double getHeight(Vector3b camPos, boolean useFuturePosition)
    • getHeight

      public double getHeight(Vector3b camPos, Vector3b nextPos)
    • getHeightScale

      public double getHeightScale()
    • getSize

      public double getSize()
      Returns the size (diameter) of this entity in internal units.
      Returns:
      The size in internal units.
    • setSize

      public void setSize(Double size)
      Sets the absolute size (diameter) of this entity
      Parameters:
      size - The diameter in internal units
    • setSize

      public void setSize(Long size)
      Sets the absolute size (diameter) of this entity
      Parameters:
      size - The diameter in internal units
    • getPosSph

      public Vector2d getPosSph()
    • getAlpha

      public double getAlpha()
    • getDelta

      public double getDelta()
    • setColor

      public void setColor(double[] color)
      Sets the object color, as an RGBA double array.
      Parameters:
      color - The color.
    • setColor

      public void setColor(float[] color)
      Sets the object color, as an RGBA float array.
      Parameters:
      color - The color.
    • getColor

      public float[] getColor()
    • setLabelcolor

      public void setLabelcolor(double[] color)
      Sets the label color, as an RGBA double array.
      Parameters:
      color - The label color.
    • setLabelcolor

      public void setLabelcolor(float[] color)
      Sets the label color, as an RGBA float array.
      Parameters:
      color - The label color.
    • setLabelcolor

      public void setLabelcolor(float[] color, String name)
    • getLabelcolor

      public float[] getLabelcolor()
    • getOctant

      public OctreeNode getOctant()
    • computeFuturePosition

      public Vector3d computeFuturePosition()
    • getDistToCamera

      public double getDistToCamera()
      Returns the current distance to the camera in internal units.
      Returns:
      The current distance to the camera, in internal units.
    • getViewAngle

      public double getViewAngle()
      Returns the current view angle of this entity, in radians.
      Returns:
      The view angle in radians.
    • getViewAngleApparent

      public double getViewAngleApparent()
      Returns the current apparent view angle (view angle corrected with the field of view) of this entity, in radians.
      Returns:
      The apparent view angle in radians.
    • render2DLabel

      protected void render2DLabel(ExtSpriteBatch batch, ExtShaderProgram shader, RenderingContext rc, BitmapFont font, ICamera camera, String label, Vector3d pos3d)
    • render2DLabel

      protected void render2DLabel(ExtSpriteBatch batch, ExtShaderProgram shader, RenderingContext rc, BitmapFont font, ICamera camera, String label, float x, float y)
    • render2DLabel

      protected void render2DLabel(ExtSpriteBatch batch, ExtShaderProgram shader, RenderingContext rc, BitmapFont font, ICamera camera, String label, float x, float y, float scale)
    • render2DLabel

      protected void render2DLabel(ExtSpriteBatch batch, ExtShaderProgram shader, RenderingContext rc, BitmapFont font, ICamera camera, String label, float x, float y, float scale, int align)
    • render3DLabel

      protected void render3DLabel(ExtSpriteBatch batch, ExtShaderProgram shader, BitmapFont font, ICamera camera, RenderingContext rc, String label, Vector3d pos, double distToCamera, float scale, double size, boolean forceLabel)
    • render3DLabel

      protected void render3DLabel(ExtSpriteBatch batch, ExtShaderProgram shader, BitmapFont font, ICamera camera, RenderingContext rc, String label, Vector3d pos, double distToCamera, float scale, double size, float minSizeDegrees, float maxSizeDegrees, boolean forceLabel)
    • setCoordinates

      public void setCoordinates(IBodyCoordinates coord)
    • getCoordinates

      public IBodyCoordinates getCoordinates()
    • setPos

      public void setPos(double[] pos)
    • getPosition

      public Vector3b getPosition()
      Specified by:
      getPosition in interface IPosition
    • getUnrotatedPos

      public Vector3d getUnrotatedPos()
    • setVisible

      public void setVisible(boolean visible)
      Specified by:
      setVisible in interface IVisibilitySwitch
    • isVisible

      public boolean isVisible()
      Specified by:
      isVisible in interface IVisibilitySwitch
    • isVisible

      public boolean isVisible(boolean attributeValue)
      Specified by:
      isVisible in interface IVisibilitySwitch
    • setVisible

      public void setVisible(boolean visible, String name)
      Specified by:
      setVisible in interface IVisibilitySwitch
    • isVisible

      public boolean isVisible(String name)
      Specified by:
      isVisible in interface IVisibilitySwitch
    • isVisibleGroup

      public boolean isVisibleGroup()
    • isVisibleGroup

      public boolean isVisibleGroup(boolean attributeValue)
    • setVisibleGroup

      public void setVisibleGroup(boolean visibility)
    • msSinceStateChange

      protected long msSinceStateChange()
    • getVisibilityOpacityFactor

      protected float getVisibilityOpacityFactor()
    • shouldRender

      protected boolean shouldRender()
    • setForceLabel

      public void setForceLabel(Boolean forceLabel)
    • setForcelabel

      public void setForcelabel(Boolean forceLabel)
    • setForceLabel

      public void setForceLabel(Boolean forceLabel, String name)
    • isForceLabel

      public boolean isForceLabel()
    • isForceLabel

      public boolean isForceLabel(String name)