1
Bones / Bone length
« on: April 03, 2013, 11:30:16 pm »
Hi raft,
Is there a way to get the length of different bones in Bones API?
Ani
Is there a way to get the length of different bones in Bones API?
Ani
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
private void rotateJoint(SkeletonPose pose, int jointIndex, SimpleVector bindPoseDirection, float angle, final float targetStrength) {
final int parentIndex = pose.getSkeleton().getJoint(jointIndex).getParentIndex();
final Matrix jointInverseBindPose = pose.getSkeleton().getJoint(jointIndex).getInverseBindPose();
final Matrix jointBindPose = jointInverseBindPose.invert();
// Get a vector representing forward direction in neck space, use inverse to take from world -> neck space.
SimpleVector forwardDirection = new SimpleVector(bindPoseDirection);
forwardDirection.rotate(jointInverseBindPose);
// Calculate a rotation to go from one direction to the other and set that rotation on a blank transform.
Quaternion quat = new Quaternion();
quat.fromAngleAxis(angle, forwardDirection);
quat.slerp(Quaternion.IDENTITY, quat, targetStrength);
final Matrix subGlobal = quat.getRotationMatrix();
subGlobal.matMul(jointBindPose);
subGlobal.matMul(pose.getSkeleton().getJoint(parentIndex).getInverseBindPose());
// set that as the neck's transform
pose.getLocal(jointIndex).setTo(subGlobal);
}