Wednesday, February 23, 2011

Making a Spring RTS Map Game Table

The Spring coffee table
Here’s a bit more background and detailed step-by-step instructions about the coffee table I made for the April issue of Wired magazine. Don't forget to check out my other projects. I really enjoy making custom shaped Bookcases. you can see what i am talking about here.

Step 1: Select a Map (using Tasclient)
Regular players of Spring will recognize any map from that game in any form. But I wanted this table to appeal to non-players, too, so I chose a map that would be compelling on its own. From the beginning, the MoonQ (lunar-terrain) maps seemed like the best choice to me. The table in the Wired article is based on MoonQ20, a rectangular moonscape.

 Once you settle on your map, you have to decide the dimensions of your table (or other object)—width, length, depth, etc. The easiest method for viewing Spring maps is with Tasclient (Download from this page). You'll also need Spring ( Tasclient lets you connect to a game, but it also will let you view game maps. To do this, host a game, then select a map. A minimap of the selected map is actually a button for a 3D preview of the map. When you've found the map you want to use, remember its name.

Step 2: Extract the Heightmap (Using Spring Map Edit)

Maps in Spring are actually compressed files that contain all kinds of goodies. For instance, every MAP file contains not only the texture and color but also the height map information, and several other important files. We're only concerned with the heightmap. I mentioned it’s compressed. You’ll need 7zip to open it up. You need to get the .SMF file. It’s inside the map file, inside a folder called "Maps". Extract it, and remember where.
Now start up Spring Map Edit (SME). SME is one of the tools used to create/modify maps in the game. I don't make maps, and I don't modify them either. What I do know is how to use SME to get the heightmap. To do this, Select Map>Load>Import Spring SM2 Map. ]There is no graphical progress bar. Just give it a bit of time. It will come up. If you want to see that it’s loading, you can switch over to the console window that opened with SME.

When its loaded, select Map>Save>Save Heightmap (PNG 16bit). And there you go. You now have a 16-bit heightmap.

Step 3: Adjust Heightmap (Using Photoshop)
A heightmap is a 2D representation of a 2.5D object. (2.5D objects are things that have no "under" areas. So no caves, no inverted cliffs. Just the tops An example of a 2.5D object might be a pyramid in the desert, while an example of a 3D object would be the same pyramid, with the point at the bottom.—3D because it has "undercuts," or areas under other areas. Heightmaps represent 2.5D objects. The height is represented in color, usually black/white, or grayscale. If you look at the heightmap you just made, it’s all whites, blacks and grays. What does this have to do with anything?

Each shade of gray represents a particular height. In the next step we are going to tell some software to set white for the minimum depth of cutting, and black as maximum depth. With this, however, if the heightmap contains only grays right in the middle of the shade range, the result will be that the router won’t cut to our desired maximum depth because there is no black. So the trick is to get the darkest color in the heightmap to be black, and the brightest color to be white. This is called "Levels" in Photoshop. We are going to tell Photoshop to change the darkest gray in the heightmap to black and the lightest to white, then adjust all the grays in between accordingly. The result will be a heightmap with higher contrast, which will allow for greater precision.

Open the PNG file in Photoshop and open the “Levels” dialog. In the picture at right, “A” and “C” represent the scale’s black and white values, respectively. Note that there is true black but no true white. The lightest value, indicated by “B,” is actually 20% gray. To correct this, grab the little slider below “C” and drag it left until it’s under the right-most value that registers on the scale (again, noted in this image by “B”). Similarly, if the levels scale for your image has a gap between the blackest level and the left edge of the scale, grab the left slider and position it under the darkest level on the scale. Once you’ve got the sliders positioned at the edge of your image’s outer edges, pres “OK.” Your image will transform into one with full contrast. You’ll now have true black, true white, and a wider range in between.

Eight-bit images will struggle here, as they can hold only 256 values (0-255). If you start with an 8-bit image that has black thru 50% gray, for example, you’re starting with only 128 levels. If you use the process I’ve just outlined to convert that 50% gray to white, the grays in between will scale evenly between black and white, but the jumps will be rather pronounced, since you’ll be dealing with only 128 levels to cover the full range between black and white.

I started with an 8-bit heightmap, and you can see the stair-steps where the drill bit transitioned from one shade to the next. Sixteen-bit images can hold 65,000+ colors, meaning you’ll always have a pleasantly progressive transition from black to white and will have a much smoother carving

Step 4: Generate gCode (using PhotoVCarve)

PhotoVCarve (PVC) was designed to take a photograph and generate instructions for a CNC router to, essentially, scratch the image into wood—deeper scratches for darker areas, and shallow scratches for light areas. It’s all carved with a V-Bit (a Bit with two sharp angles, typically 90 degrees).

We’re going to change all this drastically.

First, change the bit to a ballnose/bullnose bit (the kind that is half a sphere at the tip). Then adjust the stepover. This is the amount of space between each “scratch,” usually measured as a percentage of the bit’s diameter. Set it between 6 and 9 percent. Under 6 percent, and the cutting gets torturously slow; over 9, and you start getting pronounced ridges between the passes. I keep mine at 8 percent.

Next, change “Carve Max Depth” to be whatever you want the carving to cut down to. I’m starting with wood that’s 2.25 inches thick, and I don’t want to go all the way through, so I set the max depth to 1.75 inches. Make sure you know how deep your bit can cut in a single pass. Mine can only cut 1.25 inches, so I will be cutting this twice—first a rough cut, then a second “finishing” pass.

There are several ways to compensate for the desired Max Depth being deeper than your bit can cut in one pass. You decide how to handle that. I usually set the machine to have a stepover of 40 percent, enter the max depth of the bit as my max carving depth, and save the gCode. I repeat that process, going deeper each time, until I am at my desired max depth. The finishing is as I just described: Max depth of carving, and a stepover between 6 and 9 percent.

With your settings dialed in, save the file as gCode and transfer it to your CNC’s computer.

Step 5: Machining the Wood (using Mach3)

There isn't much to say here. Secure the wood, position the machine over your designated starting position, load the gCode file you created in PVC, and press “Start.” Then wait. This table took four hours to carve.

I have read comments from people concerned about running a router for that long. Here is my plug for the Hitachi M12VC. When you are doing this kind of machining, the router isn’t under much load. It’s mostly spinning free, since you’re cutting off only tiny layers with each pass. I have run my router for over 35 hours without stopping. I've had to replace the bearings several times over the past for years, but overall it works like a charm. For this 18"x24" carving, I used a 1/4" cutter.

Step 6: Painting (using Professionals)

I’m not a painter. My wife—and I totally agree with her on this—says “you make beautiful stuff, then you paint it, and it’s destroyed.” Still, I wanted a cool paint job to finish this off. Where can you find someone good at painting and who would want to paint something like this? Your local tabletop-gaming store—the place where the D&D players meet. Could be a comic store, too. Regardless, these shops are full of people who do masterful paint jobs of figurines. I guarantee it you’ll find someone to help you.

The shop close to me has a “painting night” every Monday. Anyone interested in painting detail stuff is welcome to come watch, paint, advise, whatever. I took a small test version of this table down there to practice on and got great advice on how to paint it. Then it was just a matter of scaling that up for the full-size map. End result: An epic, intergalactic coffee table.


Antoni said...

I read your article in Wired and on you blog here and I thought this was great. I am also a 28 year old IT professional looking to learn about wood carving and everything. I was just wondering if you had any info on how you setup the router to work as a CNC? I'd like to try this type of thing out. Thanks for the article!

Kenneth Barry said...

Yeah I do.

First off,

There is a ton of information available. But you gotta begin some place. is a large community for anyone and everyone who does CNC stuff (professionally, and hobby)

My machine is based off the ideas of JoeCNC ( Hybrid 4x4.

You need software to actually control the machine (reads the gCode, and then make the machine parts move), i use Mach3

Feel free to email me directly and

Martijn said...

I'd just like to say: Thank you for using my MoonQ map! It looks just awesome! I could try and look/search through my backups and check if i have any more, or better heigthmaps that i did for TASpring? Good luck with the CNC carving anyways!!!

Tom Ulrich said...

Awesome Wired got me thinking about trying to carve some of my photos out in 3D. One question: do you know if anyone makes a PhotoVCarve equivalent for Macs? Thanks!

Kenneth Barry said...

I'm not aware of anything like photovcarve for a Mac. I mean, I am using photovcarve on a mac (running XP). Might be time to try bootcamp?

ericsoco said...

nice work, especially on making your own rig! but...look out for MDF. when airborne it's basically a cloud of formaldehyde:

why not use plywood? maybe it's not the aesthetic you're going for, but i think it makes nice topos when you mill contours out of it...

Kenneth Barry said...

I never considered using plywood. It sure would make some interesting contour lines. There are a few problems in general with Plywood. But i think they could be overcome. I don't think i have ever tried carving 3D/2.5D stuff from Plywood.

Elizabeth J. Neal said...

A minimap of the selected map is actually a button for a 3D preview of the map. When you've found the map you want to use, remember its name. 1617evspk

Tom Bradly said...

Oh my gosh, I like that moon map you used! I think my nephew and I will have fun making this.