private ButtonState checkClick(OVRInput.Button button, OVRInput.Controller controller, string key, string eventName)
 {
     if (OVRInput.Get(button, controller))
     {
         if (clickTime[key] > 0)
         {
             return(ButtonState.Pressed); // Pressed
         }
         clickTime[key]     = Time.timeSinceLevelLoad;
         clickPosition[key] = userCamera.transform.position;
         return(ButtonState.Down); // Down
     }
     else if (clickTime[key] > 0)
     {
         Infos info = new Infos(1);
         info.Add("Duration", Time.timeSinceLevelLoad - clickTime[key]);
         VadRAnalyticsManager.RegisterEvent(eventName, clickPosition[key], filterDictionary[key], info, clickTime[key]);
         VadRLogger.debug("Event Registered: " + eventName);
         clickTime[key] = 0.0f;
         return(ButtonState.Up); // Up
     }
     else
     {
         clickTime[key] = 0.0f;
         return(ButtonState.None);
     }
 }
    //ToDo add rotation info
    public void loop()
    {
        float time = Time.time - lastTime;

        if (time > 0)
        {
            position    = userCamera.transform.position;
            velocity    = (position - lastPosition) / time;
            orientation = userCamera.transform.localRotation;
            Infos info = new Infos(8);
            info.Add("Time", time);
            info.Add("Velocity X", velocity.x);
            info.Add("Velocity Y", velocity.y);
            info.Add("Velocity Z", velocity.z);
            info.Add("Orientation X", orientation.x);
            info.Add("Orientation Y", -1 * orientation.y);
            info.Add("Orientation Z", -1 * orientation.z);
            info.Add("Orientation W", orientation.w);
            if (VadRAnalyticsManager.IsMediaActive())
            {
                VadRAnalyticsManager.RegisterEvent("vadrMedia Position", position, info);
            }
            else
            {
                VadRAnalyticsManager.RegisterEvent("vadrPosition", position, info);
            }
            lastPosition = position;
            lastTime     = Time.time;
        }
    }
Beispiel #3
0
 private void Update()
 {
     if (!VadRAnalyticsManager.IsDefaultCollectionPause())
     {
         checkAllButtons();
     }
 }
Beispiel #4
0
    private void gazeDataInMedia()
    {
        Vector3 rotation = getNormalizedRotation(userCamera.transform.rotation.eulerAngles +
                                                 VadRAnalyticsManager.GetMediaCameraOrientation());

        if (rotation.x >= -90 && rotation.x <= 90)
        {
            gazePosition.x = rotation.x; // Since registerData would multiply by -1, Not multiplying here
            gazePosition.y = rotation.y - 90;
            gazePosition.z = rotation.z;
        }
        else if (rotation.x >= 90 && rotation.x <= 180)
        {
            gazePosition.x = 180 - rotation.x; // Since registerData would multiply by -1, Inverting here
            gazePosition.y = rotation.y - 90;
            gazePosition.z = rotation.z;
        }
        else if (rotation.x >= -180 && rotation.x <= -90)
        {
            gazePosition.x = -1 * (180 + rotation.x); // Since registerData would multiply by -1, Inverting here
            gazePosition.y = rotation.y + 90;
            gazePosition.z = rotation.z;
        }
        gazePosition = getNormalizedRotation(gazePosition);
    }
 private void headsetMounted()
 {
     isHeadsetMounted = true;
     if (DataCollectionManager.Instance.pauseOnHeadsetRemoval)
     {
         VadRAnalyticsManager.PauseDefaultEventCollection(false);
         VadRAnalyticsManager.PauseTime(false);
     }
 }
    private void Update()
    {
#if VADR_GEARVR
        if (!VadRAnalyticsManager.IsDefaultCollectionPause())
        {
            checkAllButtons();
        }
#endif
    }
    /// <summary>
    /// Checks whether headset is removed even after 5 seconds. There could be false alarms
    /// </summary>
    /// <returns></returns>
    IEnumerator RegisterHeadsetRemovalEvent(float removalTime, Vector3 position)
    {
        yield return(new WaitForSeconds(5.0f));

        if (!isHeadsetMounted && !isRemovalRegistered)
        {
            isRemovalRegistered = true;
            VadRAnalyticsManager.RegisterEvent("vadrHeadset Removed", position, headsetFilter, removalTime);
        }
    }
