com.jme.animation
Class SkinNode

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

public class SkinNode
extends Node
implements Savable, BoneChangeListener

SkinNode defines a scene node that contains skinned mesh data. A skinned mesh is defined by a Geometry object representing the "skin" that is attached to a skeleton (or a tree of Bones). The orientation, translation of these bones define the position of the skin vertices. These bones can then be driven by an animation system to provide the animation of the skin. SkinNode defines for each vertex of the skin the bone that affects it and the weight (BoneInfluence) of that affect. This allows multiple bones to share a single vertex (although the total weight must add up to 1).

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  Matrix4f bindMatrix
           
protected  java.util.ArrayList<BoneInfluence>[][] cache
           
protected  java.util.ArrayList<ConnectionPoint> connectionPoints
           
protected  boolean needsRefresh
           
protected  boolean newSkeletonAssigned
           
protected static Vector3f normal
           
protected  Bone skeleton
           
protected  Node skins
           
protected static Vector3f vertex
           
 
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
SkinNode()
          Empty Constructor to be used internally only.
SkinNode(java.lang.String name)
          Constructor creates a new SkinNode object with the supplied name.
 
Method Summary
 void addBoneInfluence(int geomIndex, int vert, Bone bone, float weight)
          addBoneInfluence defines how a vertex will be affected by a bone.
 void addBoneInfluence(int geomIndex, int vert, java.lang.String boneId, float weight)
           
 ConnectionPoint addConnectionPoint(java.lang.String name, Bone b)
           
 void addSkin(Geometry skin)
          addSkins sets the skin that the SkinNode will affect.
 void assignSkeletonBoneInfluences()
           
 void boneChanged(BoneChangeEvent e)
          Invoked when the target of the listener has changed bone status.
 void childChange(Geometry geometry, int index1, int index2)
           
 java.lang.String getAnimationString()
           
 java.util.ArrayList<BoneInfluence>[][] getCache()
           
 java.util.ArrayList<ConnectionPoint> getConnectionPoints()
           
 int getInfluenceCount(int geomIndex)
           
 Bone getSkeleton()
           
 Node getSkins()
          getSkin returns the skins (Geometry objects) that the SkinNode is currently controlling.
 boolean isExternalControl()
           
 void normalizeWeights()
          normalizeWeights insures that all vertex BoneInfluences equal 1.
 void normalizeWeights(int geomIndex)
           
 void read(JMEImporter e)
           
 void recreateCache()
          recreateCache initializes the cache of BoneInfluences for use by the skin node.
 void regenInfluenceOffsets()
          regenInfluenceOffsets calculate the offset of a particular vertex from a bone.
 void remapInfluences(VertMap[] mappings)
           
 void remapInfluences(VertMap mappings, int geomIndex)
           
 void removeGeometry(int geomIndex)
           
 void revertToBind()
           
 void setAnimation(BoneAnimation anim)
           
 void setAnimation(int index)
           
 void setAnimation(java.lang.String name)
           
 void setBindMatrix(Matrix4f mat)
           
 void setCache(java.util.ArrayList<BoneInfluence>[][] cache)
           
 void setExternalControl(boolean externalControl)
           
 void setSkeleton(Bone b)
           
 void setSkins(Node skins)
          setSkin sets the skin that the SkinNode will affect.
 void updateGeometricState(float time, boolean initiator)
          updateGeometricState overrides Spatials updateGeometric state to update the assigned skeleton bone influences, if changed.
 void updateSkin()
          updateSkin positions the vertices of the skin based on the bones and the BoneInfluences those bones have on the vertices.
 void write(JMEExporter e)
           
 
Methods inherited from class com.jme.scene.Node
applyRenderState, attachChild, attachChildAt, 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
addController, 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, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setLocalTranslation, setLocks, setLocks, setName, setNormalsMode, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setUserData, setZOrder, setZOrder, toString, unlock, unlock, unlockBranch, unlockMeshes, updateRenderState, updateRenderState, updateWorldRotation, updateWorldScale, updateWorldTranslation, updateWorldVectors, 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

vertex

protected static Vector3f vertex

normal

protected static Vector3f normal

needsRefresh

protected boolean needsRefresh

skins

protected Node skins

skeleton

protected Bone skeleton

cache

protected java.util.ArrayList<BoneInfluence>[][] cache

connectionPoints

protected java.util.ArrayList<ConnectionPoint> connectionPoints

