WC model conversion

To convert a new model To the Vision Engine (WCP/SO):

Atention: The main difference bettween building fighter style ships and corvette style capships, is collision, fighters handle collision well, but corvettes need to have a tree... To make a corvette, follow the the steps until you reach the tree proccess.

First you need to check the poly count of the model, it must be less than 1200 polys (vision engine limit, the ideal would be about ~600 or less polys)...look for less textures possible (there seems to be a limit bettween poly count and textures, thats why a ship that has 1000 polys, but 20 textures could still crash the game), also check if its centered on its axis, because the AI will always target the ship in its center, and if its not correctly positioned, it might dont be able to hit it at all, try to center and position it in the right way (so it dont fly backwards) before starting conversion.
A good tool to take a look at the models is 3D Exploration, also you can get it to almost any format you might need. If you want to make sure the model is centered, just click on it on 3D Exploration, you should be able to see the axis, check the poly count, the materials in the object list, also look for the objects, it needs to be only one, if it isnt, follow the next step.
Get the model converted to obj format (in 3D Exploration : Files -> Save as -> Select .obj format -> Make sure to check the ‘Show export dialog’ box -> Save...In the next window: -> check all boxes and choose the way you want the textures (store links, save as bmp, tga...)...) now open the .obj file with wordpad, search for ‘g ‘ ( thats g and a space), leave the first one alone, then erase the next ones ( just the lines with the ‘g ‘) and then save it. It now should be in one object.
Open it again with 3D Exploration (the obj file of course) and save as .peo (Homeworld Format).
Now open the peo viewer, put in the number of the starting mat (texture), it will be used in a sequence, if the first mat is 22001, the next ones will be 22002, 22003...put in the path to the model, and then choose it into the file option, the model should appear in the black window (just wireframe, if its look all messed up, its not in one object, go back and try again). Now just click ‘save data (c:\wcp)’. It should create the files: fvrt.wcp, radi.wcp, vert.wcp and vtnm.wcp into your root directory (C:\ )
Now open modelc and click the ‘Load Data’ button. It will open the model, now you can scale it, for comparison purposes, the panther is: ‘x:8.0 y:1.7 z: 13.3’, the kilathi corvette is ‘x: 84.8 y: 11.0 z:110.0’ and the midway: ‘x:737.4 y: 282.4 z: 1841.6’ (this info is shown under the vert option in modelc), you migh need to rotate it, in this case use the frmTools window (since modelc is a bad place to rotate models to the right position, the right position in modelc is upside down, inclinated and a little to the right, it might be easier to get the model into the right position in some 3D editing tool before starting it), take a note at ‘radi’ just under the scale option, press ’calc vtnm’ twice and then ‘save data’. It will update the .wcp files mentioned before.
The newest version of modelc allows you to compile the mesh with it, click on the script tab and made any operations needed on the mesh file:

Now get the ship scripts, the ship sript holds the stats (speed, guns, turrets, armour...), the mesh script holds the model and hardpoints, both scripts are in txt format. There is a ship script:

IFF "Ship.iff" //ship name
{
FORM "SHIP"
{
CHUNK "TYPE"
{
long 2
long 25 //ship id, determines the vdu pic and ship name long 0
}
CHUNK "BASE"
{
cstring "shipm" //points to the meshfile
long 0
}
CHUNK "CKPT"
{
long 52
cstring "panther" //points to the cockpit. AvailableCockpits: Def_cock, Panther, Piranha, Shrike, Tigersha, Vampire, Wasp
}
FORM "MNVR"
{
CHUNK "ATTK"
{
cstring "attack"
cstring "chaseattack"
cstring "attackflee"
cstring "componentattack"
cstring "turretattack"
}
CHUNK "MISL"
{
cstring "launchchaff"
}
CHUNK "GUNS"
{
cstring "rolloutavoid"
cstring "pitchavoid"
}
CHUNK "AVDF"
{
cstring "pitchavoid"
cstring "yawavoid"
cstring "flee"
}
CHUNK "AVDC"
{
cstring "capshipflee"
}
CHUNK "CHAS"
{
cstring "loop"
cstring "yoyo"
cstring "barrelroll"
cstring "flee"
}
}
CHUNK "PHYS"
{
float 500000 //mass
}
CHUNK "HITP"
{
float 10000 //hitpoints
}
CHUNK "POWR"
{
float 100
long 0
}
FORM "PSYS"
{
FORM "ENGN"
{
CHUNK "POWR"
{
float 100
float 0
float 160
float 160 //speed max
float 160 //speed std
float 160 //speed min
}
CHUNK "DATA"
{
float 0 //accleration
float 160 //speed afterb.
float 0 //accleration afterb.
float 0 //afterb fuel
float 8 //Y
float 8 //P
float 8 //R
float 0 //YPR rate of change
}
}
FORM "GUNS"
{
CHUNK "POWR"
{
float 100
float 0
float 0 //gun energy
float 150 //recharge max
float 100 //recharge std
float 10 //recharge min
}
CHUNK "GUN_"
{
long 11 //gun id
long 0 //ammo
cstring "gun1" //hardpoint to mount it on
}
CHUNK "GUN_"
{
long 11 //gun id
long 0 //ammo
cstring "gun2" //hardpoint to mount it on
}
}
FORM "MISS"
{
CHUNK "POWR"
{
float 100
long 0
float 800
float 580
float 360
float 36
}
CHUNK "DECY"
{
long 0 //# of decoys
}
CHUNK "LNCH"
{
cstring "miss1" //enum all miss hardpoints here
}
CHUNK "MIS_"
{
long 0 //miss ID
long 4000 //ammo
}
}
FORM "FSHD"
{
CHUNK "POWR"
{
float 100
float 0
float 2000
float 220 //shield recharge max
float 220 //shield recharge std
float 220 //shield recharge min
}
CHUNK "DATA"
{
float 20000 //shields front
float 20000 //shields rear
float 0.5
}
CHUNK "MESH"
{
cstring "c_shld_1" //shield mesh
float 15
}
}
}
FORM "ARMR"
{
CHUNK "DATA"
{
float 100 //armor front
float 100 //armor rear
float 100 //armor left
float 100 //armor right
}
}
FORM "EXPL"
{
CHUNK "TYPE"
{
long 0
long 3
long 16
}
}
}
}


Use a iff editor and choose -> file -> import asc, for the ship script
Now for the textures, make sure they are all are in indexed color format, if not they will appear corrupted and might make the game crash, then convert it to .mat format with texconv (supports bmp, jpg and tga formats) using the number you choosed before for the textures, mats use 8 numbers for the textures, so if you choose 22001, save the mat as 00022001.mat, 00022002.mat... Also note that the dimensions of the texture should be a power of 2. So 256x128 is ok, while 57x231 is not.
Important: if you use texconv to convert the textures, make sure you flip them vertically before doing it, texconv reads the textures in a different way from the game...
Also, if you get a texture or part of it transparent when you dont want to, use bmp2mat to convert, it doesnt do transparent textures (doesnt need to flip the texture, but it will create a .pal, a pallete file, you must place it into the WCP/SO directory in a folder named pal)

To use bmp2mat, do the following (in DOS mode):
Bmp2mat texture.bmp 22000 
              (bmp file) (mat number)

Bmp and mat is assumed (after all its bmp2mat ;) ), also make sure the bmp file name has less than 6 or exact 6 characters, it doesnt accept more than that. Pal file will be created automaticaly, also dont put the zeros before the first number of the mat, bmp2mat will do that for you. If you put 22000, the mat will be named 00022000.

Place the ship.iff in a folder named ship (obvious isnt it? :D) into your WCP/SO directory, do the same with mesh and mat. Now your ship is done, use it with wcpedit, you can alter the stats if you want, also dont forget to add the hardpoints in the mesh with a turret editor, you need to place hardpoints for each one you put in the ship script (guns, turrets, missiles, engine, bridge...) and position them.

Doing a corvette style capship:

With ModelC 0.8 or above:

If you get the newest version of Modelc, you will be able to do it easily. Still in modelc after saving the model, just click on the “make tree” button in the VERT/VTNM tab. Save it in your C:\ root directory (or edit the path in the mesh file, with the name tree, remove the // from the entire EXTN structure.
Now continue with step 7 from the above until the end. Otherwise follow the next steps ( more complicated):

Without ModelC 0.8:

After you save it with modelc, its time to build a tree, only corvettes and capships need it...copy all .wcp files to a directory where you have HCl’s tree builder, then type (in DOS mode): TREE.EXE > tree, it will creat a ‘tree’ file.
Now you need to edit it with a hex editor, open it and remove the first 2 lines and add FORM "TREE" on the 1st line, and a { on the 2nd line, like below:

FORM "TREE"
{
CHNK "DATA"

Also, the last line should look like:

"counter = 0"

Remove "counter = 0" and and another } (basically to close the { back on FORM "TREE").

Run: FORM tree tree.out >NUL’.
Now rename the tree.out file created to tree.iff and copy it to the root directory (C:\ ) or edit the mesh scrip to show the new location of the files..., also remove the // from the entire EXTN structure.
Now continue on to the end.


Coverting older wc game ships to the vision engine:

Extract the models from the ‘Data.tre’ file (for Armada, WC3 or WC4), you could use a tool like treman, the files should be named just by numbers, you will need a prog like windows find and search the iff files for text of some part of the ships name, like for the kilrathi destroyer, look for ‘kdes’ or something like that...
2. Using HCl’s convertor, run Conv.bat <iff-name> <starting_mat_number> <scale>
example: conv paktahn.iff 90000 6
It should create a file called newship.iff, run modelc and select ‘rip mesh’ to open it
Take note of the mats it uses, press ‘calc vtnm’ twice and ‘save data’ you shouldnt need to rotate it, since it will likely be already in the right position, and correct scale, if you used scale 6 before...
Procced with the ship and mesh sripts as above...the textures are already done, place the right ones into the mat directory into SO/WCP folder, also place the right palette file.pal into a pal directory->WC3.pal to WC3 ships, Wc4.pal to WC4 ships...


Adding turrets:

Place the following into the ship script just after FORM "ARMR":


FORM "TLST"
{
FORM "GTUR"
{
CHUNK "DATA"
{
cstring "turret1" //turret hardpoint
cstring "sortr01" //turret type (double barreled turret), devtr01 (single barreled turret)
float 131072
}
CHUNK "BULL"
{
long 12 //bullet type
}
FORM "MOVS"
{
CHUNK "LIMT"
{
float 180
float 180
float 90
}
CHUNK "BARL"
{
cstring "sortrgun" //double barreled turret, devtrg (single barreled turret)
}
}
}
}

There is a limit of 6 turrets on a corvette style capship, to add new turrets, just add another:

FORM "GTUR"
{
CHUNK "DATA"
{
cstring "turret2"
cstring "sortr01"
float 131072
}
CHUNK "BULL"
{
long 12
}
FORM "MOVS"
{
CHUNK "LIMT"
{
float 180
float 180
float 90
}
CHUNK "BARL"
{
cstring "sortrgun"
}
}
}

before the closing “}”.

Missile turrets:

FORM "MTUR"
{
CHUNK "DATA"
{
cstring "mturret_01_midmt"
cstring "midmt"
float 131072
}
CHUNK "MISL"
{
long 30
}
FORM "MOVS"
{
CHUNK "LIMT"
{
float 180
float 10
float 90
}
CHUNK "BARL"
{
cstring "midmtg"
}
}
}

About the ship stats:

It doesnt relly matters the stats on the ship script, because it can be changed later by wcpedit or wcppas...

Note about the tree (from HCl):

BSP trees require that, for best results, there are no intersecting polygons on the same mesh, there are no overlapping faces, that models are completely closed...(a "convex hull", as some people call it iirc).

Tools:

Modelc, WCP 3D exploration plugin, texconv, hardpoint editor and iff editor, 
peoviewer...................................................... by Thomas Bruckner
WCA/WC3/WC4 tree manager............................ by PopsiclePete 
WCA/WC3/WC4 mesh extractor, tree builder......... by HCl


Tutorial by KillerWave