Beispiel #8
0
 private void trackingAcquired()
 {
     if (trackingLostTime >= 0 && !VadRAnalyticsManager.IsDefaultCollectionPause())
     {
         Infos info = new Infos(1);
         info.Add("Time", Time.timeSinceLevelLoad - trackingLostTime);
         VadRAnalyticsManager.RegisterEvent("vadrRift Tracking Lost", trackingLostPos, headsetFilter, info, trackingLostTime);
         trackingLostTime = -1.0f;
     }
 }
 private void headsetUnmounted()
 {
     isHeadsetMounted    = false;
     isRemovalRegistered = false;
     StartCoroutine(RegisterHeadsetRemovalEvent(Time.timeSinceLevelLoad, userCamera.transform.position));
     if (DataCollectionManager.Instance.pauseOnHeadsetRemoval)
     {
         VadRAnalyticsManager.PauseDefaultEventCollection(true);
         VadRAnalyticsManager.PauseTime(true);
     }
 }
Beispiel #10
0
    /// <summary>
    /// Gets data like Playarea, Player Height, No. of Trackers
    /// </summary>
    /// <returns></returns>
    IEnumerator GetRiftData()
    {
        yield return(new WaitForSeconds(1.0f));

        float   height       = OVRManager.profile.eyeHeight;
        Vector3 dimension    = OVRManager.boundary.GetDimensions(OVRBoundary.BoundaryType.PlayArea);
        float   area         = dimension.x * dimension.z;
        float   trackerCount = OVRManager.tracker.count;
        Dictionary <string, float> riftMetadata = new Dictionary <string, float>
        {
            { "User Height", height },
            { "PlayArea", area },
            { "Trackers", trackerCount }
        };

        VadRAnalyticsManager.AddSessionMetadata(riftMetadata);
    }
