Example #1
0
    public SecondPassBase(IKControl parent)
    {
        PAM = parent;
        G   = parent.IKCS;

        numBones = G.i_IKparents + 1;
        bd_data  = new BoneData[numBones];

        Setup();
    }
Example #2
0
    public virtual bool Init(IKControl control, Transform p)
    {
        CONTROL = control;
        IKCS    = CONTROL.IKCS;
        BoneData[] targetBones = CONTROL.bdArr_boneData;
        if (IKControl.IsBoneDataInvalid(targetBones))
        {
            return(false);
        }
        t_target   = p;
        bdArr_data = targetBones;
        LENGTH     = bdArr_data.Length;


        // Get the axis of rotation for each joint
        rotateAxes   = new Vector3[bdArr_data.Length - 2];
        rotateAngles = new float[bdArr_data.Length - 2];
        rotations    = new Quaternion[bdArr_data.Length - 2];

        //boneLengths = new float[bones.Length - 1];

        v3bones     = new Vector3[bdArr_data.Length - 1];
        v3bonesInit = new Vector3[bdArr_data.Length - 1];
        boneLengths = new float[bdArr_data.Length - 1];

        // Set up the bones axes
        for (int i = 0; i < bdArr_data.Length - 1; i++)
        {
            v3bonesInit[i] = bdArr_data[i + 1].position - bdArr_data[i].position;
            v3bones[i]     = v3bonesInit[i];


            // Get the length of each bone
            boneLengths[i] = v3bonesInit[i].magnitude;
        }

        v3_initUp      = bdArr_data[0].parent.InverseTransformVector(bdArr_data[0].up);
        v3_initForward = bdArr_data[0].parent.InverseTransformVector(bdArr_data[0].forward);

        return(true);
    }