Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- namespace Cerios.Miner.Cameras
- {
- public class Camera
- {
- public Viewport Viewport
- {
- get;
- private set;
- }
- public Camera(Viewport viewport)
- {
- Viewport = viewport;
- Origin = new Vector2(viewport.Width / 2.0f, viewport.Height / 2.0f);
- Position = Vector2.Zero;
- Zoom = 1f;
- }
- public Vector2 Position { get; set; }
- public float Rotation { get; set; }
- public Vector2 Origin { get; set; }
- public float Zoom { get; set; }
- public Matrix TransformMatrix
- {
- get
- {
- return Matrix.CreateRotationZ(Rotation) * Matrix.CreateScale(Zoom) *
- Matrix.CreateTranslation(Position.X, Position.Y, 0);
- }
- }
- public Matrix GetParallaxMatrix(Vector2 parallax)
- {
- return Matrix.CreateTranslation(new Vector3(-Position * parallax, 0.0f)) *
- Matrix.CreateTranslation(new Vector3(-Origin, 0.0f)) *
- Matrix.CreateRotationZ(Rotation) *
- Matrix.CreateScale(Zoom, Zoom, 1) *
- Matrix.CreateTranslation(new Vector3(Origin, 0.0f));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement