Jump to content

Creating an animation rig in Blender: Difference between revisions

Added "Creating the Rigify metarig and adding limb flexion" header
(Added "Creating the Rigify metarig and adding limb flexion" header)
Line 45: Line 45:
* [http://mods.oni2.net/node/38 '''Current version of OniSplit.'''] This is the tool needed to import and export assets out of Oni. '''DO NOT USE OniSplit GUI or Vago for importing Oni assets into Blender''' - neither of these weren't updated in a long time, and thus they don't support OniSplit's v0.9.99.2 -blender option. You can still use them for other purposes though, such as sounds and converting .oni files to XMLs, etc.
* [http://mods.oni2.net/node/38 '''Current version of OniSplit.'''] This is the tool needed to import and export assets out of Oni. '''DO NOT USE OniSplit GUI or Vago for importing Oni assets into Blender''' - neither of these weren't updated in a long time, and thus they don't support OniSplit's v0.9.99.2 -blender option. You can still use them for other purposes though, such as sounds and converting .oni files to XMLs, etc.
* [https://cmder.net/ '''Cmder'''] (Windows only) - because OniSplit is a command line tool, it is highly recommended to get any upgrade to Windows' Command Prompt. As shown in the screenshot on the right, Cmder allows you to start it from the context menu in any selected folder, and it also remembers your most recently used commands, vastly improving your workflow when you're forced to use any command line tools.
* [https://cmder.net/ '''Cmder'''] (Windows only) - because OniSplit is a command line tool, it is highly recommended to get any upgrade to Windows' Command Prompt. As shown in the screenshot on the right, Cmder allows you to start it from the context menu in any selected folder, and it also remembers your most recently used commands, vastly improving your workflow when you're forced to use any command line tools.
* [https://docs.blender.org/manual/en/2.81/addons/rigging/rigify.html '''Rigify'''] - it's a plugin for Blender designed to automate a lot of rigging work. The rig described here is generated using Rigify.
* [https://docs.google.com/document/d/175uJGklYASAgrFjxuUG4-kJRDoMTjjP7GvNxSj1GscU/edit '''Oni-Blender tutorial'''] by EdT. Please read this in entirety to know likely-to-happen issues and refer to this as your guide for OniSplit commands relating to Blender.
* [https://docs.google.com/document/d/175uJGklYASAgrFjxuUG4-kJRDoMTjjP7GvNxSj1GscU/edit '''Oni-Blender tutorial'''] by EdT. Please read this in entirety to know likely-to-happen issues and refer to this as your guide for OniSplit commands relating to Blender.
* [http://oni.bungie.org/forum/viewtopic.php?pid=23230#p23230 '''Brief overview on creating TRAMs'''] by EdT - while this was written with XSI in mind, this is still relevant as the process for preparing the XML files for Oni is still the same. Also the next post in that thread, called '''Brief walk through on modifying a TRAM,''' is an example of that overview put into practice.
* [http://oni.bungie.org/forum/viewtopic.php?pid=23230#p23230 '''Brief overview on creating TRAMs'''] by EdT - while this was written with XSI in mind, this is still relevant as the process for preparing the XML files for Oni is still the same. Also the next post in that thread, called '''Brief walk through on modifying a TRAM,''' is an example of that overview put into practice.


===Rotation order issue between Oni and Blender===
===Rotation order issue between Oni and Blender===
Line 59: Line 61:
For detailed explanation of the required OniSplit commands, please refer to the '''Oni-Blender Tutorial by EdT''' listed in the '''Tools and relevant tutorials'''.
For detailed explanation of the required OniSplit commands, please refer to the '''Oni-Blender Tutorial by EdT''' listed in the '''Tools and relevant tutorials'''.


[[Image:ARB SceneUponImportingKonokos.png|400px|right|thumb|Expected result at point 9]]
[[Image:ARB SceneUponImportingKonokos.png|400px|right|thumb|Expected result by the end of this header]]


# Using OniSplit, export any character you want as a DAE (-extract:dae) using -noanim and -blender arguments.  
# Using OniSplit, export any character you want as a DAE (-extract:dae) using -noanim and -blender arguments.  
Line 73: Line 75:
## Move the T-Posed model to ''T-pose'', and move ''.001'' and ''.002'' animated models to ''Pose 1'' and ''Pose 2'' collections respectively.
## Move the T-Posed model to ''T-pose'', and move ''.001'' and ''.002'' animated models to ''Pose 1'' and ''Pose 2'' collections respectively.
# If you've imported the textured model, [https://wiki.oni2.net/Creating_an_animation_rig_in_Blender#Broken_alpha_transparency_and_textures_on_animated_models apply textures to the animated models and fix the alpha transparency issue.]
# If you've imported the textured model, [https://wiki.oni2.net/Creating_an_animation_rig_in_Blender#Broken_alpha_transparency_and_textures_on_animated_models apply textures to the animated models and fix the alpha transparency issue.]
# At this point, your scene should look like in the screenshot on the right.
# At this point, your scene should look as shown in the screenshot on the right.
# You can hide the Pose 1 and Pose 2 collections - they won't be needed until later in the tutorial.
 
==Adjusting T-posed model's Z location==
At this moment the T-posed model is sunk to the ground. That's because the pelvis location is set to 0,0,0. All of the animations in Oni have their heights adjusted [https://wiki.oni2.net/XML:TRAM#List_of_tags.2C_types.2C_and_flags (through the <Height> tags)] so that the pelvis is roughly at Z ~ 0.9, so that the characters appear standing on the floor instead of, again, sinking into it. For this reason, we want to adjust the position of the pelvis so that the feet soles are aligned with the floor.
 
[[Image:PelvisZLocation.png|400px|right|thumb|Expected result by the end of this header]]
 
# <li value="10">Adjust the Z position of the T-posed model's Pelvis in one of the two ways:</li>
## Simply switch to Front Ortographic view (Num 1) and move the Pelvis along the Z axis so that the feet soles are roughly aligned with the floor. This will work, but if you want 100% accuracy, use the method below.
## The 3D Cursor method:
### Select one of the feet in Object mode.
### Switch to Edit mode.
### Select one of the lowest-reaching vertices on the foot and Snap Cursor to Active. (Shift + S, 3)
### Switch back to object mode.
### Select the Pelvis.
### Snap Selection to Cursor. (Shift+S, 8)
### Set the X and Y locations of the pelvis to 0.
### Invert the Z location of the pelvis.
### The pelvis should be now at Z ~ 0.9 with feet soles perfectly aligned with the floor.
# At this point, your scene should look as shown in the screenshot on the right.
 
==Creating the Rigify metarig and adding limb flexion==
This part describes how to create a Rigify metarig and how to adjust it so that it matches the T-posed model body parts.
 
# <li value="12">Before you proceed to create the rig, you need to add small rotations to the limbs, which will allow Rigify to know in which direction the elbows and knees are going to bend. Otherwise, the rig will not function properly.</li>
## Add the following Z rotations to the respective body parts in accordance with the list below:
 
{| class="wikitable"
|-
! Z rotation !! Bones
|-
| -5 || <ul><li>right_thigh <li>left_thigh <li></ul>
|-
| -10 || <ul><li>right_calf <li>left_calf <li>right_wrist <li>left_wrist </ul>
|-
| 5 || <ul><li>right_biceps <li>left_biceps <li> right_handfist <li>left_handfist <li>right_foot <li>left_foot</ul>
|}
 
# <li value="13">Enable Rigify in Blender if you haven't already - you can do that by going to Edit / Preferences / Addons and looking it up, as Rigify comes with by Blender by default.</li>
# Add a Basic Human Metarig  to the scene. ( Add Menu / Armature / Basic / Basic Human (Meta-Rig) )
## Scale the rig by 10 or so that it's roughly the size of the character.
## Apply the scale. ( Object / Apply / Scale )
# Go to Metarig's Object Data Properties tab and:
## Open Viewport Display,
## Check "In Front" box to make the metarig easier to select when your Viewport is in Solid or Material Preview shading modes,
## Check the Axes box to see the local axes of each bones - this makes their rolls easier to understand.
# Remove the following bones from the Metarig:
*pelvis.L
*pelvis.R
*breast.L
*breast.R
*spine.005
*spine.006
# <li value="17">Go to Edit mode, select Bone Properties tab and change the ''Connected'' box of the following Metarig's bones accordingly to the below table:</li>
 
{| class="wikitable"
|-
! Bone || Connected
|-
| spine.003 || Disable
|-
| spine.004 || Enable
|-
| shoulder.l || Enable
|-
| shoulder.r || Enable
|}
 
# <li value="18">The default Rigify bone layer order is highly unergonomic. For this reason, reassign the following bones to bone layers in accordance with the table below. You can reassign bones' bone layers by selecting them and pressing M. Make sure you have enabled User Tooltips in Preferences / Interface - that way when you move your cursor over the layer box, a tooltip will display the layer number.</li>
 
{| class="wikitable"
|-
! Bones !! Bone layer
|-
| <ul><li>spine <li>spine.001 <li>spine.002 <li>spine.003 <li>spine.004 <li>shoulder.l <li>shoulder.r </ul> || 8
|-
| <ul><li>upper_arm.L <li>forearm.L <li>hand.L </ul> || 0
|-
| <ul><li>upper_arm.R <li>forearm.R <li>hand.R </ul> || 16
|-
| <ul><li>thigh.L <li>shin.L <li>foot.L <li>toe.L <li>heel.02.L </ul> || 4
|-
| <ul><li>thigh.R <li>shin.R <li>foot.R <li>toe.R <li>heel.02.R </ul> || 20
|}
 
# <li value="19">Go to Pose mode, select Bone Properties tab and open the Rigify Type box.</li>
# Set ''Limb Segments'' and ''B-Bone Segments'' to 1 on the bones listed below. Because Oni uses rigid body parts, Limb Segments and Bendy bones are not needed.
* upper_arm.L
* upper_arm.R
* thigh.L
* thigh.R
 
# <li value="20"> Disable ''Assign Tweak Layers'' checkbox on the bones listed below.</li>
* upper_arm.L
* upper_arm.R
* thigh.L
* thigh.R
* spine
 
# <li value="21"> Remove ''rig type'' on the ''spine.004'' bone.</li>
# Enable the ''Connect chain'' checkbox on the ''spine.003'' bone.
# Disable the ''Widget'' checkbox on ''shoulder.L'' and ''shoulder.R bones''.
# Set ''pivot_position'' on the ''spine'' bone to 1.
# Enable the ''Custom Pivot Control'' checkbox on the ''spine'' bone.
# Assign Tweak Layer of spine.003 to 9.
# Assign FK layers for the following bones in accordance with the table below:
 
{| class="wikitable"
|-
! Bones !! Bone layer
|-
| <ul><li>spine <li>spine.003</ul> || 9
|-
| upper_arm.L || 1
|-
| upper_arm.R || 17
|-
| thigh.L </ul> || 5
|-
| thigh.R </ul> || 21
|}
 
# <li value="26>Now you need to adjust metarig's bones so that they match up with character body parts. In order to reduce the amount of needed work, switch to Edit Mode and check the X-Axis Mirror either in Options or the Tool tab.</li>
# Switch to Object mode and using the Snapping Cursor to Active, and Snapping Selection to Cursor in the Snap menu (Shift + S), keep snapping cursor to model's body parts, selecting the Metarig, switching to Edit mode, selecting the appropriate bone and snapping it to 3D Cursor. '''I believe it is intuitive which bones should be snapped to which body parts, therefore there is no need for a table describing that, with the exception of hints on what should be done about spine.004, hand.L, hand.R, toe.L, toe.R, heel.02.L and heel.02.R.'''
## There is actually nothing you need to do about the heel bones, leave them as they are.
## Snap the tails of spine.004, hand.L and hand.R to their heads and move them along the axis they're pointing at, to some whatever point that makes sense to you, e.g. furthest reaching vertex on the hand. No need to be precise here, and thus snapping - just move the tail so that it is roughly where you want it to be.
## In order to keep the toe bones aligned and properly positioned, do the following for each toe bone:
### Select the foot in object mode,
### Snap cursor to the furthest and lowest reaching vertex on the foot,
### Copy the X location of that vertex,
### Snap the bone to cursor,
### Paste the X location to the bone's head,
### Snap bone's tail to the head,
### Move the head along the Y axis by some amount will make it easy to select but not too big.
# In edit mode, set the following rolls for the Metarig bones as described below:
## shoulder.L, 90 degrees,
## shoulder.R, -90 degrees,
## ''All'' other bones, 0 degrees.


[[Category:Modding tutorials]]
[[Category:Modding tutorials]]
191

edits