Beispiel #11
0
 public void loop()
 {
     if (!VadRAnalyticsManager.IsMediaActive())
     {
         if (gazeDataInModel())
         {
             VadRAnalyticsManager.RegisterEvent("vadrGaze", gazePosition);
         }
     }
     else
     {
         gazeDataInMedia();
         if (VadRAnalyticsManager.IsVideoPaused())
         {
             VadRAnalyticsManager.RegisterEvent("vadrMedia Gaze", gazePosition, pauseFilter);
         }
         else
         {
             VadRAnalyticsManager.RegisterEvent("vadrMedia Gaze", gazePosition);
         }
     }
 }
    public void loop()
    {
        if (totalFrames > 0)
        {
            Vector3 position = userCamera.transform.position;
            float   fps      = fpsSum / totalFrames;
            Infos   info     = new Infos();
            info.Add("FPS", fps);
#if UNITY_ANDROID
            if (cpuUsage > 0)
            {
                info.Add("Cpu Usage", cpuUsage);
            }
            if (residentStorage >= 0 && swapStorage >= 0)
            {
                info.Add("Memory ResidentUsage", residentStorage);
                info.Add("Memory SwapUsage", swapStorage);
            }
#endif
            VadRAnalyticsManager.RegisterEvent("vadrPerformance", position, info);
            fpsSum      = 0;
            totalFrames = 0;
        }
    }
    public void loop()
    {
#if VADR_GEARVR
        if (OVRInput.GetActiveController() == OVRInput.Controller.RTrackedRemote)
        {
            orientation                   = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTrackedRemote);
            controllerPosition            = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTrackedRemote);
            controllerVelocity            = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.RTrackedRemote);
            controllerAcceleration        = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.RTrackedRemote);
            controllerAngularVelocity     = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.RTrackedRemote);
            controllerAngularAcceleration = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.RTrackedRemote);
            Infos info = new Infos(19);
            // Changing between left handed and right handed system.
            // Refer https://gamedev.stackexchange.com/questions/129204/switch-axes-and-handedness-of-a-quaternion
            info.Add("Orientation X", orientation.x);
            info.Add("Orientation Y", -1 * orientation.y);
            info.Add("Orientation Z", -1 * orientation.z);
            info.Add("Orientation W", orientation.w);
            info.Add("Position X", -1 * controllerPosition.x);
            info.Add("Position Y", controllerPosition.y);
            info.Add("Position Z", controllerPosition.z);
            info.Add("Velocity X", -1 * controllerVelocity.x);
            info.Add("Velocity Y", controllerVelocity.y);
            info.Add("Velocity Z", controllerVelocity.z);
            info.Add("Acceleration X", -1 * controllerAcceleration.x);
            info.Add("Acceleration Y", controllerAcceleration.y);
            info.Add("Acceleration Z", controllerAcceleration.z);
            info.Add("Ang Velocity X", controllerAngularVelocity.x);
            info.Add("Ang Velocity Y", -1 * controllerAngularVelocity.y);
            info.Add("Ang Velocity Z", -1 * controllerAngularVelocity.z);
            info.Add("Ang Acceleration X", controllerAngularAcceleration.x);
            info.Add("Ang Acceleration Y", -1 * controllerAngularAcceleration.y);
            info.Add("Ang Acceleration Z", -1 * controllerAngularAcceleration.z);
            VadRAnalyticsManager.RegisterEvent("vadrGearVR Controller Orientation", userCamera.transform.position, filterDictionary["RController"], info);
        }
        if (OVRInput.GetActiveController() == OVRInput.Controller.LTrackedRemote)
        {
            orientation                   = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTrackedRemote);
            controllerPosition            = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTrackedRemote);
            controllerVelocity            = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.LTrackedRemote);
            controllerAcceleration        = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.LTrackedRemote);
            controllerAngularVelocity     = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.LTrackedRemote);
            controllerAngularAcceleration = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.LTrackedRemote);
            Infos info = new Infos(19);
            // Changing between left handed and right handed system.
            // Refer https://gamedev.stackexchange.com/questions/129204/switch-axes-and-handedness-of-a-quaternion
            info.Add("Orientation X", orientation.x);
            info.Add("Orientation Y", -1 * orientation.y);
            info.Add("Orientation Z", -1 * orientation.z);
            info.Add("Orientation W", orientation.w);
            info.Add("Position X", -1 * controllerPosition.x);
            info.Add("Position Y", controllerPosition.y);
            info.Add("Position Z", controllerPosition.z);
            info.Add("Velocity X", -1 * controllerVelocity.x);
            info.Add("Velocity Y", controllerVelocity.y);
            info.Add("Velocity Z", controllerVelocity.z);
            info.Add("Acceleration X", -1 * controllerAcceleration.x);
            info.Add("Acceleration Y", controllerAcceleration.y);
            info.Add("Acceleration Z", controllerAcceleration.z);
            info.Add("Ang Velocity X", controllerAngularVelocity.x);
            info.Add("Ang Velocity Y", -1 * controllerAngularVelocity.y);
            info.Add("Ang Velocity Z", -1 * controllerAngularVelocity.z);
            info.Add("Ang Acceleration X", controllerAngularAcceleration.x);
            info.Add("Ang Acceleration Y", -1 * controllerAngularAcceleration.y);
            info.Add("Ang Acceleration Z", -1 * controllerAngularAcceleration.z);
            VadRAnalyticsManager.RegisterEvent("vadrGearVR Controller Orientation", userCamera.transform.position, filterDictionary["LController"], info);
        }
#endif
    }
