using OpenTK; namespace RecrownedGTK.Graphics { /// /// Basic camera handling up to x, y and z axis. /// public class Camera { private Vector3 scale = new Vector3(1f), translate, rotation; /// /// Scale factor multiplied to the camera coordinates. /// /// The value to be multiplied. public Vector3 Scale { get { return scale; } set { updated = true; scale = value; } } /// /// The translation applied after scaling and rotating. /// /// public Vector3 Translate { set { updated = true; translate = value; } } /// /// Rotation applied before translation. /// /// public Vector3 Rotation { set { updated = true; rotation = value; } get { return rotation; } } private Matrix4 transform; /// /// If values have updated, recalculate transformation matrix. /// /// The transformation matrix. public Matrix4 Transform { get { if (!updated) return transform; updated = true; transform = Matrix4.CreateScale(scale) * Matrix4.CreateRotationX(rotation.X) * Matrix4.CreateRotationY(rotation.Y) * Matrix4.CreateRotationZ(rotation.Z) * Matrix4.CreateTranslation(translate); transform = Matrix4.Transpose(transform); return transform; } } private bool updated; } }