Skip to content

Resource Converter

Dzmitry Malyshau edited this page Apr 4, 2023 · 4 revisions

convert binary is a command line utility for converting the game data into formats that are more interoperable.

Basically you provide 2 arguments as fully-qualified file names (can be relative, but relative to the current directory - the settings paths are not used here), and the converter figures out the way to convert one into another. Note that only part after "--" makes sense when running a standalone binary.

Note: the destination path is always to a file that gets created or overwritten!

Model (M3D) <-> OBJ+RON

cargo run --bin convert -- game/resource/m3d/items/i21.m3d my_dir/model.ron

The body, wheels, and debris are saved as separate Wavefront OBJ files near the target RON, which contains model meta-data.

You can change the OBJ files using popular mesh editors, save them, and even manually tweak RON, after which you may want to generate a new M3D file:

cargo run --bin convert -- my_dir/model.ron game/resource/m3d/items/i21-new.m3d

model import

Animated model (A3D) <-> OBJ+RON

cargo run --bin convert -- game/resource/m3d/animated/a1.a3d my_dir/animodel.ron

Each mesh in the animated series is saved separately.

cargo run --bin convert -- my_dir/animodel.ron game/resource/m3d/animated/a1-new.a3d

Level (INI+VMC/VMP) <-> PNG+RON

cargo run --bin convert -- game/thechain/fostral/world.ini my_dir/fostral.ron

The RON file contains the size and names of two images: heights and materials. The former conains the following data:

  • R stands for the bottom layer height
  • G stands for the top layer height
  • B stands for the delta between the bottom and the ground above

The materials image only uses two channels:

  • R contains the index of the bottom layer material in its higher 4 bits. The lower 4 bits are ignored.
  • G contains the index of the top layer

You can change the images in a photo editor, and then we can import it as a non-compressed level:

cargo run --bin convert -- my_dir/fostral.ron game/thechain/fostral/output.vmp

model level

Note: one can easily turn a non-compressed level file (VMP) into a pseudo-compressed one (VMC) by prepending the unzipped etc/vmc-header.zip file.

Level (INI+VMC/VMP) <-> OBJ

cargo run --release --bin convert -- /x/games/Vangers\ RU/game/thechain/fostral/world.ini tmp/fostral.obj

(this may take a while, release is strongly preferred)

PAL <-> PNG

Palette files are really simple one-dimensional arrays of 256 colors. They ca be converted to PNG with the following command:

cargo run --bin convert -- game/thechain/fostral/harmony.pal my_dir/harmony.png

The image can be edited and then converted back to a palette:

cargo run --bin convert -- my_dir/harmony.png my_dir/harmony-new.pal