ParticleEmitter.pkg 5.7 KB

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