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; }); } }
public void Run(string username, string password, AppStarted callback) { appStarted = callback; Authentication auth = new Authentication(); Authentication.Success success = AuthenticationSuccess; Authentication.Error error = AuthenticationError; StartCoroutine(auth.Authenticate(username, password, success, error)); }
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 void OnAppStarted(AppStarted callback) { appStarted = callback; }
/// <summary> /// Invokes app started event /// </summary> private void OnAppStarted() { AppStarted?.Invoke(this, EventArgs.Empty); }