Skip to content

Commit

Permalink
Extraction: Mdl data parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
thearchivalone committed Nov 11, 2024
1 parent 29d23c5 commit 3fbc666
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
85 changes: 85 additions & 0 deletions Scripts/BRS-Model-Data.bms
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
idstring "INSM"

# Start getting some known variables
set EMBED_START 0x34 # to get embedded section if it exists
set DATA_START 0x28
set VERTEX_OFFSET 0x2c
set CHUNK 0x04
get SIZE asize
set ARBITRARY_NUMBER 10000000000
set VERTEX_STRIDE 0x1c # Distance between Vertex Buffers

# Recursively replace known locations with their values since those are address locations in the ROM
goto EMBED_START
get EMBED_START long

goto DATA_START
get DATA_START long

goto VERTEX_OFFSET
get VERTEX_OFFSET long

# Do some math to get where the first data section ends so we can access the rest of the Vertex Data in the next section
set VERTEX_START VERTEX_OFFSET
math VERTEX_START + DATA_START

# Get the total size of the VERTEX_DATA section
set VERTEX_DATA_SIZE EMBED_START
math VERTEX_DATA_SIZE - DATA_START

set TRIS VERTEX_DATA_SIZE
math TRIS / VERTEX_STRIDE

# Get the amount of lines to part before moving to next triangle
set LINES VERTEX_STRIDE
math LINES / CHUNK

# Start the parsing here
goto DATA_START
savepos CUR_POS

# Create a Vertex Array to house the data
set SHIFT VERTEX_OFFSET
set START_POS CUR_POS
math SHIFT + START_POS

for i = TRIS > 0
if CUR_POS > EMBED_START | CUR_POS == EMBED_START | START_POS > VERTEX_OFFSET | START_POS == VERTEX_OFFSET
break
endif
print "TRI: %i%"
goto CUR_POS
for k = 0 < 4
get WHAT long
string T = WHAT
string T b T
if T != "00000010"
#print "CURRENT_OFFSET: %CUR_POS% ==== WHAT: %T%"
print "WHAT: %T%"
else
savepos START_POS # So that we can come back to the chunk right after
goto SHIFT
set CUR_POS SHIFT
# Reset SHIFT so it doesn't stack the offsets
set SHIFT VERTEX_OFFSET
math SHIFT + START_POS
endif
set TMP CUR_POS
math TMP + CHUNK
set CUR_POS TMP
next k
for k = 0 < 4
get VERTEX float
if VERTEX > -257 & VERTEX < 257
#print "CURRENT_OFFSET: %CUR_POS% ==== VERTEX: %VERTEX%"
print "VERTEX: %VERTEX%"
else
math k - 1
math VERTEX_OFFSET - CHUNK
endif
set TMP CUR_POS
math TMP + CHUNK
set CUR_POS TMP
next k
set CUR_POS START_POS
next i - 1
4 changes: 4 additions & 0 deletions Specifications/File Formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,12 @@ This documentation is mostly here to help structure, describe and name the vario
* Extension: .mdl (if PTMD or alternative structures are found within)
* Header: INSM
* Purpose: Stores model data
* Notes:
* Vertex Stride: 0x0c (first section); 0x14 (second section)
* Structure:
* 0x34 - Offset of PTMD or alternative structures from Header
* 0x28 - Start position of First Data section
* 0x2c - Offset from 0x28 to get to the Second Data Section

===================================================================
* Tentative Name: Internal Node Structure Animation
Expand Down

0 comments on commit 3fbc666

Please sign in to comment.