newSkeletonAssigned

protected transient boolean newSkeletonAssigned

bindMatrix

protected transient Matrix4f bindMatrix
Constructor Detail

SkinNode

public SkinNode()
Empty Constructor to be used internally only.


SkinNode

public SkinNode(java.lang.String name)
Constructor creates a new SkinNode object with the supplied name.

Parameters:
name - the name of this SkinNode
Method Detail

getSkins

public Node getSkins()
getSkin returns the skins (Geometry objects) that the SkinNode is currently controlling.

Returns:
the skins contained in this SkinNode

setSkins

public void setSkins(Node skins)
setSkin sets the skin that the SkinNode will affect.

Parameters:
skins - the skins that this SkinNode will affect.

addSkin

public void addSkin(Geometry skin)
addSkins sets the skin that the SkinNode will affect.

Parameters:
skin - an additional skin that this SkinNode will affect.

addBoneInfluence

public void addBoneInfluence(int geomIndex,
                             int vert,
                             Bone bone,
                             float weight)
addBoneInfluence defines how a vertex will be affected by a bone. This is given with four values, the geometry child the vertex is found, the index to the vertex in the geometry, the index of the bone that has been or will be set via setBones or addBone and the weight that this indexed bone affects the vertex.

Parameters:
geomIndex - the geometry child that contains the vertex to be affected.
vert - the index to the vertex.
bone - the bone that affects the vertex.
weight - the weight that the bone will affect the vertex.

setAnimation

public void setAnimation(BoneAnimation anim)

setAnimation

public void setAnimation(int index)

setAnimation

public void setAnimation(java.lang.String name)

getAnimationString

public java.lang.String getAnimationString()

addBoneInfluence

public void addBoneInfluence(int geomIndex,
                             int vert,
                             java.lang.String boneId,
                             float weight)

addConnectionPoint

public ConnectionPoint addConnectionPoint(java.lang.String name,
                                          Bone b)

getConnectionPoints

public java.util.ArrayList<ConnectionPoint> getConnectionPoints()

recreateCache

public void recreateCache()
recreateCache initializes the cache of BoneInfluences for use by the skin node.


updateGeometricState

public void updateGeometricState(float time,
                                 boolean initiator)
updateGeometricState overrides Spatials updateGeometric state to update the assigned skeleton bone influences, if changed.

Overrides:
updateGeometricState in class Spatial
Parameters:
time - the time that has passed between calls.
initiator - true if this is the top level being called.

normalizeWeights

public void normalizeWeights()
normalizeWeights insures that all vertex BoneInfluences equal 1. The total BoneInfluence on a single vertex should be 1 otherwise the position of the vertex will be multiplied.


getInfluenceCount

public int getInfluenceCount(int geomIndex)

normalizeWeights

public void normalizeWeights(int geomIndex)

setSkeleton

public void setSkeleton(Bone b)

getSkeleton

public Bone getSkeleton()

assignSkeletonBoneInfluences

public void assignSkeletonBoneInfluences()

regenInfluenceOffsets

public void regenInfluenceOffsets()
regenInfluenceOffsets calculate the offset of a particular vertex from a bone. This allows the bone's rotation to position the vertex in world space. This should only be called a single time during initialization.


updateSkin

public void updateSkin()
updateSkin positions the vertices of the skin based on the bones and the BoneInfluences those bones have on the vertices. Each vertex is placed into world space for rendering.


getCache

public java.util.ArrayList<BoneInfluence>[][] getCache()

setCache

public void setCache(java.util.ArrayList<BoneInfluence>[][] cache)

setBindMatrix

public void setBindMatrix(Matrix4f mat)

childChange

public void childChange(Geometry geometry,
                        int index1,
                        int index2)
Overrides:
childChange in class Node

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()

boneChanged

public void boneChanged(BoneChangeEvent e)
Description copied from interface: BoneChangeListener
Invoked when the target of the listener has changed bone status.

Specified by:
boneChanged in interface BoneChangeListener
Parameters:
e - a ChangeEvent object

remapInfluences

public void remapInfluences(VertMap[] mappings)

remapInfluences

public void remapInfluences(VertMap mappings,
                            int geomIndex)

removeGeometry

public void removeGeometry(int geomIndex)

setExternalControl

public void setExternalControl(boolean externalControl)

isExternalControl

public boolean isExternalControl()