CCPUCircleEmitter.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /****************************************************************************
  2. Copyright (C) 2013 Henry van Merode. All rights reserved.
  3. Copyright (c) 2015-2017 Chukong Technologies Inc.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef __CC_PU_PARTICLE_3D_CIRCLE_EMITTER_H__
  22. #define __CC_PU_PARTICLE_3D_CIRCLE_EMITTER_H__
  23. #include "extensions/Particle3D/PU/CCPUEmitter.h"
  24. NS_CC_BEGIN
  25. class CC_DLL PUCircleEmitter : public PUEmitter
  26. {
  27. public:
  28. // Constants
  29. static const float DEFAULT_RADIUS;
  30. static const float DEFAULT_STEP;
  31. static const float DEFAULT_ANGLE;
  32. static const bool DEFAULT_RANDOM;
  33. static const Vec3 DEFAULT_NORMAL;
  34. static PUCircleEmitter* create();
  35. /**
  36. */
  37. float getRadius() const;
  38. void setRadius(const float radius);
  39. /**
  40. */
  41. float getCircleAngle() const;
  42. void setCircleAngle(const float circleAngle);
  43. /**
  44. */
  45. float getStep() const;
  46. void setStep(const float step);
  47. /**
  48. */
  49. bool isRandom() const;
  50. void setRandom(const bool random);
  51. /*
  52. */
  53. const Quaternion& getOrientation(void) const;
  54. const Vec3& getNormal(void) const;
  55. void setNormal(const Vec3 &normal);
  56. /** See ParticleEmiter
  57. */
  58. virtual void notifyStart(void) override;
  59. virtual PUCircleEmitter* clone() override;
  60. virtual void copyAttributesTo (PUEmitter* emitter) override;
  61. CC_CONSTRUCTOR_ACCESS:
  62. PUCircleEmitter(void);
  63. virtual ~PUCircleEmitter(void) {};
  64. protected:
  65. /** Determine a particle position on the circle.
  66. */
  67. virtual void initParticlePosition(PUParticle3D* particle) override;
  68. /** Determine the particle direction.
  69. */
  70. virtual void initParticleDirection(PUParticle3D* particle) override;
  71. Quaternion getRotationTo(const Vec3 &src, const Vec3& dest,
  72. const Vec3& fallbackAxis = Vec3::ZERO) const;
  73. protected:
  74. float _radius;
  75. float _circleAngle;
  76. float _originalCircleAngle;
  77. float _step;
  78. float _x;
  79. float _z;
  80. bool _random;
  81. Quaternion _orientation;
  82. Vec3 _normal;
  83. };
  84. NS_CC_END
  85. #endif