Jump to content

Decompiling Rotwood game assets


Recommended Posts

Hi everyone! This is my first time writing on here.

I have recently taken interest in modding Rotwood for the fun of it, even though there is no official mod support yet, and I decided to try extracting game assets (textures and anims) to have a closer look and perhaps adding in custom assets. I came here to share my findings along as hoping to find some help and guidance to decompile the anim.bin files.

Rotwood .tex files can be decompiled using instant-noodles' Griftlands file converter tools (GitHub: https://github.com/instant-noodles/gltools). If the .tex format is truly the same as Griftlands then the data includes the header (the KTEX magic string and another mysterious 5 bytes sequence which I assume is like a serial number that cant be changed) and the image data (the rest of the file).

As for animation files, I could only get them to be partially read by simplex's ktools (original repo: https://github.com/nsimplex/ktools)

*fork used is dstmodders/ktools because it's more recent and being the only one I could build on linux with up to date dependencies: https://github.com/dstmodders/ktools

Simply using krane on Rotwood animation files will not work, though. Here's the workaround I found:

1. Use gltools tex to png converter to convert the atlas texture to png.

2. Use ktools ktech to convert said .png file into a ds compatible .tex.

3. Finally, use krane to decompile build.bin, anim.bin and atlas-0.tex to scml.

 

Unfortunately krane didn't succeed and I expected that, however I was able to gather some info about it:

 > krane -vvv . .
Loading build from `./build.bin'...
Loading atlas from `./atlas-0.tex'...
Loading anims from `./anim.bin'...
Animation file has unsupported encoding version 5.
WARNING: Animation has unsupported encoding version. Skipping animation file.
ERROR: No animation found in the input files.

So it can read build.bin just fine, but anim.bin has encoding version 5 as opposed to version 4 in dst.

Running krane again with the verbose level 3 (i think?) gave more information:

 > krane -vvv . .
Loading build from `./build.bin'...
Loading build information...
Got build version 6.
Reading build name...
        Got build name: npc_hunter
Reading atlas names...
        Got atlas name: atlas-0.tex
Reading animation symbols...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
                Reading symbol frame at position #3...
                Reading symbol frame at position #4...
                Reading symbol frame at position #5...
                Reading symbol frame at position #6...
                Reading symbol frame at position #7...
                Reading symbol frame at position #8...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
                Reading symbol frame at position #3...
                Reading symbol frame at position #4...
                Reading symbol frame at position #5...
                Reading symbol frame at position #6...
                Reading symbol frame at position #7...
                Reading symbol frame at position #8...
                Reading symbol frame at position #9...
                Reading symbol frame at position #10...
                Reading symbol frame at position #11...
                Reading symbol frame at position #12...
                Reading symbol frame at position #13...
                Reading symbol frame at position #14...
                Reading symbol frame at position #15...
        Reading symbol frames...
                Reading symbol frame at position #1...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
                Reading symbol frame at position #3...
                Reading symbol frame at position #4...
                Reading symbol frame at position #5...
                Reading symbol frame at position #6...
                Reading symbol frame at position #7...
                Reading symbol frame at position #8...
                Reading symbol frame at position #9...
                Reading symbol frame at position #10...
                Reading symbol frame at position #11...
                Reading symbol frame at position #12...
                Reading symbol frame at position #13...
                Reading symbol frame at position #14...
                Reading symbol frame at position #15...
                Reading symbol frame at position #16...
                Reading symbol frame at position #17...
                Reading symbol frame at position #18...
                Reading symbol frame at position #19...
                Reading symbol frame at position #20...
                Reading symbol frame at position #21...
                Reading symbol frame at position #22...
                Reading symbol frame at position #23...
                Reading symbol frame at position #24...
                Reading symbol frame at position #25...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
                Reading symbol frame at position #3...
                Reading symbol frame at position #4...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
                Reading symbol frame at position #3...
                Reading symbol frame at position #4...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
                Reading symbol frame at position #3...
                Reading symbol frame at position #4...
                Reading symbol frame at position #5...
                Reading symbol frame at position #6...
                Reading symbol frame at position #7...
                Reading symbol frame at position #8...
                Reading symbol frame at position #9...
                Reading symbol frame at position #10...
                Reading symbol frame at position #11...
                Reading symbol frame at position #12...
                Reading symbol frame at position #13...
                Reading symbol frame at position #14...
                Reading symbol frame at position #15...
                Reading symbol frame at position #16...
                Reading symbol frame at position #17...
                Reading symbol frame at position #18...
                Reading symbol frame at position #19...
                Reading symbol frame at position #20...
                Reading symbol frame at position #21...
                Reading symbol frame at position #22...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
                Reading symbol frame at position #3...
        Reading symbol frames...
                Reading symbol frame at position #1...
        Reading symbol frames...
                Reading symbol frame at position #1...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
                Reading symbol frame at position #3...
                Reading symbol frame at position #4...
                Reading symbol frame at position #5...
                Reading symbol frame at position #6...
                Reading symbol frame at position #7...
                Reading symbol frame at position #8...
                Reading symbol frame at position #9...
                Reading symbol frame at position #10...
                Reading symbol frame at position #11...
                Reading symbol frame at position #12...
                Reading symbol frame at position #13...
                Reading symbol frame at position #14...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
                Reading symbol frame at position #3...
                Reading symbol frame at position #4...
                Reading symbol frame at position #5...
                Reading symbol frame at position #6...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
                Reading symbol frame at position #3...
                Reading symbol frame at position #4...
        Reading symbol frames...
                Reading symbol frame at position #1...
        Reading symbol frames...
                Reading symbol frame at position #1...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
                Reading symbol frame at position #3...
                Reading symbol frame at position #4...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
                Reading symbol frame at position #3...
        Reading symbol frames...
                Reading symbol frame at position #1...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
                Reading symbol frame at position #3...
                Reading symbol frame at position #4...
        Reading symbol frames...
                Reading symbol frame at position #1...
                Reading symbol frame at position #2...
