j3d.org Code

org.j3d.geom.hanim
Class HAnimJoint

java.lang.Object
  extended by org.j3d.geom.hanim.HAnimObject
      extended by org.j3d.geom.hanim.HAnimJoint
All Implemented Interfaces:
HAnimObjectParent

public class HAnimJoint
extends HAnimObject
implements HAnimObjectParent

Representation of a H-Anim Joint object.

The joint object is defined by 6.5 Joint.

Although the HAnim spec does not define bounding box fields, VRML/X3D do, and we have an internal Grouping node to handling this joint, so we've added fields and support for it anyway.

Internationalisation Resource Names

Version:
$Revision: 1.7 $
Author:
Justin Couch

Field Summary
protected  float[] bboxCenter
          The current bboxCenter of the joint
protected  float[] bboxSize
          The current bboxSize of the joint
protected  HAnimObject[] children
          The current collection of children nodes registered to this object.
protected  HAnimDisplacer[] displacers
          The current collection of children nodes registered to this object.
protected  javax.vecmath.Matrix4f globalMatrix
          Matrix that contains the global transformation down to this site
protected  javax.vecmath.Matrix4f localMatrix
          Local matrix value that combines all the fields together
protected  boolean matrixChanged
          Flag to indicate the root matrix values have changed, thus needing to regenerate the entire skeleton and vertices.
protected  int numChildren
          The number of valid children of this object
protected  int numDisplacers
          The number of valid children of this object
protected  int numSkinCoord
          The number of items in skinCoordIndex and skinCoordWeight fields
protected  int numSourceCoords
          The current number of source skin coordinates
protected  int numSourceNormals
          The current number of source skin normals
protected  int objectIndex
          Index of this joint into the global array of values.
protected  java.lang.Object outputCoords
          Reference to the object that we place the modified coordinates in.
protected  java.lang.Object outputNormals
          Reference to the object that we place the modified normals in.
protected  HAnimObjectParent parent
          The parent of this joint
protected  int[] skinCoordIndex
          The skin coordinate index values into the global coordinate list
protected  float[] skinCoordWeight
          The skin coordinate weight values.
protected  float[] sourceCoords
          Reference to the array that holds the base coordinate values
protected  float[] sourceNormals
          Reference to the array that holds the base normal values
protected  boolean updateSent
          Flag to say that we're already sent an update request and there's no need to send another.
 
Fields inherited from class org.j3d.geom.hanim.HAnimObject
errorReporter, name
 
Constructor Summary
HAnimJoint()
          Create a new, default instance of the joint.
 
Method Summary
 void addChild(HAnimObject kid)
          Add a child node to the existing collection.
 void addDisplacer(HAnimDisplacer kid)
          Add a child node to the existing collection.
 void childUpdateRequired(HAnimObject child)
          Notification that the child has changed and will need to recalculate it's vertex positions.
 void getBboxCenter(float[] val)
          Get the current value of the bboxCenter.
 void getBboxSize(float[] val)
          Get the current value of the bboxSize.
 void getCenter(float[] val)
          Get the current value of the center.
 void getChildren(HAnimObject[] vals)
          Get the current collection of children.
 void getDisplacers(HAnimDisplacer[] vals)
          Get the current collection of children.
 void getLimitOrientation(float[] val)
          Get the current value of the limitOrientation.
 void getLowerLimit(float[] val)
          Get the current value of the lowerLimit.
 void getRotation(float[] val)
          Get the current value of the rotation.
 void getScale(float[] val)
          Get the current value of the scale.
 void getScaleOrientation(float[] val)
          Get the current value of the scaleOrientation.
 void getSkinCoordIndex(float[] val)
          Get the current value of the skinCoordIndex.
 void getSkinCoordWeight(float[] val)
          Get the current value of the skinCoordWeight.
 void getStiffness(float[] val)
          Get the current value of the stiffness.
 void getTranslation(float[] val)
          Get the current value of the translation.
 void getUpperLimit(float[] val)
          Get the current value of the upperLimit.
 int numChildren()
          Get the number of currently valid children.
 int numDisplacers()
          Get the number of currently valid children.
 int numLowerLimit()
          Get the number of elements in lowerLimit
 int numSkinCoord()
          Get the number of elements in the skinCoordIndex field, and by association skinCoordWeight (if any weights have been set).
 int numStiffness()
          Get the number of elements in stiffness
 int numUpperLimit()
          Get the number of elements in upperLimit
 void removeChild(HAnimObject kid)
          Remove a child node from the existing collection.
 void removeDisplacer(HAnimDisplacer kid)
          Remove a child node from the existing collection.
 int requestNextObjectIndex()
          Get the object's index into the greater list of things.
