Esempio n. 1
0
 public static void Lerp(ref Transform2D key1, ref Transform2D key2, float amount, ref Transform2D result)
 {
     result.Pos = Vector2.Lerp(key1.Pos, key2.Pos, amount);
     result.Scale = Vector2.Lerp(key1.Scale, key2.Scale, amount);
     result.Rot = MathHelper.Lerp(key1.Rot, key2.Rot, amount);
     result.Origin = Vector2.Lerp(key1.Origin, key2.Origin, amount);
 }
Esempio n. 2
0
 public static void Compose(ref Transform2D key1, ref Transform2D key2, ref Vector2 flipping, out Transform2D result)
 {
     result.Pos = key1.TransformPoint(key2.Pos, flipping);
     result.Rot = key1.Rot + key2.Rot;
     result.Scale = key1.Scale * key2.Scale;
     result.Origin = key2.Origin;
 }
Esempio n. 3
0
 public static void Compose(ref Transform2D key1, ref Transform2D key2, out Transform2D result)
 {
     Vector2 transformedPos = key1.TransformPoint(key2.Pos);
     result.Pos = transformedPos;
     result.Rot = key1.Rot + key2.Rot;
     result.Scale = key1.Scale * key2.Scale;
 }
Esempio n. 4
0
 public static void Compose(ref Transform2D key1, ref Transform2D key2, out Transform2D result)
 {
     Vector2 key2Origin = key2.Pos - key2.Origin;
     Vector2 transformedPos = key1.TransformPoint(key2Origin);
     result.Pos = transformedPos + key2.Origin * key1.Scale;
     result.Rot = key1.Rot + key2.Rot;
     result.Scale = key1.Scale * key2.Scale;
     result.Origin = key2.Origin;
 }
Esempio n. 5
0
 public static Transform2D Compose(Transform2D key1, Transform2D key2)
 {
     Transform2D result = new Transform2D();
     Vector2 transformedPos = key1.TransformPoint(key2.Pos);
     result.Pos = transformedPos;
     result.Rot = key1.Rot + key2.Rot;
     result.Scale = key1.Scale * key2.Scale;
     return result;
 }
Esempio n. 6
0
 public SpriteState(Texture2D texture)
 {
     Texture = texture;
     Transform = Transform2D.Identity;
     Transform.Origin = new Vector2(texture.Width / 2, texture.Height / 2);
     Color = Color.White;
     TextureRect = new Rectangle(0, 0, texture.Width, texture.Height);
     FlipState = SpriteEffects.None;
     Visible = true;
 }
Esempio n. 7
0
        public static Transform2D Compose(Transform2D key1, Transform2D key2)
        {
            Transform2D result = new Transform2D();
            Vector2 key2Origin = key2.Pos - key2.Origin;
            Vector2 transformedPos = key1.TransformPoint(key2Origin);
            result.Pos = transformedPos + key2.Origin * key1.Scale;
            result.Rot = key1.Rot + key2.Rot;
            result.Scale = key1.Scale * key2.Scale;
            result.Origin = key2.Origin;
            return result;

            // Old way that didn't take origin into account
            //Vector2 transformedPos = key1.TransformPoint(key2.Pos);
            //result.Pos = transformedPos;
            //result.Rot = key1.Rot + key2.Rot;
            //result.Scale = key1.Scale * key2.Scale;
        }
Esempio n. 8
0
 static Transform2D()
 {
     _identity = new Transform2D();
     _identity.Scale = Vector2.One;
 }
Esempio n. 9
0
 public static void Lerp(ref Transform2D key1, ref Transform2D key2, float amount, ref Transform2D result)
 {
     result.Pos   = Vector2.Lerp(key1.Pos, key2.Pos, amount);
     result.Scale = Vector2.Lerp(key1.Scale, key2.Scale, amount);
     result.Rot   = MathHelper.Lerp(key1.Rot, key2.Rot, amount);
 }
Esempio n. 10
0
 static Transform2D()
 {
     _identity       = new Transform2D();
     _identity.Scale = Vector2.One;
 }
Esempio n. 11
0
 public static void Lerp(ref Transform2D key1, ref Transform2D key2, float amount, ref Transform2D result)
 {
     result.Pos   = Vector2.Lerp(key1.Pos, key2.Pos, amount);
     result.Scale = Vector2.Lerp(key1.Scale, key2.Scale, amount);
     result.Rot   = Math.Abs(key2.Rot - key1.Rot) < MathHelper.Pi ?
                    MathHelper.Lerp(key1.Rot, key2.Rot, amount) : MathHelper.Lerp(key2.Rot, key1.Rot, amount);
     result.Origin = Vector2.Lerp(key1.Origin, key2.Origin, amount);
 }
Esempio n. 12
0
 public static void Compose(ref Transform2D key1, ref Transform2D key2, ref Vector2 flipping, out Transform2D result)
 {
     result.Pos    = key1.TransformPoint(key2.Pos, flipping);
     result.Rot    = key1.Rot + key2.Rot;
     result.Scale  = key1.Scale * key2.Scale;
     result.Origin = key2.Origin;
 }