Post-processing animation symbols...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #3...
                Post-processing symbol frame at position #4...
                Post-processing symbol frame at position #5...
                Post-processing symbol frame at position #6...
                Post-processing symbol frame at position #7...
                Post-processing symbol frame at position #8...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #3...
                Post-processing symbol frame at position #4...
                Post-processing symbol frame at position #5...
                Post-processing symbol frame at position #6...
                Post-processing symbol frame at position #7...
                Post-processing symbol frame at position #8...
                Post-processing symbol frame at position #9...
                Post-processing symbol frame at position #10...
                Post-processing symbol frame at position #11...
                Post-processing symbol frame at position #12...
                Post-processing symbol frame at position #13...
                Post-processing symbol frame at position #14...
                Post-processing symbol frame at position #15...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #3...
                Post-processing symbol frame at position #4...
                Post-processing symbol frame at position #5...
                Post-processing symbol frame at position #6...
                Post-processing symbol frame at position #7...
                Post-processing symbol frame at position #8...
                Post-processing symbol frame at position #9...
                Post-processing symbol frame at position #10...
                Post-processing symbol frame at position #11...
                Post-processing symbol frame at position #12...
                Post-processing symbol frame at position #13...
                Post-processing symbol frame at position #14...
                Post-processing symbol frame at position #15...
                Post-processing symbol frame at position #16...
                Post-processing symbol frame at position #17...
                Post-processing symbol frame at position #18...
                Post-processing symbol frame at position #19...
                Post-processing symbol frame at position #20...
                Post-processing symbol frame at position #21...
                Post-processing symbol frame at position #22...
                Post-processing symbol frame at position #23...
                Post-processing symbol frame at position #24...
                Post-processing symbol frame at position #25...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #3...
                Post-processing symbol frame at position #4...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #3...
                Post-processing symbol frame at position #4...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #3...
                Post-processing symbol frame at position #4...
                Post-processing symbol frame at position #5...
                Post-processing symbol frame at position #6...
                Post-processing symbol frame at position #7...
                Post-processing symbol frame at position #8...
                Post-processing symbol frame at position #9...
                Post-processing symbol frame at position #10...
                Post-processing symbol frame at position #11...
                Post-processing symbol frame at position #12...
                Post-processing symbol frame at position #13...
                Post-processing symbol frame at position #14...
                Post-processing symbol frame at position #15...
                Post-processing symbol frame at position #16...
                Post-processing symbol frame at position #17...
                Post-processing symbol frame at position #18...
                Post-processing symbol frame at position #19...
                Post-processing symbol frame at position #20...
                Post-processing symbol frame at position #21...
                Post-processing symbol frame at position #22...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #3...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #3...
                Post-processing symbol frame at position #4...
                Post-processing symbol frame at position #5...
                Post-processing symbol frame at position #6...
                Post-processing symbol frame at position #7...
                Post-processing symbol frame at position #8...
                Post-processing symbol frame at position #9...
                Post-processing symbol frame at position #10...
                Post-processing symbol frame at position #11...
                Post-processing symbol frame at position #12...
                Post-processing symbol frame at position #13...
                Post-processing symbol frame at position #14...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #3...
                Post-processing symbol frame at position #4...
                Post-processing symbol frame at position #5...
                Post-processing symbol frame at position #6...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #3...
                Post-processing symbol frame at position #4...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #3...
                Post-processing symbol frame at position #4...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #3...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
                Post-processing symbol frame at position #3...
                Post-processing symbol frame at position #4...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
