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

getBindPose() is Late

(1/1)

AGP:
Can I forcefully update it in order to have an item keep up with my character's hand?

AGP:
My next best attempt was this (but it doesn't look quite right):


--- Code: --- weapon.getRotationMatrix().interpolate(weapon.getRotationMatrix(), skeletonPose.getLocal(rightHandIndex), 1f);
weapon.getRotationMatrix().matMul(model.get(0).getWorldTransformation());

--- End code ---

AGP:
Yet another attempt. This is based off of SkeletonDebugger. It's still not quite right:


--- Code: ---     private void updateWeaponPos() {
SimpleVector o = weapon.getTransformedCenter();
SimpleVector d = getJointPosition(rightHand);
SimpleVector left = model.get(0).getXAxis();
weapon.translate(d.x-o.x, d.y-o.y+.1f, d.z-o.z);//d.x-o.x, d.y-o.y+.125f, d.z-o.z

//NOW ROTATION:
Skeleton skeleton = model.get(0).getSkeleton();

final int parentIndex = skeleton.getJoint(rightHandIndex).getParentIndex();
if (parentIndex != Joint.NO_PARENT) {
     Object3D bone = weapon;
     updateWeapon(bone, skeletonPose.getGlobal(parentIndex), skeletonPose.getGlobal(rightHandIndex));
}
     }
     private void updateWeapon(Object3D weapon, final Matrix start, final Matrix end) {
SimpleVector from = start.getTranslation();
SimpleVector to = end.getTranslation();
SimpleVector direction = to.calcSub(from);

weapon.getRotationMatrix().setTo(direction.getRotationMatrix());
weapon.rotateY((float)Math.PI+rotY);//rotY IS SO THAT THE WEAPON ROTATES ALONG WITH model.getRoot()
weapon.rotateAxis(weapon.getZAxis(), (float)Math.PI*.2f);
     }

--- End code ---

Notes:
-Adding the weapon to the root of the character breaks the whole thing.
-I'm having to rotate the weapon by the same amount as the root because it otherwise doesn't chase the hand.
-It kind of looks right until you look straight at the hand and you see that the weapon is not facing the right direction during any given animation

Navigation

[0] Message Index

Go to full version