コード例 #1
0
        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();
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
 void controller_ActiveWindowChanged(SceneViewWindow window)
 {
     if (window != null)
     {
         transparencyStateName = window.CurrentTransparencyState;
     }
 }
コード例 #4
0
        private void createTouchUndo()
        {
            SceneViewWindow sceneView = sceneViewController.ActiveWindow;

            if (touchUndoPosition == null && sceneView != null)
            {
                touchUndoPosition = sceneView.createCameraPosition();
            }
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        public override void sendUpdate(Clock clock)
        {
            SceneViewWindow followWindow = sceneViewController.ActiveWindow;

            if (camera != null && followWindow != null)
            {
                camera.Translation = followWindow.Translation;
                camera.LookAt      = followWindow.LookAt;
            }
        }
コード例 #7
0
 private void commitTouchUndo()
 {
     if (touchUndoPosition != null)
     {
         SceneViewWindow activeWindow = sceneViewController.ActiveWindow;
         if (activeWindow != null)
         {
             activeWindow.pushUndoState(touchUndoPosition);
         }
         touchUndoPosition = null;
     }
 }
コード例 #8
0
 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();
     }
 }
コード例 #9
0
 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();
     }
 }
コード例 #10
0
 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;
         }
     });
 }
コード例 #11
0
 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);
     }
 }
コード例 #12
0
        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();
                };
            }
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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();
                            }
                        }
                    }
                }
            }
        }
コード例 #15
0
 void TextureSceneView_RenderingEnded(SceneViewWindow window, bool currentCameraRender)
 {
     RenderOneFrame = false;
 }