Merge pull request #10659 from super626/v3

Remove expolosion particle
This commit is contained in:
minggo 2015-03-03 23:03:02 +08:00
commit 13e4525772
13 changed files with 170 additions and 1791 deletions

View File

@ -131,17 +131,26 @@ void Animate3D::startWithTarget(Node *target)
auto action = (*runningAction).second;
if (action != this)
{
s_fadeOutAnimates[sprite] = action;
action->_state = Animate3D::Animate3DState::FadeOut;
action->_accTransTime = 0.0f;
action->_weight = 1.0f;
action->_lastTime = 0.f;
if (_transTime < 0.001f)
{
s_runningAnimates[sprite] = this;
_state = Animate3D::Animate3DState::Running;
_weight = 1.0f;
}
else
{
s_fadeOutAnimates[sprite] = action;
action->_state = Animate3D::Animate3DState::FadeOut;
action->_accTransTime = 0.0f;
action->_weight = 1.0f;
action->_lastTime = 0.f;
s_fadeInAnimates[sprite] = this;
_accTransTime = 0.0f;
_state = Animate3D::Animate3DState::FadeIn;
_weight = 0.f;
_lastTime = 0.f;
s_fadeInAnimates[sprite] = this;
_accTransTime = 0.0f;
_state = Animate3D::Animate3DState::FadeIn;
_weight = 0.f;
_lastTime = 0.f;
}
}
}
else

View File

@ -89,9 +89,12 @@ public:
void setOriginInterval(float interval);
float getOriginInterval() const {return _originInterval; }
/** animate transition time */
/** get animate transition time between 3d animations */
static float getTransitionTime() { return _transTime; }
/** set animate transition time between 3d animations */
static void setTransitionTime(float transTime) { if (transTime >= 0.f) _transTime = transTime; }
/**get & set play reverse, these are deprecated, use set negative speed instead*/
CC_DEPRECATED_ATTRIBUTE bool getPlayBack() const { return _playReverse; }
CC_DEPRECATED_ATTRIBUTE void setPlayBack(bool reverse) { _playReverse = reverse; }

View File

@ -723,15 +723,11 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
GLuint textureID = mesh->getTexture() ? mesh->getTexture()->getName() : 0;
#endif
float globalZ = _globalZOrder;
bool isTransparent = (mesh->_isTransparent || color.a < 1.f);
if (isTransparent && Camera::getVisitingCamera())
{
// use the view matrix for Applying to recalculating transparent mesh's Z-Order
const auto& viewMat = Camera::getVisitingCamera()->getViewMatrix();
//fetch the Z from the result matrix
globalZ = -(viewMat.m[2] * transform.m[12] + viewMat.m[6] * transform.m[13] + viewMat.m[10] * transform.m[14] + viewMat.m[14]);
}
float globalZ = isTransparent ? 0 : _globalZOrder;
if (isTransparent)
flags |= Node::FLAGS_RENDER_AS_3D;
meshCommand.init(globalZ, textureID, programstate, _blend, mesh->getVertexBuffer(), mesh->getIndexBuffer(), mesh->getPrimitiveType(), mesh->getIndexFormat(), mesh->getIndexCount(), transform, flags);
meshCommand.setLightMask(_lightMask);

View File

