ShapeModule.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // ShapeModule.h
  3. // cocos2d_libs
  4. //
  5. // Created by 徐俊杰 on 2020/4/24.
  6. //
  7. #ifndef ShapeModule_h
  8. #define ShapeModule_h
  9. //#include "cocos2d.h"
  10. #include "rparticle/Macros/RParticleMacros.h"
  11. //#include "Runtime/BaseClasses/BaseObject.h"
  12. #include "rparticle/Modules/ParticleSystemModule.h"
  13. #include "rparticle/Math/Random/rand.h"
  14. //#include "Runtime/Utilities/LinkedList.h"
  15. NS_RRP_BEGIN
  16. struct MeshTriangleData
  17. {
  18. float area;
  19. UInt16 indices[3];
  20. };
  21. struct ParticleSystemEmitterMeshVertex
  22. {
  23. Vector3f position;
  24. Vector3f normal;
  25. ColorRGBA32 color;
  26. };
  27. class Mesh;
  28. class ShapeModule : public ParticleSystemModule
  29. {
  30. public:
  31. DECLARE_MODULE (ShapeModule)
  32. ShapeModule ();
  33. enum MeshPlacementMode { kVertex, kEdge, kTriangle, kModeMax };
  34. enum { kSphere, kSphereShell, kHemiSphere, kHemiSphereShell, kCone, kBox, kMesh, kConeShell, kConeVolume, kConeVolumeShell, kCircle, kCircleEdge, kMax };
  35. void AwakeFromLoad (RParticleSystem* system, const ParticleSystemReadOnlyState& roState);
  36. void ResetSeed(const ParticleSystemReadOnlyState& roState);
  37. void DidModifyMeshData ();
  38. void DidDeleteMesh (RParticleSystem* system);
  39. //TODO: Mesh stuff
  40. // PPtr<Mesh> GetMeshEmitterShape () { return m_Mesh; }
  41. void Start (const ParticleSystemReadOnlyState& roState, const ParticleSystemState& state, ParticleSystemParticles& ps, const Matrix4x4f& matrix, size_t fromIndex, float t);
  42. void CalculateProceduralBounds(MinMaxAABB& bounds, const Vector3f& emitterScale, Vector2f minMaxBounds) const;
  43. void CheckConsistency ();
  44. // inline void SetShapeType(int type) { m_Type = type; };
  45. // inline void SetRadius(float radius) { m_Radius = radius; };
  46. inline int GetType() const { return m_Type; }
  47. inline void SetType(int value) { m_Type = value; }
  48. inline float GetRadius() const { return m_Radius; }
  49. inline void SetRadius(float value) { m_Radius = value; }
  50. inline float GetRadiusThickness() const { return m_RadiusThickness; }
  51. inline void SetRadiusThickness(float value) { m_RadiusThickness = value; }
  52. inline float GetAngle() const { return m_Angle; }
  53. inline void SetAngle(float value) { m_Angle = value; }
  54. inline float GetLength() const { return m_Length; }
  55. inline void SetLength(float value) { m_Length = value; }
  56. inline float GetArc() const { return m_Arc; }
  57. inline void SetArc(float value) { m_Arc = value; }
  58. inline bool GetBurstSpread() const { return m_BurstSpread; }
  59. inline void SetBurstSpread(bool value) { m_BurstSpread = value; }
  60. inline float GetSpreadSpaceThickness() const { return m_SpreadSpaceThickness; }
  61. inline void SetSpreadSpaceThickness(float value) { m_SpreadSpaceThickness = value; }
  62. inline float GetBoxX() const { return m_BoxX; }
  63. inline void SetBoxX(float value) { m_BoxX = value; }
  64. inline float GetBoxY() const { return m_BoxY; }
  65. inline void SetBoxY(float value) { m_BoxY = value; }
  66. inline float GetBoxZ() const { return m_BoxZ; }
  67. inline void SetBoxZ(float value) { m_BoxZ = value; }
  68. inline bool GetRandomDirection() const { return m_RandomDirection; }
  69. inline void SetRandomDirection(bool value) { m_RandomDirection = value; }
  70. template<class TransferFunction>
  71. void Transfer (TransferFunction& transfer);
  72. private:
  73. Rand& GetRandom();
  74. int m_Type;
  75. // Primitive stuff
  76. float m_Radius;
  77. float m_RadiusThickness;
  78. float m_Angle;
  79. float m_Length;
  80. float m_Arc;
  81. bool m_BurstSpread;
  82. float m_SpreadSpaceThickness;
  83. float m_BoxX;
  84. float m_BoxY;
  85. float m_BoxZ;
  86. //TODO: Mesh stuff
  87. /*
  88. // Mesh stuff
  89. int m_PlacementMode;
  90. PPtr<Mesh> m_Mesh;
  91. Mesh* m_CachedMesh;
  92. dynamic_array<ParticleSystemEmitterMeshVertex> m_CachedVertexData;
  93. dynamic_array<MeshTriangleData> m_CachedTriangleData;
  94. float m_CachedTotalTriangleArea;
  95. ListNode<Object> m_MeshNode;
  96. */
  97. bool m_RandomDirection;
  98. Rand m_Random;
  99. #if UNITY_EDITOR
  100. public:
  101. Rand m_EditorRandom;
  102. #endif
  103. };
  104. NS_RRP_END
  105. #endif /* ShapeModule_h */