hmi.elckerlyc.animationengine.procanimation
Class Rotation

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

public class Rotation
extends XMLStructureAdapter

Describes the rotation of a single joint in a formula The rotation can be a function of time t (0 < t < 1) and some parameters

Author:
welberge, Mark ter Maat

Field Summary
private  VJoint joint
           
private  boolean local
           
private  org.nfunk.jep.Node[] node
           
private  org.lsmp.djep.xjep.XJep parser
           
private  String[] rotFormula
           
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
Rotation(org.lsmp.djep.xjep.XJep p)
          Creates a new Rotation with null target
Rotation(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.
 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.
 Rotation deepCopy()
           
 boolean evaluate(float[] goal)
           
 float evaluateSingleIndex(int i)
          Evaluates the rotation for time 0 < t < 1
 Vector findParameters(Vector v)
          returns list with all parameters used in all formulas
 VJoint getJoint()
          Gets the joint the rotation works on
 String getRotationFormula(int i)
          Get the rotation formula
 String getTarget()
          Get the target joint sid
 String getXMLTag()
          returns the XML tag that is used to encode this type of XMLStructure.
 boolean isLocal()
           
 void mirror()
           
 void set(Rotation eff)
          Copy the rotation formulas and target from eff into this Rotation
 void setJoint(VJoint j)
          Sets the new joint, sets the target to the joints sid, if j!
 void setRotation(int i, String rotation)
          Set the rotation path
 void setTarget(String t)
          Sets the target joint sid
 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

node

private org.nfunk.jep.Node[] node

rotFormula

private String[] rotFormula

target

private String target

joint

private VJoint joint

parser

private org.lsmp.djep.xjep.XJep parser

local

private boolean local
Constructor Detail

Rotation

public Rotation(org.lsmp.djep.xjep.XJep p)
Creates a new Rotation with null target

Parameters:
p - the XJep rotation formula parser

Rotation

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

Parameters:
p - the XJep rotation formula parser
t - the target joint sid
Method Detail

mirror

public void mirror()

set

public void set(Rotation eff)
Copy the rotation formulas and target from eff into this Rotation

Parameters:
eff - the rotation to copy

getTarget

public String getTarget()
Get the target joint sid

Returns:
the target joint sid

setTarget

public void setTarget(String t)
Sets the target joint sid

Parameters:
t - the sid of the target joint

getRotationFormula

public String getRotationFormula(int i)
Get the rotation formula

Parameters:
i - index (0=x axis,1=y axis,2=z axis)
Returns:
the rotation formula

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

evaluate

public boolean evaluate(float[] goal)
Parameters:
goal - : output rotation
Returns:
false on error

evaluateSingleIndex

public float evaluateSingleIndex(int i)
Evaluates the rotation for time 0 < t < 1

Returns:
the rotation

findParameters

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


setTarget

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

Parameters:
h - the target

setJoint

public void setJoint(VJoint j)
Sets the new joint, sets the target to the joints sid, if j!=null

Parameters:
j - new joint

getJoint

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

Returns:
the joint, null if none set

deepCopy

public Rotation deepCopy()
Returns:
A clone of the Rotation. The clone is still linked to the same joint

isLocal

public boolean isLocal()
Returns:
the local

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

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

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

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

getXMLTag

public String getXMLTag()
Description copied from class: XMLStructureAdapter
returns the XML tag that is used to encode this type of XMLStructure. The default returns null.

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