优化95空仓换弹时的左手姿势

This commit is contained in:
Atsuihsio 2024-11-12 22:19:46 +08:00
parent e2fc0eb701
commit 20926f9469
3 changed files with 78 additions and 29 deletions

View file

@ -22,6 +22,13 @@ public class Qbz95ItemModel extends GeoModel<Qbz95Item> {
public static float fireRotY = 0f; public static float fireRotY = 0f;
public static float fireRotZ = 0f; public static float fireRotZ = 0f;
public static float rotXBipod = 0f; public static float rotXBipod = 0f;
public static float lHandPosX = 0f;
public static float lHandPosY= 0f;
public static float lHandPosZ = 0f;
public static float lHandRotX = 0f;
public static float lHandRotY= 0f;
public static float lHandRotZ = 0f;
@Override @Override
public ResourceLocation getAnimationResource(Qbz95Item animatable) { public ResourceLocation getAnimationResource(Qbz95Item animatable) {
return ModUtils.loc("animations/qbz95.animation.json"); return ModUtils.loc("animations/qbz95.animation.json");
@ -88,15 +95,15 @@ public class Qbz95ItemModel extends GeoModel<Qbz95Item> {
default -> 0f; default -> 0f;
}; };
float posZ = switch (type) { float posZ = switch (type) {
case 0 -> 5.9f; case 0 -> 10.6f;
case 1 -> 5.8f; case 1 -> 8.8f;
case 2 -> 14.51f; case 2 -> 14.51f;
case 3 -> 17.2f; case 3 -> 17.2f;
default -> 0f; default -> 0f;
}; };
float scaleZ = switch (type) { float scaleZ = switch (type) {
case 0 -> 0.2f; case 0 -> 0.5f;
case 1 -> 0.21f; case 1 -> 0.51f;
case 2 -> 0.792f; case 2 -> 0.792f;
case 3 -> 0.891f; case 3 -> 0.891f;
default -> 0f; default -> 0f;
@ -108,13 +115,11 @@ public class Qbz95ItemModel extends GeoModel<Qbz95Item> {
gun.setRotZ((float) (0.05f * zpz)); gun.setRotZ((float) (0.05f * zpz));
gun.setScaleZ(1f - (scaleZ * (float) zp)); gun.setScaleZ(1f - (scaleZ * (float) zp));
if (main.getRotZ() < 10 * Mth.DEG_TO_RAD) { button.setScaleY(1f - (0.85f * (float) zp));
button.setScaleY(1f - (0.85f * (float) zp)); button3.setScaleX(1f - (0.5f * (float) zp));
button3.setScaleX(1f - (0.5f * (float) zp)); button6.setScaleX(1f - (0.8f * (float) zp));
button6.setScaleX(1f - (0.5f * (float) zp));
}
stack.getOrCreateTag().putBoolean("HoloHidden", gun.getPosX() < 3.1 || main.getRotZ() > 10 * Mth.DEG_TO_RAD); stack.getOrCreateTag().putBoolean("HoloHidden", gun.getPosX() < 3.1);
CoreGeoBone shen; CoreGeoBone shen;
if (zt < 0.5) { if (zt < 0.5) {
@ -176,20 +181,31 @@ public class Qbz95ItemModel extends GeoModel<Qbz95Item> {
root.setRotY((float) (0.2f * movePosX + Mth.DEG_TO_RAD * 300 * ClientEventHandler.drawTime + Mth.DEG_TO_RAD * turnRotY)); root.setRotY((float) (0.2f * movePosX + Mth.DEG_TO_RAD * 300 * ClientEventHandler.drawTime + Mth.DEG_TO_RAD * turnRotY));
root.setRotZ((float) (0.2f * movePosX + moveRotZ + Mth.DEG_TO_RAD * 90 * ClientEventHandler.drawTime + 2.7f * mph + Mth.DEG_TO_RAD * turnRotZ)); root.setRotZ((float) (0.2f * movePosX + moveRotZ + Mth.DEG_TO_RAD * 90 * ClientEventHandler.drawTime + 2.7f * mph + Mth.DEG_TO_RAD * turnRotZ));
float numR = 1; float numR = (float) (1 - 0.975 * zt);
float numP = 1; float numP = (float) (1 - 0.97 * zt);
CoreGeoBone leftHand = getAnimationProcessor().getBone("Lefthand");
CoreGeoBone anim = getAnimationProcessor().getBone("anim");
boolean isZooming = zt > 0 && anim.getPosZ() == 0 ;
lHandPosX = Mth.lerp(1.5f * times, lHandPosX, isZooming ? 0 : leftHand.getPosX());
lHandPosY = Mth.lerp(1.5f * times, lHandPosY, isZooming ? 0 : leftHand.getPosY());
lHandPosZ = Mth.lerp(1.5f * times, lHandPosZ, isZooming ? 0 : leftHand.getPosZ());
lHandRotX = Mth.lerp(1.5f * times, lHandRotX, isZooming ? -2.1f : leftHand.getRotX());
lHandRotY = Mth.lerp(1.5f * times, lHandRotY, isZooming ? 0.2419f : leftHand.getRotY());
lHandRotZ = Mth.lerp(1.5f * times, lHandRotZ, isZooming ? 2.9228f : leftHand.getRotZ());
if (stack.getOrCreateTag().getBoolean("is_empty_reloading")) { if (stack.getOrCreateTag().getBoolean("is_empty_reloading")) {
numR = (float) (1 - 0.72 * zt); leftHand.setPosX(lHandPosX);
numP = (float) (1 - 0.95 * zt); leftHand.setPosY(lHandPosY);
leftHand.setPosZ(lHandPosZ);
leftHand.setRotX(lHandRotX);
leftHand.setRotY(lHandRotY);
leftHand.setRotZ(lHandRotZ);
} }
if (stack.getOrCreateTag().getBoolean("is_normal_reloading")) {
numR = (float) (1 - 0.98 * zt);
numP = (float) (1 - 0.96 * zt);
}
AnimationHelper.handleReloadShakeAnimation(stack, main, camera, numR, numP); AnimationHelper.handleReloadShakeAnimation(stack, main, camera, numR, numP);
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(), Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ()); ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(), Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
} }

View file

@ -632,6 +632,15 @@
"1.3": [0, -1.3107, 0.06869], "1.3": [0, -1.3107, 0.06869],
"1.325": [0, 0, 0] "1.325": [0, 0, 0]
} }
},
"anim": {
"position": {
"0.0": [0, 0, 0],
"2.6": [0, 0, 0],
"2.625": [0, 0, -10],
"3.125": [0, 0, -10],
"3.15": [0, 0, 0]
}
} }
}, },
"sound_effects": { "sound_effects": {
@ -1350,6 +1359,15 @@
"1.3": [0, -1.3107, 0.06869], "1.3": [0, -1.3107, 0.06869],
"1.325": [0, 0, 0] "1.325": [0, 0, 0]
} }
},
"anim": {
"position": {
"0.0": [0, 0, 0],
"2.6": [0, 0, 0],
"2.625": [0, 0, -10],
"3.125": [0, 0, -10],
"3.15": [0, 0, 0]
}
} }
}, },
"sound_effects": { "sound_effects": {
@ -2034,6 +2052,15 @@
"1.3": [0, -1.3107, 0.06869], "1.3": [0, -1.3107, 0.06869],
"1.325": [0, 0, 0] "1.325": [0, 0, 0]
} }
},
"anim": {
"position": {
"0.0": [0, 0, 0],
"2.6": [0, 0, 0],
"2.625": [0, 0, -10],
"3.125": [0, 0, -10],
"3.15": [0, 0, 0]
}
} }
}, },
"sound_effects": { "sound_effects": {
@ -2716,6 +2743,15 @@
"1.3": [0, -1.3107, 0.06869], "1.3": [0, -1.3107, 0.06869],
"1.325": [0, 0, 0] "1.325": [0, 0, 0]
} }
},
"anim": {
"position": {
"0.0": [0, 0, 0],
"2.6": [0, 0, 0],
"2.625": [0, 0, -10],
"3.125": [0, 0, -10],
"3.15": [0, 0, 0]
}
} }
}, },
"sound_effects": { "sound_effects": {

View file

@ -13,7 +13,7 @@
"bones": [ "bones": [
{ {
"name": "camera", "name": "camera",
"pivot": [3.87141, 8.56276, 13.57702] "pivot": [3.8714, 8.5628, 13.577]
}, },
{ {
"name": "root", "name": "root",
@ -3474,7 +3474,6 @@
"name": "button3", "name": "button3",
"parent": "Scope3", "parent": "Scope3",
"pivot": [-1.64609, 8.58315, 0.34398], "pivot": [-1.64609, 8.58315, 0.34398],
"rotation": [0, 0, 0],
"cubes": [ "cubes": [
{ {
"origin": [-1.5182, 7.73861, 0.07448], "origin": [-1.5182, 7.73861, 0.07448],
@ -3562,7 +3561,6 @@
"name": "button6", "name": "button6",
"parent": "Scope3", "parent": "Scope3",
"pivot": [1.63438, 8.58315, 0.34398], "pivot": [1.63438, 8.58315, 0.34398],
"rotation": [0, 0, 0],
"cubes": [ "cubes": [
{ {
"origin": [1.1818, 7.73861, 0.07448], "origin": [1.1818, 7.73861, 0.07448],
@ -4115,8 +4113,6 @@
{ {
"origin": [0.78962, 7.58803, -1.83623], "origin": [0.78962, 7.58803, -1.83623],
"size": [0.39576, 1.98716, 2.38542], "size": [0.39576, 1.98716, 2.38542],
"pivot": [0.9875, 8.58161, -0.64352],
"rotation": [0, 0, 0],
"uv": { "uv": {
"north": {"uv": [14, 188], "uv_size": [0.25, 1.25]}, "north": {"uv": [14, 188], "uv_size": [0.25, 1.25]},
"south": {"uv": [24, 178], "uv_size": [0.25, 1.25]}, "south": {"uv": [24, 178], "uv_size": [0.25, 1.25]},
@ -5662,8 +5658,6 @@
{ {
"origin": [-0.03649, -1.23493, -145.76641], "origin": [-0.03649, -1.23493, -145.76641],
"size": [0.07299, 9.5308, 0], "size": [0.07299, 9.5308, 0],
"pivot": [0, 8.58047, -145.76641],
"rotation": [0, 0, 0],
"uv": { "uv": {
"north": {"uv": [5.75, 5], "uv_size": [-0.75, 0.75]}, "north": {"uv": [5.75, 5], "uv_size": [-0.75, 0.75]},
"east": {"uv": [5.75, 5], "uv_size": [-0.75, 0.75]}, "east": {"uv": [5.75, 5], "uv_size": [-0.75, 0.75]},
@ -5704,8 +5698,6 @@
{ {
"origin": [-0.06892, -1.23493, -145.76641], "origin": [-0.06892, -1.23493, -145.76641],
"size": [0.13393, 4, 0], "size": [0.13393, 4, 0],
"pivot": [0, 8.58047, -145.76641],
"rotation": [0, 0, 0],
"uv": { "uv": {
"north": {"uv": [5, 5], "uv_size": [0.75, 0.75]}, "north": {"uv": [5, 5], "uv_size": [0.75, 0.75]},
"east": {"uv": [5, 5], "uv_size": [0.75, 0.75]}, "east": {"uv": [5, 5], "uv_size": [0.75, 0.75]},
@ -13808,6 +13800,11 @@
} }
] ]
}, },
{
"name": "anim",
"parent": "0",
"pivot": [0, 0, 0]
},
{ {
"name": "gun", "name": "gun",
"parent": "0", "parent": "0",