mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
fix: added binary start padding
This commit is contained in:
1 parent
662e0bb9ce
commit
2e2ab9b2d9
2 files changed
+12
-15
No files matched your search
@@ -298,6 +298,7 @@ if (allTargets || targets?.includes('tankModels')) {
|
|||||||
const nationVehicleId = tank.id;
|
const nationVehicleId = tank.id;
|
||||||
const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1;
|
const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1;
|
||||||
|
|
||||||
|
// if (id !== 897) continue;
|
||||||
console.log(`Building model ${id} @ ${nation}/${tankIndex}`);
|
console.log(`Building model ${id} @ ${nation}/${tankIndex}`);
|
||||||
|
|
||||||
const parameters = await readYAMLDVPL<TankParameters>(
|
const parameters = await readYAMLDVPL<TankParameters>(
|
||||||
@@ -314,6 +315,7 @@ if (allTargets || targets?.includes('tankModels')) {
|
|||||||
const scgStream = await SCPGStream.fromDVPLFile(
|
const scgStream = await SCPGStream.fromDVPLFile(
|
||||||
`${DATA}/${DOI['3d']}/${scgPath}.dvpl`,
|
`${DATA}/${DOI['3d']}/${scgPath}.dvpl`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const sc2 = sc2Stream.consumeSC2();
|
const sc2 = sc2Stream.consumeSC2();
|
||||||
const scg = scgStream.consumeSCG();
|
const scg = scgStream.consumeSCG();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,12 +90,7 @@ const VECTOR_SIZES = [
|
|||||||
VertexType.CUBETEXCOORD2,
|
VertexType.CUBETEXCOORD2,
|
||||||
VertexType.CUBETEXCOORD3,
|
VertexType.CUBETEXCOORD3,
|
||||||
],
|
],
|
||||||
[
|
[VertexType.PIVOT4, VertexType.JOINTINDEX, VertexType.JOINTWEIGHT],
|
||||||
VertexType.PIVOT4,
|
|
||||||
VertexType.JOINTINDEX,
|
|
||||||
VertexType.JOINTWEIGHT,
|
|
||||||
// VertexType.TANGENT,
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export class SCPGStream {
|
export class SCPGStream {
|
||||||
@@ -221,22 +216,22 @@ export class SCPGStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const verticesStream = new SCPGStream(polygonGroupRaw.vertices);
|
const verticesStream = new SCPGStream(polygonGroupRaw.vertices);
|
||||||
const vertexFormat = [
|
|
||||||
...polygonGroupRaw.vertexFormat.toString(2).padEnd(64, '0'),
|
|
||||||
]
|
|
||||||
.map((bit, index) => (bit === '1' ? index : null))
|
|
||||||
.filter((index) => index !== null) as VertexType[];
|
|
||||||
const vertices: Partial<Record<VertexType, number[]>>[] = [];
|
const vertices: Partial<Record<VertexType, number[]>>[] = [];
|
||||||
|
const vertexFormatBuffer = Buffer.alloc(4);
|
||||||
|
vertexFormatBuffer.writeUInt32LE(polygonGroupRaw.vertexFormat, 0);
|
||||||
|
const vertexFormat = [...vertexFormatBuffer]
|
||||||
|
.map((number) => number.toString(2))
|
||||||
|
.join('')
|
||||||
|
.split('')
|
||||||
|
.map((bitString, index) => (bitString === '1' ? index : null))
|
||||||
|
.filter((type) => type !== null) as VertexType[];
|
||||||
|
|
||||||
for (let index = 0; index < polygonGroupRaw.vertexCount; index++) {
|
for (let index = 0; index < polygonGroupRaw.vertexCount; index++) {
|
||||||
vertexFormat.forEach((type) => {
|
vertexFormat.forEach((type) => {
|
||||||
const resolved = VECTOR_SIZES.some((types, size) => {
|
const resolved = VECTOR_SIZES.some((types, size) => {
|
||||||
if (types.includes(type)) {
|
if (types.includes(type)) {
|
||||||
if (!(index in vertices)) vertices[index] = {};
|
if (!(index in vertices)) vertices[index] = {};
|
||||||
|
vertices[index][type] = verticesStream.consumeVectorN(size + 1);
|
||||||
vertices[index][type] = times(size + 1).map(() =>
|
|
||||||
verticesStream.consumeFloat(),
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user