Oolite : Create Your Own Ship (2)

This tutorial uses Wings 3D, the cross-platform subdivision modeler used to create some of Oolite's ships. You'll need a two button mouse to use Wings3D.

The files and the DropObj2DatTex tool and script used in this tutorial are available here (376Kb).

Click the thumbnails for larger versions of the pictures.
Creating the ship.
tut001.jpg Launch Wings3d, and right-click the main panel to pop up this menu.
tut002.jpg Choose cube and then select the 'objects' mode (the red pyramid in the toolbar for the main panel), and select the cube.
tut003.jpg Cubes created by wings3d measure one unit on a side. In Oolite these units are meters and a 1m x 1m x 1m spaceship is a bit small, so we're going to scale it to 30m wide, 10m tall, and 30m long.

Right-click and choose .Scale Axis.
tut004.jpg Choose the .X. axis then press tab to allow numeric input, this is a percentage, so enter 3000 to scale the objects x-axis dimension to 30m.
tut005.jpg You'll need to dolly the camera away from your object a bit to be able to see it all in the view now. I use the scroll-wheel to do this, but ctrl-alt-[left mouse button] and up or down will also work.
tut006.jpg Do the same scaling on the .Y. axis, scaling by 1000%.
tut007.jpg And on the .Z. axis scaling by 3000%.
tut008.jpg This gives us our basic shape, 30m wide by 30m long by 10m high.

Now some details, we'll add a bevel for the front viewscreen and some fins.

First the bevel, select the 'edges' mode (the pyramid with three red edges in the toolbar) and press space to clear the current selection.
tut009.jpg Select the upper front edge and right-click to pop up this menu.
tut010.jpg Choose Bevel and move the mouse until you've got the right look, then left-click to set the bevel. You can also press tab to allow numeric entry of the bevel amount again.
tut011.jpg Next the fins. These will be a bit trickier.

Select 'edges' mode again and press space to clear the selection, then choose one of the two upper edges going from front to back.
tut012.jpg Right-click for the menu and then choose .Cut. and choose 2 2 to cut the line into two pieces.

Do the same for the line the other side. You'll find yourself in 'points' mode, with the indicated point selected.
tut013.jpg
tut014.jpg
Now we need a quick trick to make life easier - choose 'faces' mode and press command-a to select all faces. Right-click and choose Tesselate and then Triangulate, which will make turn all the flat faces into bunches of triangles.
tut015.jpg Return to 'edges' modes and select the two edges to become fins.
tut016.jpg Right-click and choose .Extrude. and Normal.
tut017.jpg + and - control the thickness of the fin you extrude or you can again press tab to enter values numerically.
tut018.jpg Tadaa! A flying brick.
Save your work.
Generating a texture map
tut019.jpg There are a few ways to do this in Wings3d, we'll choose one of the easiest.

Enter 'objects' mode and select your ship.
tut020.jpg Right-click and choose UV Mapping.
tut021.jpg This will pop up a new panel which you'll need to dolly to be able to see your ship.
tut022.jpg Right-click this panel and choose 'Segment by' and then 'Projection'.
tut023.jpg This will colour the panels of your ship according to the direction they're facing.
tut024.jpg Right-click and choose 'Continue' and then 'Projection'.
tut025.jpg This will create the UV mapping for the ship as a series of shapes arrranged in a square. You can see how each shape relates to the different groups of panels of the ship.
tut026.jpg These shapes can be dragged around so that you can organise the texture as you choose. Eventually though you can right-click and choose 'Create Texture'.
tut027.jpg This gives you a number of options, I'm choosing to all the edges of the shapes and use a 512x512 texture.
tut028.jpg This creates the basic texture layout that you'll decorate later.
tut029.jpg You can close the texture panel now. At this point it's useful to rename some of the elements of your ship in the outliner. Select 'cube1' in the Outliner, right-click and choose Rename, I'll call it 'brick-hull'.
tut030.jpg Similarly I'll rename 'cube1_auv' to 'brick-hull_auv' and 'diffuse' to 'bricktexture', this isn't essential but it makes life less difficult when making more complex ships.
Save your work.
tut031.jpg Next select 'bricktexture', right-click and select 'Make External..' (and choose PNG as the file format) to create the texture file.
basictexture.jpg Here's the basic bricktexture.png
tut032.jpg And now the last step with wings3d, choose File -> Export -> Wavefront (.obj) with the extra options (by clicking the menu icon next to the menu item).
tut033.jpg Choose not to scale the model (Import and Export Scales set to 1.0) and no subdivision (Sub-division steps 0), and to export the texture as PNG format.

This will create the brick.obj and brick.mtl files that with bricktexture.png make up the Wavefront format model description.
Save your work and close Wings3D.
Editing the texture
bricktexture.jpg I use Omnigraffle for this, but any graphics package that can import and export PNGs will do.

Rather than run you through a tutorial on using a graphics package I'll leave this step for you to do by yourself.

This is my finished bricktexture.png
tut034.jpg And if we re-open Wings3d we can see the brick ship in all its glory!

Converting for Oolite
This is fairly easy as there are tools provided to do this.

You can either use the 'DropObj2DatTex' application with Mac OS X, or the 'Obj2DatTex.py' Python script.

With the 'DropObj2DatTex' application, simply drop the brick.obj file onto the application and it'll create the brick.dat model description file for Oolite.

Or open a terminal and execute the 'Obj2DatTex.py' script upon the brick.obj file thus:
 

$ ./Obj2DatTex.py ~/Desktop/brick.obj
converting...
['/Volumes/teak/Users/giles/Desktop/brick.obj']
/Volumes/teak/Users/giles/Desktop/brick.obj->/volumes/teak/users/giles/desktop/brick.dat
going to open material library file: /Volumes/teak/Users/giles/Desktop/brick.mtl
Material brick-hull_auv -> bricktexture.png
done

The final stage is to move the files into the appropriate places and create a shipdata.plist entry for the new ship.

brick.dat should go in AddOns/Models/
bricktexture.png should go in AddOns/Textures/

The entry in shipdata.plist should look something like this:
 
<key>the_brick_ship</key>
<dict>
<key>ai_type</key>
<string>pirateAI.plist</string>
<key>bounty</key>
<integer>150</integer>
<key>cargo_type</key>
<string>CARGO_NOT_CARGO</string>
<key>energy_recharge_rate</key>
<real>4</real>
<key>exhaust</key>
<array>
<string>0 0 -30 10 8 15</string>
</array>
<key>forward_weapon_type</key>
<string>WEAPON_BEAM_LASER</string>
<key>has_ecm</key>
<true/>
<key>has_escape_pod</key>
<true/>
<key>likely_cargo</key>
<integer>2</integer>
<key>max_cargo</key>
<integer>10</integer>
<key>max_energy</key>
<real>300</real>
<key>max_flight_pitch</key>
<real>1.85</real>
<key>max_flight_roll</key>
<real>1.85</real>
<key>max_flight_speed</key>
<real>250</real>
<key>missiles</key>
<integer>2</integer>
<key>model</key>
<string>brick.dat</string>
<key>name</key>
<string>Brick Shaped Ship</string>
<key>roles</key>
<string>pirate</string>
<key>thrust</key>
<real>20</real>
<key>weapon_energy</key>
<real>25</real>
</dict>

If this entry is added to shipdata.plist, in AddOns/Config then because it has the roles key set to 'pirate', when pirates are added to a system the brick shaped ship will occasionally be among them.

This concludes the second 'design your own ship' tutorial.

The files used in this tutorial are available here (376Kb).