assets: bounded md3 reader
Browse filesFiles changed (11)
- docs/ASSET_PIPELINE_TODO.md+3
- docs/FINDINGS.md+3
- docs/PROVISIONAL_TODO.md+3
- docs/RESEARCH_LEDGER.md+5
- docs/REVERSE_ENGINEERING_TODO.md+3
- docs/research/MD3_CONTRACT.mdAdded+7
- docs/research/README.md+3
- docs/research/md3-contract.jsonAdded+925
- scripts/analyze_md3_contract.pyAdded+15
- scripts/md3.pyAdded+61
- scripts/test_md3_contract.pyAdded+29
741 unmodified lines742743744741 unmodified linesResearch progress: RE-690 [report](research/QVM_GEOMETRIC_REWOUND_TRACE.md); remaining native/content/runtime/platform scope stays open.741 unmodified lines742743744745746747741 unmodified linesResearch progress: RE-690 [report](research/QVM_GEOMETRIC_REWOUND_TRACE.md); remaining native/content/runtime/platform scope stays open.Research progress: RE-692 [report](research/MD3_CONTRACT.md); remaining native/content/runtime/platform scope stays open.
1087 unmodified lines1088108910901087 unmodified lines**RE-690 — Rewound trace through actual model geometry and complete cleanup:** 291641 now reaches complete returns through actual geometric model hits or model misses followed by a supplied world retry, including actual rewind/restoration and cleanup. [Evidence](research/QVM_GEOMETRIC_REWOUND_TRACE.md).1087 unmodified lines1088108910901091109210931087 unmodified lines**RE-690 — Rewound trace through actual model geometry and complete cleanup:** 291641 now reaches complete returns through actual geometric model hits or model misses followed by a supplied world retry, including actual rewind/restoration and cleanup. [Evidence](research/QVM_GEOMETRIC_REWOUND_TRACE.md).**RE-692 — Bounds-checked original MD3 reader and QVM layout contract:** Original MD3 version15 headers/surfaces match recovered model offsets; all eight selected LOD3 files parse, including case-mismatched orion/lower_3.MD3. [Evidence](research/MD3_CONTRACT.md).
1073 unmodified lines1074107510761073 unmodified linesRE-681–690 batch complete: [source model geometry through rewound trace](research/QVM_GEOMETRY_TRACE_BATCH.md). RE-691 tracks original asset/reference validation and downstream contact/damage; playable Rust/Bevy/Solari integration remains open.1073 unmodified lines1074107510761077107810791073 unmodified linesRE-681–690 batch complete: [source model geometry through rewound trace](research/QVM_GEOMETRY_TRACE_BATCH.md). RE-691 tracks original asset/reference validation and downstream contact/damage; playable Rust/Bevy/Solari integration remains open.Research progress: RE-692 [report](research/MD3_CONTRACT.md); remaining native/content/runtime/platform scope stays open.
1101 unmodified lines1102110311041101 unmodified lines## 2026-10-21 — RE-690 Rewound trace through actual model geometry and complete cleanup (separate task commit)291641 now reaches complete returns through actual geometric model hits or model misses followed by a supplied world retry, including actual rewind/restoration and cleanup. Two whole caller compositions independently check every leaf/context sort, numeric return, native candidate sequence, every rewind and all tracked restored entity records. Full suite: 1218 tests pass. Report regenerates byte-identically (953113 bytes). Storage/filter, links and whitespace checks pass. No assets/Rust runtime/shared VM evaluator changed; native/reference/legal/full platform scope remains open.1101 unmodified lines110211031104110511061107110811091101 unmodified lines## 2026-10-21 — RE-690 Rewound trace through actual model geometry and complete cleanup (separate task commit)291641 now reaches complete returns through actual geometric model hits or model misses followed by a supplied world retry, including actual rewind/restoration and cleanup. Two whole caller compositions independently check every leaf/context sort, numeric return, native candidate sequence, every rewind and all tracked restored entity records. Full suite: 1218 tests pass. Report regenerates byte-identically (953113 bytes). Storage/filter, links and whitespace checks pass. No assets/Rust runtime/shared VM evaluator changed; native/reference/legal/full platform scope remains open.## 2026-10-21 — RE-692 Bounds-checked original MD3 reader and QVM layout contract (separate task commit)Original MD3 version15 headers/surfaces match recovered model offsets; all eight selected LOD3 files parse, including case-mismatched orion/lower_3.MD3. Five parser/accessor tests independently check packed coordinates, tags, indices, UVs/shaders, malformed counts/ranges/signatures and original selected files. Full suite: 1223 tests pass. Report regenerates byte-identically (22517 bytes). Storage/filter, links and whitespace checks pass. No assets/Rust runtime/shared VM evaluator changed; native/reference/legal/full platform scope remains open.
1116 unmodified lines1117111811191116 unmodified lines- [ ] RE-691 Connect original model assets and reference traces to recovered geometry, then continue contact/damage, shared/pellet aggregation and remaining runtime/lifecycle work toward a verified Rust gameplay slice. See the [next ten tasks](research/QVM_GEOMETRY_TRACE_BATCH.md#next-ten-concrete-tasks).1116 unmodified lines1117111811191120112111221116 unmodified lines- [ ] RE-691 Connect original model assets and reference traces to recovered geometry, then continue contact/damage, shared/pellet aggregation and remaining runtime/lifecycle work toward a verified Rust gameplay slice. See the [next ten tasks](research/QVM_GEOMETRY_TRACE_BATCH.md#next-ten-concrete-tasks).- [x] RE-692 Bounds-checked original MD3 reader and QVM layout contract ([report](research/MD3_CONTRACT.md)).
1234567# Bounds-checked original MD3 reader and QVM layout contract
RE-692. Reproduce with `python3 scripts/analyze_md3_contract.py`; check with `python3 scripts/test_md3_contract.py`. The [machine report](md3-contract.json) retains source identity and bounded fixtures.
A bounded MD3 reader preserves original byte offsets and validates header/surface ranges, frame agreement, triangle indices and surface chain termination. Accessors expose frames,112-byte tags,12-byte triangles, UVs/shaders and eight-byte signed vertex records without converting originals. All eight selected Athena/Orion LOD3 files parse. The source requests orion/lower_3.md3 while extraction preserves lower_3.MD3; inventory uses suffix case-folding without renaming or choosing a runtime precedence rule. Linux resolution must handle this evidence explicitly. This establishes file layout compatibility, not rendering/native buffer ownership or complete runtime asset resolution.
No original executable/full QVM/native collision/physics/rendering executes. Native responses and legal input domains are supplied or unverified where stated; full runtime/macOS/Linux Rust/Bevy/Solari gameplay remains open.674 unmodified lines675676677674 unmodified lines[RE-681–690: Source model geometry through rewound trace](QVM_GEOMETRY_TRACE_BATCH.md), with validation limits and the next ten concrete tasks.674 unmodified lines675676677678679680674 unmodified lines[RE-681–690: Source model geometry through rewound trace](QVM_GEOMETRY_TRACE_BATCH.md), with validation limits and the next ten concrete tasks.[RE-692: Bounds-checked original MD3 reader and QVM layout contract](MD3_CONTRACT.md). Reproduce with `python3 scripts/analyze_md3_contract.py`; check with `python3 scripts/test_md3_contract.py`.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925{ "limits": "Original bytes parsed only; version15/declared ranges/surface chain/frame counts/triangle indices checked. No renderer/full runtime. Coordinate scale and fields are cross-linked to recovered QVM offsets, not external format assumptions.", "models": [ { "bytes": 3092, "first_frame": { "maxs": [ 5.916663646697998, 3.9339609146118164, 9.352885246276855 ], "mins": [ -4.893303394317627, -3.656599760055542, -1.845400094985962 ], "name": "(from 3DSMax)", "origin": [ 0.0, 0.0, 0.0 ], "radius": 11.745613098144531 }, "first_tags": [ { "axis": [ [ 1.0, 4.8268422374005745e-15, 8.346185782694571e-15 ], [ 3.3944144441452233e-15, 0.9999999403953552, -2.05560920254989e-16 ], [ -1.0582109664990062e-15, 1.4228268018531658e-14, 1.0 ] ], "name": "tag_head", "offset": 164, "origin": [ -1.5079593129740942e-09, -9.933220912472507e-11, 3.2111285008795676e-07 ] } ], "frames": 1, "name": "models/players/athena/head_3.md33md3", "offsets": { "end": 3092, "frames": 108, "surfaces": 276, "tags": 164 }, "path": "assets/extracted/zUrT43_005.pk3/members/000698/models/players/athena/head_3.md3", "sha256": "5c486f223ef44dcfd913a45d8385ae68fef4e3c3cb599c6eabb3ba1153630458", "surfaces": [ { "end": 2816, "flags": 0, "frames": 1, "name": "h_head", "offset": 276, "shaders": 1, "shaders_offset": 108, "triangles": 44, "triangles_offset": 176, "uv_offset": 704, "vertices": 132, "vertices_offset": 1760 } ], "tags": 1 }, { "bytes": 2420, "first_frame": { "maxs": [ 7.012399196624756, 4.579596519470215, 9.718878746032715 ], "mins": [ -5.060676097869873, -4.731232166290283, 1.2850357294082642 ], "name": "(from 3DSMax)", "origin": [ 0.0, 0.0, 0.0 ], "radius": 12.884676933288574 }, "first_tags": [ { "axis": [ [ 1.0, 0.0, 0.0 ], [ 0.0, 1.0, 0.0 ], [ 0.0, 0.0, 1.0 ] ], "name": "tag_head", "offset": 164, "origin": [ -1.9990831212624016e-10, -7.291174608514694e-11, 0.0 ] } ], "frames": 1, "name": "models/players/athena/helmet_3.md3", "offsets": { "end": 2420, "frames": 108, "surfaces": 276, "tags": 164 }, "path": "assets/extracted/zUrT43_005.pk3/members/000754/models/players/athena/helmet_3.md3", "sha256": "80c5b490aecb8ab022290350d21529add230bb1b0677551f8eeaf42c4dcc0c1b", "surfaces": [ { "end": 2144, "flags": 0, "frames": 1, "name": "g_helmet", "offset": 276, "shaders": 1, "shaders_offset": 108, "triangles": 72, "triangles_offset": 176, "uv_offset": 1040, "vertices": 69, "vertices_offset": 1592 } ], "tags": 1 }, { "bytes": 1475608, "first_frame": { "maxs": [ 6.827688694000244, 7.543880462646484, 24.065277099609375 ], "mins": [ -6.157504558563232, -7.524542331695557, -23.248598098754883 ], "name": "(from 3DSMax)", "origin": [ 0.0, 0.0, 0.0 ], "radius": 26.127859115600586 }, "first_tags": [ { "axis": [ [ 1.0, 0.0, 0.0 ], [ 0.0, 1.0, 0.0 ], [ 0.0, 0.0, 1.0 ] ], "name": "tag_torso", "offset": 46924, "origin": [ 0.2727545201778412, 0.004881937988102436, 19.955394744873047 ] } ], "frames": 836, "name": "C:/Users/Windows/Desktop/new_HM/female/lower_3.md3", "offsets": { "end": 1475608, "frames": 108, "surfaces": 140556, "tags": 46924 }, "path": "assets/extracted/zUrT43_005.pk3/members/000800/models/players/athena/lower_3.md3", "sha256": "1728841be5608858885be41b22dee516294ce4f91ffe21fae51b8e0d4da82630", "surfaces": [ { "end": 161000, "flags": 0, "frames": 836, "name": "l_groin", "offset": 140556, "shaders": 0, "shaders_offset": 108, "triangles": 10, "triangles_offset": 176, "uv_offset": 296, "vertices": 24, "vertices_offset": 488 }, { "end": 274988, "flags": 0, "frames": 836, "name": "l_butt", "offset": 301556, "shaders": 0, "shaders_offset": 108, "triangles": 23, "triangles_offset": 176, "uv_offset": 452, "vertices": 41, "vertices_offset": 780 }, { "end": 120800, "flags": 0, "frames": 836, "name": "l_lleg", "offset": 576544, "shaders": 0, "shaders_offset": 108, "triangles": 8, "triangles_offset": 176, "uv_offset": 272, "vertices": 18, "vertices_offset": 416 }, { "end": 187832, "flags": 0, "frames": 836, "name": "l_lfoot", "offset": 697344, "shaders": 0, "shaders_offset": 108, "triangles": 14, "triangles_offset": 176, "uv_offset": 344, "vertices": 28, "vertices_offset": 568 }, { "end": 120800, "flags": 0, "frames": 836, "name": "l_rleg", "offset": 885176, "shaders": 0, "shaders_offset": 108, "triangles": 8, "triangles_offset": 176, "uv_offset": 272, "vertices": 18, "vertices_offset": 416 }, { "end": 187832, "flags": 0, "frames": 836, "name": "l_rfoot", "offset": 1005976, "shaders": 0, "shaders_offset": 108, "triangles": 14, "triangles_offset": 176, "uv_offset": 344, "vertices": 28, "vertices_offset": 568 }, { "end": 140900, "flags": 0, "frames": 836, "name": "l_rthigh", "offset": 1193808, "shaders": 1, "shaders_offset": 108, "triangles": 9, "triangles_offset": 176, "uv_offset": 284, "vertices": 21, "vertices_offset": 452 }, { "end": 140900, "flags": 0, "frames": 836, "name": "l_lthigh", "offset": 1334708, "shaders": 1, "shaders_offset": 108, "triangles": 9, "triangles_offset": 176, "uv_offset": 284, "vertices": 21, "vertices_offset": 452 } ], "tags": 1 }, { "bytes": 3233268, "first_frame": { "maxs": [ 6.256061553955078, 15.82502555847168, 21.967098236083984 ], "mins": [ -6.123725414276123, -15.853873252868652, -8.523422241210938 ], "name": "(from 3DSMax)", "origin": [ 0.0, 0.0, 0.0 ], "radius": 27.803543090820312 }, "first_tags": [ { "axis": [ [ 0.9999999403953552, 9.050260274534594e-08, 2.0926363220041821e-07 ], [ -9.049764315705033e-08, 0.9999998807907104, 2.4192985392801347e-07 ], [ -2.2672014665658935e-07, -2.4193300873776025e-07, 1.0000001192092896 ] ], "name": "tag_head", "offset": 54932, "origin": [ -1.435609221458435, -0.00030710449209436774, 20.255207061767578 ] }, { "axis": [ [ 1.0, 0.0, 0.0 ], [ 0.0, 1.0, 0.0 ], [ 0.0, 0.0, 1.0 ] ], "name": "tag_torso", "offset": 55044, "origin": [ -7.953614988842617e-10, 1.9953094732017007e-10, 0.0 ] } ], "frames": 979, "name": "models/players/athena/upper_3.md3.md3", "offsets": { "end": 3233268, "frames": 108, "surfaces": 274228, "tags": 54932 }, "path": "assets/extracted/zUrT43_006.pk3/members/000006/models/players/athena/upper_3.md3", "sha256": "aa0b90d2da99e9aff2ec9cc698773aecfd4f4406d1fa5d777c4d0f809c71b786", "surfaces": [ { "end": 518048, "flags": 0, "frames": 979, "name": "u_armr", "offset": 274228, "shaders": 1, "shaders_offset": 108, "triangles": 36, "triangles_offset": 176, "uv_offset": 608, "vertices": 66, "vertices_offset": 1136 }, { "end": 1922944, "flags": 0, "frames": 979, "name": "u_torso", "offset": 792276, "shaders": 1, "shaders_offset": 108, "triangles": 164, "triangles_offset": 176, "uv_offset": 2144, "vertices": 245, "vertices_offset": 4104 }, { "end": 518048, "flags": 0, "frames": 979, "name": "u_arml", "offset": 2715220, "shaders": 1, "shaders_offset": 108, "triangles": 36, "triangles_offset": 176, "uv_offset": 608, "vertices": 66, "vertices_offset": 1136 } ], "tags": 2 }, { "bytes": 2612, "first_frame": { "maxs": [ 7.199967384338379, 3.379535675048828, 10.142528533935547 ], "mins": [ -5.0725297927856445, -4.360363960266113, -1.6285820007324219 ], "name": "(from 3DSMax)", "origin": [ 0.0, 0.0, 0.0 ], "radius": 13.18040943145752 }, "first_tags": [ { "axis": [ [ 1.0, 0.0, 0.0 ], [ 0.0, 1.0, 0.0 ], [ 0.0, 0.0, 1.0 ] ], "name": "tag_head", "offset": 164, "origin": [ -1.9506065651597737e-09, -1.8283007330310852e-09, 0.0 ] } ], "frames": 1, "name": "models/players/orion/head_3.md3d3", "offsets": { "end": 2612, "frames": 108, "surfaces": 276, "tags": 164 }, "path": "assets/extracted/zUrT43_007.pk3/members/000042/models/players/orion/head_3.md3", "sha256": "74721f3f369ba5ecb827d292f4cc86e9039886ff479239dc4a66294833486630", "surfaces": [ { "end": 2336, "flags": 0, "frames": 1, "name": "h_head", "offset": 276, "shaders": 0, "shaders_offset": 108, "triangles": 36, "triangles_offset": 176, "uv_offset": 608, "vertices": 108, "vertices_offset": 1472 } ], "tags": 1 }, { "bytes": 2812, "first_frame": { "maxs": [ 8.65123462677002, 4.434142589569092, 10.694853782653809 ], "mins": [ -5.758604049682617, -5.336203575134277, 0.9205818176269531 ], "name": "(from 3DSMax)", "origin": [ 0.0, 0.0, 0.0 ], "radius": 14.754620552062988 }, "first_tags": [ { "axis": [ [ 1.0, -1.8522045634808144e-16, -4.176852447083674e-15 ], [ 1.412696240158401e-16, 1.0, 1.3331593434854098e-15 ], [ -2.3560037198212336e-15, -4.888040261960579e-16, 1.0000001192092896 ] ], "name": "tag_head", "offset": 164, "origin": [ -5.772439415352437e-09, 1.6540664393716042e-09, -3.114860476216563e-07 ] } ], "frames": 1, "name": "models/players/orion/helmet_3.md3md3", "offsets": { "end": 2812, "frames": 108, "surfaces": 276, "tags": 164 }, "path": "assets/extracted/zUrT43_007.pk3/members/000099/models/players/orion/helmet_3.md3", "sha256": "ce6fc8d410d5e4263a491314f33c660412e95c81cbe813e9f770e7b3eb0a9bf6", "surfaces": [ { "end": 2536, "flags": 0, "frames": 1, "name": "g_helmet", "offset": 276, "shaders": 0, "shaders_offset": 108, "triangles": 94, "triangles_offset": 176, "uv_offset": 1304, "vertices": 77, "vertices_offset": 1920 } ], "tags": 1 }, { "bytes": 1495708, "first_frame": { "maxs": [ 6.851175308227539, 7.528242111206055, 24.065204620361328 ], "mins": [ -6.161566734313965, -7.492788791656494, -23.25568389892578 ], "name": "(from 3DSMax)", "origin": [ 0.0, 0.0, 0.0 ], "radius": 26.129430770874023 }, "first_tags": [ { "axis": [ [ 1.0, -1.286586837068171e-07, 2.219511259227147e-07 ], [ 1.28524263232066e-07, 0.9999998807907104, -7.397434054201568e-11 ], [ -2.7253599910181947e-07, 1.4987239893571314e-08, 0.9999999403953552 ] ], "name": "tag_torso", "offset": 46924, "origin": [ 0.09215898811817169, 0.010374296456575394, 19.902698516845703 ] } ], "frames": 836, "name": "C:/Users/Windows/Desktop/new_HM/male/lower_3.MD3", "offsets": { "end": 1495708, "frames": 108, "surfaces": 140556, "tags": 46924 }, "path": "assets/extracted/zUrT43_007.pk3/members/000145/models/players/orion/lower_3.MD3", "sha256": "26936617763f8b307f221cf2162993e2bfa63a2804839d65445d74a7e2762e07", "surfaces": [ { "end": 181100, "flags": 0, "frames": 836, "name": "l_groin", "offset": 140556, "shaders": 0, "shaders_offset": 108, "triangles": 11, "triangles_offset": 176, "uv_offset": 308, "vertices": 27, "vertices_offset": 524 }, { "end": 274988, "flags": 0, "frames": 836, "name": "l_butt", "offset": 321656, "shaders": 0, "shaders_offset": 108, "triangles": 23, "triangles_offset": 176, "uv_offset": 452, "vertices": 41, "vertices_offset": 780 }, { "end": 120800, "flags": 0, "frames": 836, "name": "l_lleg", "offset": 596644, "shaders": 0, "shaders_offset": 108, "triangles": 8, "triangles_offset": 176, "uv_offset": 272, "vertices": 18, "vertices_offset": 416 }, { "end": 120800, "flags": 0, "frames": 836, "name": "l_rleg", "offset": 717444, "shaders": 0, "shaders_offset": 108, "triangles": 8, "triangles_offset": 176, "uv_offset": 272, "vertices": 18, "vertices_offset": 416 }, { "end": 187832, "flags": 0, "frames": 836, "name": "l_rfoot", "offset": 838244, "shaders": 0, "shaders_offset": 108, "triangles": 14, "triangles_offset": 176, "uv_offset": 344, "vertices": 28, "vertices_offset": 568 }, { "end": 187832, "flags": 0, "frames": 836, "name": "l_lfoot", "offset": 1026076, "shaders": 0, "shaders_offset": 108, "triangles": 14, "triangles_offset": 176, "uv_offset": 344, "vertices": 28, "vertices_offset": 568 }, { "end": 140900, "flags": 0, "frames": 836, "name": "l_lthigh", "offset": 1213908, "shaders": 0, "shaders_offset": 108, "triangles": 9, "triangles_offset": 176, "uv_offset": 284, "vertices": 21, "vertices_offset": 452 }, { "end": 140900, "flags": 0, "frames": 836, "name": "l_rthigh", "offset": 1354808, "shaders": 0, "shaders_offset": 108, "triangles": 9, "triangles_offset": 176, "uv_offset": 284, "vertices": 21, "vertices_offset": 452 } ], "tags": 1 }, { "bytes": 2771644, "first_frame": { "maxs": [ 6.6534271240234375, 15.166171073913574, 21.055191040039062 ], "mins": [ -7.807436943054199, -15.437268257141113, -12.154400825500488 ], "name": "(from 3DSMax)", "origin": [ 0.0, 0.0, 0.0 ], "radius": 27.250438690185547 }, "first_tags": [ { "axis": [ [ 1.0000001192092896, 1.8568309201327793e-07, -2.815226594066189e-07 ], [ -1.8585521388558846e-07, 1.0, 4.51199930751045e-08 ], [ 3.62100365691731e-07, -6.053197409983113e-08, 0.9999999403953552 ] ], "name": "tag_head", "offset": 54932, "origin": [ -1.4975870847702026, 0.03643219172954559, 19.20456314086914 ] }, { "axis": [ [ 1.0, 4.560243275933493e-15, -1.6186670873021697e-14 ], [ 6.317532556658102e-15, 1.0, 2.6171382467524506e-18 ], [ 5.658454526333637e-15, -1.5070995709073301e-15, 0.9999999403953552 ] ], "name": "tag_torso", "offset": 55044, "origin": [ 2.2859194537261374e-09, -4.86234906504901e-11, -2.045771907432936e-08 ] } ], "frames": 979, "name": "models/players/orion/upper_3.md3.md3", "offsets": { "end": 2771644, "frames": 108, "surfaces": 274228, "tags": 54932 }, "path": "assets/extracted/zUrT43_007.pk3/members/000241/models/players/orion/upper_3.md3", "sha256": "6cd8e57f38a4910bb61463f842bc36e5b55a3ded44729e46db74032e7baf4a30", "surfaces": [ { "end": 604840, "flags": 0, "frames": 979, "name": "u_armr", "offset": 274228, "shaders": 1, "shaders_offset": 108, "triangles": 82, "triangles_offset": 176, "uv_offset": 1160, "vertices": 77, "vertices_offset": 1776 }, { "end": 1107224, "flags": 0, "frames": 979, "name": "u_torso", "offset": 879068, "shaders": 1, "shaders_offset": 108, "triangles": 134, "triangles_offset": 176, "uv_offset": 1784, "vertices": 141, "vertices_offset": 2912 }, { "end": 785352, "flags": 0, "frames": 979, "name": "u_arml", "offset": 1986292, "shaders": 1, "shaders_offset": 108, "triangles": 98, "triangles_offset": 176, "uv_offset": 1352, "vertices": 100, "vertices_offset": 2152 } ], "tags": 2 } ]}123456789101112131415#!/usr/bin/env python3"""Parse original player LOD3 model layout against the recovered QVM offsets."""import hashlibfrom dataclasses import asdictfrom pathlib import Pathfrom md3 import MD3from analyze_qvm import write_json
def selected():return sorted(p for p in Path('assets/extracted').rglob('*') if p.is_file() and '/models/players/' in str(p) and p.parent.name in ['athena','orion'] and p.name.lower() in ['lower_3.md3','upper_3.md3','head_3.md3','helmet_3.md3'])def main(): rows=[] for p in selected(): raw=p.read_bytes();m=MD3(raw);rows.append({'path':str(p),'sha256':hashlib.sha256(raw).hexdigest(),'bytes':len(raw),'name':m.name,'frames':m.frames,'tags':m.tags,'surfaces':[asdict(s) for s in m.surfaces],'offsets':{'frames':m.frames_offset,'tags':m.tags_offset,'surfaces':m.surfaces_offset,'end':m.end},'first_frame':m.frame(0),'first_tags':[m.tag(0,j) for j in range(m.tags)]}) write_json(Path('docs/research/md3-contract.json'),{'models':rows,'limits':'Original bytes parsed only; version15/declared ranges/surface chain/frame counts/triangle indices checked. No renderer/full runtime. Coordinate scale and fields are cross-linked to recovered QVM offsets, not external format assumptions.'})if __name__=='__main__':main()12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061"""Bounds-checked little-endian MD3 reader; source offsets retained for QVM research."""import math,structfrom dataclasses import dataclass
def name(raw):return raw.split(b'\0',1)[0].decode('ascii','backslashreplace')def region(offset,count,stride,end,minimum=0): if min(offset,count,stride)<0 or (count and offset<minimum) or offset>end or count*stride>end-offset:raise ValueError('MD3 region outside declared bounds')
def finite(values): if not all(math.isfinite(v) for v in values):raise ValueError('nonfinite MD3 geometry') return values
@dataclass(frozen=True)class Surface: offset:int name:str flags:int frames:int shaders:int vertices:int triangles:int triangles_offset:int shaders_offset:int uv_offset:int vertices_offset:int end:int
class MD3: def __init__(self,data): self.data=bytes(data) if len(data)<108:raise ValueError('truncated MD3 header') magic,version,raw,*v=struct.unpack_from('<4si64s9i',data) if magic!=b'IDP3' or version!=15:raise ValueError('unsupported MD3 signature/version') self.name=name(raw);self.flags,self.frames,self.tags,self.surface_count,self.skins,self.frames_offset,self.tags_offset,self.surfaces_offset,self.end=v if min(v[1:])<0 or self.end!=len(data) or self.end<108:raise ValueError('invalid MD3 counts/end') region(self.frames_offset,self.frames,56,self.end,108);region(self.tags_offset,self.frames*self.tags,112,self.end,108);region(self.surfaces_offset,self.surface_count,108,self.end,108) self.surfaces=[];offset=self.surfaces_offset for _ in range(self.surface_count): region(offset,1,108,self.end,108);ident,raw,*s=struct.unpack_from('<4s64s10i',data,offset) if ident!=b'IDP3':raise ValueError('invalid MD3 surface signature') flags,frames,shaders,vertices,triangles,tri,shader,uv,xyz,end=s if min(s[1:])<0 or frames!=self.frames or end<108 or end>self.end-offset:raise ValueError('invalid MD3 surface counts/end') for start,count,stride in [(tri,triangles,12),(shader,shaders,68),(uv,vertices,8),(xyz,frames*vertices,8)]:region(start,count,stride,end,108) surface=Surface(offset,name(raw),flags,frames,shaders,vertices,triangles,tri,shader,uv,xyz,end);self.surfaces.append(surface) for j in range(triangles): if any(k<0 or k>=vertices for k in self.triangle(surface,j)):raise ValueError('MD3 triangle index outside vertex range') offset+=end if self.surface_count and offset!=self.end:raise ValueError('MD3 surface chain does not end at EOF')
def frame(self,index): region(index,1,1,self.frames);v=struct.unpack_from('<10f16s',self.data,self.frames_offset+56*index);finite(v[:10]);return {'mins':list(v[:3]),'maxs':list(v[3:6]),'origin':list(v[6:9]),'radius':v[9],'name':name(v[10])} def tag(self,frame,index): region(frame,1,1,self.frames);region(index,1,1,self.tags);p=self.tags_offset+(frame*self.tags+index)*112;v=struct.unpack_from('<64s12f',self.data,p);finite(v[1:]);return {'offset':p,'name':name(v[0]),'origin':list(v[1:4]),'axis':[list(v[4+3*j:7+3*j]) for j in range(3)]} def triangle(self,s,index): region(index,1,1,s.triangles);return list(struct.unpack_from('<3i',self.data,s.offset+s.triangles_offset+12*index)) def vertex(self,s,frame,index): region(frame,1,1,s.frames);region(index,1,1,s.vertices);p=s.offset+s.vertices_offset+(frame*s.vertices+index)*8;v=struct.unpack_from('<3hH',self.data,p);return {'offset':p,'packed':list(v[:3]),'position':[x/64 for x in v[:3]],'normal_word':v[3]} def uv(self,s,index): region(index,1,1,s.vertices);return list(finite(struct.unpack_from('<2f',self.data,s.offset+s.uv_offset+8*index))) def shader(self,s,index): region(index,1,1,s.shaders);raw,value=struct.unpack_from('<64si',self.data,s.offset+s.shaders_offset+68*index);return {'name':name(raw),'index':value}1234567891011121314151617181920212223242526272829import json,struct,unittestfrom pathlib import Pathfrom md3 import MD3
def minimal(): end=512;d=bytearray(end);struct.pack_into('<4si64s9i',d,0,b'IDP3',15,b'test',0,1,1,1,0,108,164,276,end);struct.pack_into('<10f16s',d,108,-1,-1,-1,1,1,1,0,0,0,2,b'frame');struct.pack_into('<64s12f',d,164,b'tag_head',1,2,3,1,0,0,0,1,0,0,0,1);struct.pack_into('<4s64s10i',d,276,b'IDP3',b'h_head',0,1,1,3,1,108,120,188,212,236);struct.pack_into('<3i',d,384,0,1,2);struct.pack_into('<64si',d,396,b'texture',7) for j in range(3):struct.pack_into('<2f',d,464+8*j,j*.25,j*.5);struct.pack_into('<3hH',d,488+8*j,64*j,-64*j,32,0x1234) return dclass MD3ContractTests(unittest.TestCase): def test_original_available_player_models(self): r=json.loads(Path('docs/research/md3-contract.json').read_text());self.assertEqual(len(r['models']),8) for row in r['models']: m=MD3(Path(row['path']).read_bytes());self.assertEqual(m.frames,row['frames']);self.assertEqual(m.end,row['bytes']);self.assertEqual(len(m.surfaces),len(row['surfaces'])) def test_independent_minimal_coordinates_indices_uv_and_metadata(self): m=MD3(minimal());s=m.surfaces[0];self.assertEqual(m.triangle(s,0),[0,1,2]);self.assertEqual(m.vertex(s,0,2),{'offset':504,'packed':[128,-128,32],'position':[2,-2,.5],'normal_word':0x1234});self.assertEqual(m.uv(s,2),[.5,1]);self.assertEqual(m.shader(s,0),{'name':'texture','index':7});self.assertEqual(m.tag(0,0)['origin'],[1,2,3]) def test_truncation_signature_and_declared_ends_rejected(self): for d in [minimal()[:100],minimal()[:-1],b'XXXX'+bytes(minimal()[4:])]: with self.assertRaises(ValueError):MD3(d) def test_out_of_bounds_regions_counts_and_triangle_indices_rejected(self): for offset,value in [(80,-1),(100,510),(276+80,1),(384,3),(276+100,10000)]: d=minimal();struct.pack_into('<i',d,offset,value) with self.assertRaises(ValueError):MD3(d) def test_accessors_reject_negative_and_upper_bounds(self): m=MD3(minimal());s=m.surfaces[0] for index in [-1,1]: with self.assertRaises(ValueError):m.frame(index) with self.assertRaises(ValueError):m.tag(0,index) with self.assertRaises(ValueError):m.vertex(s,0,3)if __name__=='__main__':unittest.main()docs/ASSET_PIPELINE_TODO.md+3
docs/FINDINGS.md+3
docs/PROVISIONAL_TODO.md+3
docs/RESEARCH_LEDGER.md+5
docs/REVERSE_ENGINEERING_TODO.md+3
docs/research/MD3_CONTRACT.mdAdded+7
docs/research/README.md+3
docs/research/md3-contract.jsonAdded+925
scripts/analyze_md3_contract.pyAdded+15
scripts/md3.pyAdded+61
scripts/test_md3_contract.pyAdded+29