Beispiel #14
0
    // Checking one object in a frame for better performance.
    IEnumerator CheckObjectTracking()
    {
        rayCastHit = new RaycastHit();
        objectHit  = Physics.Raycast(userCamera.transform.position, cameraForward,
                                     out rayCastHit, Mathf.Infinity);
        planes = GeometryUtility.CalculateFrustumPlanes(userCamera);
        for (int i = 0; i < trackObjectsMetadata.Count; i++)
        {
            if (trackObjectsMetadata[i].gameObject != null)
            {
                if (isInView(trackObjectsMetadata[i], planes) ||
                    (objectHit && isParent(rayCastHit.transform, trackObjectsMetadata[i].gameObject.transform)))
                {
                    if (isInSight(trackObjectsMetadata[i].gameObject))
                    {
                        // Assuming object is visible for more than one second for observable
                        if (Time.time - trackObjectsMetadata[i].timeVisible > 1.0f)
                        {
                            cameraForward = userCamera.transform.forward;
                            // Ray Cast in camera froward direction to see if it hit the object.
                            // If hit the object angle = 0.
                            objectAngle = 0;
                            if (objectHit && isParent(rayCastHit.transform, trackObjectsMetadata[i].gameObject.transform))
                            {
                                objectAngle = 0;
                                infoGaze    = new Infos(1);
                                filterGaze  = new Filters(1);
                                filterGaze.Add("Object", trackObjectsMetadata[i].gameObject.name);
                                infoGaze.Add("Time", Time.time - trackObjectsMetadata[i].lastCheckTime);
                                VadRLogger.debug("Object Gazed: " + trackObjectsMetadata[i].gameObject.name + (Time.time - trackObjectsMetadata[i].lastCheckTime));
                                VadRAnalyticsManager.RegisterEvent("vadrObject Gaze", rayCastHit.transform.position,
                                                                   filterGaze, infoGaze);
                            }
                            else
                            {
                                objectAngle = angleBetweenVectors(cameraForward,
                                                                  trackObjectsMetadata[i].gameObject.transform.position - userCamera.transform.position);
                            }

                            objectDistance = Vector3.Distance(userCamera.transform.position,
                                                              trackObjectsMetadata[i].gameObject.transform.position);
                            focusIndex = calculateFocus(objectAngle, objectDistance, trackObjectsMetadata[i].size);
                            if (focusIndex > 0)
                            {
                                filter = new Filters(1);
                                filter.Add("Object", trackObjectsMetadata[i].gameObject.name);
                                info = new Infos(1);
                                info.Add("Focus", focusIndex);
                                VadRAnalyticsManager.RegisterEvent("vadrObject Focus", userCamera.transform.position,
                                                                   filter, info);
                            }
                        }
                    }
                    else
                    {
                        trackObjectsMetadata[i].timeVisible = Time.time; // Resetting time if not visible
                    }
                }
                else
                {
                    trackObjectsMetadata[i].timeVisible = Time.time; // Resetting time if not visible
                }
            }
            trackObjectsMetadata[i].lastCheckTime = Time.time;
            yield return(null);
        }
    }
