Package gaiasky.util.gdx.model
Class IntNode
java.lang.Object
gaiasky.util.gdx.model.IntNode
public class IntNode
extends java.lang.Object
A node is part of a hierarchy of Nodes in a
IntModel. A Node encodes a transform relative to its parents. A Node can have
child nodes. Optionally a node can specify a IntMeshPart and a Material to be applied to the mesh part.-
Field Summary
Fields Modifier and Type Field Description com.badlogic.gdx.math.Matrix4globalTransformthe global transform, product of local transform and transform of the parent node, calculated viacalculateWorldTransform()java.lang.Stringidthe id, may be null, FIXME is this unique?booleaninheritTransformWhether this node should inherit the transformation of its parent node, defaults to true.booleanisAnimatedWhether this node is currently being animated, if so the translation, rotation and scale values are not used.com.badlogic.gdx.math.Matrix4localTransformthe local transform, based on translation/rotation/scale (calculateLocalTransform()) or any applied animationprotected IntNodeparentcom.badlogic.gdx.utils.Array<IntNodePart>partscom.badlogic.gdx.math.Quaternionrotationthe rotation, relative to the parent, not modified by animationscom.badlogic.gdx.math.Vector3scalethe scale, relative to the parent, not modified by animationscom.badlogic.gdx.math.Vector3translationthe translation, relative to the parent, not modified by animations -
Constructor Summary
Constructors Constructor Description IntNode() -
Method Summary
Modifier and Type Method Description <T extends IntNode>
intaddChild(T child)Adds the specified node as the currently last child of this node.<T extends IntNode>
intaddChildren(java.lang.Iterable<T> nodes)Adds the specified nodes as the currently last child of this node.<T extends IntNode>
voidattachTo(T parent)Adds this node as child to specified parent Node, synonym for:parent.addChild(this)voidcalculateBoneTransforms(boolean recursive)com.badlogic.gdx.math.collision.BoundingBoxcalculateBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out)Calculate the bounding box of this Node.com.badlogic.gdx.math.collision.BoundingBoxcalculateBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out, boolean transform)Calculate the bounding box of this Node.com.badlogic.gdx.math.Matrix4calculateLocalTransform()Calculates the local transform based on the translation, scale and rotationvoidcalculateTransforms(boolean recursive)Calculates the local and world transform of this node and optionally all its children.com.badlogic.gdx.math.Matrix4calculateWorldTransform()Calculates the world transform; the product of local transform and the parent's world transform.IntNodecopy()Creates a nested copy of this Node, any child nodes are copied using this method as well.voiddetach()Removes this node from its current parent, if any.com.badlogic.gdx.math.collision.BoundingBoxextendBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out)Extends the bounding box with the bounds of this Node.com.badlogic.gdx.math.collision.BoundingBoxextendBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out, boolean transform)Extends the bounding box with the bounds of this Node.IntNodegetChild(int index)IntNodegetChild(java.lang.String id, boolean recursive, boolean ignoreCase)intgetChildCount()java.lang.Iterable<IntNode>getChildren()static IntNodegetNode(com.badlogic.gdx.utils.Array<IntNode> nodes, java.lang.String id, boolean recursive, boolean ignoreCase)Helper method to recursive fetch a node from an arrayIntNodegetParent()booleanhasChildren()booleanhasParent()<T extends IntNode>
intinsertChild(int index, T child)Insert the specified node as child of this node at the specified index.<T extends IntNode>
intinsertChildren(int index, java.lang.Iterable<T> nodes)Insert the specified nodes as children of this node at the specified index.<T extends IntNode>
booleanremoveChild(T child)Removes the specified node as child of this node.protected IntNodeset(IntNode other)Creates a nested copy of this Node, any child nodes are copied using thecopy()method.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
id
public java.lang.String idthe id, may be null, FIXME is this unique? -
inheritTransform
public boolean inheritTransformWhether this node should inherit the transformation of its parent node, defaults to true. When this flag is false the value ofglobalTransformwill be the same as the value oflocalTransformcausing the transform to be independent of its parent transform. -
isAnimated
public boolean isAnimatedWhether this node is currently being animated, if so the translation, rotation and scale values are not used. -
translation
public final com.badlogic.gdx.math.Vector3 translationthe translation, relative to the parent, not modified by animations -
rotation
public final com.badlogic.gdx.math.Quaternion rotationthe rotation, relative to the parent, not modified by animations -
scale
public final com.badlogic.gdx.math.Vector3 scalethe scale, relative to the parent, not modified by animations -
localTransform
public final com.badlogic.gdx.math.Matrix4 localTransformthe local transform, based on translation/rotation/scale (calculateLocalTransform()) or any applied animation -
globalTransform
public final com.badlogic.gdx.math.Matrix4 globalTransformthe global transform, product of local transform and transform of the parent node, calculated viacalculateWorldTransform() -
parts
-
parent
-
-
Constructor Details
-
IntNode
public IntNode()
-
-
Method Details
-
calculateLocalTransform
public com.badlogic.gdx.math.Matrix4 calculateLocalTransform()Calculates the local transform based on the translation, scale and rotation- Returns:
- the local transform
-
calculateWorldTransform
public com.badlogic.gdx.math.Matrix4 calculateWorldTransform()Calculates the world transform; the product of local transform and the parent's world transform.- Returns:
- the world transform
-
calculateTransforms
public void calculateTransforms(boolean recursive)Calculates the local and world transform of this node and optionally all its children.- Parameters:
recursive- whether to calculate the local/world transforms for children.
-
calculateBoneTransforms
public void calculateBoneTransforms(boolean recursive) -
calculateBoundingBox
public com.badlogic.gdx.math.collision.BoundingBox calculateBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out)Calculate the bounding box of this Node. This is a potential slow operation, it is advised to cache the result. -
calculateBoundingBox
public com.badlogic.gdx.math.collision.BoundingBox calculateBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out, boolean transform)Calculate the bounding box of this Node. This is a potential slow operation, it is advised to cache the result. -
extendBoundingBox
public com.badlogic.gdx.math.collision.BoundingBox extendBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out)Extends the bounding box with the bounds of this Node. This is a potential slow operation, it is advised to cache the result. -
extendBoundingBox
public com.badlogic.gdx.math.collision.BoundingBox extendBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out, boolean transform)Extends the bounding box with the bounds of this Node. This is a potential slow operation, it is advised to cache the result. -
attachTo
Adds this node as child to specified parent Node, synonym for:parent.addChild(this)- Parameters:
parent- The Node to attach this Node to.
-
detach
public void detach()Removes this node from its current parent, if any. Short for:this.getParent().removeChild(this) -
hasChildren
public boolean hasChildren()- Returns:
- whether this Node has one or more children (true) or not (false)
-
getChildCount
public int getChildCount()- Returns:
- The number of child nodes that this Node current contains.
- See Also:
getChild(int)
-
getChild
- Parameters:
index- The zero-based index of the child node to get, must be: 0 <= index <getChildCount().- Returns:
- The child node at the specified index
-
getChild
- Parameters:
recursive- false to fetch a root child only, true to search the entire node tree for the specified node.- Returns:
- The node with the specified id, or null if not found.
-
addChild
Adds the specified node as the currently last child of this node. If the node is already a child of another node, then it is removed from its current parent.- Parameters:
child- The Node to add as child of this Node- Returns:
- the zero-based index of the child
-
addChildren
Adds the specified nodes as the currently last child of this node. If the node is already a child of another node, then it is removed from its current parent.- Parameters:
nodes- The Node to add as child of this Node- Returns:
- the zero-based index of the first added child
-
insertChild
Insert the specified node as child of this node at the specified index. If the node is already a child of another node, then it is removed from its current parent. If the specified index is less than zero or equal or greater thangetChildCount()then the Node is added as the currently last child.- Parameters:
index- The zero-based index at which to add the childchild- The Node to add as child of this Node- Returns:
- the zero-based index of the child
-
insertChildren
Insert the specified nodes as children of this node at the specified index. If the node is already a child of another node, then it is removed from its current parent. If the specified index is less than zero or equal or greater thangetChildCount()then the Node is added as the currently last child.- Parameters:
index- The zero-based index at which to add the childnodes- The nodes to add as child of this Node- Returns:
- the zero-based index of the first inserted child
-
removeChild
Removes the specified node as child of this node. On success, the child node will be not attached to any parent node (itsgetParent()method will return null). If the specified node currently isn't a child of this node then the removal is considered to be unsuccessful and the method will return false.- Parameters:
child- The child node to remove.- Returns:
- Whether the removal was successful.
-
getChildren
- Returns:
- An
Iterableto all child nodes that this node contains.
-
getParent
- Returns:
- The parent node that holds this node as child node, may be null.
-
hasParent
public boolean hasParent()- Returns:
- Whether (true) is this Node is a child node of another node or not (false).
-
copy
Creates a nested copy of this Node, any child nodes are copied using this method as well. Thepartsare copied using theIntNodePart.copy()method. Note that that method copies the material and nodes (bones) by reference. If you intend to use the copy in a different node tree (e.g. a different Model or ModelInstance) then you will need to update these references afterwards. Override this method in your custom Node class to instantiate that class, in that case you should override theset(IntNode)method as well. -
set
Creates a nested copy of this Node, any child nodes are copied using thecopy()method. This will detach this node from its parent, but does not attach it to the parent of node being copied. Thepartsare copied using theIntNodePart.copy()method. Note that that method copies the material and nodes (bones) by reference. If you intend to use this node in a different node tree (e.g. a different Model or ModelInstance) then you will need to update these references afterwards. Override this method in your custom Node class to copy any additional fields you've added.- Returns:
- This Node for chaining
-
getNode
public static IntNode getNode(com.badlogic.gdx.utils.Array<IntNode> nodes, java.lang.String id, boolean recursive, boolean ignoreCase)Helper method to recursive fetch a node from an array- Parameters:
recursive- false to fetch a root node only, true to search the entire node tree for the specified node.- Returns:
- The node with the specified id, or null if not found.
-