Skip to content

Commit

Permalink
Joint Rotations
Browse files Browse the repository at this point in the history
- Implemented a rotate joint function
- Fixed the JointPose transformPoseStack method to actually use the transform mutliplier from before.
- Temporarily fixed FP hand item positions with a 180 deg X rotation
  • Loading branch information
Trainguy9512 committed Mar 7, 2024
1 parent 0d01b5f commit 443c3c3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
Expand Up @@ -201,8 +201,10 @@ protected AnimationPose<FPPlayerLocators> calculatePose() {
pose = dampenArmRotation(pose);


Vector3f translation = new Vector3f(Mth.sin(getEntityAnimationVariable(TIME_TEST) * 1.3F) * 3F, 0, 0);
pose.translateJoint(FPPlayerLocators.rightArm, translation, AnimationPose.TransformSpace.ENTITY, false);
Vector3f rotation = new Vector3f(Mth.sin(getEntityAnimationVariable(TIME_TEST) * 0.2F) * Mth.HALF_PI * 0.7f, 0, 0);
//Vector3f translation = new Vector3f(Mth.sin(getEntityAnimationVariable(TIME_TEST) * 1.3F) * 3F, 0, 0);
//pose.translateJoint(FPPlayerLocators.rightArm, translation, AnimationPose.TransformSpace.ENTITY, false);
//pose.rotateJoint(FPPlayerLocators.rightArm, rotation, AnimationPose.TransformSpace.ENTITY, false);


return pose;
Expand Down
Expand Up @@ -150,6 +150,9 @@ private void convertChildrenSpaceEntityToLocal(Enum<L> parent, Matrix4f parentMa
}
}




public void blend(AnimationPose<L> animationPose, float alpha, Easing easing){
for(Enum<L> locator : this.getSkeleton().getLocators()){
JointPose jointPoseA = this.getJointPoseCopy(locator);
Expand Down Expand Up @@ -234,6 +237,20 @@ public AnimationPose<L> translateJoint(Enum<L> joint, Vector3f translation, Tran
return this;
}

public AnimationPose<L> rotateJoint(Enum<L> joint, Vector3f rotationXYZ, TransformSpace transformSpace, boolean replaceExisting){
convertSpaceEntityToLocal();
if(transformSpace == TransformSpace.ENTITY){
convertSpaceLocalToEntity(joint);
}
if(replaceExisting){
this.getJointPoseReference(joint).setEulerRotationXYZ(rotationXYZ);
} else {
this.getJointPoseReference(joint).rotate(rotationXYZ, transformSpace);
}
convertSpaceEntityToLocal();
return this;
}



public void mirror(){
Expand Down
Expand Up @@ -166,9 +166,10 @@ public JointPose translate(Vector3f translation, AnimationPose.TransformSpace tr

public JointPose rotate(Quaternionf rotation, AnimationPose.TransformSpace transformSpace){
if(transformSpace == AnimationPose.TransformSpace.LOCAL){
this.getTransformReference().rotateLocal(rotation);
} else {
this.getTransformReference().rotate(rotation);
} else {
//this.getTransformReference().rotateLocal(rotation);
this.setRotation(this.getTransformCopy().getNormalizedRotation(new Quaternionf()).premul(rotation));
}
return this;
}
Expand Down Expand Up @@ -313,7 +314,7 @@ public void rotatePoseStackInverse(PoseStack poseStack){
}

public void transformPoseStack(PoseStack poseStack, float transformMultiplier){
poseStack.mulPoseMatrix(this.getTransformCopy());
poseStack.mulPoseMatrix(this.getTransformCopy().setTranslation(this.getTranslation().div(new Vector3f(transformMultiplier))));
//poseStack.translate(this.translation.x / transformMultiplier, this.translation.y / transformMultiplier, this.translation.z / transformMultiplier);
//this.rotatePoseStack(poseStack);

Expand All @@ -327,7 +328,7 @@ public void transformPoseStack(PoseStack poseStack, float transformMultiplier){
}

public void transformPoseStack(PoseStack poseStack){
this.transformPoseStack(poseStack, 16F);
this.transformPoseStack(poseStack, 1F);
}

public void transformModelPart(ModelPart modelPart){
Expand Down
Expand Up @@ -148,7 +148,8 @@ private void renderItemInHand(AbstractClientPlayer abstractClientPlayer, ItemSta
poseStack.pushPose();
//armPose.transformPoseStack(poseStack);
//poseStack.translate((humanoidArm == HumanoidArm.LEFT ? 1 : -1) /16F, 9/16F, 0);
handPose.transformPoseStack(poseStack);
handPose.transformPoseStack(poseStack, 16F);
poseStack.mulPose(Axis.XP.rotationDegrees(180.0f));

//poseStack.mulPose(Axis.XP.rotationDegrees(-90.0f));
//poseStack.mulPose(Axis.YP.rotationDegrees(180.0f));
Expand Down

0 comments on commit 443c3c3

Please sign in to comment.