Captain JonnyP's Log, Star Date

Building the Station, Part One: The Maya Kit!

Last time I said I'd get into the Maya tile kit and texture generator for the station, and it turned into another long one, so it's in two parts. This one is the Maya side, tileGen.py, and part two is the textures. Up until the end of June the floors and walls in Ack Ack Attack! were Synty placeholders, modelled at around 500 units and scaled down by 0.064 to fit a 32 unit cell. In the middle of June Claude wrote up a brief of what it wanted from me for new ones (geoSetup.md in the project): a 32 unit cell modelled at 1 unit = 10 cm and imported at 0.1 to drop "that awkward 0.064 magic number", centred pivots, "Use OBJ, not FBX", and "Pick your wall thickness (suggest 60 cm / 6 units) and tell me". It even signs off with "Hand them over", which is a pretty bossy way to end a brief to the guy doing the art!

The first version of tileGen.py went into Perforce on the evening of June 26th as "-Maya door, wall and floor tile generator", 988 lines of Maya Python with a five page user guide. You load it from the Script Editor (import tileGen, then tileGen.show()), pick a piece and a preset, build it, and export from a tick list as OBJ, glTF or FBX. That first one did floors, walls with an optional curved top, a door with the opening cut out by a boolean, a sliding door, and a corner column with a rounded edge and a stepped base and cap. The square bits are plain boxes, the curved wall top and the rounded door jambs are a 2D profile turned into a face and extruded, and the pivots follow the brief (the floor's walkable top and the wall's base both at Y = 0), baked in with a Freeze Transformations. There's a grab from that afternoon of the first pieces sitting in Maya.

The next evening it all went into the game, five check-ins in about an hour: the floor, wall and rounded corner OBJs with 130 textures out of the texture generator (more on that in part two), then the 32 by 2 wall and a 10 by 32 corner column, with levels 1 to 30 stepping through the texture variants in order so each one could be looked at in turn. The corner posts got switched off straight away (the walls "butt up cleanly without a post"), and then the sliding door went in. The last check-in that night was a camera fix. The new walls are 32 tall and the top down camera was sitting at 30, so from straight above you could see right through the walls and doors! It went up to 50, and since the camera is orthographic that doesn't change the view at all, it just gets it out of the walls.

Later that night tileGen got its second check-in, and this is where the UVs got sorted for Godot. From that version on, the floor, walls, doors and column all go through one function, with two switches at the top of the file, GODOT_UV (turn it off and you're back to plain box projection) and TEX_UNITS_PER_CELL (how many times a wall texture repeats per 32 unit cell). A floor tile's top fills the whole texture once on a floor_mat material, and everything else goes on wall_mat, U along the wall and V up its height, so the texture repeats once per cell however long the wall is. Every face goes on wall_mat first "so nothing is left on initialShadingGroup" (Maya's default material, which comes back later), and the OBJ export keeps the groups and materials, which matters because Godot's OBJ importer keeps Maya's groups as separate surfaces, and that's how the door script tells the jambs from the sliding panels.

The thing to watch is that 10 cm convention. Every size gets multiplied by 10 in Maya, so a 32 unit wall reaches the UV code as 320, and a helper divides it back out so a one cell wall repeats once and not ten times (print the ranges with verify_uvs, and the guide's tell for getting it wrong is "a value far from 1.0 (e.g. 10.0)"). The column changed in the same check-in. The first version rounded its edge with Maya's bevel, and the second builds it with the same profile extrude as the wall tops and jambs (a comment in the code calls that "guaranteed to curve, unlike bevel"), plus a diag_column helper to check "whether the rounded arc actually made it into the mesh". The stepped base and cap went at the same time and haven't come back.

First thing the next morning was the wall tops, and my check-in note says it all, "-fixed the curve on the wall tops, now spans whole distance when you generate". Before, the curved top was a circle of the top radius sat in the middle of the wall, so on a wall more than twice the radius thick it only rounded the middle and left flat shoulders either side. Now it's one arc across the full thickness, with the radius setting how tall it is. On the 2 thick walls of the time you'd never have known, but the walls have been 4 thick since July, which is exactly where it shows.

Then there was the door. The first sliding door left a seam where the panels meet the jambs, and late that night Claude tried closing it in the engine by stretching the panels, which only made them thicker, so it came back out twelve minutes later with a note that "The gap is baked into the slidingDoor asset geometry" and is "to be regenerated in Maya without it". So the fix went into the tool at 2:49 in the morning, with the panels now tucking behind the jambs (by the jamb radius plus 40% of the jamb width, unless you put your own number in the "Panel overlap" field).

Here's where it went sideways. That 2:49 check-in was made on the copy of the script from June 26th, so it quietly took out everything from the day before, the Godot UVs, the floor and wall materials, the extruded column and the wall top fix. The door that came out of it went into the game 37 minutes later sitting on initialShadingGroup (told you it would come back!), and its UVs put the texture's hazard band on the tops of the door, which are the faces the top down camera actually looks at, so Claude painted the tops plain grey in the engine to cover it. By 11 the next morning door V3 was in, same shape but back on wall_matSG with proper UVs, and the tops had been checked on a device. At 13:50 my check-in put the newer code and the door fix back together, and the description on that one doesn't mess about: "-fixing the UVs generated stomped the old changes".

With the outer walls sorted, July 2nd brought version 5 and the interior wall kit, for the Alien Breed look of rooms inside rooms: a 45 degree corner, a T junction, an X cross, an end cap, an S jog, a sliding door set into the 45 diagonal and a 45 chamfered column. The pieces centre their thickness on the tile midlines, so making a wall thicker always grows into the tile and never past it, and the S jog is a neat one, give it a negative offset and you get its mirror image, so a run can jog out and then back in. Nine interior OBJs went into the game that night along with the 4 thick wall and a matching corner, and the game started building its inner walls from them, one kit piece per cell picked by what's around it.

That's six versions of tileGen.py in seven days, from 988 lines to 2,111, and the game runs on 15 OBJs out of it. Next time is part two, the texture generator and the floor sets it paints. Stay tuned!