Beispiel #15
0
    public void loop()
    {
#if VADR_RIFT
        Infos info       = new Infos(38);
        bool  activeFlag = false;
        if (OVRInput.GetActiveController() == OVRInput.Controller.RTouch || OVRInput.GetActiveController() == OVRInput.Controller.Touch)
        {
            activeFlag                     = true;
            rOrientation                   = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);
            rControllerPosition            = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
            rControllerVelocity            = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.RTouch);
            rControllerAcceleration        = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.RTouch);
            rControllerAngularVelocity     = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.RTouch);
            rControllerAngularAcceleration = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.RTouch);
            // Changing between left handed and right handed system.
            // Refer https://gamedev.stackexchange.com/questions/129204/switch-axes-and-handedness-of-a-quaternion
            info.Add("Right Orientation X", rOrientation.x);
            info.Add("Right Orientation Y", -1 * rOrientation.y);
            info.Add("Right Orientation Z", -1 * rOrientation.z);
            info.Add("Right Orientation W", rOrientation.w);
            info.Add("Right Position X", -1 * rControllerPosition.x);
            info.Add("Right Position Y", rControllerPosition.y);
            info.Add("Right Position Z", rControllerPosition.z);
            info.Add("Right Velocity X", -1 * rControllerVelocity.x);
            info.Add("Right Velocity Y", rControllerVelocity.y);
            info.Add("Right Velocity Z", rControllerVelocity.z);
            info.Add("Right Acceleration X", -1 * rControllerAcceleration.x);
            info.Add("Right Acceleration Y", rControllerAcceleration.y);
            info.Add("Right Acceleration Z", rControllerAcceleration.z);
            info.Add("Right Ang Velocity X", rControllerAngularVelocity.x);
            info.Add("Right Ang Velocity Y", -1 * rControllerAngularVelocity.y);
            info.Add("Right Ang Velocity Z", -1 * rControllerAngularVelocity.z);
            info.Add("Right Ang Acceleration X", rControllerAngularAcceleration.x);
            info.Add("Right Ang Acceleration Y", -1 * rControllerAngularAcceleration.y);
            info.Add("Right Ang Acceleration Z", -1 * rControllerAngularAcceleration.z);
        }
        if (OVRInput.GetActiveController() == OVRInput.Controller.LTouch || OVRInput.GetActiveController() == OVRInput.Controller.Touch)
        {
            activeFlag                     = true;
            lOrientation                   = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch);
            lControllerPosition            = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch);
            lControllerVelocity            = OVRInput.GetLocalControllerVelocity(OVRInput.Controller.LTouch);
            lControllerAcceleration        = OVRInput.GetLocalControllerAcceleration(OVRInput.Controller.LTouch);
            lControllerAngularVelocity     = OVRInput.GetLocalControllerAngularVelocity(OVRInput.Controller.LTouch);
            lControllerAngularAcceleration = OVRInput.GetLocalControllerAngularAcceleration(OVRInput.Controller.LTouch);
            // Changing between left handed and right handed system.
            // Refer https://gamedev.stackexchange.com/questions/129204/switch-axes-and-handedness-of-a-quaternion
            info.Add("Left Orientation X", lOrientation.x);
            info.Add("Left Orientation Y", -1 * lOrientation.y);
            info.Add("Left Orientation Z", -1 * lOrientation.z);
            info.Add("Left Orientation W", lOrientation.w);
            info.Add("Left Position X", -1 * lControllerPosition.x);
            info.Add("Left Position Y", lControllerPosition.y);
            info.Add("Left Position Z", lControllerPosition.z);
            info.Add("Left Velocity X", -1 * lControllerVelocity.x);
            info.Add("Left Velocity Y", lControllerVelocity.y);
            info.Add("Left Velocity Z", lControllerVelocity.z);
            info.Add("Left Acceleration X", -1 * lControllerAcceleration.x);
            info.Add("Left Acceleration Y", lControllerAcceleration.y);
            info.Add("Left Acceleration Z", lControllerAcceleration.z);
            info.Add("Left Ang Velocity X", lControllerAngularVelocity.x);
            info.Add("Left Ang Velocity Y", -1 * lControllerAngularVelocity.y);
            info.Add("Left Ang Velocity Z", -1 * lControllerAngularVelocity.z);
            info.Add("Left Ang Acceleration X", lControllerAngularAcceleration.x);
            info.Add("Left Ang Acceleration Y", -1 * lControllerAngularAcceleration.y);
            info.Add("Left Ang Acceleration Z", -1 * lControllerAngularAcceleration.z);
        }
        if (activeFlag)
        {
            VadRAnalyticsManager.RegisterEvent("vadrRift Controller Orientation", userCamera.transform.position, info);
        }
#endif
    }