@ -111,6 +111,8 @@ void MeshCommand::init(float globalZOrder,
{
CCASSERT(glProgramState, "GLProgramState cannot be nill");
RenderCommand::init(globalZOrder, mv, flags);
_globalOrder = globalZOrder;
_textureID = textureID;
_blendType = blendType;

View File

@ -48,7 +48,9 @@ void RenderCommand::init(float globalZOrder, const cocos2d::Mat4 &transform, uin
_globalOrder = globalZOrder;
if (flags & Node::FLAGS_RENDER_AS_3D)
{
_depth = Camera::getVisitingCamera()->getDepthInView(transform);
if (Camera::getVisitingCamera())
_depth = Camera::getVisitingCamera()->getDepthInView(transform);
set3D(true);
}
else

View File

@ -216,8 +216,9 @@ void PUParticle3DQuadRender::render(Renderer* renderer, const Mat4 &transform, P
_indexBuffer->updateIndices(&_indexData[0], index/* * sizeof(unsigned short)*/, 0);
GLuint texId = (_texture ? _texture->getName() : 0);
float depthZ = -(viewMat.m[2] * transform.m[12] + viewMat.m[6] * transform.m[13] + viewMat.m[10] * transform.m[14] + viewMat.m[14]);
_meshCommand->init(depthZ, texId, _glProgramState, particleSystem->getBlendFunc(), _vertexBuffer->getVBO(), _indexBuffer->getVBO(), GL_TRIANGLES, GL_UNSIGNED_SHORT, index, transform, 0);
// float depthZ = -(viewMat.m[2] * transform.m[12] + viewMat.m[6] * transform.m[13] + viewMat.m[10] * transform.m[14] + viewMat.m[14]);
_meshCommand->init(0, texId, _glProgramState, particleSystem->getBlendFunc(), _vertexBuffer->getVBO(), _indexBuffer->getVBO(), GL_TRIANGLES, GL_UNSIGNED_SHORT, index, transform, Node::FLAGS_RENDER_AS_3D);
_meshCommand->setTransparent(true);
renderer->addCommand(_meshCommand);
}

View File

@ -47,7 +47,6 @@ static std::function<Layer*()> createFunctions[] =
CL(Particle3DUVAnimDemo),
CL(Particle3DFirePlaceDemo),
CL(Particle3DElectricBeamSystemDemo),
CL(Particle3DExplosionBlueDemo),
};
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
@ -242,7 +241,7 @@ bool Particle3DBlackHoleDemo::init()
if (!Particle3DTestDemo::init())
return false;
auto rootps = PUParticleSystem3D::create("blackHole.pu", "pu_mediapack_01.material");
auto rootps = PUParticleSystem3D::create("blackHole.pu", "pu_example.material");
rootps->setCameraMask((unsigned short)CameraFlag::USER1);
rootps->setPosition(-25.0f, 0.0f);
auto moveby = MoveBy::create(2.0f, Vec2(50.0f, 0.0f));
@ -269,7 +268,7 @@ bool Particle3DHypnoDemo::init()
if (!Particle3DTestDemo::init())
return false;
auto rootps = PUParticleSystem3D::create("hypno.pu", "pu_mediapack_01.material");
auto rootps = PUParticleSystem3D::create("hypno.pu", "pu_example.material");
rootps->setCameraMask((unsigned short)CameraFlag::USER1);
// auto scale = ScaleBy::create(1.0f, 2.0f, 2.0f, 2.0f);
// auto rotate = RotateBy::create(1.0f, Vec3(0.0, 100.0f, 0.0f));
@ -292,7 +291,7 @@ bool Particle3DTimeShiftDemo::init()
if (!Particle3DTestDemo::init())
return false;
auto rootps = PUParticleSystem3D::create("timeShift.pu", "pu_mediapack_01.material");
auto rootps = PUParticleSystem3D::create("timeShift.pu", "pu_example.material");
rootps->setScale(2.0f);
rootps->setCameraMask((unsigned short)CameraFlag::USER1);
rootps->startParticleSystem();
@ -312,7 +311,7 @@ bool Particle3DUVAnimDemo::init()
if (!Particle3DTestDemo::init())
return false;
auto rootps = PUParticleSystem3D::create("UVAnimation.pu", "pu_mediapack_01.material");
auto rootps = PUParticleSystem3D::create("UVAnimation.pu", "pu_example.material");
rootps->setCameraMask((unsigned short)CameraFlag::USER1);
rootps->startParticleSystem();
@ -331,7 +330,7 @@ bool Particle3DFirePlaceDemo::init()
if (!Particle3DTestDemo::init())
return false;
auto rootps = PUParticleSystem3D::create("mp_torch.pu", "pu_mediapack_01.material");
auto rootps = PUParticleSystem3D::create("mp_torch.pu", "pu_example.material");
rootps->setCameraMask((unsigned short)CameraFlag::USER1);
rootps->setScale(5.0f);
rootps->startParticleSystem();
@ -352,7 +351,7 @@ bool Particle3DLineStreakDemo::init()
return false;
auto rootps = PUParticleSystem3D::create("lineStreak.pu", "pu_mediapack_01.material");
auto rootps = PUParticleSystem3D::create("lineStreak.pu", "pu_example.material");
rootps->setCameraMask((unsigned short)CameraFlag::USER1);
rootps->setScale(5.0f);
//rootps->runAction(RepeatForever::create(Sequence::create(rotate, nullptr)));
@ -385,23 +384,3 @@ bool Particle3DElectricBeamSystemDemo::init()
return true;
}
std::string Particle3DExplosionBlueDemo::subtitle() const
{
return "ExplosionBlue";
}
bool Particle3DExplosionBlueDemo::init()
{
if (!Particle3DTestDemo::init())
return false;
auto rootps = PUParticleSystem3D::create("mp_explosion_04_blue.pu");
rootps->setCameraMask((unsigned short)CameraFlag::USER1);
rootps->setScale(0.25f);
rootps->startParticleSystem();
this->addChild(rootps, 0, PARTICLE_SYSTEM_TAG);
return true;
}

View File

@ -162,19 +162,6 @@ public:
virtual bool init() override;
};
class Particle3DExplosionBlueDemo : public Particle3DTestDemo
{
public:
CREATE_FUNC(Particle3DExplosionBlueDemo);
Particle3DExplosionBlueDemo(){};
virtual ~Particle3DExplosionBlueDemo(){};
virtual std::string subtitle() const override;
virtual bool init() override;
};
class Particle3DTestScene : public TestScene
{
public:

View File

@ -539,3 +539,123 @@ material ParticleUniverse/Beam_2
}
}
}
//-----------------------------------------------------------------------------------------------------------------------
material PUMediaPack/Pentagram_02
{
technique
{
pass
{
lighting off
scene_blend add
depth_write off
texture_unit
{
texture pump_pentagram_02.png
tex_address_mode clamp
}
}
}
}
//-----------------------------------------------------------------------------------------------------------------------
material PUMediaPack/Flare_04
{
technique
{
pass
{
lighting off
scene_blend add
depth_write off
texture_unit
{
texture pump_flare_04.png
tex_address_mode clamp
}
}
}
}
//-----------------------------------------------------------------------------------------------------------------------
material PUMediaPack/Streak_03
{
technique
{
pass
{
lighting off
scene_blend add
depth_write off
texture_unit
{
texture pump_streak_03.png
tex_address_mode clamp
}
}
}
}
//-----------------------------------------------------------------------------------------
material ParticleUniverse/Swirl_02
{
technique
{
pass
{
lighting off
scene_blend add
depth_write off
texture_unit
{
texture pump_swirl_02.png
tex_address_mode clamp
}
}
}
}
//-----------------------------------------------------------------------------------------------------------------------
material PUMediaPack/Watch
{
technique
{
pass
{
lighting off
depth_write off
scene_blend add
texture_unit
{
texture pump_watch.png
tex_address_mode clamp
}
}
}
}
//-----------------------------------------------------------------------------------------------------------------------
material PUMediaPack/Hourglass
{
technique
{
pass
{
lighting off
depth_write off
scene_blend add
texture_unit
{
texture pump_hourglass.png
tex_address_mode clamp
}
}
}
}

