28#include "Particle3D/CCParticleSystem3D.h"
29#include "Particle3D/PU/CCPUParticleSystem3D.h"
33#define PARTICLE_SYSTEM_TAG 0x0001
35Particle3DTests::Particle3DTests()
56 return "Particle3D Test";
61 if (!TestCase::init())
return false;
63 FileUtils::getInstance()->addSearchPath(
"Particle3D/materials");
64 FileUtils::getInstance()->addSearchPath(
"Particle3D/scripts");
65 FileUtils::getInstance()->addSearchPath(
"Sprite3DTest");
68 Size size = Director::getInstance()->getWinSize();
69 _camera = Camera::createPerspective(30.0f, size.width / size.height, 1.0f, 1000.0f);
70 _camera->setPosition3D(Vec3(0.0f, 0.0f, 100.0f));
71 _camera->lookAt(Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f));
72 _camera->setCameraFlag(CameraFlag::USER1);
75 auto listener = EventListenerTouchAllAtOnce::create();
79 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener,
this);
82 TTFConfig config(
"fonts/tahoma.ttf",10);
83 _particleLab = Label::createWithTTF(config,
"Particle Count: 0",TextHAlignment::LEFT);
85 _particleLab->setPosition(Vec2(0.0f, size.height / 6.0f));
102 auto touch = touches[0];
103 auto delta = touch->getDelta();
105 _angle -= CC_DEGREES_TO_RADIANS(delta.x);
107 _camera->lookAt(Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f));
124 ParticleSystem3D *ps =
static_cast<ParticleSystem3D *
>(this->getChildByTag(
PARTICLE_SYSTEM_TAG));
126 unsigned int count = 0;
127 auto children = ps->getChildren();
128 for (
auto iter : children){
129 ParticleSystem3D *child =
dynamic_cast<ParticleSystem3D *
>(iter);
131 count += child->getAliveParticleCount();
136 sprintf(str,
"Particle Count: %d", count);
148 return "AdvancedSystem";
156 auto rootps = PUParticleSystem3D::create(
"advancedLodSystem.pu");
157 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
159 auto scale = ScaleBy::create(1.0f, 2.0f, 2.0f, 2.0f);
160 auto rotate = RotateBy::create(1.0f, Vec3(0.0f, 0.0f, 100.0f));
161 rootps->runAction(RepeatForever::create(Sequence::create(rotate,
nullptr)));
162 rootps->runAction(RepeatForever::create(Sequence::create(scale, scale->reverse(),
nullptr)));
163 rootps->startParticleSystem();
181 auto rootps = PUParticleSystem3D::create(
"blackHole.pu",
"pu_mediapack_01.material");
182 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
183 rootps->setPosition(-25.0f, 0.0f);
184 auto moveby = MoveBy::create(2.0f, Vec2(50.0f, 0.0f));
185 auto moveby1 = MoveBy::create(2.0f, Vec2(-50.0f, 0.0f));
188 rootps->runAction(RepeatForever::create(Sequence::create(moveby, moveby1,
nullptr)));
191 rootps->startParticleSystem();
208 auto rootps = PUParticleSystem3D::create(
"hypno.pu",
"pu_mediapack_01.material");
209 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
214 rootps->startParticleSystem();
231 auto rootps = PUParticleSystem3D::create(
"timeShift.pu",
"pu_mediapack_01.material");
232 rootps->setScale(2.0f);
233 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
234 rootps->startParticleSystem();
251 auto rootps = PUParticleSystem3D::create(
"UVAnimation.pu",
"pu_mediapack_01.material");
252 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
253 rootps->startParticleSystem();
270 auto rootps = PUParticleSystem3D::create(
"mp_torch.pu",
"pu_mediapack_01.material");
271 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
272 rootps->setScale(5.0f);
273 rootps->startParticleSystem();
290 auto rootps = PUParticleSystem3D::create(
"lineStreak.pu",
"pu_mediapack_01.material");
291 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
292 rootps->setScale(5.0f);
294 rootps->startParticleSystem();
308 return "ElectricBeamSystem";
317 auto rootps = PUParticleSystem3D::create(
"electricBeamSystem.pu");
318 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
319 rootps->startParticleSystem();
327 return "flareShield";
336 auto rootps = PUParticleSystem3D::create(
"flareShield.pu");
337 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
339 rootps->startParticleSystem();
347 return "LightningBolt";
356 auto rootps = PUParticleSystem3D::create(
"lightningBolt.pu");
357 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
359 rootps->startParticleSystem();
367 return "ExplosionSystem";
376 auto rootps = PUParticleSystem3D::create(
"explosionSystem.pu");
377 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
383 rootps->startParticleSystem();
399 auto rootps = PUParticleSystem3D::create(
"canOfWorms.pu");
400 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
401 rootps->startParticleSystem();
409 return "RibbonTrailTest";
417 auto rootps = PUParticleSystem3D::create(
"ribbonTrailTest.pu");
418 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
419 rootps->startParticleSystem();
427 return "WeaponTrail";
435 auto rootps = PUParticleSystem3D::create(
"weaponTrail.pu");
436 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
437 rootps->startParticleSystem();
445 return "Particle3DWithSprite3D";
453 std::string c3bfileName =
"Sprite3DTest/orc.c3b";
454 auto sprite = Sprite3D::create(c3bfileName);
455 this->addChild(sprite);
456 sprite->setPosition3D(Vec3(-20.0f, 0.0f, 0.0f));
457 sprite->setRotation3D(Vec3(0, 180, 0));
458 sprite->setCameraMask((
unsigned short)CameraFlag::USER1);
460 auto animation = Animation3D::create(c3bfileName);
463 auto animate = Animate3D::create(animation);
464 sprite->runAction(RepeatForever::create(animate));
467 auto billboard = BillBoard::create(
"Images/Icon.png");
468 billboard->setPosition3D(Vec3(20.0f, 0.0f, 0.0f));
469 billboard->setScale(0.2f);
470 billboard->setCameraMask((
unsigned short)CameraFlag::USER1);
471 this->addChild(billboard);
474 auto rootps = PUParticleSystem3D::create(
"lineStreak.pu");
475 rootps->setCameraMask((
unsigned short)CameraFlag::USER1);
476 rootps->startParticleSystem();
#define ADD_TEST_CASE(__className__)
#define PARTICLE_SYSTEM_TAG
virtual bool init() override
virtual std::string subtitle() const override
virtual bool init() override
virtual std::string subtitle() const override
virtual bool init() override
virtual std::string subtitle() const override
virtual bool init() override
virtual std::string subtitle() const override
virtual bool init() override
virtual std::string subtitle() const override
virtual bool init() override
virtual std::string subtitle() const override
virtual std::string subtitle() const override
virtual bool init() override
virtual std::string subtitle() const override
virtual bool init() override
virtual std::string subtitle() const override
virtual bool init() override
virtual bool init() override
virtual std::string subtitle() const override
virtual bool init() override
virtual std::string subtitle() const override
void onTouchesMoved(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
cocos2d::Camera * _camera
void onTouchesEnded(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
virtual bool init() override
virtual ~Particle3DTestDemo()
cocos2d::Label * _particleLab
virtual std::string title() const override
void onTouchesBegan(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
virtual void update(float delta) override
virtual bool init() override
virtual std::string subtitle() const override
virtual bool init() override
virtual std::string subtitle() const override
virtual std::string subtitle() const override
virtual bool init() override
virtual bool init() override
virtual std::string subtitle() const override