Esempio n. 1
0
    // returns hows close the state is to the specified state index
    public bool Compare(int stateIndex, Transform head, Transform leftHand, Transform rightHand)
    {
        if (ignoreHead && ignoreLeftHand && ignoreRightHand)
        {
            return(false);
        }

        bool[] ignoreItems = new bool[3];
        ignoreItems[0] = ignoreHead;
        ignoreItems[1] = ignoreLeftHand;
        ignoreItems[2] = ignoreRightHand;

        VRBodyState otherState = new VRBodyState();

        MirrorVirtualComponents(head, leftHand, rightHand);
        otherState.Capture(recordedStates[stateIndex].stateTime, virtualHead, virtualLeftHand, virtualRightHand);

        if (!recordedStates[stateIndex].CompareVectors(otherState, ignoreItems))
        {
            return(false);
        }
        else
        {
            HighlightLeftHandProgress(stateIndex);
            HighlightRightHandProgress(stateIndex);
            progress = (float)stateIndex / (float)recordedStates.Count;
            action.InterpolateToProgress(progress);
        }

        // also compare angles

        return(true);
    }
Esempio n. 2
0
 public void MirrorVisualComponents(Transform head, VRBodyState otherState)
 {
     visualHead.position              = head.position;
     visualHead.eulerAngles           = head.eulerAngles;
     visualLeftHand.localEulerAngles  = otherState.LeftHandEulerAngles;
     visualLeftHand.localPosition     = otherState.LeftHandVectorFromHead;
     visualRightHand.localEulerAngles = otherState.RightHandEulerAngles;
     visualRightHand.localPosition    = otherState.RightHandVectorFromHead;
 }
Esempio n. 3
0
    public void CaptureState(Transform head, Transform leftHand, Transform rightHand)
    {
        VRBodyState newState = new VRBodyState();

        MirrorVirtualComponents(head, leftHand, rightHand);
        newState.Capture(recordingTime, virtualHead, virtualLeftHand, virtualRightHand);
        recordedStates.Add(newState);

        PlotPoints();
    }
    public bool CompareVectors(VRBodyState otherState, bool[] ignoreItems)
    {
        float evaluation = 0f;
        int   numVectors = 0;

        for (int i = 0; i < ignoreItems.Length; ++i)
        {
            if (!ignoreItems[i])
            {
                numVectors++;
            }
        }

        if (!ignoreItems[1]) // don't ignore left hand
        {
            float distance = Vector3.Distance(LeftHandVectorFromHead, otherState.LeftHandVectorFromHead);
            if (distance <= aveVectorDifLH)
            {
                evaluation += (1 - distance / aveVectorDifLH) / numVectors;
            }
            else
            {
                return(false);
            }
        }

        if (!ignoreItems[2]) // don't ignore right hand
        {
            float distance = Vector3.Distance(RightHandVectorFromHead, otherState.RightHandVectorFromHead);
            if (distance <= aveVectorDifRH)
            {
                evaluation += (1 - distance / aveVectorDifRH) / numVectors;
            }
            else
            {
                return(false);
            }
        }

        return(true);
    }