UVModule.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // UVModule.h
  3. // cocos2d_libs
  4. //
  5. // Created by 徐俊杰 on 2020/4/24.
  6. //
  7. #ifndef UVModule_h
  8. #define UVModule_h
  9. //#include "cocos2d.h"
  10. #include "rparticle/Macros/RParticleMacros.h"
  11. #include "rparticle/Modules/ParticleSystemModule.h"
  12. #include "rparticle/PolynomialCurve.h"
  13. NS_RRP_BEGIN
  14. struct ParticleSystemParticles;
  15. class UVModule : public ParticleSystemModule
  16. {
  17. public:
  18. DECLARE_MODULE (UVModule)
  19. UVModule ();
  20. void RefreshFrames (std::vector<RRP_PARTICLEQUAD_VERTEX_INFO>& vertextInfos);
  21. void Update (const ParticleSystemParticles& ps, float* tempSheetIndex, size_t fromIndex, size_t toIndex);
  22. void CheckConsistency ();
  23. inline MinMaxCurve& GetCurve() { return m_Curve; }
  24. inline const MinMaxCurve& GetCurve() const { return m_Curve; }
  25. void GetNumTiles(int& uvTilesX, int& uvTilesY) const;
  26. template<class TransferFunction>
  27. void Transfer (TransferFunction& transfer);
  28. void SetTilesX(int value) { m_TilesX = value; }
  29. int GetTilesX() const { return m_TilesX; }
  30. void SetTilesY(int value) { m_TilesY = value; }
  31. int GetTilesY() const { return m_TilesY; }
  32. void SetAnimationType(int value) { m_AnimationType = value; }
  33. int GetAnimationType() const { return m_AnimationType; }
  34. void SetRowIndex(int value) { m_RowIndex = value; }
  35. int GetRowIndex() const { return m_RowIndex; }
  36. void SetCycles(float value) { m_Cycles = value; }
  37. float GetCycles() const { return m_Cycles; }
  38. void SetRandomRow(bool value) { m_RandomRow = value; }
  39. bool GetRandomRow() const { return m_RandomRow; }
  40. void SetMode(int value) { m_Mode = value; }
  41. int GetMode() const { return m_Mode; }
  42. void SetFrameNamePrefix(const std::string& value) {
  43. if (_frameNamePrefix != value) {
  44. _frameNamePrefix = value;
  45. _isFramesDirty = true;
  46. }
  47. }
  48. const std::string& GetFrameNamePrefix() const { return _frameNamePrefix; }
  49. void SetFrameStartIndex(int value) {
  50. if (_frameStartIndex != value) {
  51. _frameStartIndex = value;
  52. _isFramesDirty = true;
  53. }
  54. }
  55. int GetFrameStartIndex() const { return _frameStartIndex; }
  56. void SetFrameEndIndex(int value) {
  57. if (_frameEndIndex != value) {
  58. _frameEndIndex = value;
  59. _isFramesDirty = true;
  60. }
  61. }
  62. int GetFrameEndIndex() const { return _frameEndIndex; }
  63. void SetFrameCount(int value) {
  64. #if REDREAM_EDITOR
  65. _frameCount = value;
  66. #endif
  67. }
  68. int GetFrameCount() const {
  69. #if REDREAM_EDITOR
  70. return _frameCount;
  71. #else
  72. return 0;
  73. #endif
  74. }
  75. void SetFrameDirty() { _isFramesDirty = true; }
  76. void ClearFrameDirty() { _isFramesDirty = false; }
  77. private:
  78. enum Mode { kModeGrid, kModeSprites, kNumModes };
  79. enum { kWholeSheet, kSingleRow, kNumAnimationTypes };
  80. int m_Mode;
  81. MinMaxCurve m_Curve;
  82. int m_TilesX;
  83. int m_TilesY;
  84. int m_AnimationType;
  85. int m_RowIndex;
  86. float m_Cycles;
  87. bool m_RandomRow;
  88. std::string _frameNamePrefix;
  89. int _frameStartIndex;
  90. int _frameEndIndex;
  91. #if REDREAM_EDITOR
  92. int _frameCount;
  93. #endif
  94. bool _isFramesDirty;
  95. };
  96. NS_RRP_END
  97. #endif /* UVModule_h */