HowTo:Add Ships

From VsWiki
Revision as of 04:11, 5 July 2005 by Halleck (talk | contribs) (+vsnav, a little wikification)
Jump to: navigation, search
arrow_left.png Texture in Wings3d arrow_up.png HowTos Add Levels Of Detail arrow_right.png

This article is a general guide on how to take your ship mesh all the way from your modelling suite of choice into the bowels of Vega Strike.

(General FIXME notice: I was kinda tired when I wrote this article, please keep an eye out for and correct my flagrant spelling mistakes, capitilization inconsistencies, etc. I wrote almost the entire thing from memory, so there may be a few factual errors as well, sorry.)

Before we begin, here are the files/executables you need to know about:

  • .obj+.mtl - the standard alias wavefront mesh format.
  • .xmesh - XML-Mesh format. Designed for VS since it is very easy to edit by hand.
  • .bfxm - binary format xmesh (FIXME - Check me on that acronym) Compiled xmesh. Loads much faster than an xmesh, and can contain multiple xmeshes (for LODs, animations, or models consisting of multiple components).
  • mesher - A command-line utility for converting between .obj+.mtl, .bfxm, and .xmesh formats.
  • units.csv - A comma seperated value spreadsheet which contains information on units that can be used by the game.

Part one: From Obj to Bfxm

First off, do yourself a favor and line your ship up correctly before we begin. For the purposes of Vegastrike, Z+ is forwards and Y+ is up. The ship's nose should be pointing forwards along the Z+ axis (so that the Z+ axis would theoretically be visible from the cockpit). The mesh should also be properly centered.

Now, it's go time! The first step in getting your cool new ship into VS is to export it to a format that Vega Strike understands. Currently, VS is able to read obj, xmesh, and bfxm files. However, it is best to use the BFXM format, so this guide is written with that in mind. It also assumes that you're running VS under windows, although linux-specific info will hopefully be added at some point.

OBJ is a standard, widely supported mesh format. Nearly all modern 3D suites support some form of OBJ import/export. If your modeller can't export to OBJ, see if it can export to some other standard format (like 3ds). You will have to find a 3d converter that can go from that format to OBJ. However, the assumption is that your model can export to OBJ.

Okay, so now you've got an .obj file (and probably an .mtl file as well). Move these files into the "bin" folder inside the main Vega Strike directory. Now, start up a command prompt or terminal of some sort, and change your directory to WHEREVER\bin\ . If you run mesher.exe without any arguments, it will print a list of avaialbe commands.

Mesher does not try to detect what kind of file you're feeding it, so you need to specify a three-character conversion code as part of the argument. You just want to go from .obj+.mtl to .bfxm right now, so run mesher with the following arguments:

mesher whatever.obj whatever.bfxm obc

The command obc means "obj to bfxm, create output file".

Okay, so now you've got a bfxm. Great! The problem with BFXM is that you can't really edit it by hand, which you need to be able to do in order to add specularity, damage, or glow maps. These tasks are easily accomplished by converting your BFXM to XMESH. Run mesher with these arguments to do so:

mesher whatever.bfxm whatever.xmesh bxc

Now Prepare to get your hands dirty. Whip out your favorite text editor, cause it's XMESH time!

Part two: XMESHin'

Under ideal conditions, you won't have to hack the xmesh much. To assign specularity maps (which you must do, unless you want your ship to look like a giant mirror), all you need to do is add an attribute to the <Mesh> tag at the beginning of the file. Your basic xmesh header looks like this:

<Mesh scale="1.000000" reverse="0" forcetexture="0" sharevert="0" polygonoffset="0.000000" 
blend="ONE ZERO" texture="mycoolship.png" >

The attributes you can add are texture1, texture2, and/or texture3, which correspond to specularity map, damage map, and glowmap respectively.

<Mesh scale="1.000000" reverse="0" forcetexture="0" sharevert="0" polygonoffset="0.000000"
blend="ONE ZERO" texture="mycoolship.png" 
texture1="mycoolshipPPL.png" texture2="mycoolshipDMG.png" texture3="mycoolshipGLO.png" >

