How to implement new models into AL


  • Please log in to reply
2 replies to this topic

#1 TYR

TYR

    Weaponsmith

  • Members
  • PipPipPipPip
  • 213 posts
  • Location:Vienna Austria

Posted 25 February 2007 - 01:52 AM

Hello and welcome to my first tutorial for AL.

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.
Posted Image

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.

Game implemantation



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  :D

-
Order is one half of life, chaos is the other - TYR -

#2 Patupi

Patupi

    Squaddie

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:Florida, USA

Posted 26 December 2012 - 05:49 PM

Does anyone have offline versions of Shadow Warriors tutorials that are mentioned at the top of this post? The ones up there were on Altar's forums which have since died. I know I'd appreciate looking through his tutorials!

#3 Patupi

Patupi

    Squaddie

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:Florida, USA

Posted 07 January 2013 - 12:03 AM

OK, as I'm finding stuff out about this (by trial and error mostly) I'll add up what I've found here. Hope someone finds this useful.

As I've just worked out how to get customized icons into the game I'll start there.

First all the icons for items (weapons, ammo, devices etc) are in two separate folders and you'll need to make these folders in your mod. From the root directory make:

root\interface\textures\items\

In this directory you put your remodelled TGA pics for use as icons. They should all be in triplets. Each item will have one file with just the item name, then an item name with '_checked' after it, then a third with '_over' after it. They are all the same except for different colored borders. One for the normal view of the icon, one for when it is clicked, and another for when you mouse over it.

EG:
ammo_h_advhybridbattery.tga
ammo_h_advhybridbattery_checked.tga
ammo_h_advhybridbattery_over.tga


2nd Folder:
root\interface\models\items\

In this directory is a copy of the .txt file from the equivalent folder in the 'gamedata.vfs' file. Choose a file to work with that is similar and copy it to your new directory. I was making larger batteries for use in the Reticulan weapons, a 2x2 battery rather than the 1x2 Reticulan batteries so I chose the robot batteries which are 2x2. I didn't change the 3D models as I'm having difficulty with positioning models so they look right. On the battlefield these should still look like the old Reticulan batteries.

The name of this file should be the same as the name of the icons but with .txt instead of .tga and with neither _checked or _over after it.

EG:
ammo_h_advhybridbattery.txt


Use a hex editor to edit the .txt file and change the 3 filenames that will refer to the above three pics you've made. Again there should be a .tga, a _checked.tga, and a _over.tga here and each should be changed to the new names you use above. Don't change any other file names in this file! There are multiple references to similar names here, but only three have the '.tga' at the end. Since you're using a hex editor (I couldn't find a notepad prog that didn't corrupt the files!) you need to insert or delete bytes to make the length of the name you are using fit. If your new file name is 3 characters longer add 3 bytes. If it's shorter delete 3 bytes. Then change the file name here to what you need.

EG:

.....Interface/T
extures/Items/am
modron_h_battery
.tga.....F......


I had to add 5 bytes in the middle of the file, then change the text to:


.....Interface/T
extures/Items/am
mo_h_advhybridba
ttery.tga.....F.


This will point to the right files for the pics to work.

After this you just need to change the 'equipment.txt' file for your new item to point to these new files you've made:


  id INT 2014
  ismanufacturable BOOL T
  g_modelid STR "Items/Models/ammo_r_batery.TXT"
  g_ifacemodelid STR "Interface/Models/Items/ammo_h_advhybridbattery.txt"
  startquantity INT 0


Then save, use your vfs compile tool (whichever you use) and run it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users