Loading build hash table...
        Got 0x58666640 => "eye_untex"
        Got 0x18e203c0 => "head"
        Got 0x16f1c7c2 => "hair"
        Got 0x1ddfa303 => "horn"
        Got 0x7fe92dc1 => "scarf_back"
        Got 0x522a2927 => "mouth"
        Got 0xce597769 => "eyebrow"
        Got 0x2c259373 => "torso"
        Got 0x29ae65b3 => "skirt"
        Got 0xc0cf00ce => "foot"
        Got 0x16f6c8ef => "hand"
        Got 0x1c529f30 => "cloak"
        Got 0x6823f5d1 => "leg_upper"
        Got 0x94f328d2 => "satchel"
        Got 0x350987b3 => "nose"
        Got 0x321d3636 => "ear"
        Got 0xe1c90137 => "eyepatch"
        Got 0xd9c03a90 => "leg_lower"
        Got 0x339f66af => "hip"
        Got 0x3035fc5c => "arm"
        Got 0xd4b4566f => "scarf_front"
Loading atlas from `./atlas-0.tex'...
Loading anims from `./anim.bin'...
Loading anim file information...
Got anim version 5.
Animation file has unsupported encoding version 5.
WARNING: Animation has unsupported encoding version. Skipping animation file.
ERROR: No animation found in the input files.

If I alter the source code and skip the version check, it goes a bit further:

> krane -vvv . .
...
...
...
                Post-processing symbol frame at position #4...
                Post-processing symbol frame at position #1...
                Post-processing symbol frame at position #2...
Loading build hash table...
        Got 0x58666640 => "eye_untex"
        Got 0x18e203c0 => "head"
        Got 0x16f1c7c2 => "hair"
        Got 0x1ddfa303 => "horn"
        Got 0x7fe92dc1 => "scarf_back"
        Got 0x522a2927 => "mouth"
        Got 0xce597769 => "eyebrow"
        Got 0x2c259373 => "torso"
        Got 0x29ae65b3 => "skirt"
        Got 0xc0cf00ce => "foot"
        Got 0x16f6c8ef => "hand"
        Got 0x1c529f30 => "cloak"
        Got 0x6823f5d1 => "leg_upper"
        Got 0x94f328d2 => "satchel"
        Got 0x350987b3 => "nose"
        Got 0x321d3636 => "ear"
        Got 0xe1c90137 => "eyepatch"
        Got 0xd9c03a90 => "leg_lower"
        Got 0x339f66af => "hip"
        Got 0x3035fc5c => "arm"
        Got 0xd4b4566f => "scarf_front"
