Class Joint


  • public class Joint
    extends Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Joint​(int index, String name, javax.vecmath.Matrix4f inverseBindMatrix, javax.vecmath.Matrix4f bindLocalPose)
      Creating new joint
      Joint​(Joint other)
      Creating new joint as copy from the passed joint
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addChild​(Joint child)
      Adding new child to the joint
      void calcAnimatedTransformAndPose​(javax.vecmath.Matrix4f parentLocalPose)
      Calculate the animated and pose transformation by multiplying the local pose (transformation matrix of the joint in bone space) with all parents local poses and the inverse bind matrix (inverted pose in model space).
      void calcBindPose​(javax.vecmath.Matrix4f parentPose)
      Calculate the bind pose transformation by multiplying the local bind pose (bind transformation matrix of the joint in bone space) with all parents local bind poses.
      void fromBytes​(byte[] data)
      Constructing this joint hierarchy from bytes.

      Format:
      First Sector [MetaData]:
      JointCount (int) | Joint0NameSize (int) | Joint1NameSize (int) | ...

      Second Sector [JointData]:
      Joint0Index (int) | Joint0ParentIndex (int) | Joint0Name (String) | Joint0InverseBindMatrix (float[]) | Joint0BindLocalPoseMatrix (float[]) | Joint1Index (int) | ...
      javax.vecmath.Matrix4f getAnimatedTransform()  
      javax.vecmath.Matrix4f getBindPose()  
      Joint getByName​(String name)
      Getting first found joint in this hierarchy with this name.
      List<Joint> getChildren()  
      int getIndex()  
      javax.vecmath.Matrix4f getLocalPose()  
      String getName()  
      javax.vecmath.Matrix4f getPose()  
      void setLocalPose​(javax.vecmath.Matrix4f localPose)
      Setting the current local pose matrix of this joint in model space
      byte[] toBytes()
      Converting recursively this joint and all children into a byte array.

      Format:
      First Sector [MetaData]:
      JointCount (int) | Joint0NameSize (int) | Joint1NameSize (int) | ...

      Second Sector [JointData]:
      Joint0Index (int) | Joint0ParentIndex (int) | Joint0Name (String) | Joint0InverseBindMatrix (float[]) | Joint0BindLocalPoseMatrix (float[]) | Joint1Index (int) | ...
    • Constructor Detail

      • Joint

        public Joint​(int index,
                     String name,
                     javax.vecmath.Matrix4f inverseBindMatrix,
                     javax.vecmath.Matrix4f bindLocalPose)
        Creating new joint
        Parameters:
        index - Index of the joint in the skeleton
        name - Name of the joint
        inverseBindMatrix - Inverse matrix of joints default position
        bindLocalPose - Matrix of joints binding local pose
      • Joint

        public Joint​(Joint other)
        Creating new joint as copy from the passed joint
        Parameters:
        other - Joint to copy
    • Method Detail

      • calcBindPose

        public void calcBindPose​(javax.vecmath.Matrix4f parentPose)
        Calculate the bind pose transformation by multiplying the local bind pose (bind transformation matrix of the joint in bone space) with all parents local bind poses.
        Parameters:
        parentPose - Parents local bind pose or null, if root
      • calcAnimatedTransformAndPose

        public void calcAnimatedTransformAndPose​(javax.vecmath.Matrix4f parentLocalPose)
        Calculate the animated and pose transformation by multiplying the local pose (transformation matrix of the joint in bone space) with all parents local poses and the inverse bind matrix (inverted pose in model space).
        Parameters:
        parentLocalPose - Parents local pose or null, if root
      • getLocalPose

        public javax.vecmath.Matrix4f getLocalPose()
        Returns:
        Current local pose of the joint
      • getByName

        public Joint getByName​(String name)
        Getting first found joint in this hierarchy with this name. If joint couldn't be found returning null.
        Parameters:
        name - Name to find
        Returns:
        Found joint or null
      • setLocalPose

        public void setLocalPose​(javax.vecmath.Matrix4f localPose)
        Setting the current local pose matrix of this joint in model space
        Parameters:
        localPose - Current local pose of this joint
      • addChild

        public void addChild​(Joint child)
        Adding new child to the joint
        Parameters:
        child - Child to add
      • getChildren

        public List<Joint> getChildren()
        Returns:
        Children joint of this joint
      • getIndex

        public int getIndex()
        Returns:
        Index if this joint in the skeleton
      • getAnimatedTransform

        public javax.vecmath.Matrix4f getAnimatedTransform()
        Returns:
        Transformation to put a vertex into the animated pose
      • getName

        public String getName()
        Returns:
        Name of the joint
      • getBindPose

        public javax.vecmath.Matrix4f getBindPose()
        Returns:
        Bind transformation matrix of the joint in model space
      • getPose

        public javax.vecmath.Matrix4f getPose()
        Returns:
        Current transformation matrix of the joint in model space
      • toBytes

        public byte[] toBytes()
        Converting recursively this joint and all children into a byte array.

        Format:
        First Sector [MetaData]:
        JointCount (int) | Joint0NameSize (int) | Joint1NameSize (int) | ...

        Second Sector [JointData]:
        Joint0Index (int) | Joint0ParentIndex (int) | Joint0Name (String) | Joint0InverseBindMatrix (float[]) | Joint0BindLocalPoseMatrix (float[]) | Joint1Index (int) | ...
        Returns:
        Converted byte array
      • fromBytes

        public void fromBytes​(byte[] data)
        Constructing this joint hierarchy from bytes.

        Format:
        First Sector [MetaData]:
        JointCount (int) | Joint0NameSize (int) | Joint1NameSize (int) | ...

        Second Sector [JointData]:
        Joint0Index (int) | Joint0ParentIndex (int) | Joint0Name (String) | Joint0InverseBindMatrix (float[]) | Joint0BindLocalPoseMatrix (float[]) | Joint1Index (int) | ...
        Parameters:
        data - Bytes to construct hierarchy from