PageRenderTime 103ms CodeModel.GetById 61ms app.highlight 6ms RepoModel.GetById 34ms app.codeStats 0ms

/PhysicsEngines/Jitter/JitterDatatypesMapping.cs

#
C# | 122 lines | 74 code | 7 blank | 41 comment | 0 complexity | fd2c9ef5f62c05ba0b9328fdce8cb911 MD5 | raw file
  1using Delta.Utilities.Datatypes;
  2using Jitter.LinearMath;
  3
  4namespace Delta.PhysicsEngines.Jitter
  5{
  6	/// <summary>
  7	/// Implements mapping between Jitter data types and Delta engine data types.
  8	/// 
  9	/// Sadly we can't do all the nice union stuff we do with XNA, because we
 10	/// don't have Jitter referenced in the datatypes.
 11	/// </summary>
 12	internal static class JitterDatatypesMapping
 13	{
 14		#region Convert (Static)
 15		/// <summary>
 16		/// Perform conversion between DeltaEngine Matrix and Jitter Matrix.
 17		/// </summary>
 18		/// <param name="matrix">The DeltaEngine matrix.</param>
 19		/// <returns>The converted Jitter matrix.</returns>
 20		public static JMatrix Convert(ref Matrix matrix)
 21		{
 22			JMatrix result;
 23			result.M11 = matrix.M11;
 24			result.M12 = matrix.M12;
 25			result.M13 = matrix.M13;
 26			result.M21 = matrix.M21;
 27			result.M22 = matrix.M22;
 28			result.M23 = matrix.M23;
 29			result.M31 = matrix.M31;
 30			result.M32 = matrix.M32;
 31			result.M33 = matrix.M33;
 32			return result;
 33		}
 34
 35		/// <summary>
 36		/// Convert a Jitter matrix into a Delta Matrix.
 37		/// </summary>
 38		/// <param name="matrix">The Jitter matrix to convert.</param>
 39		/// <param name="result">The converterd delta matrix.</param>
 40		public static void Convert(JMatrix matrix, ref Matrix result)
 41		{
 42			result.M11 = matrix.M11;
 43			result.M12 = matrix.M12;
 44			result.M13 = matrix.M13;
 45			result.M21 = matrix.M21;
 46			result.M22 = matrix.M22;
 47			result.M23 = matrix.M23;
 48			result.M31 = matrix.M31;
 49			result.M32 = matrix.M32;
 50			result.M33 = matrix.M33;
 51		}
 52
 53		/// <summary>
 54		/// Convert DeltaEngine vector to Jitter vector.
 55		/// </summary>
 56		/// <param name="vector">DeltaEngine vector.</param>
 57		/// <returns>The converted Jitter vector.</returns>
 58		public static JVector Convert(ref Vector vector)
 59		{
 60			JVector result;
 61			result.X = vector.X;
 62			result.Y = vector.Y;
 63			result.Z = vector.Z;
 64			return result;
 65		}
 66
 67		/// <summary>
 68		/// Convert DeltaEngine vector to Jitter vector.
 69		/// </summary>
 70		/// <param name="vector">DeltaEngine vector.</param>
 71		/// <param name="result">The converted Jitter vector.</param>
 72		public static void Convert(ref Vector vector, out JVector result)
 73		{
 74			result.X = vector.X;
 75			result.Y = vector.Y;
 76			result.Z = vector.Z;
 77		}
 78		#endregion
 79
 80		#region ConvertSlow (Static)
 81		/// <summary>
 82		/// Convert DeltaEngine vector to Jitter vector.
 83		/// </summary>
 84		/// <param name="vector">DeltaEngine vector.</param>
 85		/// <returns>The converted Jitter vector.</returns>
 86		public static JVector ConvertSlow(Vector vector)
 87		{
 88			JVector result;
 89			result.X = vector.X;
 90			result.Y = vector.Y;
 91			result.Z = vector.Z;
 92			return result;
 93		}
 94		#endregion
 95
 96		#region Convert (Static)
 97		/// <summary>
 98		/// Convert Jitter vector to DeltaEngine vector.
 99		/// </summary>
100		/// <param name="vector">Jitter vector.</param>
101		/// <param name="result">The converted Jitter vector.</param>
102		public static void Convert(JVector vector, out Vector result)
103		{
104			result.X = vector.X;
105			result.Y = vector.Y;
106			result.Z = vector.Z;
107		}
108
109		/// <summary>
110		/// Convert Jitter vector to DeltaEngine vector.
111		/// </summary>
112		/// <param name="vector">Jitter vector.</param>
113		/// <param name="result">The converted Jitter vector.</param>
114		public static void Convert(ref JVector vector, out Vector result)
115		{
116			result.X = vector.X;
117			result.Y = vector.Y;
118			result.Z = vector.Z;
119		}
120		#endregion
121	}
122}