Loading atlas from `./atlas-0.tex'...
Loading anims from `./anim.bin'...
Loading anim file information...
Got anim version 5.
Loading 32 animations...
Got animation name: idle
Loading animation frames...
        Loading animation frame 1...
                Loading events...
                Loading elements...
        Loading animation frame 2...
                Loading events...
WARNING: failed to read data from stream. It might be corrupt. Skipping animation file.
ERROR: No animation found in the input files.

There's a chance that this might be because of the .tex file that i converted, but really I have no idea.

I tried putting in debug cout lines to inspect some variables like framerate and coordinates but it did no help.

I also tried comparing various dst and Rotwood .bin files in a hex editor but I couldn't find any useful patterns either :/

 

So I am asking on Klei forums if anyone can point me to the right direction, I would really really appreciate any help!

Thank you so much to instant-noodles and simplex for the amazing tools that helped me get this far, I also learned so much reading the two projects' source code.

On 3/12/2024 at 9:13 AM, gibberish said:

So I am asking on Klei forums if anyone can point me to the right direction, I would really really appreciate any help!

Spoiler
#ANIM format 5 (Rotwood)
# 'ANIM'
# Version (int)
# total num element refs (int)
# total num frames (int)
# total num events (int)
# Numanims (int)
#   animname (int, string)
#   validfacings (byte bit mask) (xxxx dlur)
#   rootsymbolhash int
#   frame rate (float)
#   num frames (int)
#       x, y, w, h : (all floats)
#       num events(int)
#           event hash
#       num elements(int)
#           symbol hash (int)
#           symbol frame (int)
#           folder hash (int)
#           flag (int)
#           ? (float) Who knows what these three floats are!
#           ? (float)
#           ? (float)
#           color a, b, g, r: (all floats)
#           mat a, b, c, d, tx, ty, tz: (all floats)
#
# num hashed strings (int)
#   hash (int)
#   original string (int, string)

The Rotwood KAnim binary format is very similar to DS/T's with the addition of a few more pieces of data. you can read the extra pieces of data in your ktools fork.

Happy modding!

51 minutes ago, Hornete said:
  Hide contents
#ANIM format 5 (Rotwood)
# 'ANIM'
# Version (int)
# total num element refs (int)
# total num frames (int)
# total num events (int)
# Numanims (int)
#   animname (int, string)
#   validfacings (byte bit mask) (xxxx dlur)
#   rootsymbolhash int
#   frame rate (float)
#   num frames (int)
#       x, y, w, h : (all floats)
#       num events(int)
#           event hash
#       num elements(int)
#           symbol hash (int)
#           symbol frame (int)
#           folder hash (int)
#           flag (int)
#           ? (float) Who knows what these three floats are!
#           ? (float)
#           ? (float)
#           color a, b, g, r: (all floats)
#           mat a, b, c, d, tx, ty, tz: (all floats)
#
# num hashed strings (int)
#   hash (int)
#   original string (int, string)

The Rotwood KAnim binary format is very similar to DS/T's with the addition of a few more pieces of data. you can read the extra pieces of data in your ktools fork.

Happy modding!

Thank you so so so much! This is a huge discovery for me, knowing that data structure will definitely help out a ton, I'll see what I can do with it, you're awesome.

On 4/14/2024 at 11:01 AM, GodIess said:

unpackAtlas.bat 29 B · 27 downloads gla2p.py 1.71 kB · 26 downloads

Create atlas png files. Use with gltools.

Just put these files in a folder with other gltools files and run by dragging the .tex files to the .bat, the .xml file should also be next to the .tex

image.png.99b332b21c21e977476011928848ab0e.png

Hi! Thank you again for the great tool, I had some issues with file not found path errors when converting tex files that are not in the same directory as the scripts, so I made some changes to the gla2p script to fix that, I think it's because of working directory mismatch when calling glt2p via the os shell, so I just imported gltex and called its main() directly. Also I changed the output folder's name to use the input file base name so you don't have to deal with the output folder after every convert when you're extracting multiple files, pretty convenient for automation too.

Below is the updated gla2p.py

gla2p.py

It would be nice if there was a repository for this (I couldn't find one so I posted it here)

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...