User Tools

Site Tools


3d_modeling_animation:importing_armor_models_using_blender

Importing Armor Models Using Blender

By: SixshotOverdrive

Original article location

Introduction

This is a companion to Dusho's tutorial, so read that if you haven't already. I won't be going into details of how to set up blender etc.

Things you'll need before we get started:

note: These scripts only work with blender v2.49 and python 2.6. If your armor is in a non-standard format, you'll also need to find an importer which works for 2.49.

Setting Up

Place the import and export scripts in blenders scripts folder (it'll either be in the same directory as your install or

 %appdata%\Roaming\Blender Foundation\Blender\.blender\scripts

depending on which option you selected).

You should now have an 'ogrepkg' folder, you'll need to place the alternate armature script in here. It reorders the bones to match the way torchlight does.

Note: It should be noted that the skeletons don't export properly, but they're replaced by the character's and it has no in game effect.

Important: Make sure you open the import script and change the 'ogreXMLconverter' path.

It's a good idea to copy the files over to another folder, for the vanquisher you'll need these

  • vanquisher.mesh
  • vanquisher.skeleton
  • vanquisher.material
  • body.png

optional

  • vanquisher.animation
  • idle.skeleton (or any other animation)

The animations are just there to check your mesh is connecting to the skeleton properly. Blender only supports one, so adding more/all of them simply increases the import time.

Tutorial

For the purposes of this tutorial, the helmet and shoulder models were already separated.

The Helmet

Import your characters base model, file → import → OGRE for torchlight

Import the helmet model, file → import → whatever format your files are in

You should end up with something like this.

imported.jpg

In object mode, select both meshes, making sure vanquisherM is active (white text) and join them (ctrl + J)

activemesh.jpg

This is the 'outliner' panel. I suggest you add one, as it'll make the rest of your job a lot easier.

Deviation: If you're using the linked importer you can safely ignore this part.

Dusho's wardrobe_template.blend file will split the materials into submeshes

altimport.jpg

You can either merge these into one mesh, or make the imported mesh a child of the skeleton.

To do this, select both the helmet and skeleton, making sure the skeleton is active.

Then hit ctrl + P, it should come up with a context box, select armature then name groups.

parenting.jpg

While there are benefits to having multiple submeshes, this tutorial doesn't really deal with them. So for now I'd suggest just having a single mesh.

Don't worry when the helmet gets a bit messy, we just haven't connected it properly yet.

meltedhelm.jpg

Check your new materials to see if they have image links, and make them if they don't.

imglink.jpg

texture.jpg

Also, if you click the parent part, you'll see the setting for ambient and diffuse.

ambdif.jpg

Blender likes to reset these to 0.5 and 1 respectively.

In torchlight ambient and diffuse are generally the same.

Most armours use 0.588 for the face and shoulders, and 0.529412 for everything else.

Also deselect 'Shadow'

The materials print out a little differently.

Torchlight material

material Assasin_Set/shoulders
	{
	technique
		{
		pass
			{
			ambient 0.588 0.588 0.588
			diffuse 0.588 0.588 0.588
			specular 0 0 0 0
			emissive 0 0 0
			texture_unit
			{
				texture vanq_assassin_shoulders.png
			}
		}
	}
}

Exported material

material vanq_wrath/shoulders
	{
	receive_shadows off
	technique
		{
		pass
			{
			ambient 0.588000 0.588000 0.588000 1.000000
			diffuse 0.588000 0.588000 0.588000 1.000000
			specular 0.000000 0.000000 0.000000 1.000000 0.250000
			emissive 0.000000 0.000000 0.000000 1.000000
			texture_unit
			{
				texture wrathshouldertexture.png
				tex_address_mode wrap
				filtering trilinear
				colour_op alpha_blend
			}
		}
	}
}

You can change these manually, but I haven't noticed any negative effects of leaving them.

Rename all the materials and unlink the ones you no longer need.

For this we're using vanq_wrath/piece.

materials.jpg

While you can put anything you want before the '/' (keeping in mind blender has a 21 character limit)

The materials make submeshes, which is how torchlight knows which parts of the mesh to use.

So the pieces need to have the exact names, these are: chest knees to neck to elbows gloves elbows down boots knees down shoulders shoulder plates helmet helmet (but not the face) face the head and face

Switch to edit mode and box select the helmet (B → left click drag), make sure you don't get any of the legs if they're overlapping, then select all linked (ctrl + L)

Some of the vertices have likely doubled up, so we'll remove them (w → 6)

This makes the model smooth instead of blocky, and a lot easier to select as the entire helmet is now linked.

bonesmat.jpg

Assign it to the head bone (Bip01 Head) and the new vanq_wrath/helmet texture.

Move the Helmet over the head and scale it to fit.

The vanq has a rather round head, so you'll need to scale the axes individually. (s then x, y or z) It might take a while to get it looking right.

scaled.jpg

The jaw plate's still a little out of scale, but for the purposes of the tutorial it will do (you can spend a lot of time making them perfect).

Shoulder Plates

Now that we've got our helmet done, we can import our plates.

