ComputeBonePositions() public method

Computes the absolute position for all the bones in this skeleton.
public ComputeBonePositions ( Bone bone, Matrix world ) : void
bone Bone The bone to start with, should always be the ROOT bone.
world Matrix A world matrix to use in the calculation.
return void
Exemplo n.º 1
0
 /// <summary>
 /// When the skeleton changes (for example due to an animation) this
 /// method will recompute the meshes to adhere to the new skeleton positions.
 /// </summary>
 public void ReloadSkeleton()
 {
     Skeleton.ComputeBonePositions(Skeleton.RootBone, Matrix.Identity);
     SkelBones = new Matrix[Skeleton.Bones.Length];
     for (int i = 0; i < Skeleton.Bones.Length; i++)
     {
         SkelBones[i] = Skeleton.Bones[i].AbsoluteMatrix;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Clones this skeleton.
        /// </summary>
        /// <returns>A Skeleton instance with the same data as this one.</returns>
        public Skeleton Clone()
        {
            var result = new Skeleton();
            result.Name = this.Name;
            result.Bones = new Bone[Bones.Length];

            for (int i = 0; i < Bones.Length; i++){
                result.Bones[i] = Bones[i].Clone();
            }

            /** Construct tree **/
            foreach (var bone in result.Bones)
            {
                bone.Children = result.Bones.Where(x => x.ParentName == bone.Name).ToArray();
            }
            result.RootBone = result.Bones.FirstOrDefault(x => x.ParentName == "NULL");
            result.ComputeBonePositions(result.RootBone, Matrix.Identity);
            return result;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Clones this skeleton.
        /// </summary>
        /// <returns>A Skeleton instance with the same data as this one.</returns>
        public Skeleton Clone()
        {
            var result = new Skeleton();

            result.Name  = this.Name;
            result.Bones = new Bone[Bones.Length];

            for (int i = 0; i < Bones.Length; i++)
            {
                result.Bones[i] = Bones[i].Clone();
            }

            /** Construct tree **/
            foreach (var bone in result.Bones)
            {
                bone.Children = result.Bones.Where(x => x.ParentName == bone.Name).ToArray();
            }
            result.RootBone = result.Bones.FirstOrDefault(x => x.ParentName == "NULL");
            result.ComputeBonePositions(result.RootBone, Matrix.Identity);
            return(result);
        }