jglanim
Class JGL_Bone

java.lang.Object
  extended by jglanim.JGL_Bone

public final class JGL_Bone
extends java.lang.Object

Representation of an animated bone. It's a recursive structure witch contains a keyframes list (JGL_KeyframesArray object), a point indexes list , and a children list.
A bone can be moved by keyframes, then he modifies its associated points. Its children recursively recover its movement. A bone must have an ID and a parent ID (or "" if it's a skeleton root).

Author:
Nicolas Devere

Constructor Summary
JGL_Bone(java.lang.String _id, java.lang.String _idParent, JGL_3DVector _position, JGL_3DVector _orientation)
          Constructs a new JGL_Bone.
 
Method Summary
 boolean addBone(JGL_Bone bone)
          Adds recursively a bone.
 void addKeyframe(JGL_Keyframe keyframe)
          Adds a keyframe to the bone.
 void addPoint(int pointIndex)
          Adds a point index to the bone.
 void clearKeyframes()
          Removes all the keyframes from the bone.
 void clearPoints()
          Removes all the points indexes from the bone.
 JGL_3DVector getBaseOrientation()
          Returns the bone's relative base orientation.
 JGL_3DVector getBasePosition()
          Returns the bone's relative base position.
 java.util.Vector getChildren()
          Returns the bone's children list.
 JGL_3DVector getCurrentOrientation()
          Returns the bone's relative current orientation.
 JGL_3DVector getCurrentPosition()
          Returns the bone's relative current position.
 java.lang.String getID()
          Returns the bone's ID.
 java.lang.String getIDparent()
          Returns the bone's parent ID.
 JGL_KeyframesArray getKeyframes()
          Returns the bone's keyframes array object.
 JGL_3DVector getObjectivePosition()
          Returns the bone's objective current position (in the root bone mark).
 void interpolationByFrame(java.util.Vector allPoints, float p, JGL_3DMatrix parentMatrix, JGL_3DVector parentPosition)
          Applies a frame by frame interpolation to the bone's keyframes list, then applies the result to the bones's indexed points in the allPoints list.
 void interpolationCubic(java.util.Vector allPoints, float p, JGL_3DMatrix parentMatrix, JGL_3DVector parentPosition)
          Applies a cubic interpolation to the bone's keyframes list, then applies the result to the bones's indexed points in the allPoints list.
 void interpolationLinear(java.util.Vector allPoints, float p, JGL_3DMatrix parentMatrix, JGL_3DVector parentPosition)
          Applies a linear interpolation to the bone's keyframes list, then applies the result to the bones's indexed points in the allPoints list.
 void removeKeyframe(int index)
          Removes the keyframe at the specified position in the bone.
 int sizeKeyframes()
          Returns the keyframes number in the bone.
 int sizePoints()
          Returns the points indexes number in the bone.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JGL_Bone

public JGL_Bone(java.lang.String _id,
                java.lang.String _idParent,
                JGL_3DVector _position,
                JGL_3DVector _orientation)
Constructs a new JGL_Bone.

Parameters:
_id - : the bone's ID
_idParent - : the bone's parent ID
_position - : the bone's relative position
_orientation - : the bone's relative orientation
Method Detail

addBone

public boolean addBone(JGL_Bone bone)
Adds recursively a bone.

Parameters:
bone - : the bone to add
Returns:
true if the bone is added to a matched parent, false otherwise

addPoint

public void addPoint(int pointIndex)
Adds a point index to the bone.

Parameters:
pointIndex - : the point index

sizePoints

public int sizePoints()
Returns the points indexes number in the bone.

Returns:
the points indexes number in the bone

clearPoints

public void clearPoints()
Removes all the points indexes from the bone.


addKeyframe

public void addKeyframe(JGL_Keyframe keyframe)
Adds a keyframe to the bone.

Parameters:
keyframe - : the keyframe to add

sizeKeyframes

public int sizeKeyframes()
Returns the keyframes number in the bone.

Returns:
the keyframes number in the bone

removeKeyframe

public void removeKeyframe(int index)
Removes the keyframe at the specified position in the bone.

Parameters:
index - : the keyframe's index to remove

clearKeyframes

public void clearKeyframes()
Removes all the keyframes from the bone.


getID

public java.lang.String getID()
Returns the bone's ID.

Returns:
the bone's ID

getIDparent

public java.lang.String getIDparent()
Returns the bone's parent ID.

Returns:
the bone's parent ID

getKeyframes

public JGL_KeyframesArray getKeyframes()
Returns the bone's keyframes array object.

Returns:
the bone's keyframes array object

getBasePosition

public JGL_3DVector getBasePosition()
Returns the bone's relative base position.

Returns:
the bone's relative base position

getBaseOrientation

public JGL_3DVector getBaseOrientation()
Returns the bone's relative base orientation.

Returns:
the bone's relative base orientation

getCurrentPosition

public JGL_3DVector getCurrentPosition()
Returns the bone's relative current position.

Returns:
the bone's relative current position

getCurrentOrientation

public JGL_3DVector getCurrentOrientation()
Returns the bone's relative current orientation.

Returns:
the bone's relative current orientation

getObjectivePosition

public JGL_3DVector getObjectivePosition()
Returns the bone's objective current position (in the root bone mark).

Returns:
the bone's objective current position

getChildren

public java.util.Vector getChildren()
Returns the bone's children list.

Returns:
the bone's children list

interpolationByFrame

public void interpolationByFrame(java.util.Vector allPoints,
                                 float p,
                                 JGL_3DMatrix parentMatrix,
                                 JGL_3DVector parentPosition)
Applies a frame by frame interpolation to the bone's keyframes list, then applies the result to the bones's indexed points in the allPoints list.

Parameters:
allPoints - : the total points list
p - : the interpolation parametric variable
parentMatrix - : the transformation from parent bones
parentPosition - : the parent bone's objective position

interpolationLinear

public void interpolationLinear(java.util.Vector allPoints,
                                float p,
                                JGL_3DMatrix parentMatrix,
                                JGL_3DVector parentPosition)
Applies a linear interpolation to the bone's keyframes list, then applies the result to the bones's indexed points in the allPoints list.

Parameters:
allPoints - : the total points list
p - : the interpolation parametric variable
parentMatrix - : the transformation from parent bones
parentPosition - : the parent bone's objective position

interpolationCubic

public void interpolationCubic(java.util.Vector allPoints,
                               float p,
                               JGL_3DMatrix parentMatrix,
                               JGL_3DVector parentPosition)
Applies a cubic interpolation to the bone's keyframes list, then applies the result to the bones's indexed points in the allPoints list.

Parameters:
allPoints - : the total points list
p - : the interpolation parametric variable
parentMatrix - : the transformation from parent bones
parentPosition - : the parent bone's objective position