コード例 #1
0
 protected override void OnInitiate()
 {
     if (this.boneMapParent == null)
     {
         this.boneMapParent = new IKMapping.BoneMap();
     }
     if (this.boneMap1 == null)
     {
         this.boneMap1 = new IKMapping.BoneMap();
     }
     if (this.boneMap2 == null)
     {
         this.boneMap2 = new IKMapping.BoneMap();
     }
     if (this.boneMap3 == null)
     {
         this.boneMap3 = new IKMapping.BoneMap();
     }
     if (this.parentBone != null)
     {
         this.boneMapParent.Initiate(this.parentBone, this.solver);
     }
     this.boneMap1.Initiate(this.bone1, this.solver);
     this.boneMap2.Initiate(this.bone2, this.solver);
     this.boneMap3.Initiate(this.bone3, this.solver);
     this.boneMap1.SetPlane(this.boneMap1.node, this.boneMap2.node, this.boneMap3.node);
     this.boneMap2.SetPlane(this.boneMap2.node, this.boneMap3.node, this.boneMap1.node);
     if (this.parentBone != null)
     {
         this.boneMapParent.SetLocalSwingAxis(this.boneMap1);
     }
 }
コード例 #2
0
 protected override void OnInitiate()
 {
     if (this.boneMap == null)
     {
         this.boneMap = new IKMapping.BoneMap();
     }
     this.boneMap.Initiate(this.bone, this.solver);
 }
コード例 #3
0
 protected override void OnInitiate()
 {
     if (this.iterations <= 0)
     {
         this.iterations = 3;
     }
     if (this.spine == null || this.spine.Length != this.spineBones.Length)
     {
         this.spine = new IKMapping.BoneMap[this.spineBones.Length];
     }
     this.rootNodeIndex = -1;
     for (int i = 0; i < this.spineBones.Length; i++)
     {
         if (this.spine[i] == null)
         {
             this.spine[i] = new IKMapping.BoneMap();
         }
         this.spine[i].Initiate(this.spineBones[i], this.solver);
         if (this.spine[i].isNodeBone)
         {
             this.rootNodeIndex = i;
         }
     }
     if (this.leftUpperArm == null)
     {
         this.leftUpperArm = new IKMapping.BoneMap();
     }
     if (this.rightUpperArm == null)
     {
         this.rightUpperArm = new IKMapping.BoneMap();
     }
     if (this.leftThigh == null)
     {
         this.leftThigh = new IKMapping.BoneMap();
     }
     if (this.rightThigh == null)
     {
         this.rightThigh = new IKMapping.BoneMap();
     }
     this.leftUpperArm.Initiate(this.leftUpperArmBone, this.solver);
     this.rightUpperArm.Initiate(this.rightUpperArmBone, this.solver);
     this.leftThigh.Initiate(this.leftThighBone, this.solver);
     this.rightThigh.Initiate(this.rightThighBone, this.solver);
     for (int j = 0; j < this.spine.Length; j++)
     {
         this.spine[j].SetIKPosition();
     }
     this.spine[0].SetPlane(this.spine[this.rootNodeIndex].node, this.leftThigh.node, this.rightThigh.node);
     for (int k = 0; k < this.spine.Length - 1; k++)
     {
         this.spine[k].SetLength(this.spine[k + 1]);
         this.spine[k].SetLocalSwingAxis(this.spine[k + 1]);
         this.spine[k].SetLocalTwistAxis(this.leftUpperArm.transform.position - this.rightUpperArm.transform.position, this.spine[k + 1].transform.position - this.spine[k].transform.position);
     }
     this.spine[this.spine.Length - 1].SetPlane(this.spine[this.rootNodeIndex].node, this.leftUpperArm.node, this.rightUpperArm.node);
     this.spine[this.spine.Length - 1].SetLocalSwingAxis(this.leftUpperArm, this.rightUpperArm);
     this.useFABRIK = this.UseFABRIK();
 }
コード例 #4
0
ファイル: IKMappingLimb.cs プロジェクト: group8CA/AssignB5
        private void LocalSlerp(IKMapping.BoneMap boneMap, float w)
        {
            if (w * weight >= 1)
            {
                boneMap.RotateToPlane(w);
                return;
            }

            Quaternion boneMapRotation      = boneMap.GetPlaneRotation(w);
            Quaternion boneMapLocalRotation = Quaternion.Inverse(boneMap.transform.parent.rotation) * boneMapRotation;

            boneMap.transform.localRotation = Quaternion.Lerp(boneMap.transform.localRotation, boneMapLocalRotation, weight);
        }
コード例 #5
0
 public void SetLocalSwingAxis(IKMapping.BoneMap bone1, IKMapping.BoneMap bone2)
 {
     this.localSwingAxis = Quaternion.Inverse(this.transform.rotation) * (bone1.transform.position - bone2.transform.position);
 }
コード例 #6
0
 public void SetLocalSwingAxis(IKMapping.BoneMap swingTarget)
 {
     this.SetLocalSwingAxis(swingTarget, this);
 }
コード例 #7
0
 public void SetLength(IKMapping.BoneMap nextBone)
 {
     this.length = Vector3.Distance(this.transform.position, nextBone.transform.position);
 }