#region usings using OpenTK; using SM.Base.Types; #endregion namespace SM.Base.Drawing { /// /// Stores transformations for the textures. /// public class TextureTransformation { /// /// The offset from the origin. /// public CVector2 Offset = new CVector2(0); /// /// The rotation of the texture. /// public CVector1 Rotation = new CVector1(0); /// /// The scale of the texture. /// public CVector2 Scale = new CVector2(1); /// /// Get the texture matrix. /// /// public Matrix3 GetMatrix() { return CalculateMatrix(Offset, Scale, Rotation); } /// /// Calculates a texture matrix. /// /// /// /// /// public static Matrix3 CalculateMatrix(Vector2 offset, Vector2 scale, float rotation) { float radians = MathHelper.DegreesToRadians(rotation); Matrix3 result = Matrix3.CreateScale(scale.X, scale.Y, 1) * Matrix3.CreateRotationZ(radians); result.Row2 = new Vector3(offset.X, offset.Y, 1); return result; } } }