Random.generated.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using System.Runtime.InteropServices;
  4. namespace BansheeEngine
  5. {
  6. /** @addtogroup Math
  7. * @{
  8. */
  9. /// <summary>
  10. /// Generates pseudo random numbers using the Xorshift128 algorithm. Suitable for high performance requirements.
  11. /// </summary>
  12. public partial class Random : ScriptObject
  13. {
  14. private Random(bool __dummy0) { }
  15. protected Random() { }
  16. /// <summary>Initializes a new generator using the specified seed.</summary>
  17. public Random(uint seed = 0)
  18. {
  19. Internal_Random(this, seed);
  20. }
  21. /// <summary>Changes the seed of the generator to the specified value.</summary>
  22. public void SetSeed(uint seed)
  23. {
  24. Internal_setSeed(mCachedPtr, seed);
  25. }
  26. /// <summary>Returns a random value in range [0, std::numeric_limits<uint32_t>::max()].</summary>
  27. public uint Get()
  28. {
  29. return Internal_get(mCachedPtr);
  30. }
  31. /// <summary>Returns a random value in range [min, max].</summary>
  32. public int GetRange(int min, int max)
  33. {
  34. return Internal_getRange(mCachedPtr, min, max);
  35. }
  36. /// <summary>Returns a random value in range [0, 1].</summary>
  37. public float GetUNorm()
  38. {
  39. return Internal_getUNorm(mCachedPtr);
  40. }
  41. /// <summary>Returns a random value in range [-1, 1].</summary>
  42. public float GetSNorm()
  43. {
  44. return Internal_getSNorm(mCachedPtr);
  45. }
  46. /// <summary>Returns a random unit vector in three dimensions.</summary>
  47. public Vector3 GetUnitVector()
  48. {
  49. Vector3 temp;
  50. Internal_getUnitVector(mCachedPtr, out temp);
  51. return temp;
  52. }
  53. /// <summary>Returns a random unit vector in two dimensions.</summary>
  54. public Vector2 GetUnitVector2D()
  55. {
  56. Vector2 temp;
  57. Internal_getUnitVector2D(mCachedPtr, out temp);
  58. return temp;
  59. }
  60. /// <summary>Returns a random point inside a unit sphere.</summary>
  61. public Vector3 GetPointInSphere()
  62. {
  63. Vector3 temp;
  64. Internal_getPointInSphere(mCachedPtr, out temp);
  65. return temp;
  66. }
  67. /// <summary>
  68. /// Returns a random point inside the specified range in a sphere shell of unit radius, with the specified thickness, in
  69. /// range [0, 1]. Thickness of 0 will generate points on the sphere surface, while thickness of 1 will generate points
  70. /// within the entire sphere volume. Intermediate values represent the shell, which is a volume between two concentric
  71. /// spheres.
  72. /// </summary>
  73. public Vector3 GetPointInSphereShell(float thickness)
  74. {
  75. Vector3 temp;
  76. Internal_getPointInSphereShell(mCachedPtr, thickness, out temp);
  77. return temp;
  78. }
  79. /// <summary>Returns a random point inside a unit circle.</summary>
  80. public Vector2 GetPointInCircle()
  81. {
  82. Vector2 temp;
  83. Internal_getPointInCircle(mCachedPtr, out temp);
  84. return temp;
  85. }
  86. /// <summary>
  87. /// Returns a random point inside the specified range in a circle shell of unit radius, with the specified thickness, in
  88. /// range [0, 1]. Thickness of 0 will generate points on the circle edge, while thickness of 1 will generate points
  89. /// within the entire circle surface. Intermediate values represent the shell, which is the surface between two
  90. /// concentric circles.
  91. /// </summary>
  92. public Vector2 GetPointInCircleShell(float thickness)
  93. {
  94. Vector2 temp;
  95. Internal_getPointInCircleShell(mCachedPtr, thickness, out temp);
  96. return temp;
  97. }
  98. /// <summary>
  99. /// Returns a random point on a unit arc with the specified length (angle). Angle of 360 represents a circle.
  100. /// </summary>
  101. public Vector2 GetPointInArc(Degree angle)
  102. {
  103. Vector2 temp;
  104. Internal_getPointInArc(mCachedPtr, ref angle, out temp);
  105. return temp;
  106. }
  107. /// <summary>
  108. /// Returns a random point inside the specified range in an arc shell of unit radius, with the specified length (angle)
  109. /// and thickness in range [0, 1]. Angle of 360 represents a circle shell. Thickness of 0 will generate points on the arc
  110. /// edge, while thickness of 1 will generate points on the entire arc 'slice'. Intermediate vlaues represent the shell,
  111. /// which is the surface between two concentric circles.
  112. /// </summary>
  113. public Vector2 GetPointInArcShell(Degree angle, float thickness)
  114. {
  115. Vector2 temp;
  116. Internal_getPointInArcShell(mCachedPtr, ref angle, thickness, out temp);
  117. return temp;
  118. }
  119. /// <summary>
  120. /// Returns a random set of Barycentric coordinates that may be used for generating random points on a triangle.
  121. /// </summary>
  122. public Vector3 GetBarycentric()
  123. {
  124. Vector3 temp;
  125. Internal_getBarycentric(mCachedPtr, out temp);
  126. return temp;
  127. }
  128. [MethodImpl(MethodImplOptions.InternalCall)]
  129. private static extern void Internal_Random(Random managedInstance, uint seed);
  130. [MethodImpl(MethodImplOptions.InternalCall)]
  131. private static extern void Internal_setSeed(IntPtr thisPtr, uint seed);
  132. [MethodImpl(MethodImplOptions.InternalCall)]
  133. private static extern uint Internal_get(IntPtr thisPtr);
  134. [MethodImpl(MethodImplOptions.InternalCall)]
  135. private static extern int Internal_getRange(IntPtr thisPtr, int min, int max);
  136. [MethodImpl(MethodImplOptions.InternalCall)]
  137. private static extern float Internal_getUNorm(IntPtr thisPtr);
  138. [MethodImpl(MethodImplOptions.InternalCall)]
  139. private static extern float Internal_getSNorm(IntPtr thisPtr);
  140. [MethodImpl(MethodImplOptions.InternalCall)]
  141. private static extern void Internal_getUnitVector(IntPtr thisPtr, out Vector3 __output);
  142. [MethodImpl(MethodImplOptions.InternalCall)]
  143. private static extern void Internal_getUnitVector2D(IntPtr thisPtr, out Vector2 __output);
  144. [MethodImpl(MethodImplOptions.InternalCall)]
  145. private static extern void Internal_getPointInSphere(IntPtr thisPtr, out Vector3 __output);
  146. [MethodImpl(MethodImplOptions.InternalCall)]
  147. private static extern void Internal_getPointInSphereShell(IntPtr thisPtr, float thickness, out Vector3 __output);
  148. [MethodImpl(MethodImplOptions.InternalCall)]
  149. private static extern void Internal_getPointInCircle(IntPtr thisPtr, out Vector2 __output);
  150. [MethodImpl(MethodImplOptions.InternalCall)]
  151. private static extern void Internal_getPointInCircleShell(IntPtr thisPtr, float thickness, out Vector2 __output);
  152. [MethodImpl(MethodImplOptions.InternalCall)]
  153. private static extern void Internal_getPointInArc(IntPtr thisPtr, ref Degree angle, out Vector2 __output);
  154. [MethodImpl(MethodImplOptions.InternalCall)]
  155. private static extern void Internal_getPointInArcShell(IntPtr thisPtr, ref Degree angle, float thickness, out Vector2 __output);
  156. [MethodImpl(MethodImplOptions.InternalCall)]
  157. private static extern void Internal_getBarycentric(IntPtr thisPtr, out Vector3 __output);
  158. }
  159. /** @} */
  160. }