Tuesday, 17 March 2015

Rigging models in Blender 2.64 - a workflow

This is a run-through of the workflow I would use to get models rigged for Second Life upload. It doesn't include details on weight painting or modelling, and I assume the reader knows their way around the Blender interface.

This tutorial owes a lot to AshaSekayi's excellent youtube video series, but quite a few things have changed since then, so I wanted to give a clear and more current overview of how the rigging and export/import processes work in a recent Blender version.


Requirements:
  • Blender 2.64 installed (since the bone weight copy script apparently doesn't work with 2.65) (and please note that you can have more than one version of Blender installed at once - just use a different install location)
  • The free Bone Weight Copy script correctly installed (instructions on that page)
  • Download the free Avatar Workbench file - choose the Blender 2.63 version.
  • A ready-to-rig model


1. Preparing the file and models

Open the avatar workbench file in Blender. It has several elements on different layers:
  • Layer 1: Unjoined SL avatar model (i.e. head, upper body and lower body are 3 separate meshes)
  • Layer 2: A makehuman avatar, rigged correctly for SL
  • Layer 6: Default SL avatar hair, skirt, eyes etc.
  • Layer 10: SL armature

Only layers 1 and 10 are required. You can either ignore the models on the other layers, or delete them for tidiness. I also prefer to join the SL avatar into one piece and move it to a different layer, so layer 1 is free for my model. (To join the models, select them all and press Ctrl-J. To move, press m and then choose the target layer.)

Import the model(s) to be rigged using File > Append.

e.g. I browse to test.blend, double click to open it and there's a list of folders containing all the information in that blend file. To import a model, open the Object folder and choose the correct item from the list.

The model should now show up in your active layer. (N.B. if it was hidden in the original file, it will be hidden here too. Check the outliner or press alt-H to reveal it.) Ensure that it is positioned correctly. If necessary, activate the SL avatar layer to check this.

At this point, save the file with a different name to keep the main avatar workbench file clean for later use.


2. Parenting the model to the SL armature

Ensure that both your model's layer and layer 10 are both showing. You can shift-click in the layer panel to have more than one active at a time.

Select your model, then shift-right-click the armature to select it also. (The armature must be selected last.) Press Ctrl-P to parent the object to the armature; choose "Armature deform" from the list.

Now select the model by itself. Go to the Object Modifiers panel (the wrench icon), and you should see that an armature deform has been applied. Uncheck "bind to bone envelopes" - this is automatic weighting applied by the armature modifier that does not work in SL. It can be confusing because if we leave it checked and pose the armature, the model will appear to be weighted already. We will keep vertex groups checked, and apply our weighting that way.

Deactivate the armature layer and activate both your model's layer and the layer with the joined SL avatar.


3. Bone weight copy

We will now use the bone weight copy script to apply the correct vertex groups to our model. Select first your model, then shift-right-click select the joined avatar.

In the toolbox on the left (press t to show/hide it) at the bottom should be a section called "Bone weight copy".

Interpolation: higher = better weight copy quality, but if you're just testing then leave it at 1, because it will take longer at higher numbers.
Both checkboxes should be ticked.

Press "Copy bone weights". This will take some time depending on the complexity of your model, and it might look as if Blender has crashed. Leave it for a few minutes; when it's completed, the objects will no longer be selected.

To check that the weights have been copied, select your model and open the Object Data panel (the inverted triangle icon). Under Vertex groups there should now be a list of bones, e.g. mHead and mNeck. You can also open weight paint mode, select each bone in the vertex group box and see the coloured weights.

At this point you would normally begin to tweak the weighting and clean it up. There are some good tutorials in Asha's video series (Primer 1 & 2) and in the Avastar tutorials (video 6: Mesh Weighting). If you're just testing the process, move on to the next step.


4. Checking the rigged model

Activate the armature layer and the model layer so you can see them both at the same time. Select the armature and go into pose mode. Rotate the bones to make sure that the model is moving with the armature.


5. Exporting as Collada / Importing to SL

Select the object and choose File > Export > Collada

Select the following export options (in the panel on the left)
- check Selection Only
- check Include Armatures
- check Export for Second Life

Export the file and save.

In the Second Life mesh uploader, select the model as your highest LOD. (Usually, you would go through the above process for all the lower LODs, but you can let SL generate its own for a test upload.)

Under Upload Options, check "Include Skin Weight"

In the preview options on the right, select "skin weights" and "joints" so you can see that the model is positioned correctly on the SL avatar.

Upload and wear the model.

DRUM AND BASS