(Never)blender armature - rigging a trimesh model, help needed

I’m trying to wrap my head around creature animations in blender. So far I’ve managed to import models and create their armatures with neverblender. Now I’m stuck at how to properly rig/skin/weight all the individual trimeshes of the model to the armature so I can see what I’m doing when working with the armature.

My current process is:

  1. import > .mdl
  2. select root object > Generate Armature
  3. invert selection (everything except armature) > delete¹
  4. import > .mdl again, uncheck Import Animations
  5. select imported hierarchy > right click > parent > Clear and Keep Transformation
  6. shift-select armature > right click > parent > Armature Deform With Automatic Weights

This mostly does what I want in principle (creates vertex groups with weights and an armature modifier for each object) but the weights are all over the place - as far as I understand the one (per trimesh) vertex group with the same name as the trimesh and associated bone should have all vertices at weight 1 and other vertex groups are either not required or should have all vertices at weight 0. It seems like there should be some way to automatically create these groups and weights from the object/trimesh names since they are the same as the bone names. Am I missing something? Maybe I’m taking a completely wrong approach - I have no idea; any help very appreciated!

¹) to get rid of the animations on the model itself

I can’t help you much I’m afraid, I don’t think there as a way to automate that. Blender automatic weights will always take neighbouring bones into account. For example for bicep you always get forearm and nwn “shoulder” bones.
I don’t think you can get rid of that outside of creating the vertex groups yourself.
Maybe bone envelopes works better? Don’t know though.

Word of Warning: There could also be an issue because nwn models often aren’t in a T-pose. For example with human animations the arms are aligned with the body. Blender automatic weight feature really doesn’t like that and might add weights from the torso to bicep mesh You need to check for that.

Blender make an ok-base rig, but you’ll always need to do alot of adjustments. That lead me to the idea to use a foreign rig and port that to NWN. I wrote my way down: Porting creatures to NWN in Blender, which already have a foreign rig | The Neverwinter Vault
It includes example scripts for Mixamo, which do a pretty good rig (IMO). But, since NWN(1) don’t have many bones, you’ll probably still need to do some adjustments. For example NWN1 doesn’t have any real shoulder/clavicula bones at all (the NWN1 shoulder bones are shoulderpads on top of the NWN1-bicep body part), and only one spine = torso bone.
It’s written for NWN1, but meanwhile I used the same path for NWN2. That works, too!

Hey, thank you for the replies! Also thank you for the great tool Symmetric. The envelopes (in default state - I want to avoid adjusting anything by hand) perform worse than the automatic weights, regrettably. I noticed the pose thing, the inner parts of humanoid creatures have their weights all over the place but the extremities seem mostly ok.

BlackRider, I actually found your tutorials and used them to wrap my head around the whole process, thank you (although I completely forgot about the scripts, I’ll have a look at them later).

After creating the topic I sat down and tried to create a script, here is the result:

import bpy
import mathutils

def constraint_trimeshes_to_armature():
    root = bpy.context.object

    if not root or root.get('nvb') == None or root['nvb'].get('classification') != 2:
        raise RuntimeError("Please select a valid Aurora Base object.")
    armature = bpy.data.objects[root.name + '.armature']
    if not armature:
        raise RuntimeError("An armature associated with the selected Aurora Base object is required.")


    queue = [root]
    while queue:
        item = queue.pop()
        for c in item.children:
        if item.type != 'MESH' or item.name not in armature.data.bones:
            # fixme restrict to only trimeshes / not skinmeshes?
        item_copy = item.copy()
        item_copy.data = item.data.copy()

        item_copy.parent = None
        item_copy.modifiers.clear() # fixme required?
        item_copy.constraints.clear() # fixme required?

        item_copy.matrix_world = mathutils.Matrix()
        item_copy.matrix_local = item.matrix_world.copy()

        bpy.context.collection.objects.link(item_copy) # fixme required?

        bpy.ops.object.select_all(action='DESELECT') # fixme required?
        constraint = item_copy.constraints.new(type='ARMATURE') # constraint vs modifier?
        target = constraint.targets.new()
        target.target = armature
        target.subtarget = item.name


Its a little messy and hasn’t been tested much but it seems to do what I want by copying the pseudo bone objects, cleaning them up and constraining them to their armature bones. Suggestions for improvements are greatly appreciated ofc.

1 Like

Intresting and impressive (since I could never write up something like that!)… but I seem to be too stupid to understand its aim… I imported a model, created the amature and run your script. It created a copy of the NWN-bodyparts. If I then - in Pose Mode - move a bone, it moves the newly created bodypart. And now what? (Sorry…)

That’s it. I want the armature to animate the model (or a copy) to see whats going on with the model when working with the armature (following blender tutorials).

With skinmeshes (as far as I understand) I can just set the skinmesh to use the armature via modifier but trimeshes and other simple mesh types miss vertex groups and weights. I’m too lazy to manually go over models and create groups and weightpaint by hand, and the tools offered by blender (that I’ve found - parent to armature with automatic weights or envelopes) are very imperfect.

I haven’t found a better way to do this, which lead to the original question and the script (mostly cobbled together from stackexchange answers, I don’t understand the why of all of it either).

Ah, OK, I got it. As written: The script works for me too. Nice.

Just a notice: As long as you work with trimeshes: The keys are on the parts and the parts are moved accordingly. In this case, there is no need for an armature. That’s only needed for skinmeshes (in Blender), which need to be hooked to an armature via the Armature Modifier.

Another notice: Gmax can move skinmeshes without an armature. It sees the bodyparts with their keys/animation as bones. But then, if you don’t know Gmax, it’d be a bit like a different world. So if you actually want to work in Gmax, you’ll need some time to find your way around.

Great to hear it works.

I understand that you technically don’t need armatures for animation but (1) its convenient to have everything in one place for both skinmesh and part based models (2) the (character/creature) blender animation tutorials I’m using use armatures and its much easier to follow along if I do, too (3) some blender stuff afaik requires armatures for example pose mode and inverse kinematics.

Check! :+1:
Thanks again for sharing that script!