### Author Topic: getBindPose() is Late  (Read 53555 times)

#### AGP

• Posts: 1726
##### getBindPose() is Late
« on: July 07, 2018, 08:32:52 pm »
Can I forcefully update it in order to have an item keep up with my character's hand?

#### AGP

• Posts: 1726
##### Re: getBindPose() is Late
« Reply #1 on: July 08, 2018, 11:39:19 pm »
My next best attempt was this (but it doesn't look quite right):

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

#### AGP

`     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);     }`