Example #1
0
    private void Start()
    {
        addTwoBoneIK();

        if (false)
        {
            int arms = Random.Range(2, 6);
            for (int j = 0; j < arms; j++)
            {
                int joints = Random.Range(2, 6);

                int fork = Random.Range(1, joints - 1);

                for (int i = 0; i < joints; i++)
                {
                    DEBUG_newestBone = DEBUG_newestBone.addBone("bone_" + "_" + j + "." + i, Random.Range(0.2f, 0.8f), Random.Range(0.1f, 0.3f), Random.Range(0.1f, 0.3f));

                    //IKBone[] bones = this.gameObject.GetComponentsInChildren<IKBone>();
                    //int r = Random.Range(0, bones.Length - 1);
                    //newestBone = bones[r];
                }

                for (int b = 0; b < fork; b++)
                {
                    DEBUG_newestBone =
                        DEBUG_newestBone.parentBone;
                }
            }
        }
    }
Example #2
0
    public IKSolverCircleIntersection(string name, IKBone chainRoot, IKBone targetRoot) : base(name, chainRoot, targetRoot)
    {
        bones = new List <IKBone>();

        IKBone previous = chainRoot;

        for (int i = 0; i < 10; i++)
        {
            IKBone newbone = previous.addBone("bone_" + i, 0.3f, 0.1f, 0.1f);
            bones.Add(newbone);
            previous = newbone;
        }
    }
Example #3
0
    public IKSolverTwoBone(string name, IKBone chainRoot, IKBone targetRoot, float length, float width, float thickness, float proportion) : base(name, chainRoot, targetRoot)
    {
        neutralDir = Vector3.right;
        hingeAxis  = Vector3.up;

        upper = chainRoot.addBone(name + "_upper", length * proportion, width * proportion, thickness * proportion);
        float proportionInv = 1.0f - proportion;

        lower = upper.addBone(name + "_lower", length * proportionInv, width * proportionInv, thickness * proportionInv);
        float maxWT = Mathf.Max(width, thickness);

        end = lower.addBone(name + "_end", maxWT * proportionInv, maxWT * proportionInv, maxWT * proportionInv);

        target = IKTarget.createTarget(name + "_target", targetRoot);
        target.transform.position = upper.getStartPointWorld() + neutralDir * (upper.length + lower.length);
    }