com.jme.animation
Class Bone

java.lang.Object
  extended by com.jme.scene.Spatial
      extended by com.jme.scene.Node
          extended by com.jme.animation.Bone
All Implemented Interfaces:
Savable, java.io.Serializable

public class Bone
extends Node
implements Savable

Bone defines a scenegraph node that defines a single bone object within a skeletal system. The bone defines a bind matrix which will transform the bone into the pose position. This bine matrix is used to position the bone with the skin, then move the skin to its world position.

Version:
$Id: Bone.java 4131 2009-03-19 20:15:28Z blaine.dev $
Author:
Joshua Slack, Mark Powell
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jme.scene.Spatial
Spatial.CullHint, Spatial.LightCombineMode, Spatial.NormalsMode, Spatial.TextureCombineMode
 
Field Summary
protected  AnimationController animationController
           
protected  Matrix4f bindMatrix
           
protected  boolean boneChanged
           
protected  java.util.ArrayList<BoneChangeListener> changeListeners
           
protected  Quaternion oldRot
           
protected  Vector3f oldScale
           
protected  Vector3f oldTran
           
protected  boolean skinRoot
           
protected  Matrix4f transform
           
protected  Vector3f workVectA
           
 
Fields inherited from class com.jme.scene.Node
children
 
Fields inherited from class com.jme.scene.Spatial
cullHint, frustrumIntersects, geometricalControllers, isCollidable, lightCombineMode, localRotation, localScale, localTranslation, LOCKED_BOUNDS, LOCKED_BRANCH, LOCKED_MESH_DATA, LOCKED_NONE, LOCKED_SHADOWS, LOCKED_TRANSFORMS, lockedMode, name, normalsMode, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
Bone()
           
Bone(java.lang.String name)
          Creates a new bone with the supplied name.
Bone(java.lang.String name, Matrix4f bindMatrix)
          creates a new bone with a given name and a bind matrix.
 
Method Summary
 void addBoneListener(BoneChangeListener listener)
           
 void addController(Controller c)
          Adds a Controller to this Spatial's list of controllers.
 void applyBone(BoneInfluence inf, Vector3f vstore, Vector3f nstore)
          applyBone affects a given vertex by its current world position.
 void copyBindings(Bone newBone)
          copyBindings sets the bone's bone matrix of an incoming skeleton (or subskeleton) to that of the matching bone of this skeleton.
protected  void fireBoneChange()
           
 AnimationController getAnimationController()
           
 Matrix4f getBindMatrix()
          retrieves the bind matrix of this bone.
protected  int getListenerQuantity()
           
 Bone getRootSkeleton()
           
protected  boolean hasTransformChanged()
           
 boolean isHardpoint()
           
 boolean isSkinRoot()
           
 void propogateBoneChange(boolean initiator)
           
 void propogateBoneChangeToChildren(boolean initiator)
           
 void propogateBoneChangeToParent(boolean initiator)
           
 void read(JMEImporter e)
           
 void removeBoneListener(BoneChangeListener listener)
           
 void resetChangeValues()
           
 void revertToBind()
           
 void setBindMatrix(Matrix4f bindMatrix)
          sets the bind matrix of this bone.
 void setHardpoint(boolean isHardpoint)
           
 void setLocalRotation(Matrix3f rotation)
          setLocalRotation sets the local rotation of this node.
 void setLocalRotation(Quaternion quaternion)
          setLocalRotation sets the local rotation of this node, using a quaterion to build the matrix.
 void setLocalScale(float localScale)
          setLocalScale sets the local scale of this node.
 void setLocalScale(Vector3f localScale)
          setLocalScale sets the local scale of this node.
 void setLocalTranslation(Vector3f localTranslation)
          setLocalTranslation sets the local translation of this node.
