From ffbd2e81a2179358bff67961e7d2d70748025694 Mon Sep 17 00:00:00 2001 From: Atsuishio <842960157@qq.com> Date: Mon, 16 Jun 2025 00:12:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99XY100=E6=B7=BB=E5=8A=A0=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E4=B8=AA=E7=A2=B0=E6=92=9E=E7=AE=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/renderer/special/OBBRenderer.java | 3 +-- .../superbwarfare/entity/vehicle/Yx100Entity.java | 9 ++++++++- .../com/atsuishio/superbwarfare/tools/VectorTool.java | 8 ++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/special/OBBRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/special/OBBRenderer.java index eb9e9de81..409151b71 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/special/OBBRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/special/OBBRenderer.java @@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.client.renderer.special; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.tools.OBB; -import com.atsuishio.superbwarfare.tools.VectorTool; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.renderer.LevelRenderer; @@ -21,7 +20,7 @@ public class OBBRenderer { Vec3 position = entity.position(); Vector3f center = obb.center(); Vector3f halfExtents = obb.extents(); - Quaternionf rotation = VectorTool.combineRotations(pPartialTicks, entity); + Quaternionf rotation = obb.rotation(); renderOBB( poseStack, buffer, (float) (center.x() - position.x()), (float) (center.y() - position.y()), (float) (center.z() - position.z()), diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java index ad26c1537..ba5a0381b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -89,10 +89,12 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti public int droneReloadCoolDown; public OBB obb; + public OBB obbTurret; public Yx100Entity(EntityType type, Level world) { super(type, world); this.obb = new OBB(this.position().toVector3f(), new Vector3f(2.53125f, 1.0625f, 4.75f), new Quaternionf()); + this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(2, 1, 2), new Quaternionf()); } @Override @@ -1302,6 +1304,11 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti Matrix4f transform = getVehicleTransform(1); Vector4f worldPosition = transformPosition(transform, 0, 1.125f, 0.25f); this.obb.center().set(new Vector3f(worldPosition.x, worldPosition.y, worldPosition.z)); - this.obb.setRotation(VectorTool.combineRotations(1, this)); + this.obb.setRotation(VectorTool.combineRotationsTurret(1, this)); + + Matrix4f transformT = getTurretTransform(1); + Vector4f worldPositionT = transformPosition(transformT, 0, 1, 0); + this.obbTurret.center().set(new Vector3f(worldPositionT.x, worldPositionT.y, worldPositionT.z)); + this.obbTurret.setRotation(VectorTool.combineRotationsTurret(1, this)); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/VectorTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/VectorTool.java index f112cb010..fe2be2b47 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/VectorTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/VectorTool.java @@ -41,4 +41,12 @@ public class VectorTool { return combined; } + + public static Quaternionf combineRotationsTurret(float partialTicks, VehicleEntity entity) { + Quaternionf turretYawRot = Axis.YP.rotationDegrees(Mth.lerp(partialTicks, entity.turretYRotO, entity.getTurretYRot())); + Quaternionf combined = combineRotations(partialTicks, entity); + combined.mul(turretYawRot); + + return combined; + } }