CCPUOnPositionObserver.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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_ON_POSITION_OBSERVER_H__
  23. #define __CC_PU_PARTICLE_3D_ON_POSITION_OBSERVER_H__
  24. #include "base/CCRef.h"
  25. #include "math/CCMath.h"
  26. #include "extensions/Particle3D/PU/CCPUObserver.h"
  27. #include <vector>
  28. #include <string>
  29. NS_CC_BEGIN
  30. struct PUParticle3D;
  31. class PUParticleSystem3D;
  32. class CC_DLL PUOnPositionObserver : public PUObserver
  33. {
  34. public:
  35. // Constants
  36. static const Vec3 DEFAULT_POSITION_THRESHOLD;
  37. static PUOnPositionObserver* create();
  38. /**
  39. */
  40. virtual bool observe (PUParticle3D* particle, float timeElapsed) override;
  41. /**
  42. */
  43. void setPositionXThreshold(float threshold){_positionXThreshold = threshold; _positionXThresholdSet = true;};
  44. void setPositionYThreshold(float threshold){_positionYThreshold = threshold; _positionYThresholdSet = true;};
  45. void setPositionZThreshold(float threshold){_positionZThreshold = threshold; _positionZThresholdSet = true;};
  46. /**
  47. */
  48. float getPositionXThreshold(void) const {return _positionXThreshold;};
  49. float getPositionYThreshold(void) const {return _positionYThreshold;};
  50. float getPositionZThreshold(void) const {return _positionZThreshold;};
  51. /**
  52. */
  53. bool isPositionXThresholdSet(void) const {return _positionXThresholdSet;};
  54. bool isPositionYThresholdSet(void) const {return _positionYThresholdSet;};
  55. bool isPositionZThresholdSet(void) const {return _positionZThresholdSet;};
  56. /**
  57. */
  58. void resetPositionXThreshold(void) {_positionXThresholdSet = false;};
  59. void resetPositionYThreshold(void) {_positionYThresholdSet = false;};
  60. void resetPositionZThreshold(void) {_positionZThresholdSet = false;};
  61. /**
  62. */
  63. void setComparePositionX(PUComparisionOperator op){_comparePositionX = op;};
  64. void setComparePositionY(PUComparisionOperator op){_comparePositionY = op;};
  65. void setComparePositionZ(PUComparisionOperator op){_comparePositionZ = op;};
  66. /**
  67. */
  68. PUComparisionOperator getComparePositionX() const {return _comparePositionX;};
  69. PUComparisionOperator getComparePositionY() const {return _comparePositionY;};
  70. PUComparisionOperator getComparePositionZ() const {return _comparePositionZ;};
  71. virtual void copyAttributesTo (PUObserver* observer) override;
  72. CC_CONSTRUCTOR_ACCESS:
  73. PUOnPositionObserver(void);
  74. virtual ~PUOnPositionObserver(void) {};
  75. protected:
  76. float _positionXThreshold;
  77. float _positionYThreshold;
  78. float _positionZThreshold;
  79. bool _positionXThresholdSet;
  80. bool _positionYThresholdSet;
  81. bool _positionZThresholdSet;
  82. PUComparisionOperator _comparePositionX;
  83. PUComparisionOperator _comparePositionY;
  84. PUComparisionOperator _comparePositionZ;
  85. };
  86. NS_CC_END
  87. #endif