com.threed.jpct.skeleton
Class SimpleSkeleton

java.lang.Object
  extended by com.threed.jpct.skeleton.SimpleSkeleton

public class SimpleSkeleton
extends java.lang.Object

A simple implementation of a skeleton. The skeleton references, and controls the bones, and their animation keyframes.

Author:
mcgreevyj

Constructor Summary
SimpleSkeleton()
           
 
Method Summary
 void advanceAnimation()
          Advances the animation sequence.
 void build()
          Initializes the skeleton.
 SimpleBone getBone(int id)
          Returns a bone with the same id, or null if nothing is found.
 SimpleBone getBone(java.lang.String name)
          Returns a bone with the same name, or null if nothing is found.
 SimpleBone[] getBones()
          Return skeleton's bone array.
 void restartAnimation()
          Restarts the animation sequence.
 void setAnimations(SkeletalAnimation[] animations)
          Set the animation array.
 void setBones(SimpleBone[] bones)
          Sets the bone array of this skeleton.
 void setCurrentAnimation(int animation)
          Sets the current animation sequence directly, by its index.
 void setCurrentAnimation(java.lang.String name)
          Sets current animation sequence.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSkeleton

public SimpleSkeleton()
Method Detail

setCurrentAnimation

public void setCurrentAnimation(int animation)
Sets the current animation sequence directly, by its index.

Parameters:
animation - Index of animation sequence.

setCurrentAnimation

public void setCurrentAnimation(java.lang.String name)
Sets current animation sequence. Searches for animation index to use from the name.

Parameters:
name - Name of animation to set.

setBones

public void setBones(SimpleBone[] bones)
Sets the bone array of this skeleton. TODO: Sort bones here! Sort by parent hierarchy.

Parameters:
bones - Array of bones.

setAnimations

public void setAnimations(SkeletalAnimation[] animations)
Set the animation array. The animation array does not contain animation keyframes, but provides a way to convert from name to index, and stores the animation lengths.

Parameters:
animations - Array of animation definitions

getBone

public SimpleBone getBone(java.lang.String name)
Returns a bone with the same name, or null if nothing is found.

Parameters:
name - Name of bone to search for
Returns:
Bone with the same name

getBone

public SimpleBone getBone(int id)
Returns a bone with the same id, or null if nothing is found.

Parameters:
id - Id of bone to search for
Returns:
Bone with the same id

build

public void build()
Initializes the skeleton. Must be called before use.


restartAnimation

public void restartAnimation()
Restarts the animation sequence. Bone keyframe counters are reset, in addition to the timer.


advanceAnimation

public void advanceAnimation()
Advances the animation sequence. The faster this method is called, the higher the fidelity of the animation. The keyframes are self timed, and will not be made faster by more calls to this method.


getBones

public SimpleBone[] getBones()
Return skeleton's bone array.

Returns:
Array of bones.