View File

@ -1,380 +0,0 @@
//-----------------------------------------------------------------------------------------------------------------------
// This script is part of the Particle Universe Media Pack 1 product.
//
// Copyright (c) 2010 Henry van Merode
//
// Usage of this program is licensed under the terms of the Particle Universe Commercial License Media Pack 1.
// You can find a copy of the Commercial License in the Media Pack 1 package.
//-----------------------------------------------------------------------------------------------------------------------
system Explosion/mp_explosion_04_blue
{
technique
{
visual_particle_quota 12
material mp_explosion_04
renderer Billboard
{
texture_coords_rows 2
texture_coords_columns 2
billboard_rotation_type vertex
}
emitter Point
{
emission_rate 100
angle 360
time_to_live dyn_random
{
min 0.4
max 1.2
}
velocity dyn_random
{
min 100
max 500
}
duration 0.1
all_particle_dimensions dyn_random
{
min 1
max 50
}
colour 0.670588 0.8 0.996078 1
}
affector ScaleVelocity
{
velocity_scale dyn_curved_linear
{
control_point 0 -1500
control_point 1 -200
}
}
affector Scale
{
xyz_scale 500
}
affector Colour
{
time_colour 0 0 0.333333 0.701961 1
time_colour 1 0 0 0 1
}
affector TextureRotator
{
rotation dyn_random
{
min -3
max 3
}
rotation_speed 0
}
observer OnTime
{
observe_until_event true
handler DoStopSystem
{
}
since_start_system true
on_time greater_than 2
}
observer OnEmission
{
handler DoPlacementParticle
{
force_emitter BlackSmokeEmitter
inherit_direction true
inherit_time_to_live true
inherit_width true
inherit_height true
inherit_depth true
}
}
}
technique
{
visual_particle_quota 12
material mp_explosion_smoke_01
renderer Billboard
{
billboard_rotation_type vertex
}
emitter Point BlackSmokeEmitter
{
emission_rate 100
angle 360
time_to_live dyn_random
{
min 0.8
max 1.2
}
velocity dyn_random
{
min 100
max 500
}
duration 0.1
all_particle_dimensions dyn_random
{
min 1
max 50
}
colour 0 0 0 1
}
affector ScaleVelocity
{
velocity_scale dyn_curved_linear
{
control_point 0 -1500
control_point 1 -200
}
}
affector Scale
{
xyz_scale 400
}
affector Colour
{
time_colour 0 0.294118 0.294118 0.294118 0
time_colour 0.5 0.172549 0.172549 0.172549 0.3
time_colour 0.6 0.137255 0.137255 0.137255 0.5
time_colour 1 0 0 0 0
}
affector TextureRotator
{
rotation dyn_random
{
min -3
max 3
}
rotation_speed 0
}
}
technique
{
visual_particle_quota 50
material mp_explosion_04
renderer Billboard
{
texture_coords_rows 2
texture_coords_columns 2
billboard_type oriented_self
billboard_origin bottom_center
billboard_rotation_type vertex
}
emitter Point
{
emission_rate 1000
angle 360
time_to_live dyn_random
{
min 0.2
max 0.4
}
velocity dyn_random
{
min 200
max 300
}
duration 0.2
particle_width dyn_random
{
min 10
max 30
}
particle_height dyn_random
{
min 1
max 10
}
texture_coords 2
colour 0.670588 0.815686 0.996078 1
}
affector Scale
{
y_scale dyn_random
{
min 100
max 300
}
}
affector Colour
{
time_colour 0 0 0.384314 0.807843 1
time_colour 0.6 1 1 1 1
time_colour 1 0 0 0 1
}
}
technique
{
visual_particle_quota 50
material mp_explosion_04
renderer Billboard
{
texture_coords_rows 2
texture_coords_columns 2
billboard_type oriented_self
billboard_origin bottom_center
billboard_rotation_type vertex
}
emitter Point
{
emission_rate 1000
angle 360
time_to_live dyn_random
{
min 0.2
max 0.4
}
velocity dyn_random
{
min 100
max 200
}
duration 0.2
particle_width dyn_random
{
min 10
max 30
}
particle_height dyn_random
{
min 1
max 10
}
texture_coords 3
colour 0.984314 0.992157 0.67451 1
}
affector Scale
{
x_scale dyn_random
{
min 60
max 90
}
y_scale dyn_random
{
min 200
max 300
}
}
affector Colour
{
time_colour 0 0 0.396078 0.835294 1
time_colour 0.2 1 1 1 1
time_colour 1 0 0 0 1
colour_operation multiply
}
}
technique
{
visual_particle_quota 12
material mp_explosion_04
renderer Billboard
{
texture_coords_rows 2
texture_coords_columns 2
billboard_type oriented_self
billboard_rotation_type vertex
}
emitter Box
{
emission_rate 30
angle 360
time_to_live dyn_random
{
min 0.3
max 0.5
}
velocity dyn_random
{
min 5
max 10
}
duration 0.15
all_particle_dimensions dyn_random
{
min 1
max 50
}
texture_coords 1
colour 0.984314 0.992157 0.67451 1
box_width 20
box_height 20
box_depth 20
}
affector Scale
{
xyz_scale dyn_random
{
min 700
max 1000
}
}
affector Colour
{
time_colour 0 1 1 1 1
time_colour 1 0 0 0 1
}
affector TextureRotator
{
rotation dyn_random
{
min -3
max 3
}
rotation_speed 0
}
}
technique
{
visual_particle_quota 20
material mp_explosion_debris
renderer Billboard
{
billboard_type oriented_self
billboard_rotation_type vertex
}
emitter Point
{
emission_rate 200
angle 360
time_to_live dyn_random
{
min 0.5
max 1
}
velocity dyn_random
{
min 200
max 350
}
duration 0.1
colour 0 0 0 1
}
affector ScaleVelocity
{
velocity_scale dyn_curved_linear
{
control_point 0 -1500
control_point 0.2 -200
}
}
affector Scale
{
xyz_scale 300
}
affector Colour
{
time_colour 0 0.65098 0.815686 1 1
time_colour 0.5 0.0901961 0.52549 1 1
time_colour 1 0 0 0 1
}
affector TextureRotator
{
rotation dyn_random
{
min -3
max 3
}
rotation_speed 0
}
}
}

