Example #1
0
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            if (!_mouseLMBDown)
            {
                return;
            }

            var position = e.GetPosition(this);
            var movement = position - _previousPosition;

            _previousPosition = position;

            if (Keyboard.IsKeyDown(Key.LeftShift))
            {
                MoveSceneUsingMouse(movement);
                return;
            }

            var rotationMatrix = Transformations3D.RotationY(0.005 * movement.X)
                                 * Transformations3D.RotationX(0.005 * movement.Y);

            _worldTransformation = rotationMatrix * _worldTransformation;

            RefreshImage();
        }
Example #2
0
        public Matrix4X4 GetWorldMatrix()
        {
            var translation = Transformations3D.Translation((Vector3D)Position);
            var rotation    = Transformations3D.RotationX(Orientation.X)
                              * Transformations3D.RotationY(Orientation.Y)
                              * Transformations3D.RotationZ(Orientation.Z);
            var scaling = Transformations3D.Scaling(Scale);

            return(translation * rotation * scaling);
        }
Example #3
0
        public Matrix4X4 GetViewMatrix()
        {
            var scale       = Transformations3D.Scaling(Zoom);
            var translation = Transformations3D.Translation(-(Vector3D)Position);
            var rotation    = Transformations3D.RotationX(XRotation) *
                              Transformations3D.RotationY(YRotation);
            var d    = Transformations3D.Translation(new Vector3D(0, 0, ObserverOffset));
            var invd = Transformations3D.Translation(new Vector3D(0, 0, -ObserverOffset));

            return(scale * invd * rotation * d * translation);
        }
Example #4
0
        public Matrix4X4 GetViewMatrix()
        {
            var vec       = new Vector3D(0, 0, -1);
            var transform = Transformations3D.Scaling(Zoom)
                            * Transformations3D.RotationY(YRotation)
                            * Transformations3D.RotationX(XRotation);
            var eye = (Point3D)(vec.ExtendTo4D().Transform(transform));

            return(Transformations3D.LookAt(
                       eye,
                       new Point3D(0, 0, 0),
                       new Vector3D(0, 1, 0)));
        }