Please note that this is an intermediate level tutorial, it is highly recommended that you do the basics first before you start this.
For Vfstool handling check out Shadowarrior's tutorial and Afterlight Modding Tips FIRST.
If you are already familiar with the Vfstool and the basic file structure handling you may proceed as I do not want to answer unnecessary questions like "how does the meshexporter work". I will describe it shortly but if you have troubles as I said there are basic descriptions available already so I will concentrate on the further steps.
How to export a model and why we need it
Okay so let's start right away. I assume you extracted the gamedata.vfs already and have stored it in a separate folder. We call this folder EX-Folder here. In this folder you should have placed the meshconverter tool, which has been provided kindly by ALTAR. You can download it here.
To have the meshconverter work properly, you have to have it in your ex-folder as it will fail to convert the file you want to extract properly if not. Note that on some files you will have to have the scenes.vfs folders extracted as well, this counts for all items that store further data like animations, including aliens, humans, and even some special weapons which have their own animation like the "bossgun" or the gatlingun.
Now let's convert a model and I will tell you why we need it. You can either convert files manually or use the binconverter, or the tool written by stucuk implemented in his ufo editor package. I rather do it manually though, it's more fun that way and besides I want you guys to learn it so you better do it manually
So let's pick a model we want to export, they are stored under items\models in your ex-folder. I already have selected a model for you so don't bother with it, let's start our command console window application via start cmd. Switch to your ex-folder and convert the file with meshconverter bt items\models\wu_h_ancient_rifle.txt ancient-rifle-ex.txt .
This will extract the file we have specified and adds it to our ex-folder under the given name ancient-rifle-ex.
Here's an important note: Think of a proper naming in advance and stick to it. I call my extracted files always with an -ex and my import files with an -imp, so I will know later what it is because we will mess up the ex-folder pretty quick but more on it later.
Now we have converted the binary file into a textfile. Just leave it where it is now, although you can view it in the ufo editor, or convert it there to .obj format to view or modify it in a 3d tool. Note that it is not supported yet to save files properly with ufo edit yet, (saving only works from obj. -> textfile direction) it will screw up the data, and therefor reconverting the file to bin format will fail! Instead we do the "Bodysnaptrick" as I call it.
The BODYSNAP trick
I assume you already made your own model ? If not we can modify an existing one, however we cannot export/import it directly, instead we have to use an existing converted modelfile as a body. UFOEDIT only supports .obj format atm so you have to export the model you have made to this format. Load it with ufoedit. A popup window will appear and asks how to map the texture. Click on FLIP Y axis, as the engine has a different coordinate system which will mess up your texture if you dont flip it. Also you can vertically flip your texture in Photoshop but don't do both. You can preview your model with texture in UFOedit, but the important part is you can save it to AM format. [DO NOT SAVE AS AS/AL] I said saving does not work before, yes but we only want to save our vertices data therefor the tool already does the job, however we cannot store any other data YET.
Now we have 2 files, 1 is the converted original and the 2nd our .obj file that we converted to textformat.
Open up both in your favorite texteditor aka notepad
Now select your made modelfile and select all numbers including VERTS 00000
down to the last line of the number block you see PRIMITIVE_GEOMETRY_GROUPS 1 or something similar. Copy paste it into the original file, make sure you overwrite all data from VERTS to the line GENERIC_ATTRIBS. Now do the same for COUNT and copy paste this into the original file. We now have bodysnapped our new model into the original file. Why do we do this ?
Because the file holds some more data like helpers, texture infos, and more complex ones refer to animationfiles and bones, however this is not possible to edit yet.
Now save the file but don't overwrite the original as you can use it again and again as your body, save the new file under "mynewweapon"-imp.txt, so you will know later what it is. Store it in your
ex-folder\items\models folder. Now you can close the file we have copy pasted our modeldata from but keep the newweaponfile file open....
How to edit helpers
Load it into ufo edit.
Click on the rider model and select show helpers. Now you will see some Pivots as they are also called, these little helpers define some special connection points for the game engine. Now what do we need them for ? Weapon files always have 5 helpers, you can select and highlight them with the drop-down menu, the first is called point-f which indicates the starting point for the muzzle-flash of the weapon, the second is called muzzle, it defines the length of the muzzle-flash, scope and underbarrel mark the points where the add-ons are mounted, and eject defines the eject point of the bullet case.
As you may see these points do not correspond correctly with your model. Well that alone is not a problem but it may look weird when you add add-ons. So we have to fix them. NOTE: you cannot save in ufoedit yet properly so we have to edit them manually. However we can already move them around in ufo edit and find the right spot. As seen on the picture.
When you are done open your mynewweapon-imp.txt if you have it closed and edit the helper data manually. The helpers are stored at the top of the file, each helper as actually a parent helper below, its the position of the model itself, only edit the first one! The values are a bit cryptic so you can always view into the editor to see its original value and figure it out which is XYZ, as these are stored in a 4x4 grid, like rotation and 3d coordinates.
Basically it should be every 3rd value so 3 6 and 9 for xyz, a little trick to make sure you change the correct is to leave the values behind them, when you change them in ufo edit to adjust a helper, as they where so you can find the corresponding value in the file new weapon file. Edit the xyz values in the new weapon file manually and then save the file by clicking ctrl-s. Later it will be possible by saving this via ufo edit, however again this is not implemented yet.
Now we are almost done, if you use your own texture you have to edit the texture file paths as well, the game uses 4 diff, spec, bump and normals. You will only need diffuse however to make it look real good you will need the others as well, I'm still experimenting on it, it's a bit tricky, so using original textures on your model is much easier. Now you also have to store your new textures (if you made them) in the ex-folder\items\textures ,as the meshconverter will look for them. Convert the file back with
tb items\models\mynewmodel-imp.xt mynewmodel.txt. The new converted file will be stored in ex-data folder again. Place it properly with your textures in your modfilder according to the file structure and compile them into a mod.vfs file.
NOTE: To actually see the model ingame you have to give the file a name of a model which is actually stored in the equipment.txt and the entitiy.txt. For testing issues you can name it wu_h_ancient_rifle.txt for example. It will replace the model of the original fn2000 ingame, but still have the same stats and description. How we edit these I will explain in another tutorial