Creation of a new unit for OpenRA (step by step) - UberWaffe/OpenRA GitHub Wiki

This step-by-step tutorial explains the creation of a new unit for OpenRA. It assumes that you have 3DSMAX and Photoshop (but the steps can be done with Blender and Gimp). 3DSMAX is available in a student version and Photoshop with an evaluation version during 30 days.

In this tutorial, I will show you what I did to create the SHP file of my Aircraft Carrier: http://www.sleipnirstuff.com/forum/viewtopic.php?f=83&t=16262


3DSMAX

  1. Open this 3DS MAX default scene and start modeling:
  1. Once your unit/vehicle is finished, make sure that these checkboxes are enabled:
  • in Render Setup > Renderer tab: Antialiasing

  • in Customize > Preferences > Redering tab: Don't Antialias Against Background

  1. Make sure to set an output folder (in Render Setup) to save each frame as single PNG files

  2. Render the scene with a 800x600 image dimension (you can choose a smaller image if you want)

You will now have 16 png images, one for each position of your unit. There are two problems: their dimensions are too big and the color palette is not compatible (yet) with OpenRA


PHOTOSHOP

How to know the optimal dimensions of each frame of the SHP ?

3DSMAX rendered 800x600 images but your unit/vehicle is slighly smaller than that. To discover what the optimal dimensions of each frame should be, just follow these steps:

  1. Go to your 3DSMAX output folder and open the first image (1.png) in Photoshop

  2. Then, add all other images (2.png, 3.png ...) over the first image as new layers (so you should end up with 16 layers)

  3. Gather all these layers in a Group

  4. Duplicate this group and hide the first one

  5. Merge this new group (your layer will contain all positions of your unit)

  1. Choose the Magic Wand Tool and click on an empty area of your layer (not on units !)

  2. Invert Select

  3. Select > Modify > Expand selection to 10 px (you can choose 5px if you prefer)

  4. Crop

  5. Save your PSD file

  6. Make sure to display your INFO panel

  7. Select All with CTRL+A (and note the dimensions of your current image)

Now you know the optimal dimensions for each frame of your future SHP file. In my example, it's 215x187 pixels.


How to create a large image that contains all these frames ?

...Because it's how SHP files work, all positions of your unit must look like this:

You can't keep these 16 images with their current big dimensions (800x600), you have to crop them to the optimal dimension you discovered earlier.

  1. Reopen the PSD file that you saved earlier

  2. Now that you know the dimension of each frame, you can calculate the dimensions of your large image that will conain the 16 frames. Just multiply the width of your frame by 16. In my example (215x16=3440).

  3. Go to Image > Canvas Size and expand your image

  1. Select your 2nd layer (I mean the layer that matches your 2.png image)

  2. Create a new Action to record what you are going to do (to reproduce this step easier later)

  1. Move your layer by the exact width of your frame (for me it's 215 pixels)

  1. Stop Recording your action

  2. Select your 3rd layer and Play your previously recorded action

  3. Do the same for all other layers (as many times as required)

After doing this several times, you'll end up with 16 frames, displayed next to each other on a large image:


How to use the correct color palette ?

The large image that you just created (with all positions of your unit) is not ready yet to be converted to SHP. You have to change its color palette and use the one OpenRA supports.

  1. Open the following image in your Image Editor, you'll notice that the colors are indexed.

  1. Expand the canvas size of your image to match your other large image (with all positions of your unit) So set the new size to 3440x185 (with Image menu > Canvas size...)

  1. Select the empty area with you Magic Wand Tool and fill it with pure black

  2. Copy and Paste the other large image over this one (it won't add a layer because it's an indexed file, it will replace the current image).


How to convert this PNG file to SHP ?

  1. Launch "cmd.exe" to be able to run command lines

  2. Go to your openra folder

  3. Type this command:

OpenRA.Utility.exe --shp aircraftcarrier.png 215

This will convert the PNG file to SHP.