ParticleEmitter.pkg 5.8 KB

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