ParticleEffect.pkg 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. $#include "Graphics/ParticleEffect.h"
  2. enum EmitterType
  3. {
  4. EMITTER_SPHERE,
  5. EMITTER_BOX,
  6. EMITTER_SPHEREVOLUME,
  7. EMITTER_CYLINDER,
  8. EMITTER_RING
  9. };
  10. struct ColorFrame
  11. {
  12. ColorFrame();
  13. ColorFrame(const Color& color);
  14. ColorFrame(const Color& color, float time);
  15. ~ColorFrame();
  16. Color Interpolate(const ColorFrame& next, float time);
  17. Color color_ @ color;
  18. float time_ @ time;
  19. };
  20. struct TextureFrame
  21. {
  22. TextureFrame();
  23. ~TextureFrame();
  24. Rect uv_ @ uv;
  25. float time_ @ time;
  26. };
  27. class ParticleEffect : public Resource
  28. {
  29. ParticleEffect();
  30. ~ParticleEffect();
  31. void SetMaterial(Material* material);
  32. void SetNumParticles(unsigned num);
  33. void SetUpdateInvisible(bool enable);
  34. void SetRelative(bool enable);
  35. void SetScaled(bool enable);
  36. void SetSorted(bool enable);
  37. void SetFixedScreenSize(bool enable);
  38. void SetAnimationLodBias(float lodBias);
  39. void SetEmitterType(EmitterType type);
  40. void SetEmitterSize(const Vector3& size);
  41. void SetMinDirection(const Vector3& direction);
  42. void SetMaxDirection(const Vector3& direction);
  43. void SetConstantForce(const Vector3& force);
  44. void SetDampingForce(float force);
  45. void SetActiveTime(float time);
  46. void SetInactiveTime(float time);
  47. void SetMinEmissionRate(float rate);
  48. void SetMaxEmissionRate(float rate);
  49. void SetMinParticleSize(const Vector2& size);
  50. void SetMaxParticleSize(const Vector2& size);
  51. void SetMinTimeToLive(float time);
  52. void SetMaxTimeToLive(float time);
  53. void SetMinVelocity(float velocity);
  54. void SetMaxVelocity(float velocity);
  55. void SetMinRotation(float rotation);
  56. void SetMaxRotation(float rotation);
  57. void SetMinRotationSpeed(float speed);
  58. void SetMaxRotationSpeed(float speed);
  59. void SetSizeAdd(float sizeAdd);
  60. void SetSizeMul(float sizeMul);
  61. void AddColorTime(const Color& color, float time);
  62. void AddColorFrame(const ColorFrame& colorFrame);
  63. void RemoveColorFrame(unsigned index);
  64. void SetColorFrame(unsigned index, const ColorFrame& colorFrame);
  65. void SetNumColorFrames(unsigned number);
  66. void SortColorFrames();
  67. void AddTextureTime(const Rect& uv, float time);
  68. void AddTextureFrame(const TextureFrame& textureFrame);
  69. void RemoveTextureFrame(unsigned index);
  70. void SetTextureFrame(unsigned index, const TextureFrame& textureFrame);
  71. void SetNumTextureFrames(unsigned number);
  72. void SortTextureFrames();
  73. // SharedPtr<ParticleEffect> Clone(const String cloneName = String::EMPTY) const;
  74. tolua_outside ParticleEffect* ParticleEffectClone @ Clone(const String cloneName = String::EMPTY) const;
  75. Material* GetMaterial() const;
  76. unsigned GetNumParticles() const;
  77. bool GetUpdateInvisible() const;
  78. bool IsRelative() const;
  79. bool IsScaled() const;
  80. bool IsSorted() const;
  81. bool IsFixedScreenSize() const;
  82. float GetAnimationLodBias() const;
  83. EmitterType GetEmitterType() const;
  84. const Vector3& GetEmitterSize() const;
  85. const Vector3& GetMinDirection() const;
  86. const Vector3& GetMaxDirection() const;
  87. const Vector3& GetConstantForce() const;
  88. float GetDampingForce() const;
  89. float GetActiveTime() const;
  90. float GetInactiveTime() const;
  91. float GetMinEmissionRate() const;
  92. float GetMaxEmissionRate() const;
  93. const Vector2& GetMinParticleSize() const;
  94. const Vector2& GetMaxParticleSize() const;
  95. float GetMinTimeToLive() const;
  96. float GetMaxTimeToLive() const;
  97. float GetMinVelocity() const;
  98. float GetMaxVelocity() const;
  99. float GetMinRotation() const;
  100. float GetMaxRotation() const;
  101. float GetMinRotationSpeed() const;
  102. float GetMaxRotationSpeed() const;
  103. float GetSizeAdd() const;
  104. float GetSizeMul() const;
  105. unsigned GetNumColorFrames() const;
  106. const ColorFrame* GetColorFrame(unsigned index) const;
  107. unsigned GetNumTextureFrames() const;
  108. const TextureFrame* GetTextureFrame(unsigned index) const;
  109. tolua_property__get_set Material* material;
  110. tolua_property__get_set unsigned numParticles;
  111. tolua_property__get_set bool updateInvisible;
  112. tolua_property__is_set bool relative;
  113. tolua_property__is_set bool scaled;
  114. tolua_property__is_set bool sorted;
  115. tolua_property__is_set bool fixedScreenSize;
  116. tolua_property__get_set float animationLodBias;
  117. tolua_property__get_set EmitterType emitterType;
  118. tolua_property__get_set const Vector3& emitterSize;
  119. tolua_property__get_set const Vector3& minDirection;
  120. tolua_property__get_set const Vector3& maxDirection;
  121. tolua_property__get_set const Vector3& constantForce;
  122. tolua_property__get_set float dampingForce;
  123. tolua_property__get_set float activeTime;
  124. tolua_property__get_set float inactiveTime;
  125. tolua_property__get_set float minEmissionRate;
  126. tolua_property__get_set float maxEmissionRate;
  127. tolua_property__get_set const Vector2& minParticleSize;
  128. tolua_property__get_set const Vector2& maxParticleSize;
  129. tolua_property__get_set float minTimeToLive;
  130. tolua_property__get_set float maxTimeToLive;
  131. tolua_property__get_set float minVelocity;
  132. tolua_property__get_set float maxVelocity;
  133. tolua_property__get_set float minRotation;
  134. tolua_property__get_set float maxRotation;
  135. tolua_property__get_set float minRotationSpeed;
  136. tolua_property__get_set float maxRotationSpeed;
  137. tolua_property__get_set float sizeAdd;
  138. tolua_property__get_set float sizeMul;
  139. tolua_property__get_set unsigned numColorFrames;
  140. tolua_property__get_set unsigned numTextureFrames;
  141. };
  142. ${
  143. #define TOLUA_DISABLE_tolua_GraphicsLuaAPI_ParticleEffect_new00
  144. static int tolua_GraphicsLuaAPI_ParticleEffect_new00(lua_State* tolua_S)
  145. {
  146. return ToluaNewObject<ParticleEffect>(tolua_S);
  147. }
  148. #define TOLUA_DISABLE_tolua_GraphicsLuaAPI_ParticleEffect_new00_local
  149. static int tolua_GraphicsLuaAPI_ParticleEffect_new00_local(lua_State* tolua_S)
  150. {
  151. return ToluaNewObjectGC<ParticleEffect>(tolua_S);
  152. }
  153. static ParticleEffect* ParticleEffectClone(const ParticleEffect* effect, const String& cloneName = String::EMPTY)
  154. {
  155. if (!effect)
  156. return 0;
  157. return effect->Clone(cloneName).Detach();
  158. }
  159. $}