Random.generated.cs 6.5 KB

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