C# Класс Axiom.Animating.Skeleton

A collection of Bone objects used to animate a skinned mesh.
Skeletal animation works by having a collection of 'bones' which are actually just joints with a position and orientation, arranged in a tree structure. For example, the wrist joint is a child of the elbow joint, which in turn is a child of the shoulder joint. Rotating the shoulder automatically moves the elbow and wrist as well due to this hierarchy.

So how does this animate a mesh? Well every vertex in a mesh is assigned to one or more bones which affects it's position when the bone is moved. If a vertex is assigned to more than one bone, then weights must be assigned to determine how much each bone affects the vertex (actually a weight of 1.0 is used for single bone assignments). Weighted vertex assignments are especially useful around the joints themselves to avoid 'pinching' of the mesh in this region.

Therefore by moving the skeleton using preset animations, we can animate the mesh. The advantage of using skeletal animation is that you store less animation data, especially as vertex counts increase. In addition, you are able to blend multiple animations together (e.g. walking and looking around, running and shooting) and provide smooth transitions between animations without incurring as much of an overhead as would be involved if you did this on the core vertex data.

Skeleton definitions are loaded from datafiles, namely the .xsf file format. They are loaded on demand, especially when referenced by a Mesh.

Наследование: Axiom.Core.Resource
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
animationList Axiom.Collections.AnimationCollection
attachmentPoints List
boneList BoneCollection
namedBoneList AxiomCollection
rootBones BoneList

Открытые методы

Метод Описание
ContainsAnimation ( string name ) : bool
ContainsBone ( string name ) : bool

Checks to see if a bone exists

CreateAnimation ( string name, float length ) : Animation

Creates a new Animation object for animating this skeleton.

CreateAttachmentPoint ( string name, ushort parentHandle, Axiom.MathLib.Quaternion rotation, Vector3 translation ) : AttachmentPoint

TODO: should this replace an existing attachment point with the same name?

CreateBone ( ) : Bone

Creates a brand new Bone owned by this Skeleton.

This method creates an unattached new Bone for this skeleton. Unless this is to be the root bone (there must only be one of these), you must attach it to another Bone in the skeleton using addChild for it to be any use. For this reason you will likely be better off creating child bones using the Bone.CreateChild method instead, once you have created the root bone.

Note that this method automatically generates a handle for the bone, which you can retrieve using Bone.Handle. If you wish the new Bone to have a specific handle, use the alternate form of this method which takes a handle as a parameter, although you should note the restrictions.

CreateBone ( string name ) : Bone

Creates a brand new Bone owned by this Skeleton.

This method creates an unattached new Bone for this skeleton. Unless this is to be the root bone (there must only be one of these), you must attach it to another Bone in the skeleton using addChild for it to be any use. For this reason you will likely be better off creating child bones using the Bone.CreateChild method instead, once you have created the root bone.

CreateBone ( string name, ushort handle ) : Bone

Creates a brand new Bone owned by this Skeleton.

CreateBone ( ushort handle ) : Bone

Creates a brand new Bone owned by this Skeleton.

DumpContents ( string fileName ) : void

GetAnimation ( string name ) : Animation

Returns the animation with the specified name.

GetBone ( string name ) : Bone

Gets a bone by its name.

GetBone ( ushort handle ) : Bone

Gets a bone by its handle.

GetRootBone ( int index ) : Bone

Gets the root bone at the specified index.

InitAnimationState ( Axiom.Animating.AnimationStateSet animSet ) : void

Initialize an animation set suitable for use with this mesh.

Only recommended for use inside the engine, not by applications.

RemoveAnimation ( string name ) : void

Removes the animation with the specified name from this skeleton.

Reset ( ) : void

Resets the position and orientation of all bones in this skeleton to their original binding position.

A skeleton is bound to a mesh in a binding pose. Bone positions are then modified from this position during animation. This method returns all the bones to their original position and orientation.

Reset ( bool resetManualBones ) : void

Resets the position and orientation of all bones in this skeleton to their original binding position.

A skeleton is bound to a mesh in a binding pose. Bone positions are then modified from this position during animation. This method returns all the bones to their original position and orientation.

SetAnimationState ( Axiom.Animating.AnimationStateSet animSet ) : void

SetBindingPose ( ) : void

Sets the current position / orientation to be the 'binding pose' ie the layout in which bones were originally bound to a mesh.

Skeleton ( ResourceManager parent, String name, System.UInt64 handle, string group ) : System

Constructor, don't call directly, use SkeletonManager.

On creation, a Skeleton has a no bones, you should create them and link them together appropriately.

Skeleton ( ResourceManager parent, String name, System.UInt64 handle, string group, bool isManual, IManualResourceLoader loader ) : System

Constructor, don't call directly, use SkeletonManager.

On creation, a Skeleton has a no bones, you should create them and link them together appropriately.

UpdateTransforms ( ) : void

Updates all the derived transforms in the skeleton.

Защищенные методы

Метод Описание
DeriveRootBone ( ) : void

Internal method which parses the bones to derive the root bone.

load ( ) : void

Generic load, called by SkeletonManager.

unload ( ) : void

Generic unload, called by SkeletonManager.

Приватные методы

Метод Описание
GetBoneMatrices ( Axiom.MathLib.Matrix4 matrices ) : void

Populates the passed in array with the bone matrices based on the current position.

Internal use only. The array passed in must be at least as large as the number of bones. Assumes animation has already been updated.

Skeleton ( ) : System

Описание методов

ContainsAnimation() публичный Метод

public ContainsAnimation ( string name ) : bool
name string
Результат bool

ContainsBone() публичный Метод

Checks to see if a bone exists
public ContainsBone ( string name ) : bool
name string Name of the bone to check.
Результат bool

CreateAnimation() публичный Метод

Creates a new Animation object for animating this skeleton.
public CreateAnimation ( string name, float length ) : Animation
name string The name of this animation
length float The length of the animation in seconds
Результат Animation

CreateAttachmentPoint() публичный Метод

TODO: should this replace an existing attachment point with the same name?
public CreateAttachmentPoint ( string name, ushort parentHandle, Axiom.MathLib.Quaternion rotation, Vector3 translation ) : AttachmentPoint
name string
parentHandle ushort
rotation Axiom.MathLib.Quaternion
translation Vector3
Результат AttachmentPoint

CreateBone() публичный Метод

Creates a brand new Bone owned by this Skeleton.
This method creates an unattached new Bone for this skeleton. Unless this is to be the root bone (there must only be one of these), you must attach it to another Bone in the skeleton using addChild for it to be any use. For this reason you will likely be better off creating child bones using the Bone.CreateChild method instead, once you have created the root bone.

Note that this method automatically generates a handle for the bone, which you can retrieve using Bone.Handle. If you wish the new Bone to have a specific handle, use the alternate form of this method which takes a handle as a parameter, although you should note the restrictions.

public CreateBone ( ) : Bone
Результат Bone

CreateBone() публичный Метод

Creates a brand new Bone owned by this Skeleton.
This method creates an unattached new Bone for this skeleton. Unless this is to be the root bone (there must only be one of these), you must attach it to another Bone in the skeleton using addChild for it to be any use. For this reason you will likely be better off creating child bones using the Bone.CreateChild method instead, once you have created the root bone.
public CreateBone ( string name ) : Bone
name string /// The name to give to this new bone - must be unique within this skeleton. /// Note that the way the engine looks up bones is via a numeric handle, so if you name a /// Bone this way it will be given an automatic sequential handle. The name is just /// for your convenience, although it is recommended that you only use the handle to /// retrieve the bone in performance-critical code. ///
Результат Bone

CreateBone() публичный Метод

Creates a brand new Bone owned by this Skeleton.
public CreateBone ( string name, ushort handle ) : Bone
name string /// The name to give to this new bone - must be unique within this skeleton. /// Note that the way the engine looks up bones is via a numeric handle, so if you name a /// Bone this way it will be given an automatic sequential handle. The name is just /// for your convenience, although it is recommended that you only use the handle to /// retrieve the bone in performance-critical code. ///
handle ushort /// The handle to give to this new bone - must be unique within this skeleton. /// You should also ensure that all bone handles are eventually contiguous (this is to simplify /// their compilation into an indexed array of transformation matrices). For this reason /// it is advised that you use the simpler createBone method which automatically assigns a /// sequential handle starting from 0. ///
Результат Bone

CreateBone() публичный Метод

Creates a brand new Bone owned by this Skeleton.
public CreateBone ( ushort handle ) : Bone
handle ushort /// The handle to give to this new bone - must be unique within this skeleton. /// You should also ensure that all bone handles are eventually contiguous (this is to simplify /// their compilation into an indexed array of transformation matrices). For this reason /// it is advised that you use the simpler createBone method which automatically assigns a /// sequential handle starting from 0. ///
Результат Bone

DeriveRootBone() защищенный Метод

Internal method which parses the bones to derive the root bone.
protected DeriveRootBone ( ) : void
Результат void

DumpContents() публичный Метод

public DumpContents ( string fileName ) : void
fileName string
Результат void

GetAnimation() публичный Метод

Returns the animation with the specified name.
public GetAnimation ( string name ) : Animation
name string Name of the animation to retrieve.
Результат Animation

GetBone() публичный Метод

Gets a bone by its name.
public GetBone ( string name ) : Bone
name string Name of the bone to retrieve.
Результат Bone

GetBone() публичный Метод

Gets a bone by its handle.
public GetBone ( ushort handle ) : Bone
handle ushort Handle of the bone to retrieve.
Результат Bone

GetRootBone() публичный Метод

Gets the root bone at the specified index.
public GetRootBone ( int index ) : Bone
index int Index of the root bone to return.
Результат Bone

InitAnimationState() публичный Метод

Initialize an animation set suitable for use with this mesh.
Only recommended for use inside the engine, not by applications.
public InitAnimationState ( Axiom.Animating.AnimationStateSet animSet ) : void
animSet Axiom.Animating.AnimationStateSet
Результат void

RemoveAnimation() публичный Метод

Removes the animation with the specified name from this skeleton.
public RemoveAnimation ( string name ) : void
name string Name of the animation to remove.
Результат void

Reset() публичный Метод

Resets the position and orientation of all bones in this skeleton to their original binding position.
A skeleton is bound to a mesh in a binding pose. Bone positions are then modified from this position during animation. This method returns all the bones to their original position and orientation.
public Reset ( ) : void
Результат void

Reset() публичный Метод

Resets the position and orientation of all bones in this skeleton to their original binding position.
A skeleton is bound to a mesh in a binding pose. Bone positions are then modified from this position during animation. This method returns all the bones to their original position and orientation.
public Reset ( bool resetManualBones ) : void
resetManualBones bool
Результат void

SetAnimationState() публичный Метод

public SetAnimationState ( Axiom.Animating.AnimationStateSet animSet ) : void
animSet Axiom.Animating.AnimationStateSet
Результат void

SetBindingPose() публичный Метод

Sets the current position / orientation to be the 'binding pose' ie the layout in which bones were originally bound to a mesh.
public SetBindingPose ( ) : void
Результат void

Skeleton() публичный Метод

Constructor, don't call directly, use SkeletonManager.
On creation, a Skeleton has a no bones, you should create them and link them together appropriately.
public Skeleton ( ResourceManager parent, String name, System.UInt64 handle, string group ) : System
parent Axiom.Core.ResourceManager
name String
handle System.UInt64
group string
Результат System

Skeleton() публичный Метод

Constructor, don't call directly, use SkeletonManager.
On creation, a Skeleton has a no bones, you should create them and link them together appropriately.
public Skeleton ( ResourceManager parent, String name, System.UInt64 handle, string group, bool isManual, IManualResourceLoader loader ) : System
parent Axiom.Core.ResourceManager
name String
handle System.UInt64
group string
isManual bool
loader IManualResourceLoader
Результат System

UpdateTransforms() публичный Метод

Updates all the derived transforms in the skeleton.
public UpdateTransforms ( ) : void
Результат void

load() защищенный Метод

Generic load, called by SkeletonManager.
protected load ( ) : void
Результат void

unload() защищенный Метод

Generic unload, called by SkeletonManager.
protected unload ( ) : void
Результат void

Описание свойств

animationList защищенное свойство

Lookup table for animations related to this skeleton.
protected AnimationCollection,Axiom.Collections animationList
Результат Axiom.Collections.AnimationCollection

attachmentPoints защищенное свойство

Internal list of bones attached to this skeleton, indexed by handle.
protected List attachmentPoints
Результат List

boneList защищенное свойство

Internal list of bones attached to this skeleton, indexed by handle.
protected BoneCollection boneList
Результат BoneCollection

namedBoneList защищенное свойство

Internal list of bones attached to this skeleton, indexed by name.
protected AxiomCollection namedBoneList
Результат AxiomCollection

rootBones защищенное свойство

Reference to the root bone of this skeleton.
protected BoneList rootBones
Результат BoneList