|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jme.scene.Spatial
com.jme.scene.Node
com.jme.animation.SkinNode
public class SkinNode
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).
One of the removeSkinGeometry methods should be used to remove skins. Simply detaching a skin from the scene may result in a memory leak, since the bone influences for that skin will be retained.
The 'skins' Node of a SkinNode should only parent Geometries. Do not parent it to anything else.
| 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 StringStringMap |
geometryRegions
We use a String key so that this structure won't delay garbage collection. |
protected boolean |
needsRefresh
|
protected boolean |
newSkeletonAssigned
|
protected Vector3f |
normal
|
protected Bone |
skeleton
|
protected Node |
skins
|
protected Vector3f |
vertex
|
| Fields inherited from class com.jme.scene.Node |
|---|
children |
| Fields inherited from class com.jme.scene.Spatial |
|---|
collisionBits, cullHint, frustrumIntersects, geometricalControllers, 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()
Assigns Bone instance references to BoneInfluences, by looking up the boneId names. |
void |
assignSkeletonBoneInfluences(Geometry skinGeo)
Assigns Bone instance references for one specific skin Geometry. |
protected void |
assignSkeletonBoneInfluences(int i)
|
protected void |
assimilate(Geometry newSkinGeo,
java.util.ArrayList<BoneInfluence>[] newInfluences,
java.lang.String skinRegion)
|
void |
assimilate(SkinNode otherSkinNode)
Assimilate all skin Geometries from the specified 'otherSkinNode', leaving this other SkinNode castrated. |
void |
assimilate(SkinNode otherSkinNode,
java.lang.String geoNameRegex)
Assimilates the specified skin mesh Geometries from the specified 'otherSkinNode' into this one, removing them from 'otherSkinNode'. |
void |
boneChanged(BoneChangeEvent e)
Invoked when the target of the listener has changed bone status. |
void |
childChange(Geometry geometry,
int index1,
int index2)
|
protected void |
cullRegionMappings()
We can't control how skin Geometries are removed, so we must cull unused region mappings before we use it. |
int |
deassimilate(java.lang.String skinRegion)
Remove specified skin Geometries, including associated BoneInfluences. |
java.lang.String |
getAnimationString()
|
java.util.ArrayList<BoneInfluence>[][] |
getCache()
|
java.util.ArrayList<ConnectionPoint> |
getConnectionPoints()
|
int |
getInfluenceCount(int geomIndex)
|
Bone |
getSkeleton()
|
Geometry |
getSkin(int i)
Returns a typed skin Geometry. |
Node |
getSkins()
getSkin returns the skins (Geometry objects) that the SkinNode is currently controlling. |
boolean |
hasSkinGeometry(java.lang.String geoName,
java.lang.String skinRegion)
|
boolean |
isExternalControl()
|
void |
normalizeWeights()
normalizeWeights insures that all vertex BoneInfluences equal 1. |
void |
normalizeWeights(int geomIndex)
|
void |
pose(int frameNum)
Stops the current animation and poses the skins to the static pose of the specified and frame. |
void |
pose(java.lang.String frameName)
Stops the current animation and poses the skins to the static pose of the specified and frame. |
void |
pose(java.lang.String animationName,
int frameNum)
Stops any running animation and poses the skins to the static pose of the specified animation and frame. |
void |
pose(java.lang.String animationName,
java.lang.String frameName)
Stops any running animation and poses the skins to the static pose of the specified animation and frame. |
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 |
regenInfluenceOffsets(Geometry skinGeo)
Regenerates the offsets for one specific skin Geometry. |
protected void |
regenInfluenceOffsets(int index)
|
void |
remapInfluences(VertMap[] mappings)
|
void |
remapInfluences(VertMap mappings,
int geomIndex)
|
void |
removeGeometry(int geomIndex)
This method DOES NOT REMOVE THE Geometry. |
int |
removeSkinGeometries()
Remove all skin Geometries, including associated BoneInfluences. |
Geometry |
removeSkinGeometry(int i)
Detaches a skin mesh from the SkinNode, removing the associated BoneInfluences along with it. |
Geometry |
removeSkinGeometry(java.lang.String geoName)
Detaches the named skin mesh from the SkinNode, removing the associated BoneInfluences along with it. |
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 |
setSkinRegion(Geometry skinGeometry,
java.lang.String skinRegion)
Use this to assign a skin region for a specific skin geometry. |
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. |
protected void |
validateSkins()
Validates that the 'skins' node is either null or contains only Geometry children. |
void |
write(JMEExporter e)
|
| 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 |
|---|
protected Vector3f vertex
protected Vector3f normal
protected boolean needsRefresh
protected Node skins
protected Bone skeleton
protected java.util.ArrayList<BoneInfluence>[][] cache
protected java.util.ArrayList<ConnectionPoint> connectionPoints
protected transient boolean newSkeletonAssigned
protected transient Matrix4f bindMatrix
protected StringStringMap geometryRegions
| Constructor Detail |
|---|
public SkinNode()
public SkinNode(java.lang.String name)
name - the name of this SkinNode| Method Detail |
|---|
public Node getSkins()
public Geometry getSkin(int i)
java.lang.RuntimeException - or Error subclass if 'skins' is null, if child
not present, or is not a Geometry.public void setSkins(Node skins)
skins - the skins that this SkinNode will affect.protected void validateSkins()
java.lang.IllegalStateException - if 'skins' contains a non-Geometry child.public void addSkin(Geometry skin)
skin - an additional skin that this SkinNode will affect.
public void addBoneInfluence(int geomIndex,
int vert,
Bone bone,
float weight)
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.public void setAnimation(BoneAnimation anim)
public void setAnimation(int index)
public void setAnimation(java.lang.String name)
public java.lang.String getAnimationString()
public void addBoneInfluence(int geomIndex,
int vert,
java.lang.String boneId,
float weight)
public ConnectionPoint addConnectionPoint(java.lang.String name,
Bone b)
public java.util.ArrayList<ConnectionPoint> getConnectionPoints()
public void recreateCache()
public void updateGeometricState(float time,
boolean initiator)
updateGeometricState in class Spatialtime - the time that has passed between calls.initiator - true if this is the top level being called.public void normalizeWeights()
public int getInfluenceCount(int geomIndex)
public void normalizeWeights(int geomIndex)
public void setSkeleton(Bone b)
public Bone getSkeleton()
public void assignSkeletonBoneInfluences()
public void assignSkeletonBoneInfluences(Geometry skinGeo)
assignSkeletonBoneInfluences()protected void assignSkeletonBoneInfluences(int i)
public void regenInfluenceOffsets()
public void regenInfluenceOffsets(Geometry skinGeo)
regenInfluenceOffsets()protected void regenInfluenceOffsets(int index)
public void updateSkin()
public java.util.ArrayList<BoneInfluence>[][] getCache()
public void setCache(java.util.ArrayList<BoneInfluence>[][] cache)
public void setBindMatrix(Matrix4f mat)
public void childChange(Geometry geometry,
int index1,
int index2)
childChange in class Node
public void write(JMEExporter e)
throws java.io.IOException
write in interface Savablewrite in class Nodejava.io.IOException
public void read(JMEImporter e)
throws java.io.IOException
read in interface Savableread in class Nodejava.io.IOExceptionpublic void revertToBind()
public void boneChanged(BoneChangeEvent e)
BoneChangeListener
boneChanged in interface BoneChangeListenere - a ChangeEvent objectpublic void remapInfluences(VertMap[] mappings)
public void remapInfluences(VertMap mappings,
int geomIndex)
public void removeGeometry(int geomIndex)
public void setExternalControl(boolean externalControl)
public boolean isExternalControl()
public void assimilate(SkinNode otherSkinNode)
assimilate(SkinNode, String)
public void assimilate(SkinNode otherSkinNode,
java.lang.String geoNameRegex)
For this first implementation, we have some rather stringent requirements. If use cases justify accommodating other states, these requirements can be relaxed with further development work.
This method will not succeed if the rest animation and rest pose frame have not been set in the AnimationController (unless no AnimationController has been assigned for this SkinNode yet).
IMPORTANT: The calling signature is tentative. It's likely that checked exceptions will be added, so expect to need to update your exception-handling until this method has stabilized.
otherSkinNode - Node from which the Geometries and BoneInfluences
will be taken.geoNameRegex - To specify which Geometries to assimilate.
Null to assimilate all skin Geometries from
'otherSkinNode'.
java.lang.RuntimeException - for various state validation failures.
This is easier to use, but not as robust.
This is likely to change soon.
protected void assimilate(Geometry newSkinGeo,
java.util.ArrayList<BoneInfluence>[] newInfluences,
java.lang.String skinRegion)
public Geometry removeSkinGeometry(java.lang.String geoName)
removeSkinGeometry(int)
public boolean hasSkinGeometry(java.lang.String geoName,
java.lang.String skinRegion)
skinRegion - null means match any (including no) skin regionpublic Geometry removeSkinGeometry(int i)
removeGeometry(int)public int removeSkinGeometries()
public int deassimilate(java.lang.String skinRegion)
skinRegion - All skin Geometries associated with this skinRegion
name will be removed.
IMPORTANT: null means to remove all
skin Geometries, not just those with null skinRegion,
nor just those added by assimilation.
There is no method to remove just null skinRegion
skins, since null means they should be managed
obliviously to skinRegions.
protected void cullRegionMappings()
public void setSkinRegion(Geometry skinGeometry,
java.lang.String skinRegion)
If the skinRegion for skinGeometry is already set to skin region, no harm done.
skinGeometry - Should already be a skin geometry of this SkinNode.
If it isn't, it will have no effect and no indication will be given.
(The entry will get lazily culled in the future).public void pose(int frameNum)
public void pose(java.lang.String frameName)
public void pose(java.lang.String animationName,
int frameNum)
public void pose(java.lang.String animationName,
java.lang.String frameName)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||