CCPUBehaviour.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /****************************************************************************
  2. Copyright (C) 2013 Henry van Merode. All rights reserved.
  3. Copyright (c) 2015-2016 Chukong Technologies Inc.
  4. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. #ifndef __CC_PU_PARTICLE_3D_BEHAVIOUR_H__
  23. #define __CC_PU_PARTICLE_3D_BEHAVIOUR_H__
  24. #include "base/CCRef.h"
  25. #include "math/CCMath.h"
  26. #include "extensions/Particle3D/PU/CCPUParticleSystem3D.h"
  27. #include <vector>
  28. #include <string>
  29. NS_CC_BEGIN
  30. struct PUParticle3D;
  31. class PUParticleSystem3D;
  32. class CC_DLL PUBehaviour : public Ref
  33. {
  34. friend class PUParticleSystem3D;
  35. public:
  36. /** Todo
  37. */
  38. const std::string& getBehaviourType(void) const {return _behaviourType;};
  39. void setBehaviourType(const std::string& behaviourType) {_behaviourType = behaviourType;};
  40. /** Notify that the Behaviour is rescaled.
  41. */
  42. virtual void notifyRescaled(const Vec3& scale){_behaviourScale = scale;};
  43. virtual void prepare() {};
  44. virtual void unPrepare() {};
  45. virtual void updateBehaviour(PUParticle3D *particle, float deltaTime);
  46. /** Perform initialising activities as soon as the particle with which the ParticleBehaviour is
  47. associated, is emitted.
  48. */
  49. virtual void initParticleForEmission(PUParticle3D* particle);
  50. /** Perform some action if a particle expires.
  51. */
  52. virtual void initParticleForExpiration(PUParticle3D* particle, float timeElapsed);
  53. virtual PUBehaviour* clone();
  54. virtual void copyAttributesTo (PUBehaviour* behaviour);
  55. CC_CONSTRUCTOR_ACCESS:
  56. PUBehaviour(void);
  57. virtual ~PUBehaviour(void);
  58. protected:
  59. PUParticleSystem3D* _particleSystem;
  60. // Type of behaviour
  61. std::string _behaviourType;
  62. /** Although the scale is on a Particle System level, the behaviour can also be scaled.
  63. */
  64. Vec3 _behaviourScale;
  65. };
  66. NS_CC_END
  67. #endif