Avatar是什麼
Working with humanoid animations
The Mecanim Animation System is particularly well suited for working with animations for humanoid skeletons. Since humanoid skeletons are used extensively in games, Unity provides a specialized workflow, and an extended tool set for humanoid animations.Because of the similarity in bone structure, it is possible to map animations from one humanoid skeleton to another, allowing retargeting and inverse kinematics. With rare exceptions, humanoid models can be expected to have the same basic structure, representing the major articulate parts of the body, head and limbs. The Mecanim system makes good use of this idea to simplify the rigging and control of animations. A fundamental step in creating a animation is to set up a mapping between the simplified humanoid bone structure understood by Mecanim and the actual bones present in the skeleton; in Mecanim terminology, this mapping is called an Avatar. The pages in this section explain how to create an Avatar for your model.
Avatar其實就是一個映射表,記錄着動畫骨骼與真實骨骼的映射信息
public class Avatar : Object
{
private Avatar()
{
}
// Return true if this avatar is a valid mecanim avatar. It can be a generic avatar or a human avatar.
extern public bool isValid
{
[NativeMethod("IsValid")]
get;
}
// Return true if this avatar is a valid human avatar.
extern public bool isHuman
{
[NativeMethod("IsHuman")]
get;
}
extern public HumanDescription humanDescription
{
get;
}
.......
}
public struct HumanDescription
{
[NativeName("m_Human")]
public HumanBone[] human;
[NativeName("m_Skeleton")]
public SkeletonBone[] skeleton;
internal float m_ArmTwist;
internal float m_ForeArmTwist;
internal float m_UpperLegTwist;
internal float m_LegTwist;
internal float m_ArmStretch;
internal float m_LegStretch;
internal float m_FeetSpacing;
internal float m_GlobalScale;
internal string m_RootMotionBoneName;
internal bool m_HasTranslationDoF;
internal bool m_HasExtraRoot;
internal bool m_SkeletonHasParents;
public float upperArmTwist { get { return m_ArmTwist; } set { m_ArmTwist = value; } }
public float lowerArmTwist { get { return m_ForeArmTwist; } set { m_ForeArmTwist = value; } }
public float upperLegTwist { get { return m_UpperLegTwist; } set { m_UpperLegTwist = value; } }
public float lowerLegTwist { get { return m_LegTwist; } set { m_LegTwist = value; } }
public float armStretch { get { return m_ArmStretch; } set { m_ArmStretch = value; } }
public float legStretch { get { return m_LegStretch; } set { m_LegStretch = value; } }
public float feetSpacing { get { return m_FeetSpacing; } set { m_FeetSpacing = value; } }
public bool hasTranslationDoF { get { return m_HasTranslationDoF; } set { m_HasTranslationDoF = value; }}
}
HumanDescription中的HumanBone應是映射保存的地方。
Avatar的意義
Retargeting of Humanoid animations
One of the most powerful features of Mecanim is retargeting of humanoid animations. This means that with relative ease, you can apply the same set of animations to various character models. Retargeting is only possible for humanoid models, where an Avatar has been configured, because this gives us a correspondence between the models’ bone structure.
也就是說Avatar是在動畫重定向中構造出來的。Avatar用於動畫重定向技術。