protected  void sendUpdateMsg()
          Send an update message to the parent, if one has not already been sent.
 void setBboxCenter(float[] val)
          Set a new value for the bboxCenter of this segment.
 void setBboxSize(float[] val)
          Set a new value for the bboxSize of this segment.
 void setCenter(float[] val)
          Set a new value for the center of this joint.
 void setChildren(HAnimObject[] kids, int numValid)
          Replace the existing children with the new set of children.
 void setDisplacers(HAnimDisplacer[] kids, int numValid)
          Replace the existing displacers with the new set of displacers.
 void setErrorReporter(ErrorReporter reporter)
          Register an error reporter with the object so that any errors generated by the object can be reported in a nice, pretty fashion.
 void setLimitOrientation(float[] val)
          Set a new value for the limitOrientation of this joint.
 void setLowerLimit(float[] val, int numElements)
          Set a new value for the lowerLimit of this joint.
protected  void setParent(HAnimObjectParent parent, float[] srcCoords, int numCoords, float[] srcNormals, int numNormals, java.lang.Object destCoords, java.lang.Object destNormals)
          Set the parent of this node to the given reference.
 void setRotation(float[] val)
          Set a new value for the rotation of this joint.
 void setScale(float[] val)
          Set a new value for the scale of this joint.
 void setScaleOrientation(float[] val)
          Set a new value for the scaleOrientation of this joint.
 void setSkinCoordIndex(int[] val, int numValid)
          Set a new value for the skinCoordIndex of this joint.
 void setSkinCoordWeight(float[] val)
          Set a new value for the skinCoordWeight of this joint.
 void setStiffness(float[] val, int numElements)
          Set a new value for the stiffness of this joint.
 void setTranslation(float[] val)
          Set a new value for the translation of this joint.
 void setUpperLimit(float[] val, int numElements)
          Set a new value for the upperLimit of this joint.
protected  void updateSkeleton(javax.vecmath.Matrix4f parentTransform, boolean parentChanged)
          All the skeletal changes are in for this frame, so update the matrix values now.
protected  void updateSources(float[] srcCoords, int numCoords, float[] srcNormals, int numNormals, java.lang.Object destCoords, java.lang.Object destNormals)
          The global coordinate and/or normal values were changed by the user, so go through and update the local references.
 
Methods inherited from class org.j3d.geom.hanim.HAnimObject
getName, setName, updateMatrix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bboxCenter

protected float[] bboxCenter
The current bboxCenter of the joint


bboxSize

protected float[] bboxSize
The current bboxSize of the joint


skinCoordIndex

protected int[] skinCoordIndex
The skin coordinate index values into the global coordinate list


skinCoordWeight

protected float[] skinCoordWeight
The skin coordinate weight values. If set, one for each index


numSkinCoord

protected int numSkinCoord
The number of items in skinCoordIndex and skinCoordWeight fields


children

protected HAnimObject[] children
The current collection of children nodes registered to this object.


numChildren

protected int numChildren
The number of valid children of this object


displacers

protected HAnimDisplacer[] displacers
The current collection of children nodes registered to this object.


numDisplacers

protected int numDisplacers
The number of valid children of this object


localMatrix

protected javax.vecmath.Matrix4f localMatrix
Local matrix value that combines all the fields together


globalMatrix

protected javax.vecmath.Matrix4f globalMatrix
Matrix that contains the global transformation down to this site


parent

protected HAnimObjectParent parent
The parent of this joint


matrixChanged

protected boolean matrixChanged
Flag to indicate the root matrix values have changed, thus needing to regenerate the entire skeleton and vertices.


updateSent

protected boolean updateSent
Flag to say that we're already sent an update request and there's no need to send another.


sourceCoords

protected float[] sourceCoords
Reference to the array that holds the base coordinate values


numSourceCoords

protected int numSourceCoords
The current number of source skin coordinates


sourceNormals

protected float[] sourceNormals
Reference to the array that holds the base normal values