static void setOptimizeTransform(boolean enabled)
          Switches the transform optimization on or off.
 void setSkinRoot(boolean skinRoot)
           
 void update()
          Updates this bone's useTransform and then calls its children recursively.
 void updateGeometricState(float time, boolean initiator)
          updateGeometricState updates all the geometry information for the node.
 void updateWorldVectors()
          If not locked, updates worldscale, worldrotation and worldtranslation
 void write(JMEExporter e)
           
 
Methods inherited from class com.jme.scene.Node
applyRenderState, attachChild, attachChildAt, childChange, detachAllChildren, detachChild, detachChildAt, detachChildNamed, draw, findCollisions, findPick, getChild, getChild, getChildIndex, getChildren, getQuantity, getTriangleCount, getVertexCount, hasChild, hasCollision, lockBounds, lockMeshes, lockShadows, lockTransforms, setModelBound, sortLights, swapChildren, unlockBounds, unlockMeshes, unlockShadows, unlockTransforms, updateModelBound, updateWorldBound, updateWorldData, updateWorldVectors
 
Methods inherited from class com.jme.scene.Spatial
calculateCollisions, calculatePick, clearControllers, clearRenderState, clearRenderState, getClassTag, getController, getControllerCount, getControllers, getCullHint, getLastFrustumIntersection, getLightCombineMode, getLocalCullHint, getLocalLightCombineMode, getLocalNormalsMode, getLocalRenderQueueMode, getLocalRotation, getLocalScale, getLocalTextureCombineMode, getLocalToWorldMatrix, getLocalTranslation, getLocks, getName, getNormalsMode, getParent, getRenderQueueMode, getRenderState, getRenderState, getTextureCombineMode, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, hasAncestor, isCollidable, localToWorld, lock, lock, lockBranch, lockMeshes, lookAt, onDraw, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeController, removeFromParent, removeUserData, rotateUpTo, setCullHint, setIsCollidable, setLastFrustumIntersection, setLightCombineMode, setLocalTranslation, setLocks, setLocks, setName, setNormalsMode, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setUserData, setZOrder, setZOrder, toString, unlock, unlock, unlockBranch, unlockMeshes, updateRenderState, updateRenderState, updateWorldRotation, updateWorldScale, updateWorldTranslation, worldToLocal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.jme.util.export.Savable
getClassTag
 

Field Detail

bindMatrix

protected Matrix4f bindMatrix

animationController

protected AnimationController animationController

workVectA

protected final Vector3f workVectA

transform

protected final Matrix4f transform

oldScale

protected Vector3f oldScale

oldTran

protected Vector3f oldTran

oldRot

protected Quaternion oldRot

boneChanged

protected transient boolean boneChanged

skinRoot

protected transient boolean skinRoot

changeListeners

protected transient java.util.ArrayList<BoneChangeListener> changeListeners
Constructor Detail

Bone

public Bone()

Bone

public Bone(java.lang.String name)
Creates a new bone with the supplied name.

Parameters:
name - the name of this bone.

Bone

public Bone(java.lang.String name,
            Matrix4f bindMatrix)
creates a new bone with a given name and a bind matrix.

Parameters:
name - the name of the bone.
bindMatrix - the bind matrix of the bone.
Method Detail

setOptimizeTransform

public static void setOptimizeTransform(boolean enabled)
Switches the transform optimization on or off. The default is off when this class is first loaded. The transform optimization works by calculating this bone's world transform once before applying it to a given skin, instead of calculating the transform once for every vertex influenced by this bone.

Parameters:
enabled - true switches the transform optimization on

update

public void update()
Updates this bone's useTransform and then calls its children recursively. Called from SkinNode#updateSkin() so that this bone's transform is up to date before the skin is recomputed. The method does nothing if the transform optimization is disabled.


copyBindings

public void copyBindings(Bone newBone)
copyBindings sets the bone's bone matrix of an incoming skeleton (or subskeleton) to that of the matching bone of this skeleton.

Parameters:
newBone - the bone to copy the bindings to.