View File

@ -106,7 +106,7 @@ function Particle3DLineStreakDemo:subtitle()
end
function Particle3DLineStreakDemo:onEnter()
local rootps = cc.PUParticleSystem3D:create("lineStreak.pu", "pu_mediapack_01.material")
local rootps = cc.PUParticleSystem3D:create("lineStreak.pu", "pu_example.material")
rootps:setCameraMask(cc.CameraFlag.USER1)
rootps:setScale(5.0)
rootps:startParticleSystem()
@ -143,7 +143,7 @@ function Particle3DBlackHoleDemo:subtitle()
end
function Particle3DBlackHoleDemo:onEnter()
local rootps = cc.PUParticleSystem3D:create("blackHole.pu", "pu_mediapack_01.material")
local rootps = cc.PUParticleSystem3D:create("blackHole.pu", "pu_example.material")
rootps:setCameraMask(cc.CameraFlag.USER1)
rootps:setPosition(-25.0, 0.0)
local moveby = cc.MoveBy:create(2.0, cc.p(50.0, 0.0))
@ -182,7 +182,7 @@ function Particle3DHypnoDemo:subtitle()
end
function Particle3DHypnoDemo:onEnter()
local rootps = cc.PUParticleSystem3D:create("hypno.pu", "pu_mediapack_01.material")
local rootps = cc.PUParticleSystem3D:create("hypno.pu", "pu_example.material")
rootps:setCameraMask(cc.CameraFlag.USER1)
rootps:startParticleSystem()
self:addChild(rootps, 0, PARTICLE_SYSTEM_TAG)
@ -258,7 +258,7 @@ function Particle3DTimeShiftDemo:subtitle()
end
function Particle3DTimeShiftDemo:onEnter()
local rootps = cc.PUParticleSystem3D:create("timeShift.pu", "pu_mediapack_01.material")
local rootps = cc.PUParticleSystem3D:create("timeShift.pu", "pu_example.material")
rootps:setScale(2.0)
rootps:setCameraMask(cc.CameraFlag.USER1)
rootps:startParticleSystem()
@ -295,7 +295,7 @@ function Particle3DUVAnimDemo:subtitle()
end
function Particle3DUVAnimDemo:onEnter()
local rootps = cc.PUParticleSystem3D:create("UVAnimation.pu", "pu_mediapack_01.material")
local rootps = cc.PUParticleSystem3D:create("UVAnimation.pu", "pu_example.material")
rootps:setCameraMask(cc.CameraFlag.USER1)
rootps:startParticleSystem()
self:addChild(rootps, 0, PARTICLE_SYSTEM_TAG)
@ -330,7 +330,7 @@ function Particle3DFirePlaceDemo:subtitle()
end
function Particle3DFirePlaceDemo:onEnter()
local rootps = cc.PUParticleSystem3D:create("mp_torch.pu", "pu_mediapack_01.material")
local rootps = cc.PUParticleSystem3D:create("mp_torch.pu", "pu_example.material")
rootps:setCameraMask(cc.CameraFlag.USER1)
rootps:setScale(5.0)
rootps:startParticleSystem()
@ -376,43 +376,6 @@ function Particle3DElectricBeamSystemDemo:onExit()
self:unscheduleUpdate()
end
-- Particle3DExplosionBlueDemo
local Particle3DExplosionBlueDemo = class("Particle3DExplosionBlueDemo", function ()
local layer = cc.Layer:create()
Helper.initWithLayer(layer)
return layer
end)
function Particle3DExplosionBlueDemo:ctor()
-- body
self:init()
end
function Particle3DExplosionBlueDemo:init()
baseInit(self)
end
function Particle3DExplosionBlueDemo:title()
return "Particle3D Test"
end
function Particle3DExplosionBlueDemo:subtitle()
return "ExplosionBlue"
end
function Particle3DExplosionBlueDemo:onEnter()
local rootps = cc.PUParticleSystem3D:create("mp_explosion_04_blue.pu")
rootps:setCameraMask(cc.CameraFlag.USER1)
rootps:setScale(0.25)
rootps:startParticleSystem()
self:addChild(rootps, 0, PARTICLE_SYSTEM_TAG)
end
function Particle3DExplosionBlueDemo:onExit()
self:unscheduleUpdate()
end
function Particle3DTest()
local scene = cc.Scene:create()
@ -425,8 +388,7 @@ function Particle3DTest()
Particle3DTimeShiftDemo.create,
Particle3DUVAnimDemo.create,
Particle3DFirePlaceDemo.create,
Particle3DElectricBeamSystemDemo.create,
Particle3DExplosionBlueDemo.create,
Particle3DElectricBeamSystemDemo.create
}
scene:addChild(Particle3DLineStreakDemo.create())

View File

@ -113,7 +113,7 @@ local _allTests = {
{ isSupported = true, name = "OpenGLTest" , create_func= OpenGLTestMain },
{ isSupported = true, name = "ParallaxTest" , create_func = ParallaxTestMain },
{ isSupported = true, name = "ParticleTest" , create_func = ParticleTest },
{ isSupported = true, name = "Particle3DTest" , create_func = Particle3DTest },
{ isSupported = true, name = "Particle3D (PU)" , create_func = Particle3DTest },
{ isSupported = true, name = "PerformanceTest" , create_func= PerformanceTestMain },
{ isSupported = true, name = "PhysicsTest" , create_func = PhysicsTest },
{ isSupported = true, name = "RenderTextureTest" , create_func = RenderTextureTestMain },