numSourceNormals

protected int numSourceNormals
The current number of source skin normals


outputCoords

protected java.lang.Object outputCoords
Reference to the object that we place the modified coordinates in. May be either a float[] or NIO FloatBuffer, depending on the end user implementation.


outputNormals

protected java.lang.Object outputNormals
Reference to the object that we place the modified normals in. May be either a float[] or NIO FloatBuffer, depending on the end user implementation.


objectIndex

protected int objectIndex
Index of this joint into the global array of values. A value of -1 means that there is not the ability to know at this stage.

Constructor Detail

HAnimJoint

public HAnimJoint()
Create a new, default instance of the joint.

Method Detail

childUpdateRequired

public void childUpdateRequired(HAnimObject child)
Notification that the child has changed and will need to recalculate it's vertex positions. A change could be in the transformation matrix, coordinate weights or referenced coordinates (or elsewhere).

Specified by:
childUpdateRequired in interface HAnimObjectParent
Parameters:
child - Reference to the child that has changed

requestNextObjectIndex

public int requestNextObjectIndex()
Get the object's index into the greater list of things. For example, a joint needs to be able to update it's matrix in a large array of matrices and it needs to update the same matrix every time.

Specified by:
requestNextObjectIndex in interface HAnimObjectParent
Returns:
The index of the object into global lists

setErrorReporter

public void setErrorReporter(ErrorReporter reporter)
Register an error reporter with the object so that any errors generated by the object can be reported in a nice, pretty fashion. Setting a value of null will clear the currently set reporter. If one is already set, the new value replaces the old.

Overrides:
setErrorReporter in class HAnimObject
Parameters:
reporter - The instance to use or null

setCenter

public void setCenter(float[] val)
Set a new value for the center of this joint. If the array is null or not long enough an exception is generated. The array must be at least 3 units long, and the center is taken from the 1st three values.

Parameters:
val - The new center value to use
Throws:
java.lang.IllegalArgumentException - The array is null or not long enough.

getCenter

public void getCenter(float[] val)
Get the current value of the center.

Parameters:
val - An array of at least length 3 to copy the value to

getScale

public void getScale(float[] val)
Get the current value of the scale.

Parameters:
val - An array of at least length 3 to copy the value to

setScale

public void setScale(float[] val)
Set a new value for the scale of this joint. If the array is null or not long enough an exception is generated. The array must be at least 3 units long, and the scale is taken from the 1st three values.

Parameters:
val - The new scale value to use
Throws:
java.lang.IllegalArgumentException - The array is null or not long enough.

getTranslation

public void getTranslation(float[] val)
Get the current value of the translation.

Parameters:
val - An array of at least length 3 to copy the value to

setTranslation

public void setTranslation(float[] val)
Set a new value for the translation of this joint. If the array is null or not long enough an exception is generated. The array must be at least 3 units long, and the translation is taken from the 1st three values.

Parameters:
val - The new translation value to use
Throws:
java.lang.IllegalArgumentException - The array is null or not long enough.

getScaleOrientation

public void getScaleOrientation(float[] val)
Get the current value of the scaleOrientation.

Parameters:
val - An array of at least length 4 to copy the value to

setScaleOrientation

public void setScaleOrientation(float[] val)
Set a new value for the scaleOrientation of this joint. If the array is null or not long enough an exception is generated. The array must be at least 3 units long, and the scaleOrientation is taken from the 1st three values.

Parameters:
val - The new scaleOrientation value to use
Throws:
java.lang.IllegalArgumentException - The array is null or not long enough.

getRotation

public void getRotation(float[] val)
Get the current value of the rotation.

Parameters:
val - An array of at least length 4 to copy the value to

setRotation

public void setRotation(float[] val)
Set a new value for the rotation of this joint. If the array is null or not long enough an exception is generated. The array must be at least 4 units long, and the rotation is taken from the 1st three values.

Parameters:
val - The new rotation value to use
Throws:
java.lang.IllegalArgumentException - The array is null or not long enough.

getBboxCenter

public void getBboxCenter(float[] val)
Get the current value of the bboxCenter.

Parameters:
val - An array of at least length 3 to copy the value to

setBboxCenter

public void setBboxCenter(float[] val)
Set a new value for the bboxCenter of this segment. If the array is null or not long enough an exception is generated. The array must be at least 3 units long, and the bboxCenter is taken from the 1st three values.

