Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        // Figure out which hologram is focused this frame.
        GameObject oldFocusObject = FocusedObject;

        // Do a raycast into the world based on the user's
        // head position and orientation.
        var headPosition  = Camera.main.transform.position;
        var gazeDirection = Camera.main.transform.forward;

        RaycastHit hitInfo;

        if (Physics.Raycast(headPosition, gazeDirection, out hitInfo))
        {
            // If the raycast hit a hologram, use that as the focused object.
            FocusedObject = hitInfo.collider.gameObject;
        }
        else
        {
            // If the raycast did not hit a hologram, clear the focused object.
            FocusedObject = null;
        }

        // If the focused object changed this frame,
        // start detecting fresh gestures again.
        if (FocusedObject != oldFocusObject)
        {
            recognizer.CancelGestures();
            recognizer.StartCapturingGestures();
        }
    }
    void Update()
    {
        GameObject oldFocusObject = FocusedObject;

        var headPosition  = Camera.main.transform.position;
        var gazeDirection = Camera.main.transform.forward;

        RaycastHit hitInfo;

        if (Physics.Raycast(headPosition, gazeDirection, out hitInfo))
        {
            FocusedObject = hitInfo.collider.gameObject;
        }
        else
        {
            FocusedObject = null;
        }

        // If the focused object changed this frame,
        // start detecting fresh gestures again.
        if (FocusedObject != oldFocusObject)
        {
            _recognizer.CancelGestures();
            _recognizer.StartCapturingGestures();
        }
    }
Esempio n. 3
0
    void LateUpdate()
    {
        GameObject oldFocusedObject = focusedObject;

        if (HTGazeManager.Instance.Hit &&
            OverrideFocusedObject == null &&
            HTGazeManager.Instance.HitInfo.collider != null)
        {
            // If gaze hits a hologram, set the focused object to that game object.
            // Also if the caller has not decided to override the focused object.
            focusedObject = HTGazeManager.Instance.HitInfo.collider.gameObject;
        }
        else
        {
            // If our gaze doesn't hit a hologram, set the focused object to null or override focused object.
            focusedObject = OverrideFocusedObject;
        }

        if (focusedObject != oldFocusedObject)
        {
            if (oldFocusedObject != null)
            {
                oldFocusedObject.SendMessageUpwards("OnEndGaze");
#if WINDOWS_UWP
                if (dataRecorder)
                {
                    dataRecorder.QueueMessage(oldFocusedObject.name + ";OnEndGaze");
                }
#endif
                //sw.WriteLine(oldFocusedObject.name + " OnEndGaze");
            }
            if (focusedObject != null)
            {
                focusedObject.SendMessageUpwards("OnStartGaze");
#if WINDOWS_UWP
                if (dataRecorder)
                {
                    dataRecorder.QueueMessage(focusedObject.name + ";OnStartGaze");
                }
#endif
                //sw.WriteLine(oldFocusedObject.name + " OnStartGaze");
            }

            // If the currently focused object doesn't match the old focused object, cancel the current gesture.
            // Start looking for new gestures.  This is to prevent applying gestures from one hologram to another.
            gestureRecognizer.CancelGestures();
            gestureRecognizer.StartCapturingGestures();
        }
    }
Esempio n. 4
0
    private void DismissFitbox()
    {
        // Destroy the GestureRecognizer ...
        recognizer.CancelGestures();
        recognizer.StopCapturingGestures();
        recognizer.Dispose();
        recognizer = null;

        // ... show the hologram collection ...
        if (HologramCollection)
        {
            HologramCollection.SetActive(true);
            Menu.SetActive(true);

            if (MoveCollectionOnDismiss)
            {
                // Update the Hologram Collection's position so it shows up
                // where the Fitbox left off. Start with the camera's localRotation...
                camQuat = Camera.main.transform.localRotation;

                // ... ignore pitch by disabling rotation around the x axis
                camQuat.x = 0;
                camQuat.z = 0;

                // Rotate the vector and factor y back into the position
                newPosition   = camQuat * collectionStartingOffsetFromCamera;
                newPosition.y = collectionStartingOffsetFromCamera.y;

                // Position was "Local Position" so add that to where the camera is now
                cameraPosition = Camera.main.transform.position;
                HologramCollection.transform.position = cameraPosition + newPosition;

                // Rotate the Hologram Collection to face the user.
                toQuat   = Camera.main.transform.localRotation * HologramCollection.transform.rotation;
                toQuat.x = 0;
                toQuat.z = 0;
                HologramCollection.transform.rotation = toQuat;
            }
        }

        // ... and Destroy the Fitbox
        //Destroy(gameObject);
        gameObject.SetActive(false);
        GameObject.Find("Manager").GetComponent <Load>().FileNumber = 0;
    }
Esempio n. 5
0
    private void Update()
    {
        GameObject oldFocusObject = FocusedObject;

        var headPosition  = Camera.main.transform.position;
        var gazeDirection = Camera.main.transform.forward;

        RaycastHit hitInfo;

        if (Physics.Raycast(headPosition, gazeDirection, out hitInfo))
        {
            FocusedObject = hitInfo.collider.gameObject;
        }
        else
        {
            FocusedObject = null;
        }

        // If the focused object changed this frame, start detecting fresh gestures again.
        if (FocusedObject != oldFocusObject)
        {
            tapRecognizer.CancelGestures();
            tapRecognizer.StartCapturingGestures();
        }

        if (selectedGameObject != null)
        {
            //When SelectedGameObject is not null; we know it has a parent; So, we get the parent, getComponents of MSR and enable or disable

            GameObject parent = selectedGameObject.transform.parent.gameObject;

            var moveComponent   = parent.GetComponent <MoveScript>();
            var rotateComponent = parent.GetComponent <RotateScript>();
            var scaleComponent  = parent.GetComponent <ScaleScript>();

            switch (TransformMenu.instance.currentMode)
            {
            case TransformMenu.Mode.Move:
                moveComponent.SetDragging(true);
                rotateComponent.SetRotating(false);
                scaleComponent.SetResizing(false);
                break;

            case TransformMenu.Mode.Rotate:
                rotateComponent.SetRotating(true);
                moveComponent.SetDragging(false);
                scaleComponent.SetResizing(false);
                break;

            case TransformMenu.Mode.Scale:
                scaleComponent.SetResizing(true);
                moveComponent.SetDragging(false);
                rotateComponent.SetRotating(false);
                break;

            case TransformMenu.Mode.Reset:
                Debug.Log("**************************Reset is enabled");
                TransformMenu.instance.currentMode = TransformMenu.Mode.None;
                //Call the reset function

                Debug.Log("Reset is Off~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
                break;

            default:
                scaleComponent.SetResizing(false);
                moveComponent.SetDragging(false);
                rotateComponent.SetRotating(false);
                //Debug.Log("Nothing is enabled");
                break;
            }
        }
        else
        {
            //Currently, no object is selected.
        }
    }
Esempio n. 6
0
    //public void OnHoldStartedEvent(InteractionSourceKind source, Ray headRay)
    //{
    //    GameObject.FindWithTag("Information").GetComponent<Text>().text = "Hold Gesture has been made!";
    //}

    public void OnTappedEvent(InteractionSourceKind source, int tapCount, Ray headRay)
    {
        recognizer.CancelGestures();
        GameObject.Find("ImageRecognition").GetComponent <PictureTaker>().TakePicture();
        recognizer.StartCapturingGestures();
    }