Blender Add-Ons and dealing with Bugs and Changes

A few months ago, I started developing a Blender add-on for Re-Volt. The one that was commonly used was only available for Blender 2.73 and its source was closed.

Having worked with Blender’s game engine and Blender in general for the last five years, I found it relatively easy to develop an add-on that imports and exports binary file formats. Providing GUI tools for properties exclusive to these formats has also been relatively easy.

So far, the add-on has solid support for most Re-Volt formats. At least the ones that store meshes. In the future, I would like to add support for the remaining level files that include other data like AI information, lights and other objects.

The biggest problem I encountered was a bug that prevented the UV Unwrap Reset operator from working: Using custom layers on a bmesh caused Blender to produce weird UV maps.
It took me some time to actually figure out what’s causing it. All I knew was that my add-on broke the most basic unwrapping function, making it pretty much useless for any modder. The bug has since been fixed but it didn’t reach the release version of Blender. I submitted the report a few days after 2.79 came out.

For now I referred users to the nightly version from which worked fine for the time being. When I recently grabbed another fresh build off the site, I noticed that my vertex paint operators didn’t work anymore: Color layers now also expose the Alpha channel. It previously had RGB only. It’s a simple fix as I won’t be using the new alpha channel anyway.

This, however, introduces a new problem: This change makes the add-on incompatible with the current version of 2.79. That means I’ll be stuck on the dev branch until the bug I reported and the updated vertex color layers reach the stable release of Blender.

Right now I’m pretty much stuck. There is no version of Blender that the add-on works with, except for older nightly builds.
This means that I’ll release a new version of the add-on soon. It will only work with a fresh nightly build due to the new alpha value on the vertex color channels.


StuntGP – An Attempt to read the File Structure #1


StuntGP has been a game of my childhood. My mother obtained it for whatever reason. I’ve never seen the game in shelves, though. Still, I definitely knew this game way before Re-Volt.

The game runs well on modern versions of Windows as well as Wine on Linux. Don’t be fooled by the Arcade mode, your unlocked cars and tracks are in the Exhibition mode.
My main motivation is to understand the game’s structure and convert tracks and cars to Re-Volt. Until now, I’ve seen little to no attempts to mod StuntGP or rip 3D models from the game.

This is what you’ll find in the game folder:
Screenshot from 2017-04-28 08-00-59.png

You have one folder for textures (graphics24, 24 for the bit depth) which all are .pc files, meshdata with the 3D models of the game (all .pmd files), save for your saved games, wads includes compressed game data (and the rest of the textures and sounds) as well as some plain-text parameter files with metadata for cars, tracks and other things.

Diving into the game files may give you some hope at first. Mesh data and some of the textures are exposed. The rest is packed in .wad files. Within those .wad files, we’ll find the rest of the internal structure of the game. I suspected this due to the paths linked in the game meshes. Those point to the graphics24 folder but the graphics aren’t there.

[yethiel@NX-01 wads]$ pakmount car01.wad ./mnt
not a KenSilverman GRP file
not a pack file
not a wad file
not a wad2 file
not a LGP file
malformed Dune 2 PAK file
format of file 'car01.wad' cannot be recognized

But it’s not what you think! TotalCommander and Game Archive UnPacker PRO to the rescue. I managed to unpack all .wad files at once with it. To install the addon, start up TotalCommander, go to Configuration, Options…
Then select Packer from the sidebar and click on the Configure packer extensions WCXs button. In the top right corner, type .wad and then click on the New type… button. Point it to the extension wcx file you downloaded. Then you’ll be able to open the files with TotalCommander. Select all and click the unpack button.

Screenshot from 2017-04-28 07-52-53

Now let’s restore the game’s internal file structure.

mkdir game
cp -R */* game/

And there you have it:

Screenshot from 2017-04-28 07-58-04.png

The tree.txt is something I made for you to take a look at. It lists all the files and folders:

Let’s go through those folders really quick: config contains the plain text files.

In the config folder, you get four subfolders called cams, levels, overlay and vehicles, as well as some csv and cfg files.
The files in this folder are the game’s strings, score amounts that you get for stunts,  and some level script files (commented as Pete’s SGP Game-Level Scripting File for Level Editing). Those level script files hold information about skyboxes, AI difficulty per track, track background, music, amount of laps, etc.
The cams folder has camera nodes for replays, similar to Re-Volt’s.
The levels folder contains .cfg files that hold information about each track’s fog settings, as  well as a LevelBoxList, perhaps something like Re-Volt’s track zones.
The overlay folder has a file for the demo GUI elements, all values and texture naems exposed.
The vehicles folder has files that are very similar to Re-Volt’s parameter.txt. They contain envelopes for car behavior (acceleration, etc.), weight, offsets and more.

In the graphics24 folder, you’ll find tons of .pc files. I took a look at them in a hex editor and they seem be be some sort of uncompressed bitmaps. Hopefully easy enough to sort out.

The replays folder has replays for some of the tracks, most likely recorded races for the demo mode.

The setup folder contains some .csv files about the game mode setups. That includes track order, AI setup, car tuning info, music tracks per menu and some more.

Lastly, sound/sfx/ has all the sounds in .wav format. Yay!

What’s next? I’ll take a look at the meshes first. Ripping from the game with programs like NinjaRipper didn’t work for me as all of them weren’t able to grab depth information. All I know about the mesh format right now is that all files have a header that reads PMD V.1.83. The textures are also linked as full paths a la cars\misc\tyre1. I can see some information about vertex colors, possibly. That’s it for now, though. After that, I’ll try to read the .pc texture format. If that doesn’t work out (but it should), I can still rip it with ripping programs from the running game.

Doable? Probably. I’m not that experienced with binary formats but I’m sure I can figure something out to at least import some bare models into Blender.