CCPUAffectorManager.cpp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. #include "CCPUAffectorManager.h"
  23. #include "extensions/Particle3D/PU/CCPUAlignAffector.h"
  24. #include "extensions/Particle3D/PU/CCPUBaseCollider.h"
  25. #include "extensions/Particle3D/PU/CCPUBaseForceAffector.h"
  26. #include "extensions/Particle3D/PU/CCPUBoxCollider.h"
  27. #include "extensions/Particle3D/PU/CCPUCollisionAvoidanceAffector.h"
  28. #include "extensions/Particle3D/PU/CCPUColorAffector.h"
  29. #include "extensions/Particle3D/PU/CCPUFlockCenteringAffector.h"
  30. #include "extensions/Particle3D/PU/CCPUForceFieldAffector.h"
  31. #include "extensions/Particle3D/PU/CCPUGeometryRotator.h"
  32. #include "extensions/Particle3D/PU/CCPUGravityAffector.h"
  33. #include "extensions/Particle3D/PU/CCPUInterParticleCollider.h"
  34. #include "extensions/Particle3D/PU/CCPUJetAffector.h"
  35. #include "extensions/Particle3D/PU/CCPULineAffector.h"
  36. #include "extensions/Particle3D/PU/CCPULinearForceAffector.h"
  37. #include "extensions/Particle3D/PU/CCPUParticleFollower.h"
  38. #include "extensions/Particle3D/PU/CCPUPathFollower.h"
  39. #include "extensions/Particle3D/PU/CCPUPlaneCollider.h"
  40. #include "extensions/Particle3D/PU/CCPURandomiser.h"
  41. #include "extensions/Particle3D/PU/CCPUScaleAffector.h"
  42. #include "extensions/Particle3D/PU/CCPUScaleVelocityAffector.h"
  43. #include "extensions/Particle3D/PU/CCPUSineForceAffector.h"
  44. #include "extensions/Particle3D/PU/CCPUSphereCollider.h"
  45. #include "extensions/Particle3D/PU/CCPUTextureAnimator.h"
  46. #include "extensions/Particle3D/PU/CCPUTextureRotator.h"
  47. #include "extensions/Particle3D/PU/CCPUVelocityMatchingAffector.h"
  48. #include "extensions/Particle3D/PU/CCPUVortexAffector.h"
  49. NS_CC_BEGIN
  50. PUAffectorManager::PUAffectorManager()
  51. {
  52. }
  53. PUAffectorManager::~PUAffectorManager()
  54. {
  55. }
  56. PUAffectorManager* PUAffectorManager::Instance()
  57. {
  58. static PUAffectorManager pam;
  59. return &pam;
  60. }
  61. PUScriptTranslator* PUAffectorManager::getTranslator( const std::string &type )
  62. {
  63. if (type == "Align"){
  64. return &_alignAffectorTranslator;
  65. }else if (type == "Dummy02"){
  66. return &_baseColliderTranslator;
  67. }else if (type == "Dummy01"){
  68. return &_baseForceAffectorTranslator;
  69. }else if (type == "BoxCollider"){
  70. return &_boxColliderTranslator;
  71. }else if (type == "CollisionAvoidance"){
  72. return &_collisionAvoidanceAffectorTranstor;
  73. }else if (type == "Colour"){
  74. return &_colorAffectorTranslator;
  75. }else if (type == "FlockCentering"){
  76. return &_flockCenteringAffectorTranslator;
  77. }else if (type == "ForceField"){
  78. return &_forceFieldAffectorTranslator;
  79. }else if (type == "GeometryRotator"){
  80. return &_geometryRotatorTranslator;
  81. }else if (type == "Gravity"){
  82. return &_gravityAffectorTranslator;
  83. }else if (type == "InterParticleCollider"){
  84. return &_interParticleColliderTranslator;
  85. }else if (type == "Jet"){
  86. return &_jetAffectorTranslator;
  87. }else if (type == "Line"){
  88. return &_lineAffectorTranslator;
  89. }else if (type == "LinearForce"){
  90. return &_linearForceAffectorTranslator;
  91. }else if (type == "ParticleFollower"){
  92. return &_particleFollowerTranslator;
  93. }else if (type == "PathFollower"){
  94. return &_pathFollowerTranslator;
  95. }else if (type == "PlaneCollider"){
  96. return &_planeColliderTranslator;
  97. }else if (type == "Randomiser"){
  98. return &_randomiserTranslator;
  99. }else if (type == "Scale"){
  100. return &_scaleAffectorTranslator;
  101. }else if (type == "ScaleVelocity"){
  102. return &_scaleVelocityAffectorTranslator;
  103. }else if (type == "SineForce"){
  104. return &_sineForceAffectorTranslator;
  105. }else if (type == "SphereCollider"){
  106. return &_sphereColliderTranslator;
  107. }else if (type == "TextureAnimator"){
  108. return &_textureAnimatorTranslator;
  109. }else if (type == "TextureRotator"){
  110. return &_textureRotatorTranslator;
  111. }else if (type == "VelocityMatching"){
  112. return &_velocityMatchingAffectorTranslator;
  113. }else if (type == "Vortex"){
  114. return &_vortexAffectorTranslator;
  115. }
  116. return nullptr;
  117. }
  118. PUAffector* PUAffectorManager::createAffector( const std::string &type )
  119. {
  120. if (type == "Align"){
  121. return PUAlignAffector::create();
  122. }else if (type == "Dummy02"){
  123. return nullptr;
  124. }else if (type == "Dummy01"){
  125. return nullptr;
  126. }else if (type == "BoxCollider"){
  127. return PUBoxCollider::create();
  128. }else if (type == "CollisionAvoidance"){
  129. return PUCollisionAvoidanceAffector::create();
  130. }else if (type == "Colour"){
  131. return PUColorAffector::create();
  132. }else if (type == "FlockCentering"){
  133. return PUFlockCenteringAffector::create();
  134. }else if (type == "ForceField"){
  135. return PUForceFieldAffector::create();
  136. }else if (type == "GeometryRotator"){
  137. return PUGeometryRotator::create();
  138. }else if (type == "Gravity"){
  139. return PUGravityAffector::create();
  140. }else if (type == "InterParticleCollider"){
  141. return PUParticle3DInterParticleCollider::create();
  142. }else if (type == "Jet"){
  143. return PUJetAffector::create();
  144. }else if (type == "Line"){
  145. return PULineAffector::create();
  146. }else if (type == "LinearForce"){
  147. return PULinearForceAffector::create();
  148. }else if (type == "ParticleFollower"){
  149. return PUParticleFollower::create();
  150. }else if (type == "PathFollower"){
  151. return PUPathFollower::create();
  152. }else if (type == "PlaneCollider"){
  153. return PUPlaneCollider::create();
  154. }else if (type == "Randomiser"){
  155. return PURandomiser::create();
  156. }else if (type == "Scale"){
  157. return PUScaleAffector::create();
  158. }else if (type == "ScaleVelocity"){
  159. return PUScaleVelocityAffector::create();
  160. }else if (type == "SineForce"){
  161. return PUSineForceAffector::create();
  162. }else if (type == "SphereCollider"){
  163. return PUSphereCollider::create();
  164. }else if (type == "TextureAnimator"){
  165. return PUTextureAnimator::create();
  166. }else if (type == "TextureRotator"){
  167. return PUTextureRotator::create();
  168. }else if (type == "VelocityMatching"){
  169. return PUVelocityMatchingAffector::create();
  170. }else if (type == "Vortex"){
  171. return PUVortexAffector::create();
  172. }
  173. return nullptr;
  174. }
  175. NS_CC_END