Exemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            var camera    = Registery.GetComponentsOf <CameraComponent>().FirstOrDefault();
            var transfrom = camera.Record.GetComponent <TransformComponent>();

            switch (camera.CameraType)
            {
            case CameraType.Orthographic:

                camera.ProjectionMatrix = Math1.Ortho(camera.Left, camera.Right, camera.Bottom, camera.Top, -1.0f, 1.0f);
                var transform = Math1.Translate(Matrix4.Identity(), transfrom.Position + transfrom.Velocity * (float)gameTime)
                                * Math1.Rotate(Matrix4.Identity(), Math1.Radians(transfrom.Rotation), new Vector3(0, 0, 1));

                camera.ViewMatrix           = transform.Inverse();
                camera.ViewProjectionMatrix = camera.ProjectionMatrix * camera.ViewMatrix;
                break;
            }

            base.Update(gameTime);
        }
Exemplo n.º 2
0
 public OrthographicCamera(float left, float right, float bottom, float top)
 {
     ProjectionMatrix     = Math1.Ortho(left, right, bottom, top, -1.0f, 1.0f);
     ViewMatrix           = Matrix4.Identity();
     ViewProjectionMatrix = ProjectionMatrix * ViewMatrix;
 }