public void destroyWindow(SceneViewWindow window) { if (WindowDestroyed != null) { WindowDestroyed.Invoke(window); } if (camerasCreated) { window.destroySceneView(); } if (window == cloneWindow) { cloneWindow = null; } else if (mdiWindows.Remove(window as MDISceneViewWindow)) { //On the last window, disable closing it. if (mdiWindows.Count == 1) { mdiWindows[0].AllowClose = false; } } else { textureWindows.Remove(window as TextureSceneView); } if (window == activeWindow) { ActiveWindow = mdiWindows.FirstOrDefault(); } window.Dispose(); }
void rotateGesture_Dragged(EventLayer eventLayer, FingerDragGesture gesture) { if (eventLayer.EventProcessingAllowed && currentGesture <= Gesture.Rotate) { currentGesture = Gesture.Rotate; SceneViewWindow sceneView = sceneViewController.ActiveWindow; if (sceneView != null) { switch (movementMode) { case CameraMovementMode.Rotate: sceneView.CameraMover.rotateFromMotion((int)gesture.DeltaX, (int)gesture.DeltaY); break; case CameraMovementMode.Pan: sceneView.CameraMover.panFromMotion((int)gesture.DeltaX, (int)gesture.DeltaY, eventLayer.Mouse.AreaWidth, eventLayer.Mouse.AreaHeight); break; case CameraMovementMode.Zoom: sceneView.CameraMover.zoomFromMotion((int)gesture.DeltaY); break; } } travelTracker.traveled((int)gesture.DeltaX, (int)gesture.DeltaY); eventLayer.alertEventsHandled(); } }
void controller_ActiveWindowChanged(SceneViewWindow window) { if (window != null) { transparencyStateName = window.CurrentTransparencyState; } }
private void createTouchUndo() { SceneViewWindow sceneView = sceneViewController.ActiveWindow; if (touchUndoPosition == null && sceneView != null) { touchUndoPosition = sceneView.createCameraPosition(); } }
/// <summary> /// Compute a new translation for the given camera position and returns it. /// </summary> /// <param name="cameraPosition"></param> /// <returns></returns> public Vector3 computeAdjustedTranslation(CameraPosition cameraPosition) { if (cameraPosition.UseIncludePoint && cameraPosition.IncludePoint.isNumber()) { return(SceneViewWindow.computeIncludePointAdjustedPosition(Camera.getAspectRatio(), Camera.getFOVy(), Camera.getProjectionMatrix(), cameraPosition.Translation, cameraPosition.LookAt, cameraPosition.IncludePoint)); } return(cameraPosition.Translation); }
public override void sendUpdate(Clock clock) { SceneViewWindow followWindow = sceneViewController.ActiveWindow; if (camera != null && followWindow != null) { camera.Translation = followWindow.Translation; camera.LookAt = followWindow.LookAt; } }
private void commitTouchUndo() { if (touchUndoPosition != null) { SceneViewWindow activeWindow = sceneViewController.ActiveWindow; if (activeWindow != null) { activeWindow.pushUndoState(touchUndoPosition); } touchUndoPosition = null; } }
private void ZoomGesture_Zoom(EventLayer eventLayer, TwoFingerZoom zoomGesture) { if (eventLayer.EventProcessingAllowed && currentGesture <= Gesture.Zoom) { currentGesture = Gesture.Zoom; SceneViewWindow sceneView = sceneViewController.ActiveWindow; if (sceneView != null) { sceneView.CameraMover.zoomFromMotion((int)(zoomGesture.ZoomDelta * 800)); } eventLayer.alertEventsHandled(); } }
void panGesture_Dragged(EventLayer eventLayer, FingerDragGesture gesture) { if (eventLayer.EventProcessingAllowed && currentGesture <= Gesture.Pan) { currentGesture = Gesture.Pan; SceneViewWindow sceneView = sceneViewController.ActiveWindow; if (sceneView != null) { sceneView.CameraMover.panFromMotion((int)gesture.DeltaX, (int)gesture.DeltaY, eventLayer.Mouse.AreaWidth, eventLayer.Mouse.AreaHeight); } eventLayer.alertEventsHandled(); } }
void mouseWheelTimer_Elapsed(object sender, ElapsedEventArgs e) { ThreadManager.invokeAndWait(() => { if (!currentlyInMotion && mouseUndoPosition != null) { SceneViewWindow activeWindow = sceneViewController.ActiveWindow; if (activeWindow != null) { activeWindow.pushUndoState(mouseUndoPosition); } mouseUndoPosition = null; } }); }
public override void processIncludePoint(Camera camera) { if (currentIncludePoint.HasValue) { float duration = GuiFrameworkCamerasInterface.CameraTransitionTime; Vector3 inclLookAt = LookAt; Vector3 inclTrans = Translation; if (automaticMovement) { duration = animationDuration - totalTime; inclLookAt = targetLookAt; inclTrans = targetTranslation; } setNewPosition(SceneViewWindow.computeIncludePointAdjustedPosition(camera.getAspectRatio(), camera.getFOVy(), camera.getProjectionMatrix(), inclTrans, inclLookAt, currentIncludePoint.Value), inclLookAt, duration, easingFunction); } }
void sceneViewController_WindowCreated(SceneViewWindow window) { MDISceneViewWindow mdiWindow = window as MDISceneViewWindow; if (mdiWindow != null) { SceneStatsDisplay licenseDisplay = new SceneStatsDisplay(displayStatsTarget); licenseDisplay.Visible = statsVisible; activeSceneStats.Add(licenseDisplay); mdiWindow.addChildContainer(licenseDisplay.LayoutContainer); mdiWindow.Disposed += (win) => { activeSceneStats.Remove(licenseDisplay); licenseDisplay.Dispose(); }; } }
public static Vector3 computeIncludePointAdjustedPosition(float aspect, float fovy, Matrix4x4 projectionMatrix, Vector3 translation, Vector3 lookAt, Vector3 includePoint) { fovy *= 0.5f; Vector3 direction = lookAt - translation; //Figure out direction, must use ogre fixed yaw calculation, first adjust direction to face -z Vector3 zAdjustVec = -direction; zAdjustVec.normalize(); Quaternion targetWorldOrientation = Quaternion.shortestArcQuatFixedYaw(ref zAdjustVec); Matrix4x4 viewMatrix = Matrix4x4.makeViewMatrix(translation, targetWorldOrientation); float offset = SceneViewWindow.computeOffsetToIncludePoint(viewMatrix, projectionMatrix, includePoint, aspect, fovy); direction.normalize(); Vector3 newTrans = translation + offset * direction; return(newTrans); }
void processInputEvents(EventLayer eventLayer) { if (currentGesture == Gesture.None) { SceneViewWindow activeWindow = sceneViewController.ActiveWindow; if (activeWindow != null && eventLayer.EventProcessingAllowed) { CameraMover cameraMover = activeWindow.CameraMover; if (cameraMover.AllowManualMovement) { IntVector3 mouseCoords = eventLayer.Mouse.AbsolutePosition; if (MoveCamera.FirstFrameDown) { eventLayer.makeFocusLayer(); currentlyInMotion = true; eventLayer.alertEventsHandled(); if (mouseUndoPosition == null) { mouseUndoPosition = activeWindow.createCameraPosition(); } } else if (MoveCamera.FirstFrameUp) { eventLayer.clearFocusLayer(); currentlyInMotion = false; if (mouseUndoPosition != null) { activeWindow.pushUndoState(mouseUndoPosition); mouseUndoPosition = null; } } mouseCoords = eventLayer.Mouse.RelativePosition; if (currentlyInMotion) { int x = mouseCoords.x; int y = mouseCoords.y; switch (movementMode) { case CameraMovementMode.Rotate: if (cameraMover.AllowRotation) { travelTracker.traveled(mouseCoords); if (LockX.Down) { x = 0; } if (LockY.Down) { y = 0; } cameraMover.rotateFromMotion(x, y); eventLayer.alertEventsHandled(); } break; case CameraMovementMode.Pan: travelTracker.traveled(mouseCoords); if (LockX.Down) { x = 0; } if (LockY.Down) { y = 0; } cameraMover.panFromMotion(x, y, eventLayer.Mouse.AreaWidth, eventLayer.Mouse.AreaHeight); eventLayer.alertEventsHandled(); break; case CameraMovementMode.Zoom: if (cameraMover.AllowZoom) { travelTracker.traveled(mouseCoords); cameraMover.zoomFromMotion(mouseCoords.y); eventLayer.alertEventsHandled(); } break; } } if (cameraMover.AllowZoom) { if (ZoomInCamera.Down) { if (mouseUndoPosition == null) { mouseUndoPosition = activeWindow.createCameraPosition(); } mouseWheelTimer.Stop(); mouseWheelTimer.Start(); cameraMover.incrementZoom(-1); eventLayer.alertEventsHandled(); } else if (ZoomOutCamera.Down) { if (mouseUndoPosition == null) { mouseUndoPosition = activeWindow.createCameraPosition(); } mouseWheelTimer.Stop(); mouseWheelTimer.Start(); cameraMover.incrementZoom(1); eventLayer.alertEventsHandled(); } } } } } }
void TextureSceneView_RenderingEnded(SceneViewWindow window, bool currentCameraRender) { RenderOneFrame = false; }