Пример #1
0
 private void OnBoneParentChanged(BoneManager sender, BoneActionEventArgs e)
 {
     RigResource.RigResource.Bone parent = sender.GetParent(e.Bone);
     BoneViewModel child = mChildren.FirstOrDefault(x => x.Bone == e.Bone);
     if (parent == null)
     {
         if (child == null)
         {
             mChildren.Add(new BoneViewModel(this, this, e.Bone, sender));
         }
     }
     else
     {
         if (child != null)
         {
             mChildren.Remove(child);
         }
     }
 }
Пример #2
0
 private void OnBoneRemoved(BoneManager sender, BoneActionEventArgs e)
 {
     RigResource.RigResource.Bone parent = sender.GetParent(e.Bone);
     if (parent == null)
     {
         BoneViewModel view = mChildren.FirstOrDefault(x => x.Bone == e.Bone);
         if (view != null)
         {
             mChildren.Remove(view);
         }
     }
 }
Пример #3
0
 private void OnBoneAdded(BoneManager sender, BoneActionEventArgs e)
 {
     RigResource.RigResource.Bone parent = sender.GetParent(e.Bone);
     if (parent == null)
     {
         BoneViewModel view = mChildren.FirstOrDefault(x => x.Bone == e.Bone);
         if (view == null)
         {
             var vm = new BoneViewModel(this, this, e.Bone, sender);
             vm.Opposite = mManager.Bones.IndexOf(e.Bone);
             mChildren.Add(vm);
         }
     }
 }
Пример #4
0
 private static Matrix GetAbsoluteTransform(BoneManager manager, RigResource.RigResource.Bone b)
 {
     var transforms = new List<Matrix>();
     while (b != null)
     {
         var q = new Quaternion(b.Orientation.A, b.Orientation.B, b.Orientation.C, b.Orientation.D);
         var p = new Vector3(b.Position.X, b.Position.Y, b.Position.Z);
         var s = new Vector3(b.Scaling.X, b.Scaling.Y, b.Scaling.Z);
         Matrix t = Matrix.CreateTransformMatrix(q, s, p);
         transforms.Add(t);
         b = manager.GetParent(b);
     }
     transforms.Reverse();
     Matrix absolute = transforms[0];
     transforms.RemoveAt(0);
     while (transforms.Count > 0)
     {
         Matrix m = transforms[0];
         transforms.RemoveAt(0);
         absolute = absolute*m;
     }
     return absolute;
 }
Пример #5
0
 private void OnBoneRemoved(BoneManager sender, BoneActionEventArgs e)
 {
     RigResource.RigResource.Bone parent = sender.GetParent(e.Bone);
     if (parent != null && parent.Equals(mBone))
     {
         BoneViewModel child = mChildren.FirstOrDefault(x => x.Bone == e.Bone);
         if (child != null)
         {
             mChildren.Remove(child);
         }
     }
 }
Пример #6
0
 private void OnBoneAdded(BoneManager sender, BoneActionEventArgs e)
 {
     RigResource.RigResource.Bone parent = sender.GetParent(e.Bone);
     if (parent != null && parent.Equals(mBone))
     {
         mChildren.Add(new BoneViewModel(mRig, this, e.Bone, sender));
     }
 }
Пример #7
0
        private static void CloneHierarchy(BoneManager manager, RigResource.RigResource.Bone bone, RigResource.RigResource.Bone dest)
        {
            List<RigResource.RigResource.Bone> descendants = manager.GetDescendants(bone).ToList();
            var clones = new List<RigResource.RigResource.Bone>();
            var map = new Dictionary<RigResource.RigResource.Bone, RigResource.RigResource.Bone>();
            var root = new RigResource.RigResource.Bone(0, null, bone);
            map[bone] = root;
            manager.AddBone(root, dest);

            foreach (RigResource.RigResource.Bone descendant in descendants)
            {
                var clone = new RigResource.RigResource.Bone(0, null, descendant);
                map[descendant] = clone;
                clones.Add(clone);
                manager.AddBone(clone, manager.GetParent(descendant));
            }
            foreach (RigResource.RigResource.Bone c in clones)
            {
                RigResource.RigResource.Bone parent = manager.GetParent(c);
                if (map.ContainsKey(parent))
                {
                    manager.SetParent(c, map[parent]);
                }
            }
        }