X-Hax / sa_tools

Sonic Adventure Toolset
http://info.sonicretro.org/SA_Tools
100 stars 24 forks source link

Add decoding and export of GRND blocks in mld files #263

Closed jahorta closed 1 week ago

jahorta commented 1 week ago

I saw that models can now be exported from mld files, but that GRND blocks were not extracted. So I found out that GRND blocks are encoded as a grid-based collision system on compressed meshes. I used the grid to determine and extract the vertices and meshes and put them into a BasicAttach. I also slightly modified ModelFile in SATool: I added a method called ToBytes which performs almost all of the work of SaveToFile but returns the byte array itself. SaveToFile now calls this to get the byte array and then performs the save to file. This way I was able to add the ModelFile bytes for the GRND block to the Entries in the MLDArchive so that it would work with the ArchiveTool.

PiKeyAr commented 1 week ago

Since this doesn't affect main functionality of the tools, I think this can be merged, pls see the comments above though.

Also it would probably make more sense to export to NJ files rather than .sa2mdl but I don't mind either way.

PiKeyAr commented 1 week ago

gitignore file still has that line, I'll remove it manually. Thanks for your work!