applyBone

public void applyBone(BoneInfluence inf,
                      Vector3f vstore,
                      Vector3f nstore)
applyBone affects a given vertex by its current world position. This is done by first placing the vertex into the pose position using the bind matrix, then transforming it into world space using the bone's world rotation and world translation.

Parameters:
inf - the influence this bone affects the vertex. Including its offset and weight.
vstore - the vertex to manipulate.
nstore - the normal to manipulate.

getBindMatrix

public Matrix4f getBindMatrix()
retrieves the bind matrix of this bone.

Returns:
the bind matrix of this bone.

setBindMatrix

public void setBindMatrix(Matrix4f bindMatrix)
sets the bind matrix of this bone.

Parameters:
bindMatrix - the bind matrix of this bone.

addController

public void addController(Controller c)
Description copied from class: Spatial
Adds a Controller to this Spatial's list of controllers.

Overrides:
addController in class Spatial
Parameters:
c - The Controller to add
See Also:
Controller

updateGeometricState

public void updateGeometricState(float time,
                                 boolean initiator)
Description copied from class: Spatial
updateGeometricState updates all the geometry information for the node.

Overrides:
updateGeometricState in class Spatial
Parameters:
time - the frame time.
initiator - true if this node started the update process.

resetChangeValues

public void resetChangeValues()

updateWorldVectors

public void updateWorldVectors()
Description copied from class: Spatial
If not locked, updates worldscale, worldrotation and worldtranslation

Overrides:
updateWorldVectors in class Spatial

getAnimationController

public AnimationController getAnimationController()

write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Overrides:
write in class Node
Throws:
java.io.IOException

read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Overrides:
read in class Node
Throws:
java.io.IOException

revertToBind

public void revertToBind()

getRootSkeleton

public Bone getRootSkeleton()

addBoneListener

public void addBoneListener(BoneChangeListener listener)

removeBoneListener

public void removeBoneListener(BoneChangeListener listener)

getListenerQuantity

protected int getListenerQuantity()

fireBoneChange

protected void fireBoneChange()

isSkinRoot

public boolean isSkinRoot()

setSkinRoot

public void setSkinRoot(boolean skinRoot)

propogateBoneChangeToParent

public void propogateBoneChangeToParent(boolean initiator)

propogateBoneChangeToChildren

public void propogateBoneChangeToChildren(boolean initiator)

hasTransformChanged

protected boolean hasTransformChanged()

propogateBoneChange

public void propogateBoneChange(boolean initiator)

setLocalRotation

public void setLocalRotation(Matrix3f rotation)
Description copied from class: Spatial
setLocalRotation sets the local rotation of this node.

Overrides:
setLocalRotation in class Spatial
Parameters:
rotation - the new local rotation.

setLocalRotation

public void setLocalRotation(Quaternion quaternion)
Description copied from class: Spatial
setLocalRotation sets the local rotation of this node, using a quaterion to build the matrix.

Overrides:
setLocalRotation in class Spatial
Parameters:
quaternion - the quaternion that defines the matrix.

setLocalTranslation

public void setLocalTranslation(Vector3f localTranslation)
Description copied from class: Spatial
setLocalTranslation sets the local translation of this node.

Overrides:
setLocalTranslation in class Spatial
Parameters:
localTranslation - the local translation of this node.

setLocalScale

public void setLocalScale(Vector3f localScale)
Description copied from class: Spatial
setLocalScale sets the local scale of this node.

Overrides:
setLocalScale in class Spatial
Parameters:
localScale - the new local scale.

setLocalScale

public void setLocalScale(float localScale)
Description copied from class: Spatial
setLocalScale sets the local scale of this node.

Overrides:
setLocalScale in class Spatial
Parameters:
localScale - the new local scale, applied to x, y and z

isHardpoint

public boolean isHardpoint()

setHardpoint

public void setHardpoint(boolean isHardpoint)