hmi.graphics.scenegraph
Class GSkinnedMesh

java.lang.Object
  extended by hmi.xml.XMLStructureAdapter
      extended by hmi.graphics.scenegraph.GMesh
          extended by hmi.graphics.scenegraph.GSkinnedMesh
All Implemented Interfaces:
XMLStructure

public class GSkinnedMesh
extends GMesh

Author:
Job Zwiers

Nested Class Summary
 
Nested classes/interfaces inherited from class hmi.graphics.scenegraph.GMesh
GMesh.MeshType
 
Field Summary
private static int COLORCODINGSIZE
           
private static int COLORSIZE
           
private static float EPSILON1
           
private static float EPSILON2
           
private static int FIELDWIDTH
           
private static int INDICESPERLINE
           
private  float[][] inverseBindMatrices
           
private static int JINFOFIELDWIDTH
           
private static int JINFOPRECISION
           
private static int JINFOTAB
           
private  float[][] jointMatrices
           
private  String[] jointNames
           
private  GNode[] jointNodes
           
private  float[][] jointPositions
           
private  String[] jointSIDs
           
private  boolean notshown
           
private static int NUMJOINTSSHOWN
           
private  float[][] originalInverseBindMatrices
           
private  int[] parentIndex
           
private static int PRECISION
           
private static boolean showCalc
           
private static int SHOWPOSFIELDWIDTH
           
private static int SHOWPOSPRECISION
           
private  String[] skeletonIds
           
private  GNode[] skeletonRoots
           
private  float[][] transformMatrices
           
private  VertexWeights vertexWeights
           
private static String XMLTAG
           
 
Fields inherited from class hmi.xml.XMLStructureAdapter
ATTRIBUTE_TOKEN_DELIMITERS, COMMA_SEPARATOR, DECODEDARRAYSIZE, DEFAULT_RECOVER_MODE, NEWLINE, SYSTEMNEWLINE, TAB, TAB_STRING
 
Constructor Summary
GSkinnedMesh()
          Default constructor
GSkinnedMesh(GMesh base)
          Creates a new GSkinnedMesh, with the data for the underlying GMesh fields obtained from the specified base GMesh parameter.
GSkinnedMesh(XMLTokenizer tokenizer)
          Creates a new GSkinnedMesh and reads the data from the XMLTokenizer.
 
