WindComponentAPI.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // Magica Cloth.
  2. // Copyright (c) MagicaSoft, 2020-2022.
  3. // https://magicasoft.jp
  4. using Unity.Mathematics;
  5. using UnityEngine;
  6. namespace MagicaCloth
  7. {
  8. /// <summary>
  9. /// WindComponent API
  10. /// </summary>
  11. public abstract partial class WindComponent : BaseComponent
  12. {
  13. /// <summary>
  14. /// 風量
  15. /// Air flow.
  16. /// </summary>
  17. public float Main
  18. {
  19. get => main;
  20. set
  21. {
  22. main = Mathf.Clamp(value, 0.0f, Define.Compute.MaxWindMain);
  23. status.SetDirty();
  24. }
  25. }
  26. /// <summary>
  27. /// 乱流率
  28. /// Turbulence rate.(0.0 - 1.0)
  29. /// </summary>
  30. public float Turbulence
  31. {
  32. get => turbulence;
  33. set
  34. {
  35. turbulence = Mathf.Clamp01(value);
  36. status.SetDirty();
  37. }
  38. }
  39. /// <summary>
  40. /// 周波数
  41. /// Frequency rate.(0.0 - 1.0)
  42. /// </summary>
  43. public float Frequency
  44. {
  45. get => frequency;
  46. set
  47. {
  48. frequency = Mathf.Clamp01(value);
  49. status.SetDirty();
  50. }
  51. }
  52. /// <summary>
  53. /// 基準となる風向き(ワールド)
  54. /// Wind world direction.
  55. /// </summary>
  56. public Vector3 MainDirection
  57. {
  58. get => transform.TransformDirection(GetLocalDirection());
  59. set
  60. {
  61. var lv = transform.InverseTransformDirection(value);
  62. directionAngleX = Mathf.Atan2(lv.z, lv.x) * Mathf.Rad2Deg;
  63. directionAngleY = Mathf.Atan2(lv.z, lv.y) * Mathf.Rad2Deg;
  64. status.SetDirty();
  65. }
  66. }
  67. /// <summary>
  68. /// 風向きのX軸角度(Degree)
  69. /// Wind direction X-axis angle (Degree)
  70. /// </summary>
  71. public float DirectionAngleX
  72. {
  73. get => directionAngleX;
  74. set
  75. {
  76. directionAngleX = value;
  77. status.SetDirty();
  78. }
  79. }
  80. /// <summary>
  81. /// 風向きのY軸角度(Degree)
  82. /// Wind direction Y-axis angle (Degree).
  83. /// </summary>
  84. public float DirectionAngleY
  85. {
  86. get => directionAngleY;
  87. set
  88. {
  89. directionAngleY = value;
  90. status.SetDirty();
  91. }
  92. }
  93. /// <summary>
  94. /// 風エリアのサイズ
  95. /// Wind area size.
  96. /// </summary>
  97. public Vector3 AreaSize
  98. {
  99. get => areaSize;
  100. set
  101. {
  102. areaSize = math.max(value, 0.1f);
  103. status.SetDirty();
  104. }
  105. }
  106. /// <summary>
  107. /// 風エリアの半径
  108. /// Wind area radius.
  109. /// </summary>
  110. public float AreaRadius
  111. {
  112. get => areaRadius;
  113. set
  114. {
  115. areaRadius = math.max(value, 0.1f);
  116. status.SetDirty();
  117. }
  118. }
  119. /// <summary>
  120. /// 風の方向性
  121. /// Wind direction type.
  122. /// </summary>
  123. public PhysicsManagerWindData.DirectionType DirectionType
  124. {
  125. get => directionType;
  126. set
  127. {
  128. directionType = value;
  129. status.SetDirty();
  130. }
  131. }
  132. /// <summary>
  133. /// 球形エリアの減衰率
  134. /// Damping factor of spherical area.
  135. /// </summary>
  136. /// <param name="sval">Influence rate of start point.(0.0 - 1.0)</param>
  137. /// <param name="eval">Influence rate of end point.(0.0 - 1.0)</param>
  138. /// <param name="useEval">Validity of endpoint value</param>
  139. /// <param name="cval">Strength of the curve.(-1.0 - +1.0)</param>
  140. /// <param name="useCval">Validity of curve value</param>
  141. public void SetAttenuation(float sval, float eval, bool useEval = true, float cval = 0.0f, bool useCval = false)
  142. {
  143. attenuation.SetParam(sval, eval, useEval, cval, useCval);
  144. status.SetDirty();
  145. }
  146. }
  147. }