async void HolographicSpace_CameraAdded(HolographicSpace sender, HolographicSpaceCameraAddedEventArgs args) { if (!appInited) { await window.Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { SpatialMappingManager = new SpatialMappingManager(); VoiceManager = new VoiceManager(); if (options == null) { options = new ApplicationOptions(); } //override some options: options.LimitFps = false; options.Width = (int)args.Camera.RenderTargetSize.Width; options.Height = (int)args.Camera.RenderTargetSize.Height; Game = (StereoApplication)Activator.CreateInstance(holoAppType, options); Game.Run(); GesturesManager = new GesturesManager(Game, ReferenceFrame); AppStarted?.Invoke(Game); appInited = true; }); } }
private void Awake() { Instance = this; handDetection = GetComponent <HandDetection>(); voiceControl = GetComponent <VoiceCommands>(); voiceControl.gesturesManager = this; }
void Start() { _tileParent = GetComponentInParent <WorldGridTile>(); _handDetection = FindObjectOfType <HandDetection>(); _cameraTransform = Camera.main.transform; _gesturesManager = Camera.main.GetComponent <GesturesManager>(); gridTile = GetComponentInParent <WorldGridTile>().GridTileCounterpart; }
public virtual string GetGestureName() { var gestureName = "None"; if (!IsCustomGesture) { gestureName = Gesture.ToString(); } else if (!string.IsNullOrEmpty(GestureXaml)) { gestureName = GesturesManager.GetGestureName(GestureXaml); } return(gestureName); }
void Awake() { singleton = this; for (int i = 0; i < gestures.Count; i++) { if (gestures_dict.ContainsKey(gestures[i].targetAnim)) { Debug.Log(gestures[i].targetAnim + " is a duplicate"); } else { gestures_dict.Add(gestures[i].targetAnim, i); } } }
/// <summary> /// called when the application is started /// </summary> void Start() { // link managers apiManager = ApiManager.Instance; screenshotManager = ScreenshotManager.Instance; visualTextManager = VisualTextManager.Instance; gesturesManager = GesturesManager.Instance; // Link IconObjects, deactivate animation loadingIcon = Instantiate(loadingIcon); loadingIcon.SetActive(false); cursor = GameObject.Find("CursorVisual"); cursorSize = cursor.transform.localScale; // subscribe to events screenshotManager.ScreenshotTaken += OnScreenshotTaken; apiManager.ImageAnalysed += onImageAnalysed; gesturesManager.Tapped += onTapped; gesturesManager.DoubleTapped += onDoubleTapped; visualTextManager.VisualizedTextFocused += OnVisualizedTextFocused; visualTextManager.VisualizedTextUnfocused += OnVisualizedTextUnfocused; analysingScreenshot = false; timeCounter = 0; timeInterval = 1; currentRequestCause = RequestCause.REGULAR; nextRequestCause = RequestCause.REGULAR; screenshotsTakeable = true; cameraPositionResultTmp = new CameraPositionResult(); currentId = 0; visualizedTextFocused = false; focusedVisualizedTextTmp = ""; dialogPanel = DialogPanel.Instance(); }
public unsafe void Run() { AppStarting?.Invoke(); ReferenceFrame = SpatialLocator.GetDefault().CreateStationaryFrameOfReferenceAtCurrentLocation(); var coreWindow = CoreWindow.GetForCurrentThread(); coreWindow.CustomProperties.Add(nameof(HolographicSpace), HolographicSpace); InitializeSpace(); InteractionManager = SpatialInteractionManager.GetForCurrentView(); InteractionManager.InteractionDetected += (s, e) => GesturesManager?.HandleInteraction(e.Interaction); while (!windowClosed) { if (!appInited) { SpatialMappingManager = new SpatialMappingManager(); VoiceManager = new VoiceManager(); appInited = true; if (options == null) { options = new ApplicationOptions(); } //override some options: options.LimitFps = false; options.Width = 1268; //TODO: find system options.Height = 720; Game = (HoloApplication)Activator.CreateInstance(holoAppType, options); Game.Run(); GesturesManager = new GesturesManager(Game, ReferenceFrame); AppStarted?.Invoke(Game); } if (windowVisible && (null != HolographicSpace)) { if (Game != null) { CurrentFrame = HolographicSpace.CreateNextFrame(); CurrentFrame.UpdateCurrentPrediction(); var prediction = CurrentFrame.CurrentPrediction; if (prediction.CameraPoses.Count < 1) { continue; } var cameraPose = prediction.CameraPoses[0]; var viewBox = cameraPose.TryGetViewTransform(ReferenceFrame.CoordinateSystem); if (viewBox != null) { Matrix4x4 leftViewMatrixDx = viewBox.Value.Left; Matrix4x4 rightViewMatrixDx = viewBox.Value.Right; Matrix4x4 leftProjMatrixDx = cameraPose.ProjectionTransform.Left; Matrix4x4 rightProjMatrixDx = cameraPose.ProjectionTransform.Right; Matrix4 leftViewMatrixUrho = *(Matrix4 *)(void *)&leftViewMatrixDx; Matrix4 rightViewMatrixUrho = *(Matrix4 *)(void *)&rightViewMatrixDx; Matrix4 leftProjMatrixUrho = *(Matrix4 *)(void *)&leftProjMatrixDx; Matrix4 rightProjMatrixUrho = *(Matrix4 *)(void *)&rightProjMatrixDx; Game.UpdateStereoView(leftViewMatrixUrho, rightViewMatrixUrho, leftProjMatrixUrho, rightProjMatrixUrho); } var parameters = CurrentFrame.GetRenderingParameters(cameraPose); if (Game.FocusWorldPoint != Vector3.Zero) { parameters.SetFocusPoint(ReferenceFrame.CoordinateSystem, new System.Numerics.Vector3( Game.FocusWorldPoint.X, Game.FocusWorldPoint.Y, -Game.FocusWorldPoint.Z)); //LH->RH } Game.Engine.RunFrame(); CurrentFrame.PresentUsingCurrentPrediction(HolographicFramePresentWaitBehavior.WaitForFrameToFinish); } CoreWindow.GetForCurrentThread().Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent); } else { CoreWindow.GetForCurrentThread().Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessOneAndAllPending); } } }
public unsafe void Run() { AppStarting?.Invoke(); ReferenceFrame = SpatialLocator.GetDefault().CreateStationaryFrameOfReferenceAtCurrentLocation(); var coreWindow = CoreWindow.GetForCurrentThread(); coreWindow.CustomProperties.Add(nameof(HolographicSpace), HolographicSpace); InitializeSpace(); HolographicSpace.CameraAdded += HolographicSpace_CameraAdded; InteractionManager = SpatialInteractionManager.GetForCurrentView(); if (InteractionManager != null) { InteractionManager.InteractionDetected += (s, e) => GesturesManager?.HandleInteraction(e.Interaction); } while (!windowClosed) { if (appInited && windowVisible && (null != HolographicSpace)) { if (Game != null) { CurrentFrame = HolographicSpace.CreateNextFrame(); CurrentFrame.UpdateCurrentPrediction(); var prediction = CurrentFrame.CurrentPrediction; if (prediction.CameraPoses.Count < 1) { continue; } var cameraPose = prediction.CameraPoses[0]; var viewBox = cameraPose.TryGetViewTransform(ReferenceFrame.CoordinateSystem); if (viewBox != null) { Matrix4x4 leftViewMatrixDx = viewBox.Value.Left; Matrix4x4 rightViewMatrixDx = viewBox.Value.Right; Matrix4x4 leftProjMatrixDx = cameraPose.ProjectionTransform.Left; Matrix4x4 rightProjMatrixDx = cameraPose.ProjectionTransform.Right; Matrix4 leftViewMatrixUrho = *(Matrix4 *)(void *)&leftViewMatrixDx; Matrix4 rightViewMatrixUrho = *(Matrix4 *)(void *)&rightViewMatrixDx; Matrix4 leftProjMatrixUrho = *(Matrix4 *)(void *)&leftProjMatrixDx; Matrix4 rightProjMatrixUrho = *(Matrix4 *)(void *)&rightProjMatrixDx; Game.UpdateStereoView(leftViewMatrixUrho, rightViewMatrixUrho, leftProjMatrixUrho, rightProjMatrixUrho); } var parameters = CurrentFrame.GetRenderingParameters(cameraPose); if (Game.FocusWorldPoint != Vector3.Zero) { parameters.SetFocusPoint(ReferenceFrame.CoordinateSystem, new System.Numerics.Vector3( Game.FocusWorldPoint.X, Game.FocusWorldPoint.Y, -Game.FocusWorldPoint.Z)); //LH->RH } Game.Engine.RunFrame(); CurrentFrame.PresentUsingCurrentPrediction(HolographicFramePresentWaitBehavior.WaitForFrameToFinish); } CoreWindow.GetForCurrentThread().Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent); } else { CoreWindow.GetForCurrentThread().Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessOneAndAllPending); } } }
public unsafe void Run() { LoadAssets(new[] { assetsPakName == null ? null : assetsPakName + ".pak" }); CoreWindow.GetForCurrentThread().CustomProperties.Add("HolographicSpace", HolographicSpace); InitializeSpace(); InteractionManager = SpatialInteractionManager.GetForCurrentView(); InteractionManager.InteractionDetected += (s, e) => GesturesManager?.HandleInteraction(e.Interaction); while (!windowClosed) { if (assetsLoaded && !appInited) { SpatialMappingManager = new SpatialMappingManager(); appInited = true; Game = (HoloApplication)Activator.CreateInstance(holoAppType, assetsPakName, false); Game.Run(); Game.Engine.PostUpdate += e => currentFrame?.UpdateCurrentPrediction(); GesturesManager = new GesturesManager(Game, ReferenceFrame); } if (windowVisible && (null != HolographicSpace)) { if (Game != null) { currentFrame = HolographicSpace.CreateNextFrame(); var prediction = currentFrame.CurrentPrediction; if (prediction.CameraPoses.Count < 1) { continue; } var cameraPose = prediction.CameraPoses[0]; var viewBox = cameraPose.TryGetViewTransform(ReferenceFrame.CoordinateSystem); if (viewBox != null) { Matrix4x4 leftViewMatrixDx = viewBox.Value.Left; Matrix4x4 rightViewMatrixDx = viewBox.Value.Right; Matrix4x4 leftProjMatrixDx = cameraPose.ProjectionTransform.Left; Matrix4x4 rightProjMatrixDx = cameraPose.ProjectionTransform.Right; Matrix4 leftViewMatrixUrho = *(Matrix4 *)(void *)&leftViewMatrixDx; Matrix4 rightViewMatrixUrho = *(Matrix4 *)(void *)&rightViewMatrixDx; Matrix4 leftProjMatrixUrho = *(Matrix4 *)(void *)&leftProjMatrixDx; Matrix4 rightProjMatrixUrho = *(Matrix4 *)(void *)&rightProjMatrixDx; Game.UpdateStereoView(leftViewMatrixUrho, rightViewMatrixUrho, leftProjMatrixUrho, rightProjMatrixUrho); } var parameters = currentFrame.GetRenderingParameters(cameraPose); if (Game.FocusWorldPoint != Vector3.Zero) { parameters.SetFocusPoint(ReferenceFrame.CoordinateSystem, new System.Numerics.Vector3( Game.FocusWorldPoint.X, Game.FocusWorldPoint.Y, -Game.FocusWorldPoint.Z)); //LH->RH } Game.Engine.RunFrame(); currentFrame.PresentUsingCurrentPrediction(HolographicFramePresentWaitBehavior.WaitForFrameToFinish); } CoreWindow.GetForCurrentThread().Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent); } else { CoreWindow.GetForCurrentThread().Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessOneAndAllPending); } } }
void Start() { _tileParent = GetComponentInParent <WorldGridTile>(); _gesturesManager = Camera.main.GetComponent <GesturesManager>(); }
void Start() { gestures = GesturesManager.singleton; }