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 aIntModel
. A Node encodes a transform relative to its parents. A Node can have child nodes. Optionally a node can specify aIntMeshPart
and aMaterial
to be applied to the mesh part.


Field Summary
Fields Modifier and Type Field Description com.badlogic.gdx.math.Matrix4
globalTransform
the global transform, product of local transform and transform of the parent node, calculated viacalculateWorldTransform()
java.lang.String
id
the id, may be null, FIXME is this unique?boolean
inheritTransform
Whether this node should inherit the transformation of its parent node, defaults to true.boolean
isAnimated
Whether this node is currently being animated, if so the translation, rotation and scale values are not used.com.badlogic.gdx.math.Matrix4
localTransform
the local transform, based on translation/rotation/scale (calculateLocalTransform()
) or any applied animationprotected IntNode
parent
com.badlogic.gdx.utils.Array<IntNodePart>
parts
com.badlogic.gdx.math.Quaternion
rotation
the rotation, relative to the parent, not modified by animationscom.badlogic.gdx.math.Vector3
scale
the scale, relative to the parent, not modified by animationscom.badlogic.gdx.math.Vector3
translation
the translation, relative to the parent, not modified by animations

Constructor Summary
Constructors Constructor Description IntNode()

Method Summary
All Methods Static Methods Instance Methods Concrete Methods 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)
void
calculateBoneTransforms(boolean recursive)
com.badlogic.gdx.math.collision.BoundingBox
calculateBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out)
Calculate the bounding box of this Node.com.badlogic.gdx.math.collision.BoundingBox
calculateBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out, boolean transform)
Calculate the bounding box of this Node.com.badlogic.gdx.math.Matrix4
calculateLocalTransform()
Calculates the local transform based on the translation, scale and rotationvoid
calculateTransforms(boolean recursive)
Calculates the local and world transform of this node and optionally all its children.com.badlogic.gdx.math.Matrix4
calculateWorldTransform()
Calculates the world transform; the product of local transform and the parent's world transform.IntNode
copy()
Creates a nested copy of this Node, any child nodes are copied using this method as well.void
detach()
Removes this node from its current parent, if any.com.badlogic.gdx.math.collision.BoundingBox
extendBoundingBox(com.badlogic.gdx.math.collision.BoundingBox out)
Extends the bounding box with the bounds of this Node.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.IntNode
getChild(int index)
IntNode
getChild(java.lang.String id, boolean recursive, boolean ignoreCase)
int
getChildCount()
java.lang.Iterable<IntNode>
getChildren()
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 arrayIntNode
getParent()
boolean
hasChildren()
boolean
hasParent()
<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 IntNode
set(IntNode other)
Creates a nested copy of this Node, any child nodes are copied using thecopy()
method.



Field Detail

id
public java.lang.String id
the id, may be null, FIXME is this unique?

inheritTransform
public boolean inheritTransform
Whether this node should inherit the transformation of its parent node, defaults to true. When this flag is false the value ofglobalTransform
will be the same as the value oflocalTransform
causing the transform to be independent of its parent transform.

isAnimated
public boolean isAnimated
Whether 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 translation
the translation, relative to the parent, not modified by animations

rotation
public final com.badlogic.gdx.math.Quaternion rotation
the rotation, relative to the parent, not modified by animations

scale
public final com.badlogic.gdx.math.Vector3 scale
the scale, relative to the parent, not modified by animations

localTransform
public final com.badlogic.gdx.math.Matrix4 localTransform
the local transform, based on translation/rotation/scale (calculateLocalTransform()
) or any applied animation

globalTransform
public final com.badlogic.gdx.math.Matrix4 globalTransform
the global transform, product of local transform and transform of the parent node, calculated viacalculateWorldTransform()

parts
public com.badlogic.gdx.utils.Array<IntNodePart> parts

parent
protected IntNode parent


Method Detail

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
public <T extends IntNode> void attachTo(T parent)
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
public IntNode getChild(int index)
 Parameters:
index
 The zerobased index of the child node to get, must be: 0 <= index <getChildCount()
. Returns:
 The child node at the specified index

getChild
public IntNode getChild(java.lang.String id, boolean recursive, boolean ignoreCase)
 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
public <T extends IntNode> int addChild(T child)
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 zerobased index of the child

addChildren
public <T extends IntNode> int addChildren(java.lang.Iterable<T> nodes)
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 zerobased index of the first added child

insertChild
public <T extends IntNode> int insertChild(int index, T child)
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 zerobased index at which to add the childchild
 The Node to add as child of this Node Returns:
 the zerobased index of the child

insertChildren
public <T extends IntNode> int insertChildren(int index, java.lang.Iterable<T> nodes)
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 zerobased index at which to add the childnodes
 The nodes to add as child of this Node Returns:
 the zerobased index of the first inserted child

removeChild
public <T extends IntNode> boolean removeChild(T child)
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
public java.lang.Iterable<IntNode> getChildren()
 Returns:
 An
Iterable
to all child nodes that this node contains.

getParent
public IntNode 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
public IntNode copy()
Creates a nested copy of this Node, any child nodes are copied using this method as well. Theparts
are 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
protected IntNode set(IntNode other)
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. Theparts
are 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.

