Esempio n. 1
0
    private Vector3 GetVRMAngleFromIndexAngle(int index, Vector3 angle)
    {
        var refmax       = indexHandReferences_Paper[index];
        var refmin       = indexHandReferences_Rock[index];
        var vrmmax       = vrmHandReferences_Paper[index];
        var vrmmin       = vrmHandReferences_Rock[index];
        var calcrefmax   = new Vector3(refmax.x > 180 ? refmax.x - 360 : refmax.x, refmax.y > 180 ? refmax.y - 360 : refmax.y, refmax.z > 180 ? refmax.z - 360 : refmax.z);
        var calcrefmin   = new Vector3(refmin.x > 180 ? refmin.x - 360 : refmin.x, refmin.y > 180 ? refmin.y - 360 : refmin.y, refmin.z > 180 ? refmin.z - 360 : refmin.z);
        var calcvrmmax   = new Vector3(vrmmax.x > 180 ? vrmmax.x - 360 : vrmmax.x, vrmmax.y > 180 ? vrmmax.y - 360 : vrmmax.y, vrmmax.z > 180 ? vrmmax.z - 360 : vrmmax.z);
        var calcvrmmin   = new Vector3(vrmmin.x > 180 ? vrmmin.x - 360 : vrmmin.x, vrmmin.y > 180 ? vrmmin.y - 360 : vrmmin.y, vrmmin.z > 180 ? vrmmin.z - 360 : vrmmin.z);
        var calcangle    = new Vector3(angle.x > 180 ? angle.x - 360 : angle.x, angle.y > 180 ? angle.y - 360 : angle.y, angle.z > 180 ? angle.z - 360 : angle.z);
        var ratio3       = GetRatio3(calcangle, calcrefmin, calcrefmax);
        var value3       = GetValueFromRatio3(ratio3, calcvrmmin, calcvrmmax);
        int onehandCount = indexHandReferences_Paper.Length / 2;

        if (index < 12 || (index >= onehandCount && index < 27)) //小指~人差し指
        {
            return(value3);
        }
        else //親指
        {
            var angleRef = new Vector3[] { new Vector3(0.0f, 0.0f, 1.0f), new Vector3(38f, 38f, -15f), new Vector3(34f, 56f, -7f) };
            int vrmeulerangle;
            int vrmeulersideangle;
            var vrmangles = new List <int> {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };
            int retindex = 0;
            if (index < onehandCount)
            {
                onehandCount = 0;
            }
            if (index == 12 || index == 12 + onehandCount) //指先
            {
                vrmeulerangle     = (int)GetValueFromRatio(ratio3.z, vrmHandReferenceEuler_Close[16], vrmHandReferenceEuler_Open[16]);
                vrmeulersideangle = 0;
                vrmangles[16]     = vrmeulerangle;
                retindex          = 12 + onehandCount;
            }
            else if (index == 13 || index == 13 + onehandCount)
            {
                vrmeulerangle     = (int)GetValueFromRatio(ratio3.z, vrmHandReferenceEuler_Close[17], vrmHandReferenceEuler_Open[17]);
                vrmeulersideangle = 0;
                vrmangles[17]     = vrmeulerangle;
                retindex          = 13 + onehandCount;
            }
            else if (index == 14 || index == 14 + onehandCount)
            {
                vrmeulerangle     = (int)GetValueFromRatio(ratio3.z, vrmHandReferenceEuler_Close[18], vrmHandReferenceEuler_Open[18]);
                vrmeulersideangle = (int)GetValueFromRatio(ratio3.y, vrmHandReferenceEuler_Close[19], vrmHandReferenceEuler_Open[19]);
                vrmangles[18]     = vrmeulerangle;
                vrmangles[19]     = vrmeulersideangle;
                retindex          = 14 + onehandCount;
            }
            var handEulerAngles = handController.CalcHandEulerAngles(vrmangles);
            if (handEulerAngles == null)
            {
                return(Vector3.zero);
            }
            return(handEulerAngles[retindex]);
        }
    }