给XY100添加第二个碰撞箱
This commit is contained in:
parent
50eb2a4078
commit
ffbd2e81a2
3 changed files with 17 additions and 3 deletions
|
@ -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()),
|
||||
|
|
|
@ -89,10 +89,12 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
public int droneReloadCoolDown;
|
||||
|
||||
public OBB obb;
|
||||
public OBB obbTurret;
|
||||
|
||||
public Yx100Entity(EntityType<Yx100Entity> 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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue