コード例 #1
0
 /// <summary>
 /// Assign this bone to the correct bone in the model
 /// </summary>
 /// <param name="model"></param>
 public void SetModel(SkinnedRModelInstance model)
 {
     // Find this bone
     assignedBone = model.FindBone(ClipBone.Name);
 }
コード例 #2
0
ファイル: Bone.cs プロジェクト: scotttorgeson/HeroesOfRock
        /// <summary>
        /// Constructor for a bone object
        /// </summary>
        /// <param name="name">The name of the bone</param>
        /// <param name="bindTransform">The initial bind transform for the bone</param>
        /// <param name="parent">A parent for this bone</param>
        public Bone(string name, Matrix bindTransform, Bone parent)
        {
            this.Name = name;
            this.parent = parent;
            if (parent != null)
                parent.children.Add(this);

            // I am not supporting scaling in animation in this
            // example, so I extract the bind scaling from the
            // bind transform and save it.

            this.bindScale = new Vector3(bindTransform.Right.Length(),
                bindTransform.Up.Length(), bindTransform.Backward.Length());
            Matrix.CreateScale(ref bindScale, out _scaleMatrix);

            bindTransform.Right = bindTransform.Right / bindScale.X;
            bindTransform.Up = bindTransform.Up / bindScale.Y;
            bindTransform.Backward = bindTransform.Backward / bindScale.Y;
            this.bindTransform = bindTransform;

            // Set the skinning bind transform
            // That is the inverse of the absolute transform in the bind pose

            ComputeAbsoluteTransform();
            SkinTransform = Matrix.Invert(AbsoluteTransform);
        }
コード例 #3
0
        /// <summary>
        /// Get the bones from the model and create a bone class object for
        /// each bone. We use our bone class to do the real animated bone work.
        /// </summary>
        private void ObtainBones()
        {
            ModelBoneCollection modelBones = model.Model.Bones;
            bones = new Bone[modelBones.Count];
            for (int i = 0; i < modelBones.Count; i++)
                bones[i] = new Bone(modelBones[i].Name, modelBones[i].Transform, modelBones[i].Parent != null ? bones[modelBones[i].Parent.Index] : null);

            boneTransforms = new Matrix[Bones.Length];
            skeleton = new Matrix[((SkinnedRModel)model).modelExtra.Skeleton.Count];
            bonesNeedUpdating = true;
        }