示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (!isCalibrated)
        {
            if (UDPScript.IsDataReady(UPPER_ARM_R_ID))
            {
                orig         = Quaternion.Euler(UDPScript.GetRoll(UPPER_ARM_R_ID), UDPScript.GetYaw(UPPER_ARM_R_ID), UDPScript.GetPitch(UPPER_ARM_R_ID));
                isCalibrated = true;
            }
            return;
        }


        if (Time.fixedTime >= timeToGo)
        {
            //transform.rotation = Quaternion.Euler(offset.x - UDPScript.GetRoll(UPPER_ARM_R_ID), offset.y + UDPScript.GetYaw(UPPER_ARM_R_ID),
            //    offset.z + UDPScript.GetPitch(UPPER_ARM_R_ID));

            //Quaternion q = Quaternion.Euler(offset.x - UDPScript.GetRoll(UPPER_ARM_R_ID), offset.y + UDPScript.GetYaw(UPPER_ARM_R_ID),
            //    offset.z + UDPScript.GetPitch(UPPER_ARM_R_ID));
            //transform.localRotation = Quaternion.Inverse(transform.parent.rotation) * q;


            Quaternion q = Quaternion.Euler(-UDPScript.GetRoll(UPPER_ARM_R_ID), UDPScript.GetYaw(UPPER_ARM_R_ID), UDPScript.GetPitch(UPPER_ARM_R_ID));
            transform.rotation = Quaternion.Inverse(orig) * q * offset;

            timeToGo = Time.fixedTime + 0.1f;
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (!isCalibrated)
        {
            if (UDPScript.IsDataReady(LOWER_ARM_R_ID))
            {
                orig         = Quaternion.Euler(UDPScript.GetRoll(LOWER_ARM_R_ID), UDPScript.GetYaw(LOWER_ARM_R_ID), UDPScript.GetPitch(LOWER_ARM_R_ID));
                isCalibrated = true;
            }
            return;
        }


        if (Time.fixedTime >= timeToGo)
        {
            Quaternion q = Quaternion.Euler(-UDPScript.GetRoll(LOWER_ARM_R_ID), UDPScript.GetYaw(LOWER_ARM_R_ID), UDPScript.GetPitch(LOWER_ARM_R_ID));
            transform.rotation = Quaternion.Inverse(orig) * q * offset;

            timeToGo = Time.fixedTime + 0.1f;
        }
    }