示例#1
0
 private static void ReceiveAxesGesture(HoloLensData holoLens, string gesture, Vector3 axes)
 {
     HoloLensData.AxesGesture actualGesture = null;
     
     switch (gesture)
     {
         case "manipulation":
             actualGesture = holoLens.axesGestures.Find(i => i.type == HoloLensData.AxesGesture.Type.MANIPULATION);
             actualGesture.axes = axes;
             break;
         case "navigation":
             actualGesture = holoLens.axesGestures.Find(i => i.type == HoloLensData.AxesGesture.Type.NAVIGATION);
             actualGesture.axes = axes;
             break;
     }
 }
示例#2
0
    // Loads the HoloLens configs form the json
    private void ReadHoloLensConfigs()
    {
        // For creating the trackers
        var holoLensConfigs = new Dictionary <DisplayConfig, HoloLensData>();

        // Check every display of the platform
        foreach (DisplayConfig display in PlatformConfig.current.displays)
        {
            JSONNode typeJSON = display.json["type"];

            if (typeJSON != null && typeJSON.Value.ToLower() == "hololens")
            {
                HoloLensData holoLens = new HoloLensData();
                holoLensConfigs.Add(display, holoLens);

                holoLens.ParseJson(display.json);
            }
        }

        if (holoLensConfigs.Count > 0)
        {
            this.holoLensConfigs = holoLensConfigs;
        }
    }
示例#3
0
        private static void ReceiveButtonGesture(HoloLensData holoLens, string gesture)
    {
        HoloLensData.ButtonGesture actualGesture = null;

        switch (gesture)
        {
            case "tap":
                actualGesture = holoLens.buttonGestures.Find(i => i.type == HoloLensData.ButtonGesture.Type.TAP);
                actualGesture.performed = true;
                break;
            case "double_tap":
                actualGesture = holoLens.buttonGestures.Find(i => i.type == HoloLensData.ButtonGesture.Type.DOUBLE_TAP);
                actualGesture.performed = true;
                break;
            case "hold_started":
                actualGesture = holoLens.buttonGestures.Find(i => i.type == HoloLensData.ButtonGesture.Type.HOLD);
                actualGesture.performed = true;
                break;
            case "hold_ended":
                actualGesture = holoLens.buttonGestures.Find(i => i.type == HoloLensData.ButtonGesture.Type.HOLD);
                actualGesture.performed = false;
                break;
        }
    }
示例#4
0
    // Set up the HoloLens' camera
    private void SetUpHoloLens()
    {
        HoloLensData holoLens = display.HoloLensData();

        // Get the holoLens' camera's transform
        UnityEngine.Camera camera = UnityEngine.Camera.main;

        // Create a container to adjust the difference between HoloLens' origin and HEVS' origin
        Transform container = new GameObject("HoloLensContainer").transform;

        // Make the container the camera's parent
        container.parent = camera.transform.parent;
        camera.transform.parent = container;

        // Change position and direction
        if (holoLens.origin == HoloLensData.OriginType.START_LOCATION)
        {
            container.position = -camera.transform.position * holoLens.scale;
            container.eulerAngles = new Vector3(0f, -camera.transform.localEulerAngles.y, 0f);

            // Create world anchor
            WorldAnchor worldAnchor = new GameObject("WorldAnchor").AddComponent<WorldAnchor>();
            worldAnchor.transform.position = camera.transform.position;
            worldAnchor.transform.rotation = camera.transform.rotation;
        }

        container.localScale = new Vector3(holoLens.scale, holoLens.scale, holoLens.scale);

        // Other Camera setup
        camera.clearFlags = CameraClearFlags.SolidColor;
        camera.backgroundColor = new Color(0f, 0f, 0f, 0f);
        camera.nearClipPlane = 0.85f;

        // Adjust the quality if running locally
        if (holoLens.remote == null) QualitySettings.SetQualityLevel(0);
    }
示例#5
0
    public void Enable()
    {
        Disable();

#if UNITY_WSA
        // Is the holoLens
        if (display != null)
        {
            CreateTransmitter();

            // Add gesture recogniser if needed
            HoloLensData holoLens = display.HoloLensData();
            if (holoLens != null && holoLens.axesGestures.Count > 0)
            {
                recognizer = new GestureRecognizer();

                // The types of gestures to listen for
                GestureSettings gestureMask = GestureSettings.None;

                foreach (var gesture in holoLens.buttonGestures)
                {
                    switch (gesture.type)
                    {
                        case HoloLensData.ButtonGesture.Type.TAP:
                            gestureMask |= GestureSettings.Tap;
                            break;

                        case HoloLensData.ButtonGesture.Type.DOUBLE_TAP:
                            gestureMask |= GestureSettings.DoubleTap;
                            break;

                        case HoloLensData.ButtonGesture.Type.HOLD:
                            gestureMask |= GestureSettings.Hold;
                            recognizer.HoldStarted += GestureHoldStarted;
                            recognizer.HoldCompleted += GestureHoldCompleted;
                            recognizer.HoldCanceled += GestureHoldCanceled;
                            break;
                    }
                }

                if (gestureMask.HasFlag(GestureSettings.Tap) || gestureMask.HasFlag(GestureSettings.DoubleTap))
                    recognizer.Tapped += GestureTapped;

                foreach (var gesture in holoLens.axesGestures)
                {
                    switch (gesture.type)
                    {
                        case HoloLensData.AxesGesture.Type.MANIPULATION:
                            gestureMask |= GestureSettings.ManipulationTranslate;
                            recognizer.ManipulationStarted += GestureManipulationStarted;
                            recognizer.ManipulationCompleted += GestureManipulationCompleted;
                            recognizer.ManipulationCanceled += GestureManipulationCanceled;
                            recognizer.ManipulationUpdated += GestureManipulationUpdated; ;
                            break;

                        case HoloLensData.AxesGesture.Type.NAVIGATION:
                            if (gesture.mappingsX.Count != 0) { gestureMask |= GestureSettings.NavigationX; }
                            if (gesture.mappingsX.Count != 0) { gestureMask |= GestureSettings.NavigationY; }
                            if (gesture.mappingsX.Count != 0) { gestureMask |= GestureSettings.NavigationZ; }
                            recognizer.NavigationStarted += GestureNavigationStarted;
                            recognizer.NavigationCompleted += GestureNavigationCompleted;
                            recognizer.NavigationCanceled += GestureNavigationCanceled;
                            recognizer.NavigationUpdated += GestureNavigationUpdated; ;
                            break;
                    }
                }


                // Start the recogniser
                recognizer.SetRecognizableGestures(gestureMask);
                recognizer.StartCapturingGestures();
            }

            SetUpHoloLens();
        }
#endif
    }