Ejemplo n.º 1
0
    //Creates RoboticLimb components for the mirror and IK leg, adds them to limb base servo base, then aranges the hiarchy
    void CreateRoboticLegs(List <RoboticServoMirror> servosMirror)
    {
        //Set up mirrorLimb component on the base part base
        baseMirror = servoBase.servoBase.transform;
        limbMirror = baseMirror.gameObject.AddComponent(typeof(RoboticLimbMirror)) as RoboticLimbMirror;
        limbMirror.CustomStart(this);
        limbMirror.servosMirror = servosMirror;
        limbMirror.SetLimbReference();

        limbMirror.FindEndPoint();
        //Move the Limb controller component Object into place
        transform.SetParent(baseMirror);
        transform.localPosition = Vector3.zero;
        transform.LookAt(baseMirror.up);//,vesselControl.mirrorVessel.transform.up);
        transform.rotation = Quaternion.LookRotation(baseMirror.up, vesselControl.adjustedGimbal.up);
        // transform.rotation = vesselControl.mirrorVessel.transform.rotation;
        transform.SetParent(baseMirror.parent);
        baseMirror.SetParent(transform);
        //get mirror limb groups before generating IK limb
        limbMirror.CalculateGroups();

        baseIK           = Instantiate(baseMirror).transform;
        baseMirror.name += "Mirror Arm";
        baseIK.name     += "IK Arm";
        baseIK.SetParent(transform);
        baseIK.rotation      = limbMirror.transform.rotation;
        baseIK.localPosition = Vector3.zero;
        ////Mirror leg and limb controller are in place, set reference for IK limb that was generated, then build the leg
        var mirrorLimb = baseIK.gameObject.GetComponent <RoboticLimbMirror>();

        limbIK = baseIK.gameObject.AddComponent <RoboticLimbIK>();
        limbIK.CustomStart(this);
        //  limbIK.servoWrist = mirrorLimb.servoWrist;
        //   limbIK.servoBase = mirrorLimb.servoBase;
        //limbIK.limbController = mirrorLimb.limbController;
        //  limbIK.limbEnd = mirrorLimb.limbEnd;
        Destroy(mirrorLimb);



        limbIK.ConvertToIKLimb(limbMirror);
        limbIK.SetLimbReference();


        // limbIK.FindEndPoint(false, "ik");
        limbIK.StoreGroupedServos();
    }