Example #1
0
        public CanonicalRig(Transform root, BoneMapAsset.HAnimBoneMapping[] hanimMap)
        {
            List <MappedBone> _boneMap = new List <MappedBone>();

            for (int i = 0; i < hanimMap.Length; i++)
            {
                Transform localBone = root.FindChildRecursive(hanimMap[i].src_bone);
                if (localBone == null)
                {
                    Debug.LogWarning("Couldn't find bone " + hanimMap[i].src_bone + " in " + root.name);
                    continue;
                }
                _boneMap.Add(new MappedBone(localBone, hanimMap[i].hanim_bone));
            }
            MappedBone[] res = _boneMap.ToArray();
            foreach (MappedBone m in res)
            {
                if (m.bone.parent == null)
                {
                    continue;
                }
                MappedBone parent = res.FirstOrDefault(p => p.bone == m.bone.parent);
                m.LinkParent(parent);
            }
            this.boneMap = _boneMap.ToArray();
            this.pose    = new CanonicalPose(this.boneMap, out this.partsMap);
        }
Example #2
0
 public CanonicalPose(CanonicalPose copyFrom)
 {
     this.parts = new CanonicalRepresentation.HAnimBones[copyFrom.parts.Length];
     copyFrom.parts.CopyTo(this.parts, 0);
     this.rotations = new Quaternion[copyFrom.rotations.Length];
     copyFrom.rotations.CopyTo(rotations, 0);
     this.translation = copyFrom.translation;
     this.timestamp   = copyFrom.timestamp;
 }
 public void Apply()
 {
     if (poseSource.Ready() && poseTarget.Ready())
     {
         if (poseSource != null)
         {
             CanonicalPose pose = poseSource.ExportPose();
             if (pose != null)
             {
                 poseTarget.ApplyPose(pose, bones);
             }
         }
     }
 }
Example #4
0
 public void ApplyPose(CanonicalPose p, CanonicalRepresentation.HAnimBones[] bones)
 {
     if (boneMap == null || p == null)
     {
         return;
     }
     int[] _applyMap = p.GetIdxMap(boneMap);
     for (int i = 0; i < _applyMap.Length; i++)
     {
         if (_applyMap[i] < 0 || (bones != null && !bones.Contains(boneMap[i].canonicalBoneName)))
         {
             continue;
         }
         boneMap[i].ApplyRotationFromCanonical(p.GetRotation(_applyMap[i]));
         if (boneMap[i].canonicalBoneName == CanonicalRepresentation.HAnimBones.HumanoidRoot)
         {
             boneMap[i].ApplyLocalPositionFromCanonical(p.translation);
         }
     }
 }
Example #5
0
 public static CanonicalPose Copy(CanonicalPose src)
 {
     return(new CanonicalPose(src));
 }
Example #6
0
 public CanonicalPoseSequence(string name, CanonicalRig rig)
 {
     this.name        = name;
     this.rig         = rig;
     this.poseSampler = new CanonicalPose(rig.boneMap, out partsMap);
 }
Example #7
0
 public void ApplyPose(CanonicalPose p)
 {
     ApplyPose(p, null);
 }
Example #8
0
 public CanonicalPose ExportPose()
 {
     return(CanonicalPose.Copy(this.pose));
 }