hmi.elckerlyc.animationengine.procanimation
Class Keyframes

java.lang.Object
  extended by hmi.xml.XMLStructureAdapter
      extended by hmi.elckerlyc.animationengine.procanimation.Keyframes
All Implemented Interfaces:
XMLStructure

public class Keyframes
extends XMLStructureAdapter

Procedurally describes joint rotation as key rotations at key times, inbetween rotations are calculated through slerp interpolation.

Author:
welberge

Field Summary
private  String encoding
           
private  double endT
           
private  ArrayList<Keyframe> frames
           
private  VJoint joint
           
private  org.lsmp.djep.xjep.XJep parser
           
private  double startT
           
private  String target
           
 
Fields inherited from class hmi.xml.XMLStructureAdapter
ATTRIBUTE_TOKEN_DELIMITERS, COMMA_SEPARATOR, DECODEDARRAYSIZE, DEFAULT_RECOVER_MODE, NEWLINE, SYSTEMNEWLINE, TAB, TAB_STRING
 
Constructor Summary
Keyframes(org.lsmp.djep.xjep.XJep p)
          Constructor, no target set
Keyframes(org.lsmp.djep.xjep.XJep p, String t)
          Constructor
 
Method Summary
 StringBuilder appendAttributeString(StringBuilder buf)
          Appends a String to buf that encodes the attributes for the XML encoding.
 StringBuilder appendContent(StringBuilder buf, XMLFormatting fmt)
          Appends a String to buf that encodes the contents for the XML encoding.
 void clear()
          Removes all keyframes
 boolean decodeAttribute(String attrName, String attrValue)
          decodes the value from an attribute value String returns true if succesful, returns false for attribute names that are not recognized.
 boolean decodeAttribute(String attrName, String attrValue, XMLTokenizer tokenizer)
          decodes the value from an attribute value String returns true if succesful, returns false for attribute names that are not recognized.
 void decodeContent(XMLTokenizer tokenizer)
          decodes the XML contents, i.e. the XML between the STag and ETag of the encoding.
 Keyframes deepCopy()
          Creates a deep copy linked to the same parser and joint
 boolean evaluate(double t, float[] goal, VJoint human)
          Calculates joint rotation at time t
 Vector findParameters(Vector v)
          returns list with all parameters used in all formulas
 String getEncoding()
           
 VJoint getJoint()
          Gets the joint the rotation works on
 String getTarget()
           
 String getXMLTag()
          Get the XML tag
 void mirror()
          Mirrors all joint rotations on the XY plane, switches left/right partIds
 void set(Keyframes kfs)
          Copies the KeyFrame-s of another Keyframes object into this object.
 void setJoint(VJoint j)
          Sets the new joint
 void setTarget(VJoint h)
          Sets the target humanoid for this rotation, tries to find the joint to rotate
 
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, decodeAttributes, 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, xmlTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

target

private String target

encoding

private String encoding

frames

private ArrayList<Keyframe> frames

joint

private VJoint joint

startT

private double startT

endT

private double endT

parser

private org.lsmp.djep.xjep.XJep parser
Constructor Detail

Keyframes

public Keyframes(org.lsmp.djep.xjep.XJep p)
Constructor, no target set

Parameters:
p - parser

Keyframes

public Keyframes(org.lsmp.djep.xjep.XJep p,
                 String t)
Constructor

Parameters:
p - parser
t - target
Method Detail

setTarget

public void setTarget(VJoint h)
Sets the target humanoid for this rotation, tries to find the joint to rotate

Parameters:
h - the target

mirror

public void mirror()
Mirrors all joint rotations on the XY plane, switches left/right partIds


clear

public void clear()
Removes all keyframes


setJoint

public void setJoint(VJoint j)
Sets the new joint

Parameters:
j -

getJoint

public VJoint getJoint()
Gets the joint the rotation works on

Returns:
the joint, null if none set

set

public void set(Keyframes kfs)
Copies the KeyFrame-s of another Keyframes object into this object. Also links kfs's joint and target to this keyframes.

Parameters:
kfs -

deepCopy

public Keyframes deepCopy()
Creates a deep copy linked to the same parser and joint

Returns:
the copy

findParameters

public Vector findParameters(Vector v)
returns list with all parameters used in all formulas


evaluate

public boolean evaluate(double t,
                        float[] goal,
                        VJoint human)
Calculates joint rotation at time t

Parameters:
t - : time, 0 < t < 1
goal - : output rotation
Returns:
false on error

getTarget

public String getTarget()
Returns:
the target

appendContent

public StringBuilder appendContent(StringBuilder buf,
                                   XMLFormatting fmt)
Description copied from class: XMLStructureAdapter
Appends a String to buf that encodes the contents for the XML encoding. MUST BE OVERWRITTEN BY IMPLEMENTATIONS. (The default implementation appends nothing). The encoding should start on a new line, using indentation equal to tab. There should be no newline after the encoding.

Overrides:
appendContent in class XMLStructureAdapter

appendAttributeString

public StringBuilder appendAttributeString(StringBuilder buf)
Description copied from class: XMLStructureAdapter
Appends a String to buf that encodes the attributes for the XML encoding. When non empty, the attribute string should start with a space character. Hint: call the appendAttribute(StringBuilder buf, String attrName, String attrValue) for every relevant attribute; this takes care of the leading space as well as spaces in between the attributes) MUST BE OVERWRITTEN BY IMPLEMENTATIONS. (The default implementation appends nothing). The encoding should preferably not add newline characters.

Overrides:
appendAttributeString in class XMLStructureAdapter

decodeAttribute

public boolean decodeAttribute(String attrName,
                               String attrValue)
Description copied from class: XMLStructureAdapter
decodes the value from an attribute value String returns true if succesful, returns false for attribute names that are not recognized. Might throw a RuntimeException when an attribute has been recognized, but is ill formatted. MUST BE OVERWRITTEN BY IMPLEMENTATIONS.

Overrides:
decodeAttribute in class XMLStructureAdapter

decodeContent

public void decodeContent(XMLTokenizer tokenizer)
                   throws IOException
Description copied from class: XMLStructureAdapter
decodes the XML contents, i.e. the XML between the STag and ETag of the encoding. MUST BE OVERWRITTEN BY IMPLEMENTATIONS.

Overrides:
decodeContent in class XMLStructureAdapter
Throws:
IOException

decodeAttribute

public boolean decodeAttribute(String attrName,
                               String attrValue,
                               XMLTokenizer tokenizer)
Description copied from class: XMLStructureAdapter
decodes the value from an attribute value String returns true if succesful, returns false for attribute names that are not recognized. Might throw a RuntimeException when an attribute has been recognized, but is ill formatted. Moreover, an XMLTokenizer reference is available which can be queried for attributes, like getTokenLine() or getTokenCharPos(), which might be helpful to produce error messages referring to lines/positions within the XML document The default implementation simply calls decodeAttribute(attrName, attrValue) SHOUL BE OVERWRITTEN BY IMPLEMENTATIONS.

Overrides:
decodeAttribute in class XMLStructureAdapter

getXMLTag

public String getXMLTag()
Get the XML tag

Specified by:
getXMLTag in interface XMLStructure
Overrides:
getXMLTag in class XMLStructureAdapter
Returns:
the xml tag

getEncoding

public String getEncoding()