axmol/extensions/Particle3D/PU/CCPUAffectorManager.cpp

187 lines
7.4 KiB
C++
Raw Normal View History

2015-02-11 18:14:22 +08:00
/****************************************************************************
2015-02-25 18:05:41 +08:00
Copyright (C) 2013 Henry van Merode. All rights reserved.
2015-02-12 16:09:08 +08:00
Copyright (c) 2015 Chukong Technologies Inc.
2015-02-11 18:14:22 +08:00
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
2015-03-05 13:24:06 +08:00
#include "CCPUAffectorManager.h"
#include "extensions/Particle3D/PU/CCPUAlignAffector.h"
#include "extensions/Particle3D/PU/CCPUBaseCollider.h"
#include "extensions/Particle3D/PU/CCPUBaseForceAffector.h"
#include "extensions/Particle3D/PU/CCPUBoxCollider.h"
#include "extensions/Particle3D/PU/CCPUCollisionAvoidanceAffector.h"
#include "extensions/Particle3D/PU/CCPUColorAffector.h"
#include "extensions/Particle3D/PU/CCPUFlockCenteringAffector.h"
#include "extensions/Particle3D/PU/CCPUForceFieldAffector.h"
#include "extensions/Particle3D/PU/CCPUGeometryRotator.h"
#include "extensions/Particle3D/PU/CCPUGravityAffector.h"
#include "extensions/Particle3D/PU/CCPUInterParticleCollider.h"
#include "extensions/Particle3D/PU/CCPUJetAffector.h"
#include "extensions/Particle3D/PU/CCPULineAffector.h"
#include "extensions/Particle3D/PU/CCPULinearForceAffector.h"
#include "extensions/Particle3D/PU/CCPUParticleFollower.h"
#include "extensions/Particle3D/PU/CCPUPathFollower.h"
#include "extensions/Particle3D/PU/CCPUPlaneCollider.h"
#include "extensions/Particle3D/PU/CCPURandomiser.h"
#include "extensions/Particle3D/PU/CCPUScaleAffector.h"
#include "extensions/Particle3D/PU/CCPUScaleVelocityAffector.h"
#include "extensions/Particle3D/PU/CCPUSineForceAffector.h"
#include "extensions/Particle3D/PU/CCPUSphereCollider.h"
#include "extensions/Particle3D/PU/CCPUTextureAnimator.h"
#include "extensions/Particle3D/PU/CCPUTextureRotator.h"
#include "extensions/Particle3D/PU/CCPUVelocityMatchingAffector.h"
#include "extensions/Particle3D/PU/CCPUVortexAffector.h"
2015-02-11 18:14:22 +08:00
NS_CC_BEGIN
2015-03-05 13:24:06 +08:00
PUAffectorManager::PUAffectorManager()
2015-02-11 18:14:22 +08:00
{
}
2015-03-05 13:24:06 +08:00
PUAffectorManager::~PUAffectorManager()
2015-02-11 18:14:22 +08:00
{
}
2015-03-05 13:24:06 +08:00
PUAffectorManager* PUAffectorManager::Instance()
2015-02-11 18:14:22 +08:00
{
2015-03-05 13:24:06 +08:00
static PUAffectorManager pam;
2015-02-11 18:14:22 +08:00
return &pam;
}
2015-03-05 13:24:06 +08:00
PUScriptTranslator* PUAffectorManager::getTranslator( const std::string &type )
2015-02-11 18:14:22 +08:00
{
if (type == "Align"){
return &_alignAffectorTranslator;
}else if (type == "Dummy02"){
return &_baseColliderTranslator;
}else if (type == "Dummy01"){
return &_baseForceAffectorTranslator;
}else if (type == "BoxCollider"){
return &_boxColliderTranslator;
}else if (type == "CollisionAvoidance"){
return &_collisionAvoidanceAffectorTranstor;
}else if (type == "Colour"){
return &_colorAffectorTranslator;
}else if (type == "FlockCentering"){
return &_flockCenteringAffectorTranslator;
}else if (type == "ForceField"){
return &_forceFieldAffectorTranslator;
}else if (type == "GeometryRotator"){
return &_geometryRotatorTranslator;
}else if (type == "Gravity"){
return &_gravityAffectorTranslator;
}else if (type == "InterParticleCollider"){
return &_interParticleColliderTranslator;
}else if (type == "Jet"){
return &_jetAffectorTranslator;
}else if (type == "Line"){
return &_lineAffectorTranslator;
}else if (type == "LinearForce"){
return &_linearForceAffectorTranslator;
}else if (type == "ParticleFollower"){
return &_particleFollowerTranslator;
}else if (type == "PathFollower"){
return &_pathFollowerTranslator;
}else if (type == "PlaneCollider"){
return &_planeColliderTranslator;
}else if (type == "Randomiser"){
return &_randomiserTranslator;
}else if (type == "Scale"){
return &_scaleAffectorTranslator;
}else if (type == "ScaleVelocity"){
return &_scaleVelocityAffectorTranslator;
}else if (type == "SineForce"){
return &_sineForceAffectorTranslator;
}else if (type == "SphereCollider"){
return &_sphereColliderTranslator;
}else if (type == "TextureAnimator"){
return &_textureAnimatorTranslator;
}else if (type == "TextureRotator"){
return &_textureRotatorTranslator;
}else if (type == "VelocityMatching"){
return &_velocityMatchingAffectorTranslator;
}else if (type == "Vortex"){
return &_vortexAffectorTranslator;
}
return nullptr;
}
2015-03-05 13:24:06 +08:00
PUAffector* PUAffectorManager::createAffector( const std::string &type )
2015-02-11 18:14:22 +08:00
{
if (type == "Align"){
2015-03-05 13:24:06 +08:00
return PUAlignAffector::create();
2015-02-11 18:14:22 +08:00
}else if (type == "Dummy02"){
return nullptr;
}else if (type == "Dummy01"){
return nullptr;
}else if (type == "BoxCollider"){
2015-03-05 13:24:06 +08:00
return PUBoxCollider::create();
2015-02-11 18:14:22 +08:00
}else if (type == "CollisionAvoidance"){
2015-03-05 13:24:06 +08:00
return PUCollisionAvoidanceAffector::create();
2015-02-11 18:14:22 +08:00
}else if (type == "Colour"){
2015-03-05 13:24:06 +08:00
return PUColorAffector::create();
2015-02-11 18:14:22 +08:00
}else if (type == "FlockCentering"){
2015-03-05 13:24:06 +08:00
return PUFlockCenteringAffector::create();
2015-02-11 18:14:22 +08:00
}else if (type == "ForceField"){
2015-03-05 13:24:06 +08:00
return PUForceFieldAffector::create();
2015-02-11 18:14:22 +08:00
}else if (type == "GeometryRotator"){
2015-03-05 13:24:06 +08:00
return PUGeometryRotator::create();
2015-02-11 18:14:22 +08:00
}else if (type == "Gravity"){
2015-03-05 13:24:06 +08:00
return PUGravityAffector::create();
2015-02-11 18:14:22 +08:00
}else if (type == "InterParticleCollider"){
return PUParticle3DInterParticleCollider::create();
}else if (type == "Jet"){
2015-03-05 13:24:06 +08:00
return PUJetAffector::create();
2015-02-11 18:14:22 +08:00
}else if (type == "Line"){
2015-03-05 13:24:06 +08:00
return PULineAffector::create();
2015-02-11 18:14:22 +08:00
}else if (type == "LinearForce"){
2015-03-05 13:24:06 +08:00
return PULinearForceAffector::create();
2015-02-11 18:14:22 +08:00
}else if (type == "ParticleFollower"){
2015-03-05 13:24:06 +08:00
return PUParticleFollower::create();
2015-02-11 18:14:22 +08:00
}else if (type == "PathFollower"){
2015-03-05 13:24:06 +08:00
return PUPathFollower::create();
2015-02-11 18:14:22 +08:00
}else if (type == "PlaneCollider"){
2015-03-05 13:24:06 +08:00
return PUPlaneCollider::create();
2015-02-11 18:14:22 +08:00
}else if (type == "Randomiser"){
2015-03-05 13:24:06 +08:00
return PURandomiser::create();
2015-02-11 18:14:22 +08:00
}else if (type == "Scale"){
2015-03-05 13:24:06 +08:00
return PUScaleAffector::create();
2015-02-11 18:14:22 +08:00
}else if (type == "ScaleVelocity"){
2015-03-05 13:24:06 +08:00
return PUScaleVelocityAffector::create();
2015-02-11 18:14:22 +08:00
}else if (type == "SineForce"){
2015-03-05 13:24:06 +08:00
return PUSineForceAffector::create();
2015-02-11 18:14:22 +08:00
}else if (type == "SphereCollider"){
2015-03-05 13:24:06 +08:00
return PUSphereCollider::create();
2015-02-11 18:14:22 +08:00
}else if (type == "TextureAnimator"){
2015-03-05 13:24:06 +08:00
return PUTextureAnimator::create();
2015-02-11 18:14:22 +08:00
}else if (type == "TextureRotator"){
2015-03-05 13:24:06 +08:00
return PUTextureRotator::create();
2015-02-11 18:14:22 +08:00
}else if (type == "VelocityMatching"){
2015-03-05 13:24:06 +08:00
return PUVelocityMatchingAffector::create();
2015-02-11 18:14:22 +08:00
}else if (type == "Vortex"){
2015-03-05 13:24:06 +08:00
return PUVortexAffector::create();
2015-02-11 18:14:22 +08:00
}
return nullptr;
}
NS_CC_END