Parameters:
val - The new bboxCenter value to use
Throws:
java.lang.IllegalArgumentException - The array is null or not long enough.

getBboxSize

public void getBboxSize(float[] val)
Get the current value of the bboxSize.

Parameters:
val - An array of at least length 3 to copy the value to

setBboxSize

public void setBboxSize(float[] val)
Set a new value for the bboxSize of this segment. If the array is null or not long enough an exception is generated. The array must be at least 3 units long, and the bboxSize is taken from the 1st three values.

If the three values are all -1, then this will disable the use of the explicit bounds.

Parameters:
val - The new bboxSize value to use
Throws:
java.lang.IllegalArgumentException - The array is null or not long enough.

getLimitOrientation

public void getLimitOrientation(float[] val)
Get the current value of the limitOrientation.

Parameters:
val - An array of at least length 3 to copy the value to

setLimitOrientation

public void setLimitOrientation(float[] val)
Set a new value for the limitOrientation of this joint. If the array is null or not long enough an exception is generated. The array must be at least 4 units long, and the limitOrientation is taken from the 1st three values.

Parameters:
val - The new limitOrientation value to use
Throws:
java.lang.IllegalArgumentException - The array is null or not long enough.

numLowerLimit

public int numLowerLimit()
Get the number of elements in lowerLimit

Returns:
The number of elements kept in this lower limit

getLowerLimit

public void getLowerLimit(float[] val)
Get the current value of the lowerLimit.

Parameters:
val - An array of at least length of numLowerLimit() * 3 to copy the values to

setLowerLimit

public void setLowerLimit(float[] val,
                          int numElements)
Set a new value for the lowerLimit of this joint. If the array is null or not long enough an exception is generated. The array must be at least 3 units long, and the lowerLimit is taken from the 1st three values.

Parameters:
val - The new lowerLimit value to use
numElements - The number of 3d-vectors in the array
Throws:
java.lang.IllegalArgumentException - The array is null or not long enough.

numUpperLimit

public int numUpperLimit()
Get the number of elements in upperLimit

Returns:
The number of elements kept in this upper limit

getUpperLimit

public void getUpperLimit(float[] val)
Get the current value of the upperLimit.

Parameters:
val - An array of at least length of numUpperLimit() * 3 to copy the values to

setUpperLimit

public void setUpperLimit(float[] val,
                          int numElements)
Set a new value for the upperLimit of this joint. If the array is null or not long enough an exception is generated. The array must be at least 3 units long, and the upperLimit is taken from the 1st three values.

Parameters:
val - The new upperLimit value to use
numElements - The number of 3d-vectors in the array
Throws:
java.lang.IllegalArgumentException - The array is null or not long enough.

numStiffness

public int numStiffness()
Get the number of elements in stiffness

Returns:
The number of elements kept in this stiffness list

getStiffness

public void getStiffness(float[] val)
Get the current value of the stiffness.

Parameters:
val - An array of at least length of numStiffness() * 3 to copy the values to

setStiffness

public void setStiffness(float[] val,
                         int numElements)
Set a new value for the stiffness of this joint. If the array is null or not long enough an exception is generated. The array must be at least 3 units long, and the stiffness is taken from the 1st three values.

Parameters:
val - The new stiffness value to use
numElements - The number of values in the array
Throws:
java.lang.IllegalArgumentException - The array is null or not long enough.

numSkinCoord

public int numSkinCoord()
Get the number of elements in the skinCoordIndex field, and by association skinCoordWeight (if any weights have been set).

Returns:
The number of value kept in the skin coordinate index

getSkinCoordIndex

public void getSkinCoordIndex(float[] val)
Get the current value of the skinCoordIndex. If no weights are set, the array is left unchanged.

Parameters:
val - An array of at least length of numSkinCoord() to copy the values to

setSkinCoordIndex

public void setSkinCoordIndex(int[] val,
                              int numValid)
Set a new value for the skinCoordIndex of this joint. If the array is null or not long enough an exception is generated. The array must be at least as long as the numValid field value.

Parameters:
val - The new skinCoordIndex value to use
numValid - The number of valid values to read from the index list
Throws:
java.lang.IllegalArgumentException - The array is null or not long enough.

getSkinCoordWeight

