Beispiel #1
0
 public static double GetRotatedAngle(sTileOrientation Orientation, double Angle)
 {
     Position.XY_dbl pos = new Position.XY_dbl((Math.Cos(Angle) + 1.0) / 2.0, (Math.Sin(Angle) + 1.0) / 2.0);
     Position.XY_dbl _dbl = GetTileRotatedPos_dbl(Orientation, pos);
     _dbl.X = (_dbl.X * 2.0) - 1.0;
     _dbl.Y = (_dbl.Y * 2.0) - 1.0;
     return Math.Atan2(_dbl.Y, _dbl.X);
 }
Beispiel #2
0
 public static modMath.sXY_int GetRotatedPos(sTileOrientation Orientation, modMath.sXY_int Pos, modMath.sXY_int Limits)
 {
     modMath.sXY_int _int2;
     if (Orientation.SwitchedAxes)
     {
         if (Orientation.ResultXFlip)
         {
             _int2.X = Limits.Y - Pos.Y;
         }
         else
         {
             _int2.X = Pos.Y;
         }
         if (Orientation.ResultYFlip)
         {
             _int2.Y = Limits.X - Pos.X;
             return _int2;
         }
         _int2.Y = Pos.X;
         return _int2;
     }
     if (Orientation.ResultXFlip)
     {
         _int2.X = Limits.X - Pos.X;
     }
     else
     {
         _int2.X = Pos.X;
     }
     if (Orientation.ResultYFlip)
     {
         _int2.Y = Limits.Y - Pos.Y;
         return _int2;
     }
     _int2.Y = Pos.Y;
     return _int2;
 }
Beispiel #3
0
 public static modMath.sXY_int GetTileRotatedOffset(sTileOrientation TileOrientation, modMath.sXY_int Pos)
 {
     modMath.sXY_int _int2;
     if (TileOrientation.SwitchedAxes)
     {
         if (TileOrientation.ResultXFlip)
         {
             _int2.X = 0x80 - Pos.Y;
         }
         else
         {
             _int2.X = Pos.Y;
         }
         if (TileOrientation.ResultYFlip)
         {
             _int2.Y = 0x80 - Pos.X;
             return _int2;
         }
         _int2.Y = Pos.X;
         return _int2;
     }
     if (TileOrientation.ResultXFlip)
     {
         _int2.X = 0x80 - Pos.X;
     }
     else
     {
         _int2.X = Pos.X;
     }
     if (TileOrientation.ResultYFlip)
     {
         _int2.Y = 0x80 - Pos.Y;
         return _int2;
     }
     _int2.Y = Pos.Y;
     return _int2;
 }
Beispiel #4
0
 public static void TileOrientation_To_OldOrientation(sTileOrientation TileOrientation, ref byte OutputRotation, ref bool OutputFlipX)
 {
     if (TileOrientation.SwitchedAxes)
     {
         if (TileOrientation.ResultXFlip)
         {
             OutputRotation = 1;
         }
         else
         {
             OutputRotation = 3;
         }
         OutputFlipX = !(TileOrientation.ResultXFlip ^ TileOrientation.ResultYFlip);
     }
     else
     {
         if (TileOrientation.ResultYFlip)
         {
             OutputRotation = 2;
         }
         else
         {
             OutputRotation = 0;
         }
         OutputFlipX = TileOrientation.ResultXFlip ^ TileOrientation.ResultYFlip;
     }
 }
Beispiel #5
0
 public static void RotateDirection(sTileDirection InitialDirection, sTileOrientation Orientation, ref sTileDirection ResultDirection)
 {
     ResultDirection = InitialDirection;
     if (Orientation.SwitchedAxes)
     {
         ResultDirection.SwitchAxes();
     }
     if (Orientation.ResultXFlip)
     {
         ResultDirection.FlipX();
     }
     if (Orientation.ResultYFlip)
     {
         ResultDirection.FlipY();
     }
 }
Beispiel #6
0
 public static void OldOrientation_To_TileOrientation(byte OldRotation, bool OldFlipX, bool OldFlipZ, ref sTileOrientation Result)
 {
     if (OldRotation == 0)
     {
         Result.SwitchedAxes = false;
         Result.ResultXFlip = false;
         Result.ResultYFlip = false;
     }
     else if (OldRotation == 1)
     {
         Result.SwitchedAxes = true;
         Result.ResultXFlip = true;
         Result.ResultYFlip = false;
     }
     else if (OldRotation == 2)
     {
         Result.SwitchedAxes = false;
         Result.ResultXFlip = true;
         Result.ResultYFlip = true;
     }
     else if (OldRotation == 3)
     {
         Result.SwitchedAxes = true;
         Result.ResultXFlip = false;
         Result.ResultYFlip = true;
     }
     if (OldFlipX)
     {
         if (Result.SwitchedAxes)
         {
             Result.ResultYFlip = !Result.ResultYFlip;
         }
         else
         {
             Result.ResultXFlip = !Result.ResultXFlip;
         }
     }
     if (OldFlipZ)
     {
         if (Result.SwitchedAxes)
         {
             Result.ResultXFlip = !Result.ResultXFlip;
         }
         else
         {
             Result.ResultYFlip = !Result.ResultYFlip;
         }
     }
 }
