Bones - Skeletal and Pose Animations for jPCT/jPCT-AE > Bones

Bones - Skeletal and Pose animations for jPCT

<< < (50/51) > >>

raft:
i'm no expert at these calculations either, most of the time they drives me crazy too :-\

but, it's not surprising that it goes crazy if you apply a transform based on bind pose to a pose not in bind pose. the thing you should remember is that each joint's transform is in its parent's space. all calculations depend on this.

although not strictly sure, IMHO you should do something like this:
* store your initial pose somewhere
* on each frame calculate desired world space transform of joints (ProceduralAnimationSample does this)
* then, starting from first joint, remove parent transform (multiply with parent's inverse transform). joints are ordered such that parent always come before child, so it's guaranteed that parents are updated before childs
* set local transform of joint to result of this

ProceduralAnimationSample does this but since it starts from bind pose, it uses bind pose transforms instead of another pose transforms

also have a look at this tutorial, it's one of the best texts i have found describing the subject:
http://www.okino.com/conv/skinning.htm

frag-a:
Thanks, I'll take a look at your suggestions and do some more tries.
I'll put the code here if I can make it work.

frag-a:
Hi raft, After some head banging I got it working ;D
Solution is to transform all vectors to joint's local space and do the rotation from the bind pose.
Here is the code, maybe it's useful to someone else.


--- Code: --- private static final void targetJoint(final SimpleVector targetTranslation, final SkeletonPose pose, int handleIndex, int parentIndex) {
final Skeleton skeleton = pose.getSkeleton();
final Joint handleJoint = skeleton.getJoint(handleIndex);
final Joint parentJoint = skeleton.getJoint(parentIndex);
final Matrix parentInverseBindPose = parentJoint.getInverseBindPose();
final Matrix parentBindPose = parentInverseBindPose.invert();

final SimpleVector parentVector = pose.getLocal(parentIndex).getTranslation();
final SimpleVector handleVector = pose.getLocal(handleIndex).getTranslation();
float distance = handleVector.distance(targetTranslation);
if (distance > 0.1) {
final SimpleVector targetVector = new SimpleVector(targetTranslation);
targetVector.matMul(parentInverseBindPose);
float angle = handleVector.calcAngle(targetVector);
if (Math.abs(angle) > 0.1f) {
final SimpleVector bindPoseVector = handleJoint.getBindPose().getTranslation();
bindPoseVector.matMul(parentInverseBindPose);

final Matrix rotation = new Quaternion().fromVectorToVector(bindPoseVector, targetVector).getRotationMatrix();
rotation.matMul(parentBindPose);
rotation.matMul(pose.getSkeleton().getJoint(parentJoint.getParentIndex()).getInverseBindPose());
pose.getLocal(parentIndex).setTo(rotation);
}
}
}

--- End code ---

Corrected some bugs.

Babu:
hi raft,

I am planning to use a mesh (that sits on the same skeleton as the body) for shirt.  Is it possible to use the same mesh for full-sleeve and half-sleeve shirts.  If that is possible, how do we assign the texture coordinates?

Thanks,
Babu

raft:
answered in its own thread:
http://www.jpct.net/forum2/index.php/topic,2085.0.html

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version