feat: bounding boxes

This commit is contained in:
TrèsAbhi committed 2024-01-28 20:45:50 -06:00
1 parent 9141f3d63f
commit 72a24b2770
5 files changed
+37 -7

No files matched your search

+1
View File
@@ -9,6 +9,7 @@
"artefacts",
"atgm",
"AYUV",
"bbox",
"bepaint",
"BINORMAL",
"Binormals",
+12
View File
@@ -29,6 +29,7 @@ import {
Tier,
} from '../../src/core/blitzkrieg/tankDefinitions';
import { DATA, POI } from './constants';
import { TankParameters } from './tankIcons';
type BlitzTankType = 'AT-SPG' | 'lightTank' | 'mediumTank' | 'heavyTank';
interface Strings {
@@ -119,6 +120,9 @@ interface VehicleDefinitions {
yawLimits: string | string[];
gunPosition: string | string[];
models: { undamaged: string };
hitTester: {
collisionModel: string;
};
guns: {
[key: string]: {
armor: VehicleDefinitionArmor & {
@@ -338,6 +342,9 @@ export async function definitions(production: boolean) {
const tankDefinition = await readXMLDVPL<{ root: VehicleDefinitions }>(
`${DATA}/${POI.vehicleDefinitions}/${nation}/${tankKey}.xml.dvpl`,
);
const tankParameters = await readYAMLDVPL<TankParameters>(
`${DATA}/${POI.tankParameters}/${nation}/${tankKey}.yaml.dvpl`,
);
const defaultChassis = Object.values(tankDefinition.root.chassis).at(
-1,
)!;
@@ -426,6 +433,7 @@ export async function definitions(production: boolean) {
roll: tankDefinition.root.hull.turretInitialRotation.roll,
}
: undefined,
boundingBox: tankParameters.collision.hull.bbox,
turrets: {},
};
@@ -507,6 +515,10 @@ export async function definitions(production: boolean) {
? undefined
: { min: turretYaw[0], max: turretYaw[1] },
guns: {},
boundingBox:
tankParameters.collision[
parsePath(turret.hitTester.collisionModel).name.toLowerCase()
].bbox,
};
Object.keys(turret.guns).forEach((gunKey, gunIndex) => {
+11
View File
@@ -1,4 +1,5 @@
import { readdir } from 'fs/promises';
import { Vector3Tuple } from 'three';
import { NATION_IDS } from '../../src/constants/nations';
import { readBase64DVPL } from '../../src/core/blitz/readBase64DVPL';
import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL';
@@ -14,6 +15,16 @@ export interface TankParameters {
bigIconPath: string;
blitzModelPath: string;
};
collision: {
[key: string]: {
points: Vector3Tuple;
bbox: {
min: Vector3Tuple;
max: Vector3Tuple;
};
averageThickness?: Record<string, number>;
};
};
}
export async function buildTankIcons(production: boolean) {
@@ -57,22 +57,22 @@ export function Characteristics() {
{Math.round(engine.fire_chance * 100)}
</Info>
<Info name="View range" unit="m">
TODO
{turret.view_range}
</Info>
<Info name="Camouflage when still" unit="%">
TODO
{(tank.camouflage.still * 100).toFixed(2)}
</Info>
<Info indent name="Moving" unit="%">
TODO
{(tank.camouflage.moving * 100).toFixed(2)}
</Info>
<Info indent name="Shooting still" unit="%">
TODO
{(tank.camouflage.still * gun.camouflageLoss * 100).toFixed(2)}
</Info>
<Info indent name="Shooting on move" unit="%">
TODO
{(tank.camouflage.moving * gun.camouflageLoss * 100).toFixed(2)}
</Info>
<Info indent name="On fire" unit="%">
TODO
<Info indent name="On fire penalty" unit="%">
{(tank.camouflage.onFire * 100).toFixed(2)}
</Info>
<Info indent name="Size" unit="m">
TODO
+6
View File
@@ -8,6 +8,10 @@ export interface ModelArmor {
spaced?: number[];
}
interface BoundingBox {
min: Vector3Tuple;
max: Vector3Tuple;
}
interface ModelDefinition {
armor: ModelArmor;
trackThickness: number;
@@ -15,6 +19,7 @@ interface ModelDefinition {
hullOrigin: Vector3Tuple;
turretRotation?: InitialTurretRotation;
turrets: Record<number, TurretModelDefinition>;
boundingBox: BoundingBox;
}
export interface InitialTurretRotation {
yaw: number;
@@ -22,6 +27,7 @@ export interface InitialTurretRotation {
roll: number;
}
interface TurretModelDefinition {
boundingBox: BoundingBox;
armor: ModelArmor;
model: number;
gunOrigin: Vector3Tuple;