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.
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2015-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-02-24 18:51:36 +08:00
|
|
|
https://adxeproject.github.io/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-02-11 18:14:22 +08:00
|
|
|
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:
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-02-11 18:14:22 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-02-11 18:14:22 +08:00
|
|
|
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
|
2021-12-25 10:04:45 +08:00
|
|
|
PUAffectorManager::PUAffectorManager() {}
|
2015-02-11 18:14:22 +08:00
|
|
|
|
2021-12-25 10:04:45 +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;
|
|
|
|
}
|
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
PUScriptTranslator* PUAffectorManager::getTranslator(std::string_view type)
|
2015-02-11 18:14:22 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (type == "Align")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_alignAffectorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Dummy02")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_baseColliderTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Dummy01")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_baseForceAffectorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "BoxCollider")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_boxColliderTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "CollisionAvoidance")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_collisionAvoidanceAffectorTranstor;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Colour")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_colorAffectorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "FlockCentering")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_flockCenteringAffectorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "ForceField")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_forceFieldAffectorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "GeometryRotator")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_geometryRotatorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Gravity")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_gravityAffectorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "InterParticleCollider")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_interParticleColliderTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Jet")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_jetAffectorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Line")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_lineAffectorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "LinearForce")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_linearForceAffectorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "ParticleFollower")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_particleFollowerTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "PathFollower")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_pathFollowerTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "PlaneCollider")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_planeColliderTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Randomiser")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_randomiserTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Scale")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_scaleAffectorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "ScaleVelocity")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_scaleVelocityAffectorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "SineForce")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_sineForceAffectorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "SphereCollider")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_sphereColliderTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "TextureAnimator")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_textureAnimatorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "TextureRotator")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_textureRotatorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "VelocityMatching")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_velocityMatchingAffectorTranslator;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Vortex")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return &_vortexAffectorTranslator;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
PUAffector* PUAffectorManager::createAffector(std::string_view type)
|
2015-02-11 18:14:22 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (type == "Align")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUAlignAffector::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Dummy02")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Dummy01")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "BoxCollider")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUBoxCollider::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "CollisionAvoidance")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUCollisionAvoidanceAffector::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Colour")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUColorAffector::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "FlockCentering")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUFlockCenteringAffector::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "ForceField")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUForceFieldAffector::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "GeometryRotator")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUGeometryRotator::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Gravity")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUGravityAffector::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "InterParticleCollider")
|
|
|
|
{
|
2015-02-11 18:14:22 +08:00
|
|
|
return PUParticle3DInterParticleCollider::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Jet")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUJetAffector::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Line")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PULineAffector::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "LinearForce")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PULinearForceAffector::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "ParticleFollower")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUParticleFollower::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "PathFollower")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUPathFollower::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "PlaneCollider")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUPlaneCollider::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Randomiser")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PURandomiser::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "Scale")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUScaleAffector::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "ScaleVelocity")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUScaleVelocityAffector::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "SineForce")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUSineForceAffector::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "SphereCollider")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUSphereCollider::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "TextureAnimator")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUTextureAnimator::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "TextureRotator")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUTextureRotator::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
|
|
|
else if (type == "VelocityMatching")
|
|
|
|
{
|
2015-03-05 13:24:06 +08:00
|
|
|
return PUVelocityMatchingAffector::create();
|
2021-12-25 10:04:45 +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
|