From c536212aafbcdc6a5906d82bb768f1a161d727ff Mon Sep 17 00:00:00 2001 From: Atsuishio <842960157@qq.com> Date: Sun, 13 Jul 2025 21:14:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=8463=E5=BC=8F=E7=9A=84=E7=A2=B0?= =?UTF-8?q?=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 | 24 +++++--- .../entity/vehicle/Type63Entity.java | 61 +++++++++++++------ .../atsuishio/superbwarfare/tools/OBB.java | 3 +- 3 files changed, 63 insertions(+), 25 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 0904f20af..12f40cb25 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 @@ -24,13 +24,23 @@ public class OBBRenderer { Vector3f center = obb.center(); Vector3f halfExtents = obb.extents(); Quaternionf rotation = obb.rotation(); - renderOBB( - poseStack, buffer, - (float) (center.x() - position.x()), (float) (center.y() - position.y()), (float) (center.z() - position.z()), - rotation, - halfExtents.x(), halfExtents.y(), halfExtents.z(), - red, green, blue, alpha - ); + if (obb.part().equals(OBB.Part.INTERACTIVE)) { + renderOBB( + poseStack, buffer, + (float) (center.x() - position.x()), (float) (center.y() - position.y()), (float) (center.z() - position.z()), + rotation, + halfExtents.x(), halfExtents.y(), halfExtents.z(), + 1, 0.8f, 0, 1 + ); + } else { + renderOBB( + poseStack, buffer, + (float) (center.x() - position.x()), (float) (center.y() - position.y()), (float) (center.z() - position.z()), + rotation, + halfExtents.x(), halfExtents.y(), halfExtents.z(), + red, green, blue, alpha + ); + } } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Type63Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Type63Entity.java index 12af9aab1..ecbef0340 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Type63Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Type63Entity.java @@ -67,26 +67,37 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt public OBB hoe1; public OBB hoe2; + public OBB wheel1; + public OBB wheel2; + public OBB body1; + public OBB body2; + + public double interactionTick; public Type63Entity(EntityType type, Level world) { super(type, world); - this.barrel0 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.BODY); - this.barrel1 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.BODY); - this.barrel2 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.BODY); - this.barrel3 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.BODY); - this.barrel4 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.BODY); - this.barrel5 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.BODY); - this.barrel6 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.BODY); - this.barrel7 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.BODY); - this.barrel8 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.BODY); - this.barrel9 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.BODY); - this.barrel10 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.BODY); - this.barrel11 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.BODY); - this.pitchController = new OBB(this.position().toVector3f(), new Vector3f(0.15625f, 0.21875f, 0.21875f), new Quaternionf(), OBB.Part.BODY); - this.yawController = new OBB(this.position().toVector3f(), new Vector3f(0.125f, 0.125f, 0.125f), new Quaternionf(), OBB.Part.BODY); - this.hoe1 = new OBB(this.position().toVector3f(), new Vector3f(0.125f, 0.125f, 0.875f), new Quaternionf(), OBB.Part.BODY); - this.hoe2 = new OBB(this.position().toVector3f(), new Vector3f(0.125f, 0.125f, 0.875f), new Quaternionf(), OBB.Part.BODY); + this.barrel0 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.barrel1 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.barrel2 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.barrel3 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.barrel4 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.barrel5 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.barrel6 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.barrel7 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.barrel8 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.barrel9 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.barrel10 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.barrel11 = new OBB(this.position().toVector3f(), new Vector3f(0.09375f, 0.09375f, 0.0625f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.pitchController = new OBB(this.position().toVector3f(), new Vector3f(0.15625f, 0.21875f, 0.21875f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.yawController = new OBB(this.position().toVector3f(), new Vector3f(0.125f, 0.125f, 0.125f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.hoe1 = new OBB(this.position().toVector3f(), new Vector3f(0.125f, 0.125f, 0.875f), new Quaternionf(), OBB.Part.INTERACTIVE); + this.hoe2 = new OBB(this.position().toVector3f(), new Vector3f(0.125f, 0.125f, 0.875f), new Quaternionf(), OBB.Part.INTERACTIVE); + + this.wheel1 = new OBB(this.position().toVector3f(), new Vector3f(0.125f, 0.390625f, 0.390625f), new Quaternionf(), OBB.Part.WHEEL_LEFT); + this.wheel2 = new OBB(this.position().toVector3f(), new Vector3f(0.125f, 0.390625f, 0.390625f), new Quaternionf(), OBB.Part.WHEEL_RIGHT); + this.body1 = new OBB(this.position().toVector3f(), new Vector3f(0.4765625f, 0.3515625f, 0.7578125f), new Quaternionf(), OBB.Part.BODY); + this.body2 = new OBB(this.position().toVector3f(), new Vector3f(0.771875f, 0.109375f, 0.296875f), new Quaternionf(), OBB.Part.BODY); } @Override @@ -315,7 +326,7 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt @Override public List getOBBs() { return List.of(this.barrel0, this.barrel1, this.barrel2, this.barrel3, this.barrel4, this.barrel5, this.barrel6, this.barrel7, this.barrel8, this.barrel9, this.barrel10, this.barrel11, - this.hoe1, this.hoe2, this.yawController, this.pitchController); + this.hoe1, this.hoe2, this.yawController, this.pitchController, this.wheel1, this.wheel2, this.body1, this.body2); } @Override @@ -331,6 +342,18 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt this.hoe2.center().set(new Vector3f(worldPosition2.x, worldPosition2.y, worldPosition2.z)); this.hoe2.setRotation(VectorTool.combineRotations(1, this)); + Vector4f worldPositionW = transformPosition(transform, 0.90625f, 0.390625f, 0.1071875f); + this.wheel1.center().set(new Vector3f(worldPositionW.x, worldPositionW.y, worldPositionW.z)); + this.wheel1.setRotation(VectorTool.combineRotations(1, this)); + + Vector4f worldPositionW2 = transformPosition(transform, -0.90625f, 0.390625f, 0.1071875f); + this.wheel2.center().set(new Vector3f(worldPositionW2.x, worldPositionW2.y, worldPositionW2.z)); + this.wheel2.setRotation(VectorTool.combineRotations(1, this)); + + Vector4f worldPositionBody2 = transformPosition(transform, 0, 0.42546875f, -0.090625f); + this.body2.center().set(new Vector3f(worldPositionBody2.x, worldPositionBody2.y, worldPositionBody2.z)); + this.body2.setRotation(VectorTool.combineRotationsBarrel(1, this)); + Matrix4f transformT = getTurretTransform(1); Vector4f worldPositionYaw = transformPosition(transformT, 0.62625f, 0.0396875f, -0.5f); @@ -394,6 +417,10 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt Vector4f worldPositionBarrel11 = transformPosition(transformB, -0.3659375f + 3 * i, 0.244375f - 2 * i, -0.44625f); this.barrel11.center().set(new Vector3f(worldPositionBarrel11.x, worldPositionBarrel11.y, worldPositionBarrel11.z)); this.barrel11.setRotation(VectorTool.combineRotationsBarrel(1, this)); + + Vector4f worldPositionBody1 = transformPosition(transformB, 0, 0, 0.3740625f); + this.body1.center().set(new Vector3f(worldPositionBody1.x, worldPositionBody1.y, worldPositionBody1.z)); + this.body1.setRotation(VectorTool.combineRotationsBarrel(1, this)); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/OBB.java b/src/main/java/com/atsuishio/superbwarfare/tools/OBB.java index 458737dd2..fed20a96a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/OBB.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/OBB.java @@ -487,6 +487,7 @@ public record OBB(Vector3f center, Vector3f extents, Quaternionf rotation, Part TURRET, ENGINE1, ENGINE2, - BODY + BODY, + INTERACTIVE } }