Animation in Blender: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (updated keys)
No edit summary
 
(18 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{toc-right}}
{{toc-right}}


{{blender}} This article covers '''rigging and animating a model in [[Blender]]''' in a manner that can be exported to [[SMD]]. It assumes you are familiar with [[Blender Modelling Walkthrough|using Blender to create meshes]] and with the principles of [[wikipedia:Key frame|keyframed]] [[skeletal animation]] and [[weightmap]]ping.
This article covers '''rigging and animating a model in {{Blender|4|}} for export with the {{Blendersrctools|4|}}'''. Also, make sure to try [https://github.com/bonjorno7/SourceOps Source Ops] addon for exporting from blender to source. It assumes you are familiar with [[Blender Modelling Walkthrough|using Blender to create meshes]]. See [[Exporting a model/Blender]] for general exporting help.


{{note|Pay close attention to the case of hotkeys in articles about Blender. {{key|E}} is not the same as {{key|e}}!}}


{{tip|[http://opengameart.org/content/blender-humanoid-rig Get a free humanoid rig for Blender here.]}}
{{todo | Update information for blender 3.4}}
 
{{todo | Add blender 2.8x information along 2.7x due to the fact that not everyone uses blender 2.8}}


== Creating an armature ==
== Creating an armature ==
Line 11: Line 12:
"Armature" is Blender's term for a skeleton.
"Armature" is Blender's term for a skeleton.


# Toggle into Object Mode with {{key|Tab}}. Add an armature with {{key|Space}} > Add > Armature.
# If you aren't in {{IconLabel|File:BlenderObject.png|Object Mode}}, select it from the bar at the bottom of the 3D View.
#* To prevent the mesh hiding your bones, go to the Edit panel with {{key|F9}} and find the Armature box. Click the X-Ray button, which is in the first row.
# Add a new armature with {{key|Shift|A}} > {{IconLabel|File:BlenderObArmature.png|Armature}}.
#* Also in the Armature box, un-click the Envelopes button under Deform Options. Envelope deformations are not exported, so you don't want to confuse yourself by ever seeing them.
# To prevent the mesh hiding your bones, go to {{IconLabel|File:BlenderProperties.png|plus=File:BlenderObject.png|Object Properties}}, find the Display panel, and enable the "X-Ray" option.
# To manipulate just one end of the bone, enter Edit Mode with {{key|Tab}} and select one of its connector spheres. You can resize bones in this manner at any time from Edit Mode without it affecting the mesh.
# Enter {{IconLabel|File:BlenderEditMode.png|Edit Mode}} with {{key|Tab}}. This is where you will edit the bones in the armature.
# To add bones to the chain, use {{key|Ctrl|LMB}} in Edit Mode. The new bone will be connected to the end of the one currently selected. {{tip|To create bones symmetrically, click Edit panel > Armature > X-Axis Mirror, then use {{key|e}}.}}
#* To add bones, use {{key|Shift|A}} (add a new root), {{key|E}} (extrude from the selected bone/bones), or {{key|Ctrl|LMB}} (create a new bone where you click).
# When in Edit Mode, the selected bone can be renamed from Edit panel > Armature bones. To have Blender label bones in the 3D view for your convenience, click Edit panel > Armature > Names.
#* To move one end of a bone while leaving the other in place, select one of its connector spheres.
#* To rename a bone, go to {{IconLabel|File:BlenderProperties.png|plus=File:BlenderBone.png|Bone Properties}}. To have Blender label bones in the 3D view, go to {{IconLabel|File:BlenderProperties.png|plus=File:BlenderArmature.png|Armature Properties}}, find the Display panel and enable "Names".


== Skinning ==
== Skinning ==


In Blender, the link between mesh and bones is called a "skin". There are several ways of creating a skin, but Dvondrake's SMD exporter only supports those defined by vertex groups.
In Blender, the link between mesh and bones is called a "skin". The Blender Source Tools support three methods of creating one:
 
=== Bone parent ===
 
{{Warning | This does not work with SourceOps 0.7.0 (November 2022). This section was added in July 2011 for Blender 2.5 and has not been updated since. If you know which versions of which addon this works for, please add that information here.}}
 
If your model is made up of rigid components, you can create it as a collection of separate objects and then parent each one to a bone.
 
# Enter {{IconLabel|File:BlenderPoseMode.png|Pose Mode}} and select the bone you want.
# Select your mesh, then use {{key|Shift}} to multi-select the armature.
# Press {{key|Ctrl|P}} and choose "Bone".
 
You can also set a bone parent via the Relations panel of {{IconLabel|File:BlenderProperties.png|plus=File:BlenderObject.png|Object Properties}}.
 
=== Armature modifier ===
 
Modifiers affect objects without altering their underlying data, and the {{IconLabel|File:BlenderModArmature.png|Armature Modifier}} causes a mesh to be deformed by the pose of an armature. To add an one, select your mesh and go to {{IconLabel|File:BlenderProperties.png|plus=File:BlenderMod.png|Object Modifiers}}.
 
The armature modifier can work in one or both of the following ways:


[[File:Blender skinning results.png|frame|The changes to a mesh after it is skinned.]]
==== Envelopes ====


# Toggle into Object Mode with {{key|Tab}}. Select your mesh object, then your armature. The order is important; the text in the bottom-left of the 3D window should say "Armature". {{tip|To join several mesh objects into one, select them and press {{key|Ctrl|J}}.}}
This is the easiest way to skin an organic mesh. Each bone automatically projects an "envelope" of influence, and by repositioning them and changing their Radius a fairly good skin can be created.
# Press {{key|Ctrl|P}} to make the armature the parent of the mesh. You must choose Armature from the menu that appears.
# The next menu defines whether and in what manner Blender automates the skinning process. The options are:
#; Don't create groups
#: Blender leaves all vertex grouping to the user. Don't use this now.
#; Create groups
#: Blender creates a vertex group for each bone in the armature, but does not populate them.
#; Create from Envelopes
#: Blender populates vertex groups by examining the envelopes of each bone. Safe for export.
#; Create from Bone Heat
#: Blender populates vertex groups by calculating how close to each bone each vertex is. Results in jelly-like motion at joints.
# Blender will now add an "Armature parent deform" Modifier to the mesh, and (unless you chose "Don't create groups") add vertex groups for each bone in the armature. The armature itself will not be altered.


If you had Blender populate the vertex groups for you, you will now be able to manipulate the armature and see the mesh deform accordingly.
* To change a bone's Radius, enable Envelope display from {{IconLabel|File:BlenderProperties.png|plus=File:BlenderArmature.png|Armature Properties}} then select its connector and scale it ({{key|S}}) as you would an object.


=== Weightmapping ===
==== Weight mapping ====


[[File:Blender weight painting.png|thumb|Weight painting the upper arm of the Heavy.]]
[[File:Blender weight painting.png|thumb|Weight painting the upper arm of the Heavy.]]


Blender's automatic skinning, while helpful, is rarely satisfactory for anything but the simplest objects. To properly rig a complex model you will need to tweak its [[weightmap]].
A "weight map" defines how much influence each bone has over each vertex's position (an envelope or bone parent simply generates one for you). If a vertex is weighted 50% to two bones, then the associated bones each have 50% control over it during animation.
 
In Blender, a Mesh's weightmap is defined by {{IconLabel|File:BlenderVertexGroup.png|Vertex Groups}} with names matching bones on an associated Armature. The weightmaps of other object types cannot be directly edited.
 
 
 
 
 
'''Managing Vertex Groups:'''
 
* Blender can generate and populate vertex groups automatically: select your Mesh, then your Armature, then hit {{key|Ctrl|P}} and choose the appropriate option from underneath "Armature Deform". You can do this at any time, but if an Armature Modifier already existed remember to remove the new one from {{IconLabel|File:BlenderProperties.png|plus=File:BlenderMod.png|Object Modifiers}}!
* To create or destroy groups manually, enter {{IconLabel|File:BlenderEditMode.png|Edit Mode}} and go to the Vertex Groups panel in {{IconLabel|File:BlenderProperties.png|plus=File:BlenderMesh.png|Mesh Properties}}.
 
'''Assigning to Vertex Groups:'''
 
# Select your object and enter {{IconLabel|File:BlenderWeightPaint.png|Weight Paint}} mode.
# Choose a Vertex Group either with {{key|Shift|LMB}}, which will offer a list of nearby bones, or from the Vertex Groups panel of {{IconLabel|File:BlenderProperties.png|plus=File:BlenderMesh.png|Mesh Properties}}.
# Paint! You can control the brush settings from the Tool Shelf on the left side of the 3D View. If it isn't visible, press {{key|T}}.
#* You can also manually assign weights from the Vertex Groups panel while in {{IconLabel|File:BlenderEditMode.png|Edit Mode}}.
 
 
 
'''Solution to an unconfirmed error:'''
 
Encountered inside {{css}} [[Counter-Strike:_Source|Counter-Strike: Source]] and its VHE. Bones refuses to affect the mesh. Maybe because of a recent update? (as of 01.2018)


In Blender, a skin's weightmap is defined by vertex groups on the mesh with names matching attached bones. If a vertex is split 50% between two groups, then the associated bones each have 50% control over it during animation.
To fix this: try assigning vertex groups '''and''' weight map on the same area.


To edit a vertex group:


# Select your mesh in Object Mode, then toggle into Edit Mode with {{key|Tab}}. It will become purple all over, indicating that every vertex is selected. {{tip|If you are not in vertex selection mode, press {{key|Ctrl|Tab}}, 1.}}
{{todo|Does it happen in CS:S only?}}
# Find the Vertex Groups controls in Edit panel ({{key|F9}}) > Link and Materials. Check the tooltips for a description of each field. You can change the active group from the double-arrow button in the top left of the group. {{note|Irksomely, operations from this set of buttons are additive. To remove vertices from the group, you must select them and click Remove.}}
# To paint weight onto vertices, press {{key|Ctrl+Tab}} while in Object Mode (or just select Weight Paint from the drop-down mode list).
#* Cooler colours mean less weight. Blue = 0%, red = 100%.
#* {{key|Shift}} + {{LMB}} on the mesh to select a vertex group from that region to paint with.
#* Note the options in Edit panel > Paint, which allow you to subtract weight as well as add it, and to define the rate at which weight is applied as you paint.


== Animating ==
== Animating ==


Hit {{key|Ctrl|Left}} to enter animation view. Make sure you have the armature selected and are in Pose mode ({{key|Ctrl|Tab}}), then manipulate. Use {{key|I}} to set keyframes.
{{note|Only the animation of bones created in {{IconLabel|File:BlenderPoseMode.png|Pose Mode}} will be exported. Whole-object animation ''will not'' make it out.}}


{{tip|[http://www.moddb.com/groups/noesis-interactive/videos/animation-with-the-softimagexsi-6-mod-tool#imagebox This video is an excellent introduction to keyframe animation.] Although it was made for XSI, a lot of the principles it discusses are universal.}}
In Blender, animations are stored in {{IconLabel|File:BlenderAction.png|Actions}}. You can store any number in the same file but the UI for managing them is poor.  


To store multiple animations in one file, switch the Curve Editor from Object to Pose, then hit the arrow button to the right of the drop-down you just used. You can store any number of animations here, creating and flipping between them with the arrow button. The exporter will only look at the active pose.
* To manage Actions, install the [[Blender Source Tools]] and use the new "SMD Export" panel in {{IconLabel|File:BlenderProperties.png|plus=File:BlenderArmature.png|Armature Properties}}.
* To edit an Action, enter {{IconLabel|File:BlenderPoseMode.png|Pose Mode}}, select the bones you want to animate and use {{key|I}} to create a keyframe for the first frame of your animation. Then change to another frame with the arrow keys or {{IconLabel|File:BlenderTimeline.png|Timeline}} and create more keyframes.


{{todo|Expand this section to cover the Curve Editor in general.}}
For general help with the process of animating, see:
 
* [http://wiki.blender.org/index.php/Doc:2.5/Manual/Your_First_Animation/2.Animating_the_Gingerbread_Man#Posing The official Blender docs]
* [http://www.moddb.com/groups/noesis-interactive/videos/animation-with-the-softimagexsi-6-mod-tool#imagebox Noesis' Animation with the Softimage/XSI 6 MOD Tool video tutorial] (which mostly discusses the universal principles of keyframe animation)


== Exporting ==
== Exporting ==


To export an SMD (of any type) for a rigged model, you must select the mesh followed by the armature. Then choose File > Export > Half-Life 2 (.smd).
{{note|
Blender cannot currently associate more than one Action with an Armature, making batch exporting from busy .blend files tricky.
 
The Source Tools overcome this as best they can by supporting the export of a filtered list of all Actions in the .blend, as well as of the active Action. You can configure this from the SMD Export panel of {{IconLabel|File:BlenderProperties.png|plus=File:BlenderArmature.png|Armature Properties}} (which starts off as the last panel in the list but can be dragged higher).
}}


{{note|[[Studiomdl]] will automatically remove unused bones from the model during compile.}}
To export Actions from an Armature, select it and run the "SMD Export" operator from either:


{{note| If the bones are not in the correct position when you compile your model, make sure that the mesh center is on the root joint. This can be done by placing the 3D cursor on the root joint and pressing the "Center Cursor" button in the editing panel ({{key|F9}}) }}
* The search box ({{key|Space}})
* The SMD Export panel of {{IconLabel|File:BlenderProperties.png|plus=File:Blender Scene.png|Scene Properties}} or {{IconLabel|File:BlenderProperties.png|plus=File:BlenderArmature.png|Armature Properties}}
* The {{IconLabel|File:Blender Info.png|File > Export}} menu


[[Category:Blender]]
[[Category:Blender]]

Latest revision as of 07:00, 23 December 2023

This article covers rigging and animating a model in Blender Blender for export with the Blender Source Tools Blender Source Tools. Also, make sure to try Source Ops addon for exporting from blender to source. It assumes you are familiar with using Blender to create meshes. See Exporting a model/Blender for general exporting help.


Todo:  Update information for blender 3.4
Todo:  Add blender 2.8x information along 2.7x due to the fact that not everyone uses blender 2.8

Creating an armature

"Armature" is Blender's term for a skeleton.

  1. If you aren't in (Icon) Object Mode, select it from the bar at the bottom of the 3D View.
  2. Add a new armature with Shift+A > (Icon) Armature.
  3. To prevent the mesh hiding your bones, go to (Icon)+(Icon) Object Properties, find the Display panel, and enable the "X-Ray" option.
  4. Enter (Icon) Edit Mode with Tab . This is where you will edit the bones in the armature.
    • To add bones, use Shift+A (add a new root), E (extrude from the selected bone/bones), or Ctrl+LMB (create a new bone where you click).
    • To move one end of a bone while leaving the other in place, select one of its connector spheres.
    • To rename a bone, go to (Icon)+(Icon) Bone Properties. To have Blender label bones in the 3D view, go to (Icon)+(Icon) Armature Properties, find the Display panel and enable "Names".

Skinning

In Blender, the link between mesh and bones is called a "skin". The Blender Source Tools support three methods of creating one:

Bone parent

Warning.pngWarning: This does not work with SourceOps 0.7.0 (November 2022). This section was added in July 2011 for Blender 2.5 and has not been updated since. If you know which versions of which addon this works for, please add that information here.

If your model is made up of rigid components, you can create it as a collection of separate objects and then parent each one to a bone.

  1. Enter (Icon) Pose Mode and select the bone you want.
  2. Select your mesh, then use Shift to multi-select the armature.
  3. Press Ctrl+P and choose "Bone".

You can also set a bone parent via the Relations panel of (Icon)+(Icon) Object Properties.

Armature modifier

Modifiers affect objects without altering their underlying data, and the (Icon) Armature Modifier causes a mesh to be deformed by the pose of an armature. To add an one, select your mesh and go to (Icon)+(Icon) Object Modifiers.

The armature modifier can work in one or both of the following ways:

Envelopes

This is the easiest way to skin an organic mesh. Each bone automatically projects an "envelope" of influence, and by repositioning them and changing their Radius a fairly good skin can be created.

  • To change a bone's Radius, enable Envelope display from (Icon)+(Icon) Armature Properties then select its connector and scale it (S) as you would an object.

Weight mapping

Weight painting the upper arm of the Heavy.

A "weight map" defines how much influence each bone has over each vertex's position (an envelope or bone parent simply generates one for you). If a vertex is weighted 50% to two bones, then the associated bones each have 50% control over it during animation.

In Blender, a Mesh's weightmap is defined by (Icon) Vertex Groups with names matching bones on an associated Armature. The weightmaps of other object types cannot be directly edited.



Managing Vertex Groups:

  • Blender can generate and populate vertex groups automatically: select your Mesh, then your Armature, then hit Ctrl+P and choose the appropriate option from underneath "Armature Deform". You can do this at any time, but if an Armature Modifier already existed remember to remove the new one from (Icon)+(Icon) Object Modifiers!
  • To create or destroy groups manually, enter (Icon) Edit Mode and go to the Vertex Groups panel in (Icon)+(Icon) Mesh Properties.

Assigning to Vertex Groups:

  1. Select your object and enter (Icon) Weight Paint mode.
  2. Choose a Vertex Group either with Shift+LMB, which will offer a list of nearby bones, or from the Vertex Groups panel of (Icon)+(Icon) Mesh Properties.
  3. Paint! You can control the brush settings from the Tool Shelf on the left side of the 3D View. If it isn't visible, press T.
    • You can also manually assign weights from the Vertex Groups panel while in (Icon) Edit Mode.


Solution to an unconfirmed error:

Encountered inside Counter-Strike: Source Counter-Strike: Source and its VHE. Bones refuses to affect the mesh. Maybe because of a recent update? (as of 01.2018)

To fix this: try assigning vertex groups and weight map on the same area.


Todo: Does it happen in CS:S only?

Animating

Note.pngNote:Only the animation of bones created in (Icon) Pose Mode will be exported. Whole-object animation will not make it out.

In Blender, animations are stored in (Icon) Actions. You can store any number in the same file but the UI for managing them is poor.

  • To manage Actions, install the Blender Source Tools and use the new "SMD Export" panel in (Icon)+(Icon) Armature Properties.
  • To edit an Action, enter (Icon) Pose Mode, select the bones you want to animate and use I to create a keyframe for the first frame of your animation. Then change to another frame with the arrow keys or (Icon) Timeline and create more keyframes.

For general help with the process of animating, see:

Exporting

Note.pngNote:

Blender cannot currently associate more than one Action with an Armature, making batch exporting from busy .blend files tricky.

The Source Tools overcome this as best they can by supporting the export of a filtered list of all Actions in the .blend, as well as of the active Action. You can configure this from the SMD Export panel of (Icon)+(Icon) Armature Properties (which starts off as the last panel in the list but can be dragged higher).

To export Actions from an Armature, select it and run the "SMD Export" operator from either:

  • The search box (Space)
  • The SMD Export panel of (Icon)+(Icon) Scene Properties or (Icon)+(Icon) Armature Properties
  • The (Icon) File > Export menu