public WRay Solve(int i)
    {
        var result = IKTool.IKSolve(joints[i], target, end, maxDeltaAngle);

        if (IKTool.Close(target.position, end.position))
        {
            Debug.Log("完成");
        }
        return(result);
    }
示例#2
0
 void ScaleChain()
 {
     for (int i = 0; i < joints.Count; i++)
     {
         var bone = joints[i].FindChild("Bone");
         bone.localPosition = new Vector3(0, 0, setting.boneLength * 0.5f + 0.5f);
         bone.localScale    = new Vector3(1, 1, setting.boneLength);
         bone.GetComponent <MeshRenderer>().enabled = !IKTool.CloseZero(bone.localScale.z);
         joints[i].localPosition = new Vector3(0, 0, i == 0 ? 0 : 1 + setting.boneLength);
         joints[i].localRotation = Quaternion.identity;
     }
     end.localPosition = new Vector3(0, 0, setting.boneLength + 0.5f + end.localScale.z * 0.5f);
     end.SetParent(joints[joints.Count - 1]);
 }
    public void Solve()
    {
        int i;

        for (i = 0; i < iteration; i++)
        {
            foreach (var joint in joints)
            {
                IKTool.IKSolve(joint, target, end, maxDeltaAngle);
            }
            //if (IKTool.Close(target.position, end.position)) { Debug.Log(i.ToString() + " 次迭代   完成"); return; }
            if (IKTool.Close(target.position, end.position))
            {
                return;
            }
        }
        //Debug.Log(i.ToString() + " 次迭代  未完成");
    }