public void getSkinCoordWeight(float[] val)
Get the current value of the skinCoordWeight. If no weights are set, the array is left unchanged.

Parameters:
val - An array of at least length of numSkinCoord() to copy the values to

setSkinCoordWeight

public void setSkinCoordWeight(float[] val)
Set a new value for the skinCoordWeight of this joint. If the array is null or not long enough an exception is generated. The array must be at least as long as the currently set skinCoordIndex values length.

Parameters:
val - The new skinCoordWeight value to use
Throws:
java.lang.IllegalArgumentException - The array is null or not long enough.

numChildren

public int numChildren()
Get the number of currently valid children.

Returns:
The number of values kept in the info list

getChildren

public void getChildren(HAnimObject[] vals)
Get the current collection of children. If none are set, the array is unchanged.

Parameters:
vals - An array of at least length numChildren() to copy the values to

setChildren

public void setChildren(HAnimObject[] kids,
                        int numValid)
Replace the existing children with the new set of children.

Parameters:
kids - The collection of child objects to now use
numValid - The number kids to copy from the given array
Throws:
java.lang.IllegalArgumentException - The child is not one of a Joint, Segment or Site

addChild

public void addChild(HAnimObject kid)
Add a child node to the existing collection. Duplicates and null values are allowed.

Parameters:
kid - The new child instance to add
Throws:
java.lang.IllegalArgumentException - The child is not one of a Joint, Segment or Site

removeChild

public void removeChild(HAnimObject kid)
Remove a child node from the existing collection. If there are duplicates, only the first instance is removed. Only reference comparisons are used.

Parameters:
kid - The child instance to remove
Throws:
java.lang.IllegalArgumentException - The child is not one of a Joint, Segment or Site

numDisplacers

public int numDisplacers()
Get the number of currently valid children.

Returns:
The number of values kept in the info list

getDisplacers

public void getDisplacers(HAnimDisplacer[] vals)
Get the current collection of children. If none are set, the array is unchanged.

Parameters:
vals - An array of at least length numChildren() to copy the values to

setDisplacers

public void setDisplacers(HAnimDisplacer[] kids,
                          int numValid)
Replace the existing displacers with the new set of displacers.

Parameters:
kids - The collection of child objects to now use
numValid - The number kids to copy from the given array

addDisplacer

public void addDisplacer(HAnimDisplacer kid)
Add a child node to the existing collection. Duplicates and null values are allowed.

Parameters:
kid - The new child instance to add

removeDisplacer

public void removeDisplacer(HAnimDisplacer kid)
Remove a child node from the existing collection. If there are duplicates, only the first instance is removed. Only reference comparisons are used.

Parameters:
kid - The child instance to remove

setParent

protected void setParent(HAnimObjectParent parent,
                         float[] srcCoords,
                         int numCoords,
                         float[] srcNormals,
                         int numNormals,
                         java.lang.Object destCoords,
                         java.lang.Object destNormals)
Set the parent of this node to the given reference. Any previous reference is removed.

Parameters:
parent - The new parent instance to use
srcCoords - The array for the original, unmodified coordinates
numCoords - Number of valid coordinate values
srcNormals - The array for the original, unmodified normals
numNormals - Number of valid normal values
destCoords - The array/buffer for the transformed coordinates
destNormals - The array/buffer for the transformed normals

updateSources

protected void updateSources(float[] srcCoords,
                             int numCoords,
                             float[] srcNormals,
                             int numNormals,
                             java.lang.Object destCoords,
                             java.lang.Object destNormals)
The global coordinate and/or normal values were changed by the user, so go through and update the local references.

Parameters:
srcCoords - The array for the original, unmodified coordinates
numCoords - Number of valid coordinate values
srcNormals - The array for the original, unmodified normals
numNormals - Number of valid normal values
destCoords - The array/buffer for the transformed coordinates
destNormals - The array/buffer for the transformed normals

updateSkeleton

protected void updateSkeleton(javax.vecmath.Matrix4f parentTransform,
                              boolean parentChanged)
All the skeletal changes are in for this frame, so update the matrix values now.

Parameters:
parentTransform - The transformation into global coordinates of the parent of this joint
parentChanged - Flag to indicate that the parent transformation matrix has changed or is still the same as last call

sendUpdateMsg

protected void sendUpdateMsg()
Send an update message to the parent, if one has not already been sent.


j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org