Package gaiasky.scenegraph
Class SceneGraphNode
java.lang.Object
gaiasky.scenegraph.SceneGraphNode
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable,IStarContainer,IVisibilitySwitch,IPosition
- Direct Known Subclasses:
Area,Axes,CelestialBody,ConstellationBoundaries,CosmicRuler,FadeNode,Loc,MilkyWay,StarCluster,StubModel,VertsObject
An object in the scene graph. Serves as a top class which provides the basic functionality.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static TLV3Bprotected static TLV3Bprotected static TLV3Bprotected static TLV3Bprotected static TLV3Dprotected static TLV3Dprotected static TLV3Dprotected static TLV3Dprotected static TLV3protected static TLV3protected static TLV3protected static TLV3float[]Base RGB colorcom.badlogic.gdx.utils.Array<SceneGraphNode>List of children entities.booleanFlag indicating whether the object has been computed in this step.protected IBodyCoordinatesCoordinates provider.booleanIs this just a copy?Component types, for managing visibilitydoubleThe distance to the camera from the focus center.longThe internal identifierprotected longTime of last visibility change in millisecondscom.badlogic.gdx.math.Matrix4Local transform matrix.protected StringThe key to the name in the i18n system.String[]The name(s) of the node, if any.intThe total number of descendants under this node.Its pageThe id of the octant it belongs to, if anyfloatThe ownOpacity value (alpha)This transform stores only the orientation of the object.The parent entity.protected StringThe key of the parentThe first name of the parent object.Position of this entity in the local reference system.Position in the equatorial system; ra, dec.static StringfloatSize factor in internal units.Cumulative translation object.doubleThe view angle, in radians.doubleThe view angle corrected with the field of view angle, in radians.protected booleanIs this node visible? -
Constructor Summary
ConstructorsConstructorDescriptionSceneGraphNode(int id)SceneGraphNode(SceneGraphNode parent)SceneGraphNode(String name)SceneGraphNode(String[] names, SceneGraphNode parent)SceneGraphNode(String name, SceneGraphNode parent) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(SceneGraphNode... children)Adds the given SceneGraphNode list as children to this node.voidadd(List<? extends SceneGraphNode> children)Adds the given list of children as child nodes.voidaddChild(SceneGraphNode child, boolean updateAncestorCount)Adds a child to the given node and updates the number of children in this node and in all ancestors.voidaddChild(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.voidaddFocusableObjects(com.badlogic.gdx.utils.Array<IFocus> list)Adds all the children that are focusable objects to the list.voidAdds a name to the list of names.voidaddNodes(com.badlogic.gdx.utils.Array<SceneGraphNode> nodes)protected voidaddToIndex(com.badlogic.gdx.utils.ObjectMap<String,SceneGraphNode> map)Special actions to be taken for this object when adding to the index.protected booleanaddToRender(IRenderable renderable, SceneGraphRenderer.RenderGroup rg)Adds the given renderable to the given render group list.protected voidaddToRenderLists(ICamera camera)Adds this entity to the necessary render lists after the distance to the camera and the view angle have been determined.voiddispose()voiddoneLoading(com.badlogic.gdx.assets.AssetManager manager)getAbsolutePosition(Vector3b out)Returns the absolute position of this entity in the native coordinates (equatorial system) and internal unitsgetAbsolutePosition(String name, Vector3b aux)intGets the number of nodes contained in this node, including itself.doublegetAlpha()getChildByName(String name)getChildByNameAndType(String name, Class<? extends SceneGraphNode> clazz)com.badlogic.gdx.utils.Array<SceneGraphNode>getChildrenByComponentType(ComponentTypes.ComponentType ct, com.badlogic.gdx.utils.Array<SceneGraphNode> list)com.badlogic.gdx.utils.Array<SceneGraphNode>getChildrenByType(Class<? extends SceneGraphNode> clazz, com.badlogic.gdx.utils.Array<SceneGraphNode> list)float[]getColor()getCt()doublegetDelta()doubleReturns the current distance to the camera in internal units.Gets the first ancestor of this node that is of typeStar.doubledoubledoubledoublelonggetId()<T extends SceneGraphNode>
TgetName()String[]getNames()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.getNode(int id)floatgetPos()getPosition(Vector3d aux)Returns the position of this entity in the internal reference system.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.doubleReturns the radius in internal unitsgetRoot()int<T extends SceneGraphNode>
TGets a copy of this object but does not copy its parent or children.doublegetSize()Returns the size (diameter) of this entity in internal units.intdoubleReturns the current view angle of this entity, in radians.doubleReturns the current apparent view angle (view angle corrected with the field of view) of this entity, in radians.protected floatbooleanbooleanbooleanvoidstatic booleaninsert(SceneGraphNode node, boolean addToIndex)Inserts the given node into the default scene graph, if it exists.booleanisCopy()protected booleanisInRender(IRenderable renderable, SceneGraphRenderer.RenderGroup rg)protected booleanisInRender(IRenderable renderable, SceneGraphRenderer.RenderGroup... rgs)booleanReturns whether the current position is valid (usually, when there is no coordinates overflow).booleanbooleanbooleanisVisible(boolean attributeValue)booleanbooleanprotected longbooleanWhether to add this node to the index.protected booleanWhether position must be recomputed for this entity.voidremoveChild(SceneGraphNode child, boolean updateAncestorCount)Removes the given child from this node, if it exists.protected voidremoveFromIndex(com.badlogic.gdx.utils.ObjectMap<String,SceneGraphNode> map)Special actions to be taken for this object when removing from the index.protected booleanremoveFromRender(IRenderable renderable, SceneGraphRenderer.RenderGroup rg)Removes the given renderable from the given render group list.protected voidrender2DLabel(ExtSpriteBatch batch, ExtShaderProgram shader, RenderingContext rc, BitmapFont font, ICamera camera, String label, float x, float y)protected voidrender2DLabel(ExtSpriteBatch batch, ExtShaderProgram shader, RenderingContext rc, BitmapFont font, ICamera camera, String label, float x, float y, float scale)protected voidrender2DLabel(ExtSpriteBatch batch, ExtShaderProgram shader, RenderingContext rc, BitmapFont font, ICamera camera, String label, float x, float y, float scale, int align)protected voidrender2DLabel(ExtSpriteBatch batch, ExtShaderProgram shader, RenderingContext rc, BitmapFont font, ICamera camera, String label, Vector3d pos3d)protected voidrender3DLabel(ExtSpriteBatch batch, ExtShaderProgram shader, BitmapFont font, ICamera camera, RenderingContext rc, String label, Vector3d pos, double distToCamera, float scale, double size)protected voidrender3DLabel(ExtSpriteBatch batch, ExtShaderProgram shader, BitmapFont font, ICamera camera, RenderingContext rc, String label, Vector3d pos, double distToCamera, float scale, double size, float minSizeDegrees, float maxSizeDegrees)voidvoidsetColor(double[] color)voidsetColor(float[] color)voidsetComputedFlag(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.voidsetCoordinates(IBodyCoordinates coord)voidvoidvoidsetDescription(String description)voidvoidsetLabelcolor(double[] labelColor)voidsetLabelcolor(float[] labelColor)voidvoidsetNamekey(String namekey)voidvoidvoidsetParentkey(String parentkey)voidSets the absolute size (diameter) of this entityvoidSets the absolute size (diameter) of this entityvoidsetUp(ISceneGraph sceneGraph)voidsetVisible(boolean visible)voidsetVisible(boolean visible, String name)voidsetVisibleGroup(boolean visibility)protected booleantoString()voidupdate(ITimeFrameProvider time, Vector3b parentTransform, ICamera camera)voidupdate(ITimeFrameProvider time, Vector3b parentTransform, ICamera camera, float opacity)voidupdateLocal(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.voidupdateLocalValues(ITimeFrameProvider time, ICamera camera)This function updates all the local values before the localTransform is updated.voidUpdates the name using the key.voidRecursively updates the name using the key.
-
Field Details
-
ROOT_NAME
- See Also:
- Constant Field Values
-
aux3d1
-
aux3d2
-
aux3d3
-
aux3d4
-
aux3b1
-
aux3b2
-
aux3b3
-
aux3b4
-
aux3f1
-
aux3f2
-
aux3f3
-
aux3f4
-
id
public long idThe internal identifier -
parent
The parent entity. -
children
List of children entities. -
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 localTransformLocal transform matrix. Contains the transform matrix and the transformations that will be applied to this object and not to its children. -
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
The name(s) of the node, if any. -
namekey
The key to the name in the i18n system. -
parentName
The first name of the parent object. -
parentkey
The key of the parent -
numChildren
public int numChildrenThe total number of descendants under this node. -
computed
public boolean computedFlag indicating whether the object has been computed in this step. -
visible
protected boolean visibleIs this node visible? -
lastStateChangeTimeMs
protected long lastStateChangeTimeMsTime of last visibility change in milliseconds -
opacity
public float opacityThe ownOpacity value (alpha) -
ct
Component types, for managing visibility -
pos
Position of this entity in the local reference system. The units areConstants.U_TO_KMby default. -
coordinates
Coordinates provider. Helps updating the position at each time step. -
posSph
Position in the equatorial system; ra, dec. -
size
public float sizeSize factor in internal units. -
distToCamera
public double distToCameraThe distance to the camera from the focus center. -
viewAngle
public double viewAngleThe view angle, in radians. -
viewAngleApparent
public double viewAngleApparentThe view angle corrected with the field of view angle, in radians. -
cc
public float[] ccBase RGB color -
copy
public boolean copyIs this just a copy? -
octantId
The id of the octant it belongs to, if any -
octant
Its page
-
-
Constructor Details
-
SceneGraphNode
public SceneGraphNode() -
SceneGraphNode
public SceneGraphNode(int id) -
SceneGraphNode
-
SceneGraphNode
-
SceneGraphNode
-
SceneGraphNode
-
SceneGraphNode
-
-
Method Details
-
insert
Inserts the given node into the default scene graph, if it exists.- Parameters:
node- The node to insertaddToIndex- Whether to add to the index- Returns:
- True if it was inserted, false otherwise
-
add
Adds the given SceneGraphNode list as children to this node.- Parameters:
children- The children nodes to add.
-
addChild
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
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
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
Adds the given list of children as child nodes.- Parameters:
children- The children nodes to add.
-
getChildByNameAndType
-
getChildByName
-
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
-
getNode
-
update
-
update
public void update(ITimeFrameProvider time, Vector3b parentTransform, ICamera camera, float opacity) -
updateLocal
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
Adds this entity to the necessary render lists after the distance to the camera and the view angle have been determined. -
updateLocalValues
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
-
isCopy
public boolean isCopy() -
getPosition
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
-
setName
- Specified by:
setNamein interfaceIVisibilitySwitch
-
getDescription
- Specified by:
getDescriptionin interfaceIVisibilitySwitch
-
setDescription
- Specified by:
setDescriptionin interfaceIVisibilitySwitch
-
addName
Adds a name to the list of names.- Parameters:
name- The name.
-
getNames
-
getName
- Specified by:
getNamein interfaceIVisibilitySwitch
-
namesConcat
-
hasName
-
hasName
-
setNamekey
-
updateNames
public void updateNames()Updates the name using the key. This must be called when the language changes. -
updateNamesRec
public void updateNamesRec()Recursively updates the name using the key. This must be called when the language changes. -
setId
-
getId
public long getId() -
setParent
-
setParentkey
-
dispose
public void dispose()- Specified by:
disposein interfacecom.badlogic.gdx.utils.Disposable
-
addFocusableObjects
Adds all the children that are focusable objects to the list. -
addNodes
-
setUp
-
setCt
-
setCt
-
getCt
-
getComponentType
-
hasCt
- Specified by:
hasCtin interfaceIVisibilitySwitch
-
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
-
getSimpleCopy
Gets a copy of this object but does not copy its parent or children.- Returns:
- The copied object.
-
getRoot
-
toString
-
returnToPool
public void returnToPool() -
setComputedFlag
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
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
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
-
isInRender
-
getFirstStarAncestor
Gets the first ancestor of this node that is of typeStar.- Returns:
- The first ancestor of type
Star.
-
getStarCount
public int getStarCount()- Specified by:
getStarCountin interfaceIStarContainer
-
getVelocity
- Specified by:
getVelocityin interfaceIPosition
-
getOrientation
-
isVisibilityOn
public boolean isVisibilityOn() -
getOpacity
public float getOpacity() -
getSceneGraphDepth
public int getSceneGraphDepth() -
addToIndex
Special actions to be taken for this object when adding to the index.- Parameters:
map- The index.
-
removeFromIndex
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
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
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
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
-
getAbsoluteOrientation
-
getRadius
public double getRadius()Returns the radius in internal units- Returns:
- The radius of the object, in internal units
-
getHeight
-
getHeight
-
getHeight
-
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
Sets the absolute size (diameter) of this entity- Parameters:
size- The diameter in internal units
-
setSize
Sets the absolute size (diameter) of this entity- Parameters:
size- The diameter in internal units
-
getPosSph
-
getAlpha
public double getAlpha() -
getDelta
public double getDelta() -
setColor
public void setColor(double[] color) -
setColor
public void setColor(float[] color) -
getOctant
-
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) -
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) -
setCoordinates
-
getPosition
- Specified by:
getPositionin interfaceIPosition
-
getUnrotatedPos
-
setLabelcolor
public void setLabelcolor(float[] labelColor) -
setLabelcolor
public void setLabelcolor(double[] labelColor) -
setVisible
public void setVisible(boolean visible)- Specified by:
setVisiblein interfaceIVisibilitySwitch
-
isVisible
public boolean isVisible()- Specified by:
isVisiblein interfaceIVisibilitySwitch
-
isVisible
public boolean isVisible(boolean attributeValue)- Specified by:
isVisiblein interfaceIVisibilitySwitch
-
setVisible
- Specified by:
setVisiblein interfaceIVisibilitySwitch
-
isVisible
- Specified by:
isVisiblein interfaceIVisibilitySwitch
-
isVisibleGroup
public boolean isVisibleGroup() -
setVisibleGroup
public void setVisibleGroup(boolean visibility) -
msSinceStateChange
protected long msSinceStateChange() -
getVisibilityOpacityFactor
protected float getVisibilityOpacityFactor() -
shouldRender
protected boolean shouldRender() -
getColor
public float[] getColor()
-