Root/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | using Microsoft.Xna.Framework; namespace FarseerPhysics.SamplesFramework { /// <summary> /// Convert units between display and simulation units. /// </summary> public static class ConvertUnits { private static float _displayUnitsToSimUnitsRatio = 100f; private static float _simUnitsToDisplayUnitsRatio = 1 / _displayUnitsToSimUnitsRatio; public static void SetDisplayUnitToSimUnitRatio( float displayUnitsPerSimUnit) { _displayUnitsToSimUnitsRatio = displayUnitsPerSimUnit; _simUnitsToDisplayUnitsRatio = 1 / displayUnitsPerSimUnit; } public static float ToDisplayUnits( float simUnits) { return simUnits * _displayUnitsToSimUnitsRatio; } public static float ToDisplayUnits( int simUnits) { return simUnits * _displayUnitsToSimUnitsRatio; } public static Vector2 ToDisplayUnits(Vector2 simUnits) { return simUnits * _displayUnitsToSimUnitsRatio; } public static void ToDisplayUnits( ref Vector2 simUnits, out Vector2 displayUnits) { Vector2.Multiply( ref simUnits, _displayUnitsToSimUnitsRatio, out displayUnits); } public static Vector3 ToDisplayUnits(Vector3 simUnits) { return simUnits * _displayUnitsToSimUnitsRatio; } public static Vector2 ToDisplayUnits( float x, float y) { return new Vector2(x, y) * _displayUnitsToSimUnitsRatio; } public static void ToDisplayUnits( float x, float y, out Vector2 displayUnits) { displayUnits = Vector2.Zero; displayUnits.X = x * _displayUnitsToSimUnitsRatio; displayUnits.Y = y * _displayUnitsToSimUnitsRatio; } public static float ToSimUnits( float displayUnits) { return displayUnits * _simUnitsToDisplayUnitsRatio; } public static float ToSimUnits( double displayUnits) { return ( float )displayUnits * _simUnitsToDisplayUnitsRatio; } public static float ToSimUnits( int displayUnits) { return displayUnits * _simUnitsToDisplayUnitsRatio; } public static Vector2 ToSimUnits(Vector2 displayUnits) { return displayUnits * _simUnitsToDisplayUnitsRatio; } public static Vector3 ToSimUnits(Vector3 displayUnits) { return displayUnits * _simUnitsToDisplayUnitsRatio; } public static void ToSimUnits( ref Vector2 displayUnits, out Vector2 simUnits) { Vector2.Multiply( ref displayUnits, _simUnitsToDisplayUnitsRatio, out simUnits); } public static Vector2 ToSimUnits( float x, float y) { return new Vector2(x, y) * _simUnitsToDisplayUnitsRatio; } public static Vector2 ToSimUnits( double x, double y) { return new Vector2(( float )x, ( float )y) * _simUnitsToDisplayUnitsRatio; } public static void ToSimUnits( float x, float y, out Vector2 simUnits) { simUnits = Vector2.Zero; simUnits.X = x * _simUnitsToDisplayUnitsRatio; simUnits.Y = y * _simUnitsToDisplayUnitsRatio; } } } |
Source at commit 0737379cc88f created 12 years 3 months ago. By Nathan Adams, Adding visible property to SimpleDrawableAxiosGameObject |
---|