Creation of a new unit for OpenRA (step by step)

umairazfar edited this page Oct 8, 2014 · 7 revisions
Clone this wiki locally

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:

2) Once your unit/vehicle is finished, make sure that these checkboxes are enabled:

  • in Render Setup > Renderer tab: Antialiasing

Heberger image

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

Heberger image

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

4) 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

Heberger image


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)

Heberger image

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

7) Invert Select

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

9) Crop

10) Save your PSD file

11) Make sure to display your INFO panel

12) 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.

Heberger image


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: Heberger image

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

Heberger image Heberger image

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

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

Heberger image

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

Heberger image

7) Stop Recording your action

8) Select your 3rd layer and Play your previously recorded action

9) 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:

Heberger 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.

Heberger image

2) 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...)

Heberger image

3) Select the empty area with you Magic Wand Tool and fill it with pure black

4) 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).

Heberger 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 ra --shp aircraftcarrier.png

since we are making the SHP for ra mod, we type ra in the command

This will convert the PNG file to SHP.