Basically repeat the same steps, but replacing helmet with shoulders.

You should end up with something like this.

rshldr.jpg

After getting it scaled and fitted, duplicate it (shift + D), mirror it along x (M → X) and place it over the other shoulder. Mirroring reverses the normals, so flip them back (W → 0)

Alternatively after duplicating you can just rotate it 180 degrees (R → Z → 180 → enter)

lshldr.jpg

Attach this plate to both the left clavicle (Bip01 L Clavicle) and (because of it's shape) the upper arm (Bip01 L UpperArm)

Usually the clavicle is enough though.

Do the same for the other plate, swapping left for right.

Finalizing

Go back and rename your model and skeleton, it should look something like this. (You should always recheck your structure before exporting)

final-structure.jpg

Your mesh is now ready to export. Select the mesh AND the skeleton, switch to object mode and press 'A'.

If you don't the exporter will error out, and most of the time it refuses to export anything else until you restart blender

Then go to file → export → OGRE meshes, your settings should look similar to this.

export.jpg

also, click preferences and uncheck 'Edge Lists' and 'Reorganize vertex buffers'

It might give you a few 'vertex with more than 4 bones' warnings, ignore these as they're for parts of the mesh we're not using.

If, however, it's telling you there's a vertex with no bones, you'll need to recheck your bone assignments.

Drop Meshes

While you can make the drop meshes from the full set, it's probably easier to start over and re-import them.

These are more akin to weapons, which Dusho covered nicely, so I'll just go over a few points.

  • If you use the same material names (vanq_wrath/helmet) you can use the same material file. This saves you setting them up again.
  • If you're adding the same set to multiple classes, you only need to make one drop mesh.
  • All the chests, gloves and boots use the same drop mesh.

Image Icons

The icons come in 512×512 sheets, with weapons/armour being 64×96.

For ease of use, here's a template

If your imported items have suitable icons, just grab them. If they don't, or you just don't want to use them, you can make new ones from the drop meshes.

In object mode, turn textures and perspective on, and deselect the mesh so it doesn't have the pink line. Swivel the camera around until you get an angle you like (numpad 2, 4, 6 or 8) and take a sceenshot.

screenshot.jpg

Paste this into the image editor of your choice, crop it and fix up any alignment issues.

aligned.jpg

Mask out the background

masked.jpg

Then resize it to fit into a 96×64 box

resized.jpg

Add this (as a new layer) to the first slot of your template. Do one for you shoulder plate, and add it to the second slot.

Delete the background, merge layers and save as customicons.png

For torchlight to use the icons we need to make an imageset file. These are just xmls with the names and positions of the icons. So open the text editor of your choice and add this:

<?xml version="1.0" encoding="UTF-8"?>
<Imageset Name= "customicons" Imagefile="media/ui/itemicons/customicons.png" NativeHorzRes="1024" NativeVertRes="768" AutoScaled="true" >
<Image Name="wrath_helm_icon" XPos="0" YPos="0" Width="64" Height="96" />
<Image Name="wrath_shoulder_icon" XPos="64" YPos="0" Width="64" Height="96" />
</Imageset>

The next item will have the same YPos and add 64 to XPos, until you get to XPos=“448”, after that XPos drops back to zero and you add 96 to YPos

Save the file as 'customicons.imageset'

Getting Them Into The Game

Copy the mesh(es), skeleton, material and textures over to your mods media/wardrobe/vanquisher folder

Copy the icon sheet and imageset over to your media/ui/itemicons folder

For TorchED users

You'll also need to copy them to torched's media directory.

Open up the unit editor and copy an existing helmet. Change both Name and Display Name to Wrath Helm. * Change the icon to wrath_helm_icon, you can also change the gambler icon. * Set Mesh File to wrath_helm_drop and make any stat changes.

Now open up the wardrobe tab and find the entry for vanquisher. * Change the 'Mesh' to media/wardrobe/vanquisher/vanq_wrath.mesh * Change 'Item Mesh Override' to media/wardrobe/vanquisher/wrath_helm_drop.mesh * Clear the Icon Override

For DAT editors

Copy an existing helms .dat file and rename it. Open it up in the text editor of your choice and replace or add these:

<STRING>RESOURCEDIRECTORY:media/wardrobe/vanquisher
<STRING>MESHFILE:wrath_helm_drop
<STRING>NAME:Wrath Helm
<TRANSLATE>DISPLAYNAME:Wrath Helm
<STRING>ICON:wrath_helm_icon

[WARDROBE]
<STRING>CLASS:VANQUISHER
<STRING>MESH:media/wardrobe/vanquisher/vanq_wrath.mesh
<STRING>ITEM_MESH:your_drop.mesh
[/WARDROBE]

delete <STRING>ICON:XXX from the wardrobe if it exists. you'll also need to delete the GUID '<STRING>UNIT_GUID:RANDOMNUMBERS'

Do the same thing for the shoulders.

Start the game and enjoy your new armour :)

final.jpg

3d_modeling_animation/importing_armor_models_using_blender.txt · Last modified: 2019/08/18 08:48 by anarch16sync