/PhysicsEngines/JigLib/JigLibDatatypesMapping.cs
C# | 119 lines | 78 code | 6 blank | 35 comment | 0 complexity | ce8fa8e8a25e30a30e0673adb64dd6a3 MD5 | raw file
Possible License(s): Apache-2.0
- using Delta.Utilities.Datatypes;
- using Microsoft.Xna.Framework;
- using Matrix = Delta.Utilities.Datatypes.Matrix;
- using XnaMatrix = Microsoft.Xna.Framework.Matrix;
-
- namespace Delta.PhysicsEngines.JigLib
- {
- /// <summary>
- /// Performs mapping between JigLibX and DeltaEngine.
- /// </summary>
- internal static class JigLibDatatypesMapping
- {
- #region Convert (Static)
- /// <summary>
- /// Convert XNA Vector3 used by JigLibX to Delta Vector.
- /// </summary>
- /// <param name="vector">The source Xna vector.</param>
- /// <param name="result">The converted delta vector.</param>
- public static void Convert(ref Vector3 vector, out Vector result)
- {
- result = new Vector
- {
- X = vector.X,
- Y = vector.Y,
- Z = vector.Z
- };
- }
-
- /// <summary>
- /// Convert XNA Vector3 used by JigLibX to Delta Vector.
- /// </summary>
- /// <param name="vector">The source Xna vector.</param>
- /// <param name="result">The converted delta vector.</param>
- public static void Convert(Vector3 vector, out Vector result)
- {
- result = new Vector
- {
- X = vector.X,
- Y = vector.Y,
- Z = vector.Z
- };
- }
-
- /// <summary>
- /// Convert Delta vector to XNA Vector3 used by JigLibX.
- /// </summary>
- /// <param name="vector">The source delta vector.</param>
- /// <returns>The converted Xna Vector3 vector.</returns>
- public static Vector3 Convert(ref Vector vector)
- {
- return new Vector3(vector.X, vector.Y, vector.Z);
- }
-
- /// <summary>
- /// Convert Delta Vector to Xna Vector3 used by JigLibX.
- /// </summary>
- /// <param name="vector">The source Delta vector.</param>
- /// <param name="result">The converted Xna vector.</param>
- public static void Convert(ref Vector vector, out Vector3 result)
- {
- result.X = vector.X;
- result.Y = vector.Y;
- result.Z = vector.Z;
- }
-
- /// <summary>
- /// Slow version of the JMatrix to Delta Matrix conversion. Used
- /// when properties are involved (we cannot pass them as ref and would
- /// need local copies anyway) and performance is not super critical.
- /// </summary>
- /// <param name="inputValue">The input value.</param>
- /// <returns>Delta engine Matrix created from Xna Matrix.</returns>
- public static void Convert(XnaMatrix matrix, ref Matrix result)
- {
- result.M11 = matrix.M11;
- result.M12 = matrix.M12;
- result.M13 = matrix.M13;
- result.M14 = matrix.M14;
- result.M21 = matrix.M21;
- result.M22 = matrix.M22;
- result.M23 = matrix.M23;
- result.M24 = matrix.M24;
- result.M31 = matrix.M31;
- result.M32 = matrix.M32;
- result.M33 = matrix.M33;
- result.M34 = matrix.M34;
- result.M41 = matrix.M41;
- result.M42 = matrix.M42;
- result.M43 = matrix.M43;
- result.M44 = matrix.M44;
- }
-
- /// <summary>
- /// Convert DeltaEngine Matrix to XNA Matrix used by JigLibX.
- /// </summary>
- /// <param name="matrix">The matrix.</param>
- /// <param name="result">The result.</param>
- public static void Convert(ref Matrix matrix, out XnaMatrix result)
- {
- result.M11 = matrix.M11;
- result.M12 = matrix.M12;
- result.M13 = matrix.M13;
- result.M14 = matrix.M14;
- result.M21 = matrix.M21;
- result.M22 = matrix.M22;
- result.M23 = matrix.M23;
- result.M24 = matrix.M24;
- result.M31 = matrix.M31;
- result.M32 = matrix.M32;
- result.M33 = matrix.M33;
- result.M34 = matrix.M34;
- result.M41 = matrix.M41;
- result.M42 = matrix.M42;
- result.M43 = matrix.M43;
- result.M44 = matrix.M44;
- }
- #endregion
- }
- }