Monday, December 30, 2013


Typical example

Assisting on a side project, I've put together a program named MILSGen that may help designing and building large, geographically accurate LEGO dioramas. It takes an image representing an elevation map, and splits it down to an array of corresponding MILS modules 32x32 studs in size. In case you haven't heard of it yet, MILS is a concept of creating large landscapes using pre-built modules that can be easily transported and quickly connected using regular Technic pins. (Find more about MILS system on the webpages of Antonio Bellón, who developed and wrote a detailed article about it.)

Side code matches all neighboursIt is a simple text application that lets the user choose an input image, where each pixel corresponds to a single stud at the output. Then, it solves the given terrain segment using several common LEGO plates, trying to keep it as "hollow" as possible to reduce the overall weight and part count. Finally, the standard underlying MILS structure is added, and each module exported into LDraw format one can view in LDView, edit via MLCad, etc.

There are some additional features: it automatically crops the input image to the maximum size that can be created with 32x32 tiles, covers the outside structural edges with closed bricks, lets the user choose the physical height of the highest point of the input image, and even to omit the entire substructure altogether if the overlying terrain is all one needs.

Each model is hollow In addition, to simplify the finaly assembly, one can enable the edge identifiers that put a set of 1x1 bricks at each inner edge, which matches its exact unique pair on its neighbour. The modules are named according to their coordinates in the entire system, borrowing the chess system: letters and numbers indicating columns and rows, respectively. E.g. top left corner is A1, third row in fourth column is D3, etc.

What MILSGen doesn't do are reinforcements. Since I wanted to finish it before the year 2400, structural analysis was out of the question; it is down to the builder of MILS modules to judge where are the reinforcements necessary, and in what amount. Also, it doesn't process input colors but just the pixel brightness: the entire output landscape is green. Acquiring an additional image with colour map and approximating it to a palette of common LEGO colours might be implemented in some of the future versions.

Installation is really simple ― just download the ZIP, unpack everything to a new folder, copy your input image there as well, and run the executable. It's not particularly pretty but it serves its purpose. Make sure to check out the PDF with detailed instructions, prerequisites for the input files and some other remarks included in the ZIP file, or separately available here as well.