hmi.elckerlyc.animationengine.procanimation
Class Keyframe

java.lang.Object
  extended by hmi.xml.XMLStructureAdapter
      extended by hmi.elckerlyc.animationengine.procanimation.Keyframe
All Implemented Interfaces:
XMLStructure, Comparable<Keyframe>

public class Keyframe
extends XMLStructureAdapter
implements Comparable<Keyframe>

Procedural description of a joint rotation at a key time

Author:
welberge

Field Summary
private  float[] aa
           
private  String encoding
           
private  float[] euler
           
private  VJoint joint
           
private  boolean local
           
private  org.nfunk.jep.Node[] node
           
private  org.lsmp.djep.xjep.XJep parser
           
private  float[] q
           
private  float[] qp
           
private  float[] qw
           
private  String[] rotFormula
           
private  float time
           
 
Fields inherited from class hmi.xml.XMLStructureAdapter
ATTRIBUTE_TOKEN_DELIMITERS, COMMA_SEPARATOR, DECODEDARRAYSIZE, DEFAULT_RECOVER_MODE, NEWLINE, SYSTEMNEWLINE, TAB, TAB_STRING
 
Constructor Summary
Keyframe(Keyframe kf)
          Copy-constructor.
Keyframe(org.lsmp.djep.xjep.XJep p, String enc)
          Constructor
 
Method Summary
 StringBuilder appendAttributeString(StringBuilder buf)
          Appends a String to buf that encodes the attributes for the XML encoding.
 int compareTo(Keyframe o)
          Comparable interface Compares this object with the specified object for order.
 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.
 boolean evaluate(float[] goal, VJoint human)
          Calculates the joint rotation.
 Vector findParameters(Vector v)
          returns list with all parameters used in all formulas
 float getTime()
           
 String getXMLTag()
          Get the XML tag
 void mirror()
           
 void setJoint(VJoint j)
          Sets the joint to rotate
 void setRotation(int i, String rotation)
          Set the rotation path
 String toString()
          the default toString() method returns the result of toXMLSTring()
 
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, 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, 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

parser

private org.lsmp.djep.xjep.XJep parser

time

private float time

local

private boolean local

rotFormula

private String[] rotFormula

node

private org.nfunk.jep.Node[] node

q

private float[] q

euler

private float[] euler

qw

private float[] qw

qp

private float[] qp

aa

private float[] aa

joint

private VJoint joint

encoding

private String encoding
Constructor Detail

Keyframe

public Keyframe(org.lsmp.djep.xjep.XJep p,
                String enc)
Constructor

Parameters:
p - parser

Keyframe

public Keyframe(Keyframe kf)
Copy-constructor. Copies joint rotation and local/global settings. Links parser and joint.

Parameters:
kf - keyframe to copy
Method Detail

setJoint

public void setJoint(VJoint j)
Sets the joint to rotate

Parameters:
j - joint

mirror

public void mirror()

toString

public String toString()
Description copied from class: XMLStructureAdapter
the default toString() method returns the result of toXMLSTring()

Overrides:
toString in class XMLStructureAdapter

setRotation

public void setRotation(int i,
                        String rotation)
                 throws org.nfunk.jep.ParseException
Set the rotation path

Parameters:
i - the rotation axis (0=x,1=y,2=z)
rotation - the rotation path a formula of 0 < t < 1 and amplitude a
Throws:
org.nfunk.jep.ParseException

findParameters

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


evaluate

public boolean evaluate(float[] goal,
                        VJoint human)
Calculates the joint rotation. When a rotation is specified as world rotation, the local rotation of joint to satisfy this world rotation (in the coordinate system of the human) is calculated and set as goal.

Parameters:
goal - : output rotation (quaternion)
human - : humanoid joint
Returns:
false on error

compareTo

public int compareTo(Keyframe o)
Comparable interface Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. keyframes are sorted by time

Specified by:
compareTo in interface Comparable<Keyframe>

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

getTime

public float getTime()
Returns:
the time