ParticleEmitter.pkg 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. $#include "ParticleEmitter.h"
  2. enum EmitterType
  3. {
  4. EMITTER_SPHERE,
  5. EMITTER_BOX
  6. };
  7. /*
  8. struct Particle
  9. {
  10. Vector3 velocity_;
  11. Vector2 size_;
  12. float timer_;
  13. float timeToLive_;
  14. float scale_;
  15. float rotationSpeed_;
  16. unsigned colorIndex_;
  17. unsigned texIndex_;
  18. };
  19. */
  20. struct ColorFrame
  21. {
  22. ColorFrame();
  23. ColorFrame(const Color& color);
  24. ColorFrame(const Color& color, float time);
  25. Color Interpolate(const ColorFrame& next, float time);
  26. Color color_ @ color;
  27. float time_ @ time;
  28. };
  29. struct TextureFrame
  30. {
  31. TextureFrame();
  32. Rect uv_ @ uv;
  33. float time_ @ time;
  34. };
  35. class ParticleEmitter : public BillboardSet
  36. {
  37. bool Load(XMLFile* file);
  38. bool Save(XMLFile* file);
  39. void SetNumParticles(unsigned num);
  40. void SetEmissionRate(float rate);
  41. void SetMinEmissionRate(float rate);
  42. void SetMaxEmissionRate(float rate);
  43. void SetEmitterType(EmitterType type);
  44. void SetEmitterSize(const Vector3& size);
  45. void SetActiveTime(float time);
  46. void SetInactiveTime(float time);
  47. void SetEmitting(bool enable, bool resetPeriod = false);
  48. void SetUpdateInvisible(bool enable);
  49. void SetTimeToLive(float time);
  50. void SetMinTimeToLive(float time);
  51. void SetMaxTimeToLive(float time);
  52. void SetParticleSize(const Vector2& size);
  53. void SetMinParticleSize(const Vector2& size);
  54. void SetMaxParticleSize(const Vector2& size);
  55. void SetMinDirection(const Vector3& direction);
  56. void SetMaxDirection(const Vector3& direction);
  57. void SetVelocity(float velocity);
  58. void SetMinVelocity(float velocity);
  59. void SetMaxVelocity(float velocity);
  60. void SetRotation(float rotation);
  61. void SetMinRotation(float rotation);
  62. void SetMaxRotation(float rotation);
  63. void SetRotationSpeed(float speed);
  64. void SetMinRotationSpeed(float speed);
  65. void SetMaxRotationSpeed(float speed);
  66. void SetConstantForce(const Vector3& force);
  67. void SetDampingForce(float force);
  68. void SetSizeAdd(float sizeAdd);
  69. void SetSizeMul(float sizeMul);
  70. void SetColor(const Color& color);
  71. void SetNumColors(unsigned num);
  72. void SetNumTextureFrames(unsigned num);
  73. unsigned GetNumParticles() const;
  74. bool IsEmitting() const;
  75. bool GetUpdateInvisible() const;
  76. float GetMinEmissionRate() const;
  77. float GetMaxEmissionRate() const;
  78. EmitterType GetEmitterType() const;
  79. const Vector3& GetEmitterSize() const;
  80. float GetActiveTime() const;
  81. float GetInactiveTime() const;
  82. float GetMinTimeToLive() const;
  83. float GetMaxTimeToLive() const;
  84. const Vector2& GetMinParticleSize() const;
  85. const Vector2& GetMaxParticleSize() const;
  86. const Vector3& GetMinDirection() const;
  87. const Vector3& GetMaxDirection() const;
  88. float GetMinVelocity() const;
  89. float GetMaxVelocity() const;
  90. float GetMinRotation() const;
  91. float GetMaxRotation() const;
  92. float GetMinRotationSpeed() const;
  93. float GetMaxRotationSpeed() const;
  94. const Vector3& GetConstantForce() const;
  95. float GetDampingForce() const;
  96. float GetSizeAdd() const;
  97. float GetSizeMul() const;
  98. unsigned GetNumColors() const;
  99. ColorFrame* GetColor(unsigned index);
  100. unsigned GetNumTextureFrames() const;
  101. TextureFrame* GetTextureFrame(unsigned index);
  102. tolua_property__get_set unsigned numParticles;
  103. tolua_property__get_set float emissionRate; // Write only property.
  104. tolua_property__is_set bool emitting;
  105. tolua_property__get_set bool updateInvisible;
  106. tolua_property__get_set float minEmissionRate;
  107. tolua_property__get_set float maxEmissionRate;
  108. tolua_property__get_set EmitterType emitterType;
  109. tolua_property__get_set Vector3& emitterSize;
  110. tolua_property__get_set float activeTime;
  111. tolua_property__get_set float inactiveTime;
  112. tolua_property__get_set float timeToLive; // Write only property.
  113. tolua_property__get_set float minTimeToLive;
  114. tolua_property__get_set float maxTimeToLive;
  115. tolua_property__get_set Vector2& particleSize; // Write only property.
  116. tolua_property__get_set Vector2& minParticleSize;
  117. tolua_property__get_set Vector2& maxParticleSize;
  118. tolua_property__get_set Vector3& minDirection;
  119. tolua_property__get_set Vector3& maxDirection;
  120. tolua_property__get_set float velocity; // Write only property.
  121. tolua_property__get_set float minVelocity;
  122. tolua_property__get_set float maxVelocity;
  123. tolua_property__get_set float rotation; // Write only property.
  124. tolua_property__get_set float minRotation;
  125. tolua_property__get_set float maxRotation;
  126. tolua_property__get_set float rotationSpeed; // Write only property.
  127. tolua_property__get_set float minRotationSpeed;
  128. tolua_property__get_set float maxRotationSpeed;
  129. tolua_property__get_set Vector3& constantForce;
  130. tolua_property__get_set float dampingForce;
  131. tolua_property__get_set float sizeAdd;
  132. tolua_property__get_set float sizeMul;
  133. tolua_property__get_set unsigned numColors;
  134. tolua_property__get_set unsigned numTextureFrames;
  135. };
  136. ${
  137. #define TOLUA_DISABLE_tolua_get_ParticleEmitter_emissionRate
  138. #define tolua_get_ParticleEmitter_emissionRate NULL
  139. #define TOLUA_DISABLE_tolua_get_ParticleEmitter_timeToLive
  140. #define tolua_get_ParticleEmitter_timeToLive NULL
  141. #define TOLUA_DISABLE_tolua_get_ParticleEmitter_particleSize_ref
  142. #define tolua_get_ParticleEmitter_particleSize_ref NULL
  143. #define TOLUA_DISABLE_tolua_get_ParticleEmitter_velocity
  144. #define tolua_get_ParticleEmitter_velocity NULL
  145. #define TOLUA_DISABLE_tolua_get_ParticleEmitter_rotation
  146. #define tolua_get_ParticleEmitter_rotation NULL
  147. #define TOLUA_DISABLE_tolua_get_ParticleEmitter_rotationSpeed
  148. #define tolua_get_ParticleEmitter_rotationSpeed NULL
  149. $}