(FIXME : PPL is correct nomenclature for specmaps, but I made up DMG and GLO. What should these files be named?)

Main article: HowTo:Add Per Pixel Lighting

Damage maps and glowmaps are optional. If you don't want to make a specmap, or if you want your ship to be completely matte (nonreflective), simply create a 1x1 black image and assign it as texture1.

While you have your imaging tools out, now is a good time to cope with a little bug in mesher. It inverts the UV coordinates of your mesh, so you'll need to flip your texture vertically and re-save it. If your texture is in a lossy format like JPEG, work from the master if possible. PNG shouldn't be an issue.

Once you have all your additional maps referenced in the <Mesh> tag, you're ready to go back to BFXM. Run mesher with the following argument:

mesher whatever.xmesh whatever.bfxm xbc

Your mesh is now primed and ready for insertion into Vega Strike!

Multiple Xmeshes

In some cases, mesher will generate multiple xmeshes from a single bfxm. If this is the case, you'll need to reconstruct the bfxm by first converting the main xmesh file to bfxm normally, and then running mesher as many times as needed with the following argument:

mesher #_#.xmesh whatever.bfxm xba

Where xba means "xmesh to bfxm, append". Usually, #_# will be something like 1_0. (FIXME - What do the numbers signify? Is the second number a corresponding LOD?) Once you have appended all the additional xmeshes to the bfxm file, you should be good to go.

FIXME - Need info on how to append LODs to a mesh.

Main article: HowTo:Add LODs

Part three: Units.csv

Now comes the time to get into the real nitty gritty and assosciate some data with your mesh that will tell the game how it should be used. Most spreadsheet programs can open .csv files. You can use popular software such as Microsoft Excel or OpenOffice.org Calc to edit units.csv. As an alternative, GAlex has written a nice, lightweight .csv editor tailored to work well with units.csv. (Download here.)

Once you've loaded up units.csv, start by looking in the first column for a ship that you think is reasonably similar to your own. If you're not sure, llama.begin is a good place to start. The data for each ship occupy a single row, so once you've found it, select the entire line and duplicate it. Change the unit name to whatever your shipname is. Avoid spaces and special characters in column one, since it is a name used internally by vegastrike. (FIXME - Is that even true?)

In column two, change the pathname to whatever directory you want to place your ship in. "./whatever" Means "VSINSTALLDIR\units\whatever\", so you'll want to make a new folder called "whatever" in the units directory and copy your BFXM and textures into it.

You probably want to specify what types of mount points your ship has (various missiles, guns, turrets, etc.) These can be edited in the "Mounts" column. On the left of the mounts column is the "Light" column, which gives the location and type of your ship's engine flare graphics. Light, mount, and even cockpit positions are specified with X,Y,Z coordinates on your mesh.

Main article: HowTo:Add Engine Glow

Part four: Testin' Time

Okay, that's enough to test your ship in-game. (Note: if you just want to quickly test how your mesh looks in-game without mucking about in units.csv, try swapping it out with the llama mesh, or the mesh of whatever ship you happen to be flying in VS currently).

Since your new ship isn't yet listed as a purchaseable item (and doing so is beyond the current scope of this article), you'll have to hack a save file to test it. Start by going into your VSINSTALLDIR\.vegastrike\save\ directory and copying one of your save files. Then, open the copy up in a text editor. The first line should resemble this:

Crucible/Cephid_17^13500000.000000^whatever 209160449.772106 -62167111.692738 193000385.631824

After the second caret (^) symbol, you should see a ship name. Change this to whatever you named your ship in the first column of its units.csv row, and save.

You are now ready to see your ship in action! Load up Vega Strike and load your new save game file.

Now, you can either stop, satisfied with your achievement, or return to units.csv and toil endlessly to balance your ships' stats correctly. Which will it be? :-P

arrow_left.png Texture in Wings3d arrow_up.png HowTos Add Levels Of Detail arrow_right.png