Beispiel #7
0
 public static void GetTileRotatedTexCoords(sTileOrientation TileOrientation, ref modMath.sXY_sng CoordA, ref modMath.sXY_sng CoordB, ref modMath.sXY_sng CoordC, ref modMath.sXY_sng CoordD)
 {
     sTileOrientation orientation = TileOrientation;
     orientation.Reverse();
     if (orientation.SwitchedAxes)
     {
         if (orientation.ResultXFlip)
         {
             CoordA.X = 1f;
             CoordB.X = 1f;
             CoordC.X = 0f;
             CoordD.X = 0f;
         }
         else
         {
             CoordA.X = 0f;
             CoordB.X = 0f;
             CoordC.X = 1f;
             CoordD.X = 1f;
         }
         if (orientation.ResultYFlip)
         {
             CoordA.Y = 1f;
             CoordB.Y = 0f;
             CoordC.Y = 1f;
             CoordD.Y = 0f;
         }
         else
         {
             CoordA.Y = 0f;
             CoordB.Y = 1f;
             CoordC.Y = 0f;
             CoordD.Y = 1f;
         }
     }
     else
     {
         if (orientation.ResultXFlip)
         {
             CoordA.X = 1f;
             CoordB.X = 0f;
             CoordC.X = 1f;
             CoordD.X = 0f;
         }
         else
         {
             CoordA.X = 0f;
             CoordB.X = 1f;
             CoordC.X = 0f;
             CoordD.X = 1f;
         }
         if (orientation.ResultYFlip)
         {
             CoordA.Y = 1f;
             CoordB.Y = 1f;
             CoordC.Y = 0f;
             CoordD.Y = 0f;
         }
         else
         {
             CoordA.Y = 0f;
             CoordB.Y = 0f;
             CoordC.Y = 1f;
             CoordD.Y = 1f;
         }
     }
 }
Beispiel #8
0
 public static modMath.sXY_sng GetTileRotatedPos_sng(sTileOrientation TileOrientation, modMath.sXY_sng Pos)
 {
     modMath.sXY_sng _sng2;
     if (TileOrientation.SwitchedAxes)
     {
         if (TileOrientation.ResultXFlip)
         {
             _sng2.X = 1f - Pos.Y;
         }
         else
         {
             _sng2.X = Pos.Y;
         }
         if (TileOrientation.ResultYFlip)
         {
             _sng2.Y = 1f - Pos.X;
             return _sng2;
         }
         _sng2.Y = Pos.X;
         return _sng2;
     }
     if (TileOrientation.ResultXFlip)
     {
         _sng2.X = 1f - Pos.X;
     }
     else
     {
         _sng2.X = Pos.X;
     }
     if (TileOrientation.ResultYFlip)
     {
         _sng2.Y = 1f - Pos.Y;
         return _sng2;
     }
     _sng2.Y = Pos.Y;
     return _sng2;
 }
Beispiel #9
0
 public static Position.XY_dbl GetTileRotatedPos_dbl(sTileOrientation TileOrientation, Position.XY_dbl Pos)
 {
     Position.XY_dbl _dbl2;
     if (TileOrientation.SwitchedAxes)
     {
         if (TileOrientation.ResultXFlip)
         {
             _dbl2.X = 1.0 - Pos.Y;
         }
         else
         {
             _dbl2.X = Pos.Y;
         }
         if (TileOrientation.ResultYFlip)
         {
             _dbl2.Y = 1.0 - Pos.X;
             return _dbl2;
         }
         _dbl2.Y = Pos.X;
         return _dbl2;
     }
     if (TileOrientation.ResultXFlip)
     {
         _dbl2.X = 1.0 - Pos.X;
     }
     else
     {
         _dbl2.X = Pos.X;
     }
     if (TileOrientation.ResultYFlip)
     {
         _dbl2.Y = 1.0 - Pos.Y;
         return _dbl2;
     }
     _dbl2.Y = Pos.Y;
     return _dbl2;
 }