Class SceneGraphNode
- java.lang.Object
-
- gaia.cu9.ari.gaiaorbit.scenegraph.SceneGraphNode
-
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,IStarContainer
,IPosition
- Direct Known Subclasses:
AbstractPositionEntity
public class SceneGraphNode extends java.lang.Object implements IStarContainer, IPosition
A scene graph entity.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SceneGraphNode.RenderGroup
Describes to which render vgroup this node belongs at a particular time step.protected static class
SceneGraphNode.TLV3
protected static class
SceneGraphNode.TLV3D
-
Field Summary
Fields Modifier and Type Field Description protected static SceneGraphNode.TLV3D
aux3d1
protected static SceneGraphNode.TLV3D
aux3d2
protected static SceneGraphNode.TLV3D
aux3d3
protected static SceneGraphNode.TLV3D
aux3d4
protected static SceneGraphNode.TLV3
aux3f1
protected static SceneGraphNode.TLV3
aux3f2
protected static SceneGraphNode.TLV3
aux3f3
protected static SceneGraphNode.TLV3
aux3f4
com.badlogic.gdx.utils.Array<SceneGraphNode>
children
List of children entities.boolean
computed
Flag indicating whether the object has been computed in this step.ComponentTypes
ct
Component types, for managing visibilitylong
id
The internal identifiercom.badlogic.gdx.math.Matrix4
localTransform
Local transform matrix.java.lang.String
name
The name of the node, if any.protected java.lang.String
namekey
The key to the name in the i18n system.int
numChildren
The total number of descendants under this node.float
opacity
The ownOpacity value (alpha)Matrix4d
orientation
This transform stores only the orientation of the object.SceneGraphNode
parent
The parent entity.protected java.lang.String
parentkey
The key of the parentjava.lang.String
parentName
The parent name.static java.lang.String
ROOT_NAME
static ISceneGraph
sg
Reference to scene graphVector3d
translation
Translation object.
-
Constructor Summary
Constructors Constructor Description SceneGraphNode()
SceneGraphNode(int id)
SceneGraphNode(ComponentTypes.ComponentType ct)
SceneGraphNode(SceneGraphNode parent)
SceneGraphNode(java.lang.String name)
SceneGraphNode(java.lang.String name, SceneGraphNode parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(SceneGraphNode... children)
Adds the given SceneGraphNode list as children to this node.void
add(java.util.List<? extends SceneGraphNode> children)
Adds the given list of children as child nodes.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.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.void
addFocusableObjects(com.badlogic.gdx.utils.Array<IFocus> list)
Adds all the children that are focusable objects to the list.void
addNodes(com.badlogic.gdx.utils.Array<SceneGraphNode> nodes)
protected void
addToIndex(com.badlogic.gdx.utils.ObjectMap<java.lang.String,SceneGraphNode> map)
Special actions to be taken for this object when adding to the index.protected boolean
addToRender(IRenderable renderable, SceneGraphNode.RenderGroup rg)
Adds the given renderable to the given render vgroup listvoid
dispose()
void
doneLoading(com.badlogic.gdx.assets.AssetManager manager)
int
getAggregatedChildren()
Gets the number of nodes contained in this node, including itselfSceneGraphNode
getChildByName(java.lang.String name)
SceneGraphNode
getChildByNameAndType(java.lang.String name, java.lang.Class<? extends SceneGraphNode> clazz)
com.badlogic.gdx.utils.Array<SceneGraphNode>
getChildrenByType(java.lang.Class<? extends SceneGraphNode> clazz, com.badlogic.gdx.utils.Array<SceneGraphNode> list)
ComponentTypes
getComponentType()
ComponentTypes
getCt()
SceneGraphNode
getFirstStarAncestor()
Gets the first ancestor of this node that is of typeStar
long
getId()
<T extends SceneGraphNode>
TgetLineCopy()
java.lang.String
getName()
SceneGraphNode
getNode(int id)
SceneGraphNode
getNode(java.lang.String name)
float
getOpacity()
Matrix4d
getOrientation()
Vector3d
getPosition()
SceneGraphNode
getRoot()
int
getSceneGraphDepth()
<T extends SceneGraphNode>
TgetSimpleCopy()
Gets a copy of this object but does not copy its parent or childrenint
getStarCount()
Vector3d
getVelocity()
void
initialize()
void
insert(java.util.List<? extends SceneGraphNode> nodes)
Inserts the list of nodes under the parents that match each node's name.protected boolean
isInRender(IRenderable renderable, SceneGraphNode.RenderGroup rg)
protected boolean
isInRender(IRenderable renderable, SceneGraphNode.RenderGroup... rgs)
boolean
isValidPosition()
Returns whether the current position is valid (usually, when there is no coordinates overflow)boolean
isVisibilityOn()
boolean
mustAddToIndex()
Whether to add this node to the indexvoid
removeChild(SceneGraphNode child, boolean updateAncestorCount)
Removes the given child from this node, if it exists.protected void
removeFromIndex(com.badlogic.gdx.utils.ObjectMap<java.lang.String,SceneGraphNode> map)
Special actions to be taken for this object when removing from the index.protected boolean
removeFromRender(IRenderable renderable, SceneGraphNode.RenderGroup rg)
Removes the given renderable from the given render vgroup list.void
returnToPool()
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.void
setCt(java.lang.String ct)
void
setCt(java.lang.String[] cts)
void
setId(java.lang.Long id)
void
setName(java.lang.String name)
void
setNamekey(java.lang.String namekey)
void
setParent(java.lang.String parentName)
void
setParentkey(java.lang.String parentkey)
void
setUp()
java.lang.String
toString()
void
update(ITimeFrameProvider time, Vector3d parentTransform, ICamera camera)
void
update(ITimeFrameProvider time, Vector3d parentTransform, ICamera camera, float opacity)
protected 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.void
updateNames()
Updates the name using the key.void
updateNamesRec()
Recursively updates the name using the key.
-
-
-
Field Detail
-
ROOT_NAME
public static final java.lang.String ROOT_NAME
- See Also:
- Constant Field Values
-
aux3d1
protected static SceneGraphNode.TLV3D aux3d1
-
aux3d2
protected static SceneGraphNode.TLV3D aux3d2
-
aux3d3
protected static SceneGraphNode.TLV3D aux3d3
-
aux3d4
protected static SceneGraphNode.TLV3D aux3d4
-
aux3f1
protected static SceneGraphNode.TLV3 aux3f1
-
aux3f2
protected static SceneGraphNode.TLV3 aux3f2
-
aux3f3
protected static SceneGraphNode.TLV3 aux3f3
-
aux3f4
protected static SceneGraphNode.TLV3 aux3f4
-
sg
public static ISceneGraph sg
Reference to scene graph
-
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 Vector3d translation
Translation object.
-
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.
-
name
public java.lang.String name
The name of the node, if any.
-
namekey
protected java.lang.String namekey
The key to the name in the i18n system.
-
parentName
public java.lang.String parentName
The parent name.
-
parentkey
protected java.lang.String parentkey
The key of the parent
-
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.
-
opacity
public float opacity
The ownOpacity value (alpha)
-
ct
public ComponentTypes ct
Component types, for managing visibility
-
-
Constructor Detail
-
SceneGraphNode
public SceneGraphNode()
-
SceneGraphNode
public SceneGraphNode(int id)
-
SceneGraphNode
public SceneGraphNode(ComponentTypes.ComponentType ct)
-
SceneGraphNode
public SceneGraphNode(java.lang.String name, SceneGraphNode parent)
-
SceneGraphNode
public SceneGraphNode(java.lang.String name)
-
SceneGraphNode
public SceneGraphNode(SceneGraphNode parent)
-
-
Method Detail
-
add
public final void add(SceneGraphNode... children)
Adds the given SceneGraphNode list as children to this node.- Parameters:
children
-
-
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
-updateAncestorCount
-
-
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(java.util.List<? extends SceneGraphNode> children)
Adds the given list of children as child nodes.- Parameters:
children
-
-
insert
public final void insert(java.util.List<? extends SceneGraphNode> nodes)
Inserts the list of nodes under the parents that match each node's name.- Parameters:
nodes
-
-
getChildByNameAndType
public SceneGraphNode getChildByNameAndType(java.lang.String name, java.lang.Class<? extends SceneGraphNode> clazz)
-
getChildByName
public SceneGraphNode getChildByName(java.lang.String name)
-
getChildrenByType
public com.badlogic.gdx.utils.Array<SceneGraphNode> getChildrenByType(java.lang.Class<? extends SceneGraphNode> clazz, com.badlogic.gdx.utils.Array<SceneGraphNode> list)
-
getNode
public SceneGraphNode getNode(java.lang.String name)
-
getNode
public SceneGraphNode getNode(int id)
-
update
public void update(ITimeFrameProvider time, Vector3d parentTransform, ICamera camera)
-
update
public void update(ITimeFrameProvider time, Vector3d parentTransform, ICamera camera, float opacity)
-
updateLocal
protected 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.- Parameters:
time
-
-
initialize
public void initialize()
-
doneLoading
public void doneLoading(com.badlogic.gdx.assets.AssetManager manager)
-
setName
public void setName(java.lang.String name)
-
getName
public java.lang.String getName()
-
setNamekey
public void setNamekey(java.lang.String namekey)
-
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
public void setId(java.lang.Long id)
-
getId
public long getId()
-
setParent
public void setParent(java.lang.String parentName)
-
setParentkey
public void setParentkey(java.lang.String parentkey)
-
dispose
public void dispose()
- Specified by:
dispose
in interfacecom.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.- Parameters:
list
-
-
addNodes
public void addNodes(com.badlogic.gdx.utils.Array<SceneGraphNode> nodes)
-
setUp
public void setUp()
-
setCt
public void setCt(java.lang.String ct)
-
setCt
public void setCt(java.lang.String[] cts)
-
getCt
public ComponentTypes getCt()
-
getComponentType
public ComponentTypes getComponentType()
-
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 descendents
-
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 java.lang.String toString()
- Overrides:
toString
in classjava.lang.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, SceneGraphNode.RenderGroup rg)
Adds the given renderable to the given render vgroup list- Parameters:
renderable
- The renderable to addrg
- The render vgroup that identifies the renderable list- Returns:
- True if added, false otherwise
-
removeFromRender
protected boolean removeFromRender(IRenderable renderable, SceneGraphNode.RenderGroup rg)
Removes the given renderable from the given render vgroup list.- Parameters:
renderable
- The renderable to removerg
- The render vgroup to remove from- Returns:
- True if removed, false otherwise
-
isInRender
protected boolean isInRender(IRenderable renderable, SceneGraphNode.RenderGroup rg)
-
isInRender
protected boolean isInRender(IRenderable renderable, SceneGraphNode.RenderGroup... rgs)
-
getFirstStarAncestor
public SceneGraphNode 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:
getStarCount
in interfaceIStarContainer
-
getPosition
public Vector3d getPosition()
- Specified by:
getPosition
in interfaceIPosition
-
getVelocity
public Vector3d getVelocity()
- Specified by:
getVelocity
in interfaceIPosition
-
getOrientation
public Matrix4d getOrientation()
-
isVisibilityOn
public boolean isVisibilityOn()
-
getOpacity
public float getOpacity()
-
getSceneGraphDepth
public int getSceneGraphDepth()
-
addToIndex
protected void addToIndex(com.badlogic.gdx.utils.ObjectMap<java.lang.String,SceneGraphNode> map)
Special actions to be taken for this object when adding to the index.- Parameters:
map
- The index
-
removeFromIndex
protected void removeFromIndex(com.badlogic.gdx.utils.ObjectMap<java.lang.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)- Returns:
-
-