From d577f4b92ae187f87c7cc4c84c439ee45b285f62 Mon Sep 17 00:00:00 2001 From: kion Date: Sun, 7 Jul 2024 13:37:01 +0900 Subject: [PATCH 1/3] skip non-body tests --- bun.lockb | Bin 3836 -> 5991 bytes .../basic.test.ts => test/basic.test.skip.ts | 0 tests/bin.test.ts => test/bin.test.skip.ts | 0 {tests => test}/body.test.ts | 0 .../buster.test.skip.ts | 0 tests/hair.test.ts => test/hair.test.skip.ts | 0 .../helmet.test.skip.ts | 0 .../left-arm.test.skip.ts | 0 .../right-arm.test.skip.ts | 0 .../shoes-asbestos.test.skip.ts | 0 .../shoes-cleated.test.skip.ts | 0 .../shoes-hover.test.skip.ts | 0 .../shoes-hydro.test.skip.ts | 0 .../shoes-jet.test.skip.ts | 0 .../shoes-normal.test.skip.ts | 0 15 files changed, 0 insertions(+), 0 deletions(-) rename tests/basic.test.ts => test/basic.test.skip.ts (100%) rename tests/bin.test.ts => test/bin.test.skip.ts (100%) rename {tests => test}/body.test.ts (100%) rename tests/buster.test.ts => test/buster.test.skip.ts (100%) rename tests/hair.test.ts => test/hair.test.skip.ts (100%) rename tests/helmet.test.ts => test/helmet.test.skip.ts (100%) rename tests/left-arm.test.ts => test/left-arm.test.skip.ts (100%) rename tests/right-arm.test.ts => test/right-arm.test.skip.ts (100%) rename tests/shoes-asbestos.test.ts => test/shoes-asbestos.test.skip.ts (100%) rename tests/shoes-cleated.test.ts => test/shoes-cleated.test.skip.ts (100%) rename tests/shoes-hover.test.ts => test/shoes-hover.test.skip.ts (100%) rename tests/shoes-hydro.test.ts => test/shoes-hydro.test.skip.ts (100%) rename tests/shoes-jet.test.ts => test/shoes-jet.test.skip.ts (100%) rename tests/shoes-normal.test.ts => test/shoes-normal.test.skip.ts (100%) diff --git a/bun.lockb b/bun.lockb index 6ed8d4cc3629d6a21739543932df653d803c7c96..6c580559bfb455d48f06e198da95da54bdcd6b38 100755 GIT binary patch delta 1919 zcmcIldr(wW7(e$eyDYnl`w(%#6$lj-;j#-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ZQ}+#qBi^#tfpP%3D#Fg?Rq!S~Ms$N_;AzR9PAJSNKt&)J+P%Ekl$ D(inF$ diff --git a/tests/basic.test.ts b/test/basic.test.skip.ts similarity index 100% rename from tests/basic.test.ts rename to test/basic.test.skip.ts diff --git a/tests/bin.test.ts b/test/bin.test.skip.ts similarity index 100% rename from tests/bin.test.ts rename to test/bin.test.skip.ts diff --git a/tests/body.test.ts b/test/body.test.ts similarity index 100% rename from tests/body.test.ts rename to test/body.test.ts diff --git a/tests/buster.test.ts b/test/buster.test.skip.ts similarity index 100% rename from tests/buster.test.ts rename to test/buster.test.skip.ts diff --git a/tests/hair.test.ts b/test/hair.test.skip.ts similarity index 100% rename from tests/hair.test.ts rename to test/hair.test.skip.ts diff --git a/tests/helmet.test.ts b/test/helmet.test.skip.ts similarity index 100% rename from tests/helmet.test.ts rename to test/helmet.test.skip.ts diff --git a/tests/left-arm.test.ts b/test/left-arm.test.skip.ts similarity index 100% rename from tests/left-arm.test.ts rename to test/left-arm.test.skip.ts diff --git a/tests/right-arm.test.ts b/test/right-arm.test.skip.ts similarity index 100% rename from tests/right-arm.test.ts rename to test/right-arm.test.skip.ts diff --git a/tests/shoes-asbestos.test.ts b/test/shoes-asbestos.test.skip.ts similarity index 100% rename from tests/shoes-asbestos.test.ts rename to test/shoes-asbestos.test.skip.ts diff --git a/tests/shoes-cleated.test.ts b/test/shoes-cleated.test.skip.ts similarity index 100% rename from tests/shoes-cleated.test.ts rename to test/shoes-cleated.test.skip.ts diff --git a/tests/shoes-hover.test.ts b/test/shoes-hover.test.skip.ts similarity index 100% rename from tests/shoes-hover.test.ts rename to test/shoes-hover.test.skip.ts diff --git a/tests/shoes-hydro.test.ts b/test/shoes-hydro.test.skip.ts similarity index 100% rename from tests/shoes-hydro.test.ts rename to test/shoes-hydro.test.skip.ts diff --git a/tests/shoes-jet.test.ts b/test/shoes-jet.test.skip.ts similarity index 100% rename from tests/shoes-jet.test.ts rename to test/shoes-jet.test.skip.ts diff --git a/tests/shoes-normal.test.ts b/test/shoes-normal.test.skip.ts similarity index 100% rename from tests/shoes-normal.test.ts rename to test/shoes-normal.test.skip.ts From a1e3f59974a10074dd894be9ceb49f00f6c485ce Mon Sep 17 00:00:00 2001 From: kion Date: Sun, 7 Jul 2024 13:51:57 +0900 Subject: [PATCH 2/3] re-encode texture coords --- test/body.test.ts | 70 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git a/test/body.test.ts b/test/body.test.ts index cf21d93..5797f82 100644 --- a/test/body.test.ts +++ b/test/body.test.ts @@ -118,15 +118,61 @@ test('Re-encoding the vertices read from the body', () => { }); -// test('Re-encoding the faces read from the body', () => { -// const buffer = readFileSync(`./bin/PL00P000.BIN`); -// const dat = buffer.subarray(0x30, 0x30 + 0x2b40); -// const reader = new ByteReader(dat.buffer as ArrayBuffer); - -// const geometry = body.map((mesh) => { -// const { triOfs, triCount } = mesh; - -// const triList = readFace(reader, triOfs, triCount, false); - -// }); -// }); +test('Re-encoding the faces read from the body', () => { + const buffer = readFileSync(`./bin/PL00P000.BIN`); + const dat = buffer.subarray(0x30, 0x30 + 0x2b40); + const reader = new ByteReader(dat.buffer as ArrayBuffer); + + const FACE_MASK = 0x7f; + const PIXEL_TO_FLOAT_RATIO = 0.00390625; + const PIXEL_ADJUSTMEST = 0.001953125; + + const geometry = body.map((mesh) => { + const { triOfs, triCount } = mesh; + reader.seek(triOfs) + for (let i = 0; i < triCount; i++) { + const au = reader.readUInt8(); + const av = reader.readUInt8(); + const bu = reader.readUInt8(); + const bv = reader.readUInt8(); + const cu = reader.readUInt8(); + const cv = reader.readUInt8(); + reader.seekRel(2); + + const dword = reader.readUInt32(); + const materialIndex = ((dword >> 28) & 0x3); + + const indexA = (dword >> 0x00) & FACE_MASK; + const indexB = (dword >> 0x07) & FACE_MASK; + const indexC = (dword >> 0x0e) & FACE_MASK; + + const a = { + materialIndex, + index: indexA, + u : au * PIXEL_TO_FLOAT_RATIO + PIXEL_ADJUSTMEST, + v : av * PIXEL_TO_FLOAT_RATIO + PIXEL_ADJUSTMEST, + } + + const b = { + materialIndex, + index: indexB, + u : bu * PIXEL_TO_FLOAT_RATIO + PIXEL_ADJUSTMEST, + v : bv * PIXEL_TO_FLOAT_RATIO + PIXEL_ADJUSTMEST, + } + const c = { + materialIndex, + index: indexC, + u : cu * PIXEL_TO_FLOAT_RATIO + PIXEL_ADJUSTMEST, + v : cv * PIXEL_TO_FLOAT_RATIO + PIXEL_ADJUSTMEST, + } + + expect(Math.floor((a.u - PIXEL_ADJUSTMEST) / PIXEL_TO_FLOAT_RATIO)).toEqual(au); + expect(Math.floor((a.v - PIXEL_ADJUSTMEST) / PIXEL_TO_FLOAT_RATIO)).toEqual(av); + expect(Math.floor((b.u - PIXEL_ADJUSTMEST) / PIXEL_TO_FLOAT_RATIO)).toEqual(bu); + expect(Math.floor((b.v - PIXEL_ADJUSTMEST) / PIXEL_TO_FLOAT_RATIO)).toEqual(bv); + expect(Math.floor((c.u - PIXEL_ADJUSTMEST) / PIXEL_TO_FLOAT_RATIO)).toEqual(cu); + expect(Math.floor((c.v - PIXEL_ADJUSTMEST) / PIXEL_TO_FLOAT_RATIO)).toEqual(cv); + } + + }); +}); From c348aa48b52d987441f839a4f231dba85d949966 Mon Sep 17 00:00:00 2001 From: kion Date: Sun, 7 Jul 2024 13:54:57 +0900 Subject: [PATCH 3/3] encode da triangles --- test/body.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/body.test.ts b/test/body.test.ts index 5797f82..e8487b3 100644 --- a/test/body.test.ts +++ b/test/body.test.ts @@ -172,6 +172,8 @@ test('Re-encoding the faces read from the body', () => { expect(Math.floor((b.v - PIXEL_ADJUSTMEST) / PIXEL_TO_FLOAT_RATIO)).toEqual(bv); expect(Math.floor((c.u - PIXEL_ADJUSTMEST) / PIXEL_TO_FLOAT_RATIO)).toEqual(cu); expect(Math.floor((c.v - PIXEL_ADJUSTMEST) / PIXEL_TO_FLOAT_RATIO)).toEqual(cv); + + expect(indexA | (indexB << 7) | (indexC << 14) | (materialIndex << 28)).toEqual(dword); } });