添加歼灭者的obb
This commit is contained in:
parent
9dd109c926
commit
1555e1f785
12 changed files with 102 additions and 52 deletions
|
@ -25,8 +25,9 @@ public class OBBRenderer {
|
||||||
Vector3f center = obb.center();
|
Vector3f center = obb.center();
|
||||||
Vector3f halfExtents = obb.extents();
|
Vector3f halfExtents = obb.extents();
|
||||||
Quaternionf rotation;
|
Quaternionf rotation;
|
||||||
|
if (obb.onlyHorizontal()) {
|
||||||
if (obb.isPart()) {
|
rotation = VectorTool.combineRotationsYaw(pPartialTicks, entity);
|
||||||
|
}else if (obb.isPart()) {
|
||||||
rotation = VectorTool.combineRotationsTurret(pPartialTicks, entity);
|
rotation = VectorTool.combineRotationsTurret(pPartialTicks, entity);
|
||||||
} else {
|
} else {
|
||||||
rotation = VectorTool.combineRotations(pPartialTicks, entity);
|
rotation = VectorTool.combineRotations(pPartialTicks, entity);
|
||||||
|
|
|
@ -102,17 +102,17 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
|
|
||||||
public A10Entity(EntityType<A10Entity> type, Level world) {
|
public A10Entity(EntityType<A10Entity> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
this.obb = new OBB(this.position().toVector3f(), new Vector3f(0.6875f, 1.09375f, 3.65625f), new Quaternionf(), false);
|
this.obb = new OBB(this.position().toVector3f(), new Vector3f(0.6875f, 1.09375f, 3.65625f), new Quaternionf(), false , false);
|
||||||
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(8.8125f, 0.3125f, 1.40625f), new Quaternionf(), false);
|
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(8.8125f, 0.3125f, 1.40625f), new Quaternionf(), false , false);
|
||||||
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(3.1875f, 0.125f, 0.96875f), new Quaternionf(), false);
|
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(3.1875f, 0.125f, 0.96875f), new Quaternionf(), false , false);
|
||||||
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.0625f, 1.09375f, 0.84375f), new Quaternionf(), false);
|
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.0625f, 1.09375f, 0.84375f), new Quaternionf(), false , false);
|
||||||
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(0.0625f, 1.09375f, 0.84375f), new Quaternionf(), false);
|
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(0.0625f, 1.09375f, 0.84375f), new Quaternionf(), false , false);
|
||||||
this.obb6 = new OBB(this.position().toVector3f(), new Vector3f(0.625f, 0.78125f, 1.09375f), new Quaternionf(), false);
|
this.obb6 = new OBB(this.position().toVector3f(), new Vector3f(0.625f, 0.78125f, 1.09375f), new Quaternionf(), false , false);
|
||||||
this.obb7 = new OBB(this.position().toVector3f(), new Vector3f(0.6875f, 0.75f, 2.9375f), new Quaternionf(), false);
|
this.obb7 = new OBB(this.position().toVector3f(), new Vector3f(0.6875f, 0.75f, 2.9375f), new Quaternionf(), false , false);
|
||||||
this.obb8 = new OBB(this.position().toVector3f(), new Vector3f(0.75f, 0.75f, 1.5625f), new Quaternionf(), false);
|
this.obb8 = new OBB(this.position().toVector3f(), new Vector3f(0.75f, 0.75f, 1.5625f), new Quaternionf(), false , false);
|
||||||
this.obb9 = new OBB(this.position().toVector3f(), new Vector3f(0.75f, 0.75f, 1.5625f), new Quaternionf(), false);
|
this.obb9 = new OBB(this.position().toVector3f(), new Vector3f(0.75f, 0.75f, 1.5625f), new Quaternionf(), false , false);
|
||||||
this.obb10 = new OBB(this.position().toVector3f(), new Vector3f(0.34375f, 0.359375f, 1.78125f), new Quaternionf(), false);
|
this.obb10 = new OBB(this.position().toVector3f(), new Vector3f(0.34375f, 0.359375f, 1.78125f), new Quaternionf(), false , false);
|
||||||
this.obb11 = new OBB(this.position().toVector3f(), new Vector3f(0.34375f, 0.359375f, 1.78125f), new Quaternionf(), false);
|
this.obb11 = new OBB(this.position().toVector3f(), new Vector3f(0.34375f, 0.359375f, 1.78125f), new Quaternionf(), false , false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -81,11 +81,11 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
|
|
||||||
public Ah6Entity(EntityType<Ah6Entity> type, Level world) {
|
public Ah6Entity(EntityType<Ah6Entity> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
this.obb = new OBB(this.position().toVector3f(), new Vector3f(1.0625f, 1.28125f, 1.625f), new Quaternionf(), false);
|
this.obb = new OBB(this.position().toVector3f(), new Vector3f(1.0625f, 1.28125f, 1.625f), new Quaternionf(), false , false);
|
||||||
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(0.875f, 0.6875f, 0.59375f), new Quaternionf(), false);
|
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(0.875f, 0.6875f, 0.59375f), new Quaternionf(), false , false);
|
||||||
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.3125f, 2.25f), new Quaternionf(), false);
|
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.3125f, 2.25f), new Quaternionf(), false , false);
|
||||||
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.0625f, 1.15625f, 0.40625f), new Quaternionf(), false);
|
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.0625f, 1.15625f, 0.40625f), new Quaternionf(), false , false);
|
||||||
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1f, 0.25f, 0.21875f), new Quaternionf(), false);
|
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1f, 0.25f, 0.21875f), new Quaternionf(), false , false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.component.ModDataComponents;
|
import com.atsuishio.superbwarfare.component.ModDataComponents;
|
||||||
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||||
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
||||||
|
import com.atsuishio.superbwarfare.entity.OBBEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.EnergyVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.EnergyVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition;
|
||||||
|
@ -51,17 +52,16 @@ import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.joml.Math;
|
import org.joml.Math;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.*;
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.joml.Vector4f;
|
|
||||||
import software.bernie.geckolib.animatable.GeoEntity;
|
import software.bernie.geckolib.animatable.GeoEntity;
|
||||||
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
||||||
import software.bernie.geckolib.animation.*;
|
import software.bernie.geckolib.animation.*;
|
||||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity, CannonEntity {
|
public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity, CannonEntity, OBBEntity {
|
||||||
|
|
||||||
public static final EntityDataAccessor<Integer> COOL_DOWN = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> COOL_DOWN = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Float> LASER_LEFT_LENGTH = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> LASER_LEFT_LENGTH = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.FLOAT);
|
||||||
|
@ -72,10 +72,18 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
|
||||||
public static final EntityDataAccessor<String> SHOOTER_UUID = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.STRING);
|
public static final EntityDataAccessor<String> SHOOTER_UUID = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.STRING);
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
|
|
||||||
|
public OBB obb;
|
||||||
|
public OBB obb2;
|
||||||
|
public OBB obb3;
|
||||||
|
public OBB obb4;
|
||||||
public Vec3 barrelLookAt;
|
public Vec3 barrelLookAt;
|
||||||
|
|
||||||
public AnnihilatorEntity(EntityType<AnnihilatorEntity> type, Level world) {
|
public AnnihilatorEntity(EntityType<AnnihilatorEntity> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
|
this.obb = new OBB(this.position().toVector3f(), new Vector3f(6.4375f, 1.84375f, 4.125f), new Quaternionf(), false , true);
|
||||||
|
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(5.0625f, 1.40625f, 1.5f), new Quaternionf(), false , true);
|
||||||
|
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(5.1875f, 1.84375f, 1.96875f), new Quaternionf(), false , true);
|
||||||
|
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(4.125f, 1.84375f, 0.75f), new Quaternionf(), false , true);
|
||||||
this.noCulling = true;
|
this.noCulling = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,6 +217,8 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
|
||||||
public void baseTick() {
|
public void baseTick() {
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
|
|
||||||
|
updateOBB();
|
||||||
|
|
||||||
if (this.entityData.get(COOL_DOWN) > 0) {
|
if (this.entityData.get(COOL_DOWN) > 0) {
|
||||||
this.entityData.set(COOL_DOWN, this.entityData.get(COOL_DOWN) - 1);
|
this.entityData.set(COOL_DOWN, this.entityData.get(COOL_DOWN) - 1);
|
||||||
}
|
}
|
||||||
|
@ -599,4 +609,30 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
|
||||||
public @Nullable ResourceLocation getVehicleItemIcon() {
|
public @Nullable ResourceLocation getVehicleItemIcon() {
|
||||||
return Mod.loc("textures/gui/vehicle/type/defense.png");
|
return Mod.loc("textures/gui/vehicle/type/defense.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OBB> getOBBs() {
|
||||||
|
return List.of(this.obb, this.obb2, this.obb3, this.obb4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateOBB() {
|
||||||
|
Matrix4f transform = getVehicleHorizontalTransform(1);
|
||||||
|
|
||||||
|
Vector4f worldPosition = transformPosition(transform, 0, 2.28125f, 0.875f);
|
||||||
|
this.obb.center().set(new Vector3f(worldPosition.x, worldPosition.y, worldPosition.z));
|
||||||
|
this.obb.setRotation(VectorTool.combineRotationsYaw(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition2 = transformPosition(transform, 0, 1.84375f, 6.5f);
|
||||||
|
this.obb2.center().set(new Vector3f(worldPosition2.x, worldPosition2.y, worldPosition2.z));
|
||||||
|
this.obb2.setRotation(VectorTool.combineRotationsYaw(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition3 = transformPosition(transform, 0, 2.28125f, -5.21875f);
|
||||||
|
this.obb3.center().set(new Vector3f(worldPosition3.x, worldPosition3.y, worldPosition3.z));
|
||||||
|
this.obb3.setRotation(VectorTool.combineRotationsYaw(1, this));
|
||||||
|
|
||||||
|
Vector4f worldPosition4 = transformPosition(transform, 0, 2.28125f, -7.9375f);
|
||||||
|
this.obb4.center().set(new Vector3f(worldPosition4.x, worldPosition4.y, worldPosition4.z));
|
||||||
|
this.obb4.setRotation(VectorTool.combineRotationsYaw(1, this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,11 +82,11 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
||||||
|
|
||||||
public Bmp2Entity(EntityType<Bmp2Entity> type, Level world) {
|
public Bmp2Entity(EntityType<Bmp2Entity> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
this.obb = new OBB(this.position().toVector3f(), new Vector3f(2.1875f, 0.875f, 3.90625f), new Quaternionf(), false);
|
this.obb = new OBB(this.position().toVector3f(), new Vector3f(2.1875f, 0.875f, 3.90625f), new Quaternionf(), false , false);
|
||||||
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.1875f, 0.5f, 0.65625f), new Quaternionf(), false);
|
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.1875f, 0.5f, 0.65625f), new Quaternionf(), false , false);
|
||||||
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), false);
|
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), false , false);
|
||||||
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), false);
|
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.375f, 0.78125f, 3.46875f), new Quaternionf(), false , false);
|
||||||
this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(1.5f, 0.34375f, 1.5f), new Quaternionf(), true);
|
this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(1.5f, 0.34375f, 1.5f), new Quaternionf(), true , false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -74,14 +74,14 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
|
|
||||||
public Lav150Entity(EntityType<Lav150Entity> type, Level world) {
|
public Lav150Entity(EntityType<Lav150Entity> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
this.obb = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.75f, 0.75f), new Quaternionf(), false);
|
this.obb = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.75f, 0.75f), new Quaternionf(), false , false);
|
||||||
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.75f, 0.75f), new Quaternionf(), false);
|
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.75f, 0.75f), new Quaternionf(), false , false);
|
||||||
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.75f, 0.75f), new Quaternionf(), false);
|
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.75f, 0.75f), new Quaternionf(), false , false);
|
||||||
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.75f, 0.75f), new Quaternionf(), false);
|
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.25f, 0.75f, 0.75f), new Quaternionf(), false , false);
|
||||||
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.90625f, 2.4375f), new Quaternionf(), false);
|
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.90625f, 2.4375f), new Quaternionf(), false , false);
|
||||||
this.obb6 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.53125f, 0.34375f), new Quaternionf(), false);
|
this.obb6 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.53125f, 0.34375f), new Quaternionf(), false , false);
|
||||||
this.obb7 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.625f, 0.53125f), new Quaternionf(), false);
|
this.obb7 = new OBB(this.position().toVector3f(), new Vector3f(1.3125f, 0.625f, 0.53125f), new Quaternionf(), false , false);
|
||||||
this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(0.875f, 0.3625f, 1.25f), new Quaternionf(), true);
|
this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(0.875f, 0.3625f, 1.25f), new Quaternionf(), true , false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -90,12 +90,12 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
|
||||||
public PrismTankEntity(EntityType<PrismTankEntity> type, Level world) {
|
public PrismTankEntity(EntityType<PrismTankEntity> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
this.noCulling = true;
|
this.noCulling = true;
|
||||||
this.obb = new OBB(this.position().toVector3f(), new Vector3f(2.5f, 0.8125f, 3.96875f), new Quaternionf(), false);
|
this.obb = new OBB(this.position().toVector3f(), new Vector3f(2.5f, 0.8125f, 3.96875f), new Quaternionf(), false , false);
|
||||||
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.5f, 0.5f, 0.375f), new Quaternionf(), false);
|
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.5f, 0.5f, 0.375f), new Quaternionf(), false , false);
|
||||||
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.46875f, 0.78125f, 3.3125f), new Quaternionf(), false);
|
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.46875f, 0.78125f, 3.3125f), new Quaternionf(), false , false);
|
||||||
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.46875f, 0.78125f, 3.3125f), new Quaternionf(), false);
|
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.46875f, 0.78125f, 3.3125f), new Quaternionf(), false , false);
|
||||||
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1.375f, 0.28125f, 1.375f), new Quaternionf(), false);
|
this.obb5 = new OBB(this.position().toVector3f(), new Vector3f(1.375f, 0.28125f, 1.375f), new Quaternionf(), false , false);
|
||||||
this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(0.4375f, 0.90625f, 1.21875f), new Quaternionf(), true);
|
this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(0.4375f, 0.90625f, 1.21875f), new Quaternionf(), true , false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -58,8 +58,8 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
||||||
|
|
||||||
public SpeedboatEntity(EntityType<SpeedboatEntity> type, Level world) {
|
public SpeedboatEntity(EntityType<SpeedboatEntity> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
this.obb = new OBB(this.position().toVector3f(), new Vector3f(1.5625f, 0.75f, 3.1875f), new Quaternionf(), false);
|
this.obb = new OBB(this.position().toVector3f(), new Vector3f(1.5625f, 0.75f, 3.1875f), new Quaternionf(), false , false);
|
||||||
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(1.0625f, 0.5f, 1.90625f), new Quaternionf(), false);
|
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(1.0625f, 0.5f, 1.90625f), new Quaternionf(), false , false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -97,12 +97,12 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
public Yx100Entity(EntityType<Yx100Entity> type, Level world) {
|
public Yx100Entity(EntityType<Yx100Entity> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
this.obb = new OBB(this.position().toVector3f(), new Vector3f(2.375f, 0.71875f, 4f), new Quaternionf(), false);
|
this.obb = new OBB(this.position().toVector3f(), new Vector3f(2.375f, 0.71875f, 4f), new Quaternionf(), false , false);
|
||||||
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.375f, 0.59375f, 0.65625f), new Quaternionf(), false);
|
this.obb2 = new OBB(this.position().toVector3f(), new Vector3f(2.375f, 0.59375f, 0.65625f), new Quaternionf(), false , false);
|
||||||
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.625f, 0.84375f, 3.875f), new Quaternionf(), false);
|
this.obb3 = new OBB(this.position().toVector3f(), new Vector3f(0.625f, 0.84375f, 3.875f), new Quaternionf(), false , false);
|
||||||
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.625f, 0.84375f, 3.875f), new Quaternionf(), false);
|
this.obb4 = new OBB(this.position().toVector3f(), new Vector3f(0.625f, 0.84375f, 3.875f), new Quaternionf(), false , false);
|
||||||
this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(2.375f, 0.5625f, 2.1875f), new Quaternionf(), true);
|
this.obbTurret = new OBB(this.position().toVector3f(), new Vector3f(2.375f, 0.5625f, 2.1875f), new Quaternionf(), true , false);
|
||||||
this.obbTurret2 = new OBB(this.position().toVector3f(), new Vector3f(1.625f, 0.40625f, 0.59375f), new Quaternionf(), true);
|
this.obbTurret2 = new OBB(this.position().toVector3f(), new Vector3f(1.625f, 0.40625f, 0.59375f), new Quaternionf(), true , false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -787,6 +787,13 @@ public abstract class VehicleEntity extends Entity {
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Matrix4f getVehicleHorizontalTransform(float ticks) {
|
||||||
|
Matrix4f transform = new Matrix4f();
|
||||||
|
transform.translate((float) Mth.lerp(ticks, xo, getX()), (float) Mth.lerp(ticks, yo, getY()), (float) Mth.lerp(ticks, zo, getZ()));
|
||||||
|
transform.rotate(Axis.YP.rotationDegrees(-Mth.lerp(ticks, yRotO, getYRot())));
|
||||||
|
return transform;
|
||||||
|
}
|
||||||
|
|
||||||
public Vector4f transformPosition(Matrix4f transform, float x, float y, float z) {
|
public Vector4f transformPosition(Matrix4f transform, float x, float y, float z) {
|
||||||
return transform.transform(new Vector4f(x, y, z, 1));
|
return transform.transform(new Vector4f(x, y, z, 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import java.util.Optional;
|
||||||
* @param rotation 旋转
|
* @param rotation 旋转
|
||||||
* @param isPart 是否为子部件,一般用于炮塔
|
* @param isPart 是否为子部件,一般用于炮塔
|
||||||
*/
|
*/
|
||||||
public record OBB(Vector3f center, Vector3f extents, Quaternionf rotation, boolean isPart) {
|
public record OBB(Vector3f center, Vector3f extents, Quaternionf rotation, boolean isPart, boolean onlyHorizontal) {
|
||||||
|
|
||||||
public void setCenter(Vector3f center) {
|
public void setCenter(Vector3f center) {
|
||||||
this.center.set(center);
|
this.center.set(center);
|
||||||
|
@ -215,12 +215,12 @@ public record OBB(Vector3f center, Vector3f extents, Quaternionf rotation, boole
|
||||||
|
|
||||||
public OBB inflate(float amount) {
|
public OBB inflate(float amount) {
|
||||||
Vector3f newExtents = new Vector3f(extents).add(amount, amount, amount);
|
Vector3f newExtents = new Vector3f(extents).add(amount, amount, amount);
|
||||||
return new OBB(center, newExtents, rotation, false);
|
return new OBB(center, newExtents, rotation, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OBB inflate(float x, float y, float z) {
|
public OBB inflate(float x, float y, float z) {
|
||||||
Vector3f newExtents = new Vector3f(extents).add(x, y, z);
|
Vector3f newExtents = new Vector3f(extents).add(x, y, z);
|
||||||
return new OBB(center, newExtents, rotation, false);
|
return new OBB(center, newExtents, rotation, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,6 +42,12 @@ public class VectorTool {
|
||||||
return combined;
|
return combined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 仅水平旋转
|
||||||
|
public static Quaternionf combineRotationsYaw(float partialTicks, VehicleEntity entity) {
|
||||||
|
Quaternionf yawRot = Axis.YP.rotationDegrees(-Mth.lerp(partialTicks, entity.yRotO, entity.getYRot()));
|
||||||
|
return new Quaternionf(yawRot);
|
||||||
|
}
|
||||||
|
|
||||||
public static Quaternionf combineRotationsTurret(float partialTicks, VehicleEntity entity) {
|
public static Quaternionf combineRotationsTurret(float partialTicks, VehicleEntity entity) {
|
||||||
Quaternionf turretYawRot = Axis.YP.rotationDegrees(Mth.lerp(partialTicks, entity.turretYRotO, entity.getTurretYRot()));
|
Quaternionf turretYawRot = Axis.YP.rotationDegrees(Mth.lerp(partialTicks, entity.turretYRotO, entity.getTurretYRot()));
|
||||||
Quaternionf combined = combineRotations(partialTicks, entity);
|
Quaternionf combined = combineRotations(partialTicks, entity);
|
||||||
|
|
Loading…
Add table
Reference in a new issue