Ejemplo n.º 1
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>
        protected void ObtainBones()
        {
            m_bones.Clear();
            foreach (MyModelBone bone in Model.Bones)
            {
                Matrix boneTransform = bone.Transform;

                // Create the bone object and add to the heirarchy
                MyCharacterBone newBone = new MyCharacterBone(bone.Name, boneTransform, bone.Parent != -1 ? m_bones[bone.Parent] : null);

                // Add to the bones for this model
                m_bones.Add(newBone);
            }
        }
Ejemplo n.º 2
0
        /// <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 MyCharacterBone(string name, Matrix bindTransform, MyCharacterBone parent)
        {
            this.Name = name;
            this.m_parent = parent;
            this.m_bindTransform = bindTransform;
            this.m_bindTransformInv = Matrix.Invert(bindTransform);
            this.m_bindRotationInv = Quaternion.CreateFromRotationMatrix(m_bindTransformInv); 
            this.m_children = new List<MyCharacterBone>();
            if (this.m_parent != null) this.m_parent.AddChild(this);

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

            ComputeAbsoluteTransform();

            SkinTransform = Matrix.Invert(AbsoluteTransform);
        }
Ejemplo n.º 3
0
 internal void AddChild(MyCharacterBone child)
 {
     m_children.Add(child);
 }
Ejemplo n.º 4
0
 internal void AddChild(MyCharacterBone child)
 {
     m_children.Add(child);
 }