Exemplo n.º 1
0
        public Camera()
        {
            Viewport = new Viewport();
            Track    = new Track();

            Track.Parent               = _panTrack = new PanTrack(Track);
            Track.Parent.Parent        = _orbitTrack = new OrbitTrack(Track);
            Track.Parent.Parent.Parent = _zoomTrack = new ZoomTrack(Track);

            _zoomTrack.Zoom(-5f);

            Viewport.ProjectionChanged += viewport_ProjectionChanged;

            _orbitTrack.Update(70, 60);

            Update(0f, 0f);
        }
Exemplo n.º 2
0
        public Camera( )
        {
            viewport = new Viewport( );
            track    = new Track( );

            track.Parent               = panTrack = new PanTrack(track);
            track.Parent.Parent        = orbitTrack = new OrbitTrack(track);
            track.Parent.Parent.Parent = zoomTrack = new ZoomTrack(track);

            zoomTrack.Zoom(-5f);

            viewport.ProjectionChanged += viewport_ProjectionChanged;

            orbitTrack.Update(70, 60);

            this.Update( );
        }
Exemplo n.º 3
0
        public void OnMouseMove(object sender, MouseEventArgs e)
        {
            var mouseState             = Mouse.GetState();
            var keyboardState          = Keyboard.GetState();
            var currentMouseCoordinate = new Vector2(e.X, e.Y);

            if (keyboardState.IsKeyDown(Key.ShiftLeft) && (mouseState[MouseButton.Middle]
                                                           ||
                                                           (mouseState[MouseButton.Left] &&
                                                            keyboardState[Key.ControlLeft])))
            {
                var previousMouseWorldCoordinate = this.UnProjectToViewspace(_previousMouseCoordinate);
                var mouseWorldCoordinate         = this.UnProjectToViewspace(currentMouseCoordinate);
                var delta = mouseWorldCoordinate - previousMouseWorldCoordinate;
                delta *= (Position - Vector3.Zero).Length;
                _panTrack.Update(delta.X, delta.Y);
            }
            else if (keyboardState.IsKeyDown(Key.AltLeft) && (mouseState[MouseButton.Middle]
                                                              ||
                                                              (mouseState[MouseButton.Left] &&
                                                               keyboardState[Key.ControlLeft])))
            {
                var previousMouseWorldCoordinate = this.UnProjectToViewspace(_previousMouseCoordinate);
                var mouseWorldCoordinate         = this.UnProjectToViewspace(currentMouseCoordinate);
                var delta = mouseWorldCoordinate - previousMouseWorldCoordinate;
                delta *= 10;
                _zoomTrack.Update(delta.Y, keyboardState[Key.ControlLeft] ? 2.5f : 1.0f);
            }
            else if (mouseState[MouseButton.Middle] ||
                     (mouseState[MouseButton.Left] && keyboardState[Key.ControlLeft]))
            {
                var delta = currentMouseCoordinate - _previousMouseCoordinate;
                _orbitTrack.Update(delta.X, delta.Y);
            }
            if (MouseMove != null)
            {
                MouseMove(this, new SceneMouseEventArgs(this, new Vector2(e.X, e.Y), default(Vector3), e.Button));
            }
            _previousMouseCoordinate = currentMouseCoordinate;
        }
Exemplo n.º 4
0
        public Camera()
        {
            viewport = new Viewport();
            track = new Track();

            track.Parent = panTrack = new PanTrack(track);
            track.Parent.Parent = orbitTrack = new OrbitTrack(track);
            track.Parent.Parent.Parent = zoomTrack = new ZoomTrack(track);

            zoomTrack.Zoom(-5f);

            viewport.ProjectionChanged += viewport_ProjectionChanged;

            orbitTrack.Update(70, 60);
            zoomTrack.Update(-5);

            this.Update();
        }