goliathvt@Posted: Mon Jul 05, 2004 12:43 am :
This info pre-dates Doom 3 and is obsolete. Read it if you're bored. ;) - G

Most of the weapons are missing their corresponding models when you place them in your map as something that can be picked up by the player. For example, placing the shotgun in your map usually results in a fist protruding from the floor... although when you touch it, you do indeed pick up a shotgun and it functions normally. This is because the weapon_shotgun entity is just using the idle mesh used when you have the shotgun weapon equipped. This mesh also includes the fists and a spare shotgun shell.. all of the elements needed for the other shotgun animations, like reloading, firing, etc., and that's why you see a fist protruding from the floor.

Anyhoo, if you have Maya or you otherwise know how to convert an obj to a md5mesh, you can fix this.

The first thing you will need is to convert the weapon's idle md5mesh file into an obj file. Use bozo's md5mesh2obj utility to do this:


I'll walk you through the process for the machine gun.

Run the converter on the models/weapons/machinegun/cycles/idle1.md5mesh file in order to get an idle1.obj file and an idle1.mtr file. Move the obj and mtr files here:


Now open the .obj in your particular 3D program. I'm using Maya, but the basic steps are the same.

Basically, we need to remove the extra items... the fists, muzzleflash plane, extra ammo, etc. so all you have left is the weapon. Rotate it appropriately.

Now, because the md5 converter doesn't save the path information to the materials properly, we need to re-apply them. If you don't know how to do this and you're not using Maya or Lightwave, hopefully someome else here can help you, as I'm only familiar with these two 3D packages. However, since you can't use Lightwave (as far as I know) to create md5 files, Maya will have to do.

In Maya, open the hypershade and create a shading map. Next, click "Shading Map Color", choose file, "as projection" and use "cubic" as the projection type. For the image file to use, browse to the color map of the machinegun weapon (this is already provided in D3 and is usually in top level of each weapon's folder... i.e. "machinegun.tga" in models/weapons/machinegun). Now close the material and reopen it. For the "Shader", use a phong material when you're prompted. On the phong, click the "Diffuse" inputs icon, and again apply a file, "as projection", use "cubic" for proj. type, and again use the "machinegun.tga" file.

Keeping the hypershade open, select the weapon in the perspective view. Now right-click the material you just created and choose "Apply Material to Selection".

If you have any problems with this or need extra info, check out my tutorial found here:


and just hop to the Hypershade section.

Note that when you apply the material, it won't look right in the 3D program. That's okay... all we want is to be able to have D3 know where to look for the materials... it'll look fine in the game.

And now the last step... in order to be able to export the weapon back into the md5mesh format, you need to create at least one joint and then skin->bind skin->smooth bind it to the model. Save the file.

Once this is done, we need to make some changes to the weapons.def file.

You'll need to make 2 changes for each weapon:

One is the export line so we get our new md5mesh, the other is making sure to reference the model in the "model" key of the weapon's entity definition.

So, again using the machinegun as an example, here's the export line:

export {

   // in-game weapon models
   mesh   models/weapons/machinegun/machinegun.mb

   // Begin rest of weapons.def file...

   // shotgun
   -options blah blah blah blah blah

Note that this line must appear ABOVE the // shotgun... -options etc. line... if you put it below, D3 will try to re-parent the fists, muzzleflash plane and the other things we removed earlier from the model, and the export will fail.

Now for the entityDef:

entityDef weapon_machinegun {
   "editor_color"         ".3 .3 1"
   "editor_mins"         "-16 -16 0"
   "editor_maxs"         "16 16 32"

   "editor_usage"         ""

   "spawnclass"         "idItem"
   "size"               "32 32 32"
   "model"             "models/weapons/machinegun/machinegun.md5mesh"
   "viewmodel"          "models/weapons/machinegun/cycles/idle1.md5mesh"

The "model" is the in-game/weapon-as-item model. The "viewmodel" is what you see when you're holding/using the weapon.

I think that's it. Let me know if you have any questions or problems.


BNA!@Posted: Mon Jul 05, 2004 6:21 am :
Thanks goliath - quite informative!

Never bothered with this topic, just accepted absence of weapon models.

der_ton@Posted: Mon Jul 05, 2004 9:02 am :
Thankyouthankyouthankyou Goliath... once for doing this tutorial, and twice for giving this another reason to exist:
I once wrote a converter from ASE and OBJ to MD5Mesh. Ofcourse it's pretty useless for anything that moves, because it won't generate a skeleton (since there is none in an ase or obj to begin with), but for static weapon models it sure is ok. And so much cheaper than Maya. :D
So the work could be done with Bozo's md5->obj converter, any 3d editor that reads and writes obj (Blender, Wings3D), and then the ase/obj->md5 converter.
BTW, I think it should also be possible to use an ASE model for these static weapon models.

goliathvt@Posted: Tue Jul 06, 2004 1:25 pm :
Yes, ASE's do work for static weapon models... that's what the chaingun currently is... I think it's "vulkan.ase" or something like that. In fact, when I was first testing things and toying with the idea of fixing the pickup-weapon models, I got the machine gun to show up by using the chaingun's vulkan.ase model. Worked like a charm.