Method Summary
 void addVertexWeightColors(boolean useWeights, String[] names, float[][] colorCoding3)
          assumption: colorCoding is an array of float[3] colors, same length as indices array.
 void adjustBindPose()
           
 void affineTransform(float[] ma)
          Transforms the mesh attributes with specific names: VertexCoord, Normal Assumption: transformMatrix is a 4x4 matrix, in row major order.
 StringBuilder appendAttributeString(StringBuilder buf, XMLFormatting fmt)
          appends the XML attributes to buf.
 StringBuilder appendContent(StringBuilder buf, XMLFormatting fmt)
          Appends content part of XML encoding
 void calculateGMatrices()
          (re)calculates the transform matrices: matrices[i] = jointMatrices[i] * inverseBindMatrices[i]
 void decodeAttributes(HashMap<String,String> attrMap, XMLTokenizer tokenizer)
          decodes the XML attributes.
 void decodeContent(XMLTokenizer tokenizer)
          Decodes content part of XML encoding
 float[][] getColorCoding()
           
 float[][] getInvBindMatrices()
          returns the float array with packed inverse bind matrices. 16 floats per matrix, in row major order
 GNode getJointGNode(String sid)
           
 int[] getJointIndices(String[] names)
           
 String[] getJointNames()
          Returns the String array with joint names
 String[] getJointSIDs()
          Returns the String array with joint names
 float[][] getOriginalInvBindMatrices()
          returns the float array with packed inverse bind matrices. 16 floats per matrix, in row major order
 int[] getParentIndex()
           
 String[] getSkeletonIds()
          Returns the String array with skeleton ids (probably of length 1)
 GNode[] getSkeletonRoots()
          Returns an array with the skeleton roots(s) of this skinned mesh
 VertexWeights getVertexWeights()
          Returns the VertexWeights
 VJoint getVJoint(String sid)
           
 VJoint[] getVJoints()
          Returns an array with VJoints for all joints within the skinned mesh
 String getXMLTag()
          returns the XML Stag for XML encoding
 void linearTransform(float[] mat3x3)
          Transforms the mesh attributes with specific names: VertexCoord, Normal Assumption: transformMatrix is a 4x4 matrix, in row major order.
 void printInvBindMatrices()
          Prints the inverse bind matrices to the Console
 void printJointInfo()
          Prints the name and inverse bind matrix for all joints.
 void printJointNames()
          Prints the joint names to the Console
 void renameJointSIDs(Map<String,String> renaming)
          renames the sids and names of GNodes
 void resolveJoints(List<GNode> jointRoots)
          Resolves the joints, used in this GLSkinnedMesh, by searching for skeletons and joint names within the specified VJoint scene graphs.
 void resolveSkeletonIds(List<GNode> jointRoots)
          Resolves the skeleton root node(s) within the GNode scenegraph adds these root(s) to skelRootList.
 void setBindPose()
          Sets the inverse bind matrices to the inverse of the (global) matrices of the VJoints of this skinned mesh.
 void setInvBindMatrices(float[][] matrices)
          Sets the float array with packed inverse bind matrices.
 void setJointNames(String[] names)
          Sets the array with the Collada joint names.
 void setJointSIDs(String[] jointSIDs)
          Sets the array with joint names (sid's)
 void setSkeletonIds(String[] skeletonIds)
          Sets the array with skeleton id's
 void setVertexWeights(VertexWeights vertexWeights)
          Sets the vertex weights for skinning
 void showPositions(int limit)
          assume that global matrices have been calculated, so the jointMatrices have been set
 void unifyIndices()
          Removes all attribute-specific indices, and replaces them by a single, common, indexData array.
 void writeBindMatrixRotations()
          Writes the vector of bind matrix quaternions to file
static String xmlTag()
          The XML Stag for XML encoding
 
Methods inherited from class hmi.graphics.scenegraph.GMesh
calculateTuples, checkIndexIntegrity, checkMorphTargetConsistency, checkMorphTargetConsistency, checkTriangleIntegrity, cleanupTriangles, getAttributeIndexData, getAttributeIndexData, getId, getIndexData, getMeshType, getMorphData, getMorphTargets, getNrOfAttributes, getNrOfIndices, getNrOfVertices, getVCountData, getVertexAttribute, getVertexAttribute, getVertexAttributeList, getVertexAttributeList, getVertexAttributeNameList, getVertexData, getVertexData, hasUnifiedIndexData, morphListSize, setId, setIndexData, setIndexedVertexData, setIndexedVertexData, setMeshType, setMorphTargets, setVCountData, setVertexData, setVertexData, showGMeshData, triangulate
 
Methods inherited from class hmi.xml.XMLStructureAdapter
appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttribute, appendAttributes, appendAttributes, appendAttributeString, appendBooleans, appendCloseEmptyTag, appendCloseSTag, appendComment, appendContent, appendDoubleElement, appendEmptyTag, appendEmptyTag, appendEmptyTag, appendEmptyTag, appendEmptyTag, appendEmptyTag, appendETag, appendETag, appendFloatArrayElement, appendFloatElement, appendFloats, appendIntArrayElement, appendIntElement, appendInts, appendLongElement, appendNewLine, appendNewLine, appendNewLine, appendOpenSTag, appendOptionalDoubleElement, appendOptionalFloatElement, appendOptionalIntElement, appendOptionalLongElement, appendSpaces, appendSpaces, appendSTag, appendSTag, appendSTag, appendStringArrayElement, appendStrings, appendSystemNewLine, appendTab, appendTextElement, appendXML, appendXML, appendXML, appendXML, appendXML, appendXMLStructure, appendXMLStructureList, appendXMLTextElementList, countTokens, countTokens, decodeAttribute, decodeAttribute, decodeBoolean, decodeBooleanArray, decodeBooleanArray, decodeBooleanArray, decodeBooleanArray, decodeDouble, decodeDoubleArray, decodeDoubleArray, decodeDoubleArray, decodeDoubleArray, decodeFloat, decodeFloatArray, decodeFloatArray, decodeFloatArray, decodeFloatArray, decodeInt, decodeIntArray, decodeIntArray, decodeIntArray, decodeIntArray, decodeLong, decodeStringArray, decodeStringArray, decodeStringArray, decodeStringArray, decodeXMLStructureList, decodeXMLValueElement, getNamespace, getOptionalAttribute, getOptionalAttribute, getOptionalBooleanAttribute, getOptionalDoubleAttribute, getOptionalFloatAttribute, getOptionalIntAttribute, getOptionalLongAttribute, getRequiredAttribute, getRequiredBooleanAttribute, getRequiredDoubleAttribute, getRequiredFloatAttribute, getRequiredIntAttribute, getRequiredLongAttribute, getTagLine, hasContent, parseXMLElement, postProcess, preProcess, readXML, readXML, readXML, setConsoleAttributeEnabled, setDefaultRecoverMode, setRecoverMode, spaces, toString, toXMLString, toXMLString, toXMLString, toXMLString, toXMLString, toXMLString, writeXML, writeXML, writeXML, writeXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

skeletonIds

private String[] skeletonIds

skeletonRoots

private GNode[] skeletonRoots

jointNames

private String[] jointNames

jointSIDs

private String[] jointSIDs

jointNodes

private GNode[] jointNodes

parentIndex

private int[] parentIndex

inverseBindMatrices

private float[][] inverseBindMatrices

originalInverseBindMatrices

private float[][] originalInverseBindMatrices

transformMatrices

private float[][] transformMatrices

jointMatrices

private float[][] jointMatrices

vertexWeights

private VertexWeights vertexWeights

jointPositions

private float[][] jointPositions

JINFOTAB

private static final int JINFOTAB
See Also:
Constant Field Values

JINFOFIELDWIDTH

private static final int JINFOFIELDWIDTH
See Also:
Constant Field Values

JINFOPRECISION

private static final int JINFOPRECISION
See Also:
Constant Field Values

showCalc

private static boolean showCalc

SHOWPOSFIELDWIDTH

private static final int SHOWPOSFIELDWIDTH
See Also:
Constant Field Values

SHOWPOSPRECISION

private static final int SHOWPOSPRECISION
See Also:
Constant Field Values

notshown

private boolean notshown

NUMJOINTSSHOWN

private static final int NUMJOINTSSHOWN
See Also:
Constant Field Values

FIELDWIDTH

private static final int FIELDWIDTH
See Also:
Constant Field Values

PRECISION

private static final int PRECISION
See Also:
Constant Field Values

EPSILON1

private static final float EPSILON1
See Also:
Constant Field Values

EPSILON2

private static final float EPSILON2
See Also:
Constant Field Values

COLORCODINGSIZE

private static final int COLORCODINGSIZE
See Also:
Constant Field Values

COLORSIZE

private static final int COLORSIZE
See Also:
Constant Field Values

INDICESPERLINE

private static final int INDICESPERLINE
See Also:
Constant Field Values

XMLTAG

private static final String XMLTAG
See Also:
Constant Field Values
Constructor Detail

GSkinnedMesh

public GSkinnedMesh()
Default constructor


GSkinnedMesh

public GSkinnedMesh(GMesh base)
Creates a new GSkinnedMesh, with the data for the underlying GMesh fields obtained from the specified base GMesh parameter. Data arrays from the specified base are shared, not copied.


GSkinnedMesh

public GSkinnedMesh(XMLTokenizer tokenizer)
             throws IOException
Creates a new GSkinnedMesh and reads the data from the XMLTokenizer.

Throws:
IOException
Method Detail

setSkeletonIds

public void setSkeletonIds(String[] skeletonIds)
Sets the array with skeleton id's


getSkeletonIds

public String[] getSkeletonIds()
Returns the String array with skeleton ids (probably of length 1)


setJointSIDs

public void setJointSIDs(String[] jointSIDs)
Sets the array with joint names (sid's)


getJointSIDs

public String[] getJointSIDs()
Returns the String array with joint names


setJointNames

public void setJointNames(String[] names)
Sets the array with the Collada joint names. (So, NOT the sid's, but just the "user friendly" strings)


getJointNames

public String[] getJointNames()
Returns the String array with joint names


renameJointSIDs

public void renameJointSIDs(Map<String,String> renaming)
renames the sids and names of GNodes


getJointGNode

public GNode getJointGNode(String sid)

getVJoint

public VJoint getVJoint(String sid)

printJointNames

public void printJointNames()
Prints the joint names to the Console


getParentIndex

public int[] getParentIndex()

setInvBindMatrices

public void setInvBindMatrices(float[][] matrices)
Sets the float array with packed inverse bind matrices. Matrices are stored in row major order, occupying 16 floats per matrix.


getInvBindMatrices

public float[][] getInvBindMatrices()
returns the float array with packed inverse bind matrices. 16 floats per matrix, in row major order


getOriginalInvBindMatrices

public float[][] getOriginalInvBindMatrices()
returns the float array with packed inverse bind matrices. 16 floats per matrix, in row major order


printInvBindMatrices

public void printInvBindMatrices()
Prints the inverse bind matrices to the Console


getVJoints

public VJoint[] getVJoints()
Returns an array with VJoints for all joints within the skinned mesh


getSkeletonRoots

public GNode[] getSkeletonRoots()
Returns an array with the skeleton roots(s) of this skinned mesh


printJointInfo

public void printJointInfo()
Prints the name and inverse bind matrix for all joints.


setVertexWeights

public void setVertexWeights(VertexWeights vertexWeights)
Sets the vertex weights for skinning


getVertexWeights

public VertexWeights getVertexWeights()
Returns the VertexWeights


unifyIndices

public void unifyIndices()
Removes all attribute-specific indices, and replaces them by a single, common, indexData array. Overrides the unifyIndices from GMesh (adds code for remapping vertexweight data).

Overrides:
unifyIndices in class GMesh

resolveSkeletonIds

public void resolveSkeletonIds(List<GNode> jointRoots)
Resolves the skeleton root node(s) within the GNode scenegraph adds these root(s) to skelRootList.


resolveJoints

public void resolveJoints(List<GNode> jointRoots)
Resolves the joints, used in this GLSkinnedMesh, by searching for skeletons and joint names within the specified VJoint scene graphs. The skeleton root node(s) are added to the skeletonRoots list, provided they are not already included.


showPositions

public void showPositions(int limit)
assume that global matrices have been calculated, so the jointMatrices have been set


writeBindMatrixRotations

public void writeBindMatrixRotations()
Writes the vector of bind matrix quaternions to file


adjustBindPose

public void adjustBindPose()

linearTransform

public void linearTransform(float[] mat3x3)
Description copied from class: GMesh
Transforms the mesh attributes with specific names: VertexCoord, Normal Assumption: transformMatrix is a 4x4 matrix, in row major order. The translation part of it will be applied to * the vertex coordinates, but not to the normals. Assumption two: the transform matrix is a rotation and/or translation Scaling is ok, but will result in normal vectors that are no longer unit length.

Overrides:
linearTransform in class GMesh

affineTransform

public void affineTransform(float[] ma)
Description copied from class: GMesh
Transforms the mesh attributes with specific names: VertexCoord, Normal Assumption: transformMatrix is a 4x4 matrix, in row major order. The translation part of it will be applied to * the vertex coordinates, but not to the normals. Assumption two: the transform matrix is a rotation and/or translation Scaling is ok, but will result in normal vectors that are no longer unit length.

Overrides:
affineTransform in class GMesh

setBindPose

public void setBindPose()
Sets the inverse bind matrices to the inverse of the (global) matrices of the VJoints of this skinned mesh. The effect is that the current transforms as defined by the VJoints of the skeleton will put the mesh into its bind pose.


calculateGMatrices

public void calculateGMatrices()
(re)calculates the transform matrices: matrices[i] = jointMatrices[i] * inverseBindMatrices[i]


addVertexWeightColors

public void addVertexWeightColors(boolean useWeights,
                                  String[] names,
                                  float[][] colorCoding3)
assumption: colorCoding is an array of float[3] colors, same length as indices array.


getJointIndices

public int[] getJointIndices(String[] names)

getColorCoding

public float[][] getColorCoding()

appendAttributeString

public StringBuilder appendAttributeString(StringBuilder buf,
                                           XMLFormatting fmt)
appends the XML attributes to buf.

Overrides:
appendAttributeString in class GMesh

decodeAttributes

public void decodeAttributes(HashMap<String,String> attrMap,
                             XMLTokenizer tokenizer)
decodes the XML attributes.

Overrides:
decodeAttributes in class GMesh

appendContent

public StringBuilder appendContent(StringBuilder buf,
                                   XMLFormatting fmt)
Appends content part of XML encoding

Overrides:
appendContent in class GMesh

decodeContent

public void decodeContent(XMLTokenizer tokenizer)
                   throws IOException
Decodes content part of XML encoding

Overrides:
decodeContent in class GMesh
Throws:
IOException

xmlTag

public static String xmlTag()
The XML Stag for XML encoding


getXMLTag

public String getXMLTag()
returns the XML Stag for XML encoding

Specified by:
getXMLTag in interface XMLStructure
Overrides:
getXMLTag in class GMesh