diff --git a/cocos/3d/CCAnimate3D.cpp b/cocos/3d/CCAnimate3D.cpp index 7e8a302154..799f024f66 100644 --- a/cocos/3d/CCAnimate3D.cpp +++ b/cocos/3d/CCAnimate3D.cpp @@ -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; - - s_fadeInAnimates[sprite] = this; - _accTransTime = 0.0f; - _state = Animate3D::Animate3DState::FadeIn; - _weight = 0.f; - _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; + } } } else diff --git a/cocos/3d/CCAnimate3D.h b/cocos/3d/CCAnimate3D.h index fc0df412cc..128248cd3d 100644 --- a/cocos/3d/CCAnimate3D.h +++ b/cocos/3d/CCAnimate3D.h @@ -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; } diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index b387796338..7000acb58c 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -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); diff --git a/cocos/renderer/CCMeshCommand.cpp b/cocos/renderer/CCMeshCommand.cpp index 8fd3c00d4a..cb357611b7 100644 --- a/cocos/renderer/CCMeshCommand.cpp +++ b/cocos/renderer/CCMeshCommand.cpp @@ -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; diff --git a/cocos/renderer/CCRenderCommand.cpp b/cocos/renderer/CCRenderCommand.cpp index a0affae504..6d4910c7bb 100644 --- a/cocos/renderer/CCRenderCommand.cpp +++ b/cocos/renderer/CCRenderCommand.cpp @@ -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 diff --git a/cocos/scripting/lua-bindings/auto/api/Animate3D.lua b/cocos/scripting/lua-bindings/auto/api/Animate3D.lua index 37c3c5e880..89055ce4af 100644 --- a/cocos/scripting/lua-bindings/auto/api/Animate3D.lua +++ b/cocos/scripting/lua-bindings/auto/api/Animate3D.lua @@ -54,7 +54,7 @@ -- @return Animate3D#Animate3D ret (return value: cc.Animate3D) -------------------------------- --- animate transition time +-- get animate transition time between 3d animations -- @function [parent=#Animate3D] getTransitionTime -- @param self -- @return float#float ret (return value: float) @@ -74,6 +74,13 @@ -- @param #float frameRate -- @return Animate3D#Animate3D ret (return value: cc.Animate3D) +-------------------------------- +-- set animate transition time between 3d animations +-- @function [parent=#Animate3D] setTransitionTime +-- @param self +-- @param #float transTime +-- @return Animate3D#Animate3D self (return value: cc.Animate3D) + -------------------------------- -- -- @function [parent=#Animate3D] startWithTarget diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp index 4523f0a4ae..14a6c87ab6 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp @@ -2565,6 +2565,42 @@ int lua_cocos2dx_3d_Animate3D_createWithFrames(lua_State* tolua_S) #endif return 0; } +int lua_cocos2dx_3d_Animate3D_setTransitionTime(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.Animate3D",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + double arg0; + ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Animate3D:setTransitionTime"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Animate3D_setTransitionTime'", nullptr); + return 0; + } + cocos2d::Animate3D::setTransitionTime(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Animate3D:setTransitionTime",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Animate3D_setTransitionTime'.",&tolua_err); +#endif + return 0; +} static int lua_cocos2dx_3d_Animate3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Animate3D)"); @@ -2586,6 +2622,7 @@ int lua_register_cocos2dx_3d_Animate3D(lua_State* tolua_S) tolua_function(tolua_S,"create", lua_cocos2dx_3d_Animate3D_create); tolua_function(tolua_S,"getTransitionTime", lua_cocos2dx_3d_Animate3D_getTransitionTime); tolua_function(tolua_S,"createWithFrames", lua_cocos2dx_3d_Animate3D_createWithFrames); + tolua_function(tolua_S,"setTransitionTime", lua_cocos2dx_3d_Animate3D_setTransitionTime); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Animate3D).name(); g_luaType[typeName] = "cc.Animate3D"; diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp index 3963c71800..11a7c6f625 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp @@ -74,6 +74,7 @@ int register_all_cocos2dx_3d(lua_State* tolua_S); + #endif // __cocos2dx_3d_h__ diff --git a/extensions/Particle3D/ParticleUniverse/ParticleRenders/CCPUParticle3DRender.cpp b/extensions/Particle3D/ParticleUniverse/ParticleRenders/CCPUParticle3DRender.cpp index e6e7107bc6..6b42498e2d 100644 --- a/extensions/Particle3D/ParticleUniverse/ParticleRenders/CCPUParticle3DRender.cpp +++ b/extensions/Particle3D/ParticleUniverse/ParticleRenders/CCPUParticle3DRender.cpp @@ -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); } diff --git a/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.cpp b/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.cpp index 5d6eea22b8..e463b5fc29 100644 --- a/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.cpp +++ b/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.cpp @@ -47,7 +47,6 @@ static std::function 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; -} diff --git a/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.h b/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.h index 7561701f0c..565c1882b7 100644 --- a/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.h +++ b/tests/cpp-tests/Classes/Particle3DTest/Particle3DTest.h @@ -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: diff --git a/tests/cpp-tests/Resources/Particle3D/materials/pu_example.material b/tests/cpp-tests/Resources/Particle3D/materials/pu_example.material index 6ce8f95bbf..e7d3422e82 100644 --- a/tests/cpp-tests/Resources/Particle3D/materials/pu_example.material +++ b/tests/cpp-tests/Resources/Particle3D/materials/pu_example.material @@ -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 + } + } + } +} diff --git a/tests/cpp-tests/Resources/Particle3D/materials/pu_mediapack_01.material b/tests/cpp-tests/Resources/Particle3D/materials/pu_mediapack_01.material deleted file mode 100644 index 2f718beb6e..0000000000 --- a/tests/cpp-tests/Resources/Particle3D/materials/pu_mediapack_01.material +++ /dev/null @@ -1,1302 +0,0 @@ -//----------------------------------------------------------------------------------------------------------------------- -// This script is part of the Particle Universe Media Pack product. -// -// Copyright (c) 2008 Henry van Merode -// -// Usage of this program is licensed under the terms of the Particle Universe Commercial License. -// You can find a copy of the Commercial License in the Particle Universe package. -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Bubble -{ - technique - { - pass - { - lighting off - scene_blend alpha_blend - depth_write off - - texture_unit - { - texture pump_bubble.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/BlurredBubble -{ - technique - { - pass - { - lighting off - scene_blend alpha_blend - depth_write off - - texture_unit - { - texture pump_bubble_blurred.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Streak_01 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_streak_01.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Streak_02 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - texture_unit - { - texture pump_streak_02.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 PUMediaPack/Streak_04 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_streak_04.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Flare_01 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_flare_01.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Flare_02 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_flare_02.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Flare_03 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_flare_03.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/Flare_05 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_flare_05.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Flare_06 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_flare_06.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 - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Leave -{ - technique - { - pass - { - lighting off - scene_blend alpha_blend - depth_write off - - texture_unit - { - texture pump_leave.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Smoke_01 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_smoke_01.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Smoke_11 -{ - technique - { - pass - { - lighting off - scene_blend alpha_blend - depth_write off - - texture_unit - { - texture pump_smoke_01.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Dirt_11 -{ - technique - { - pass - { - lighting off - scene_blend alpha_blend - depth_write off - - texture_unit - { - texture pump_dirt_01.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Dirt_12 -{ - technique - { - pass - { - lighting off - scene_blend alpha_blend - depth_write off - - texture_unit - { - texture pump_dirt_02.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Lightning_01 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_lightning_01.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Lightning_02 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_lightning_02.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Lightning_03 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_lightning_03.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Lightning_04 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_lightning_04.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Spark_01 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_spark_01.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Star_01 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_star_01.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Star_02 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_star_02.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Star_03 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_star_03.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Star_04 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_star_04.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Star_05 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_star_05.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Genesis_11 -{ - technique - { - pass - { - lighting off - scene_blend alpha_blend - depth_write off - - texture_unit - { - texture pump_genesis_01.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------- -material PUMediaPack/Genesis_12 -{ - technique - { - pass - { - lighting off - scene_blend alpha_blend - depth_write off - - texture_unit - { - texture pump_genesis_02.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------- -material ParticleUniverse/Swirl_01 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_swirl_01.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 ParticleUniverse/Swirl_03 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_swirl_03.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------- -material PUMediaPack/Ring_01 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_ring_01.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------- -material PUMediaPack/Ring_02 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_ring_02.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------- -material PUMediaPack/Ring_03 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_ring_03.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------- -material PUMediaPack/Ring_14 -{ - technique - { - pass - { - lighting off - scene_blend alpha_blend - depth_write off - - texture_unit - { - texture pump_ring_04.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------- -material PUMediaPack/Ring_05 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_ring_05.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Metal_01 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_metal_01.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Metal_02 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_metal_02.png - tex_address_mode clamp - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Fire_01 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_flame_01.png - tex_address_mode clamp - } - } - } -} - -//--------------------------------------------------------------------- -material PUMediaPack/Fire_02 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_flame_02.png - tex_address_mode clamp - } - } - } -} - -//--------------------------------------------------------------------- -material PUMediaPack/Fire_03 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_flame_03.png - tex_address_mode clamp - } - } - } -} - -//--------------------------------------------------------------------- -material PUMediaPack/Fire_04 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_flame_04.png - tex_address_mode clamp - } - } - } -} - -//--------------------------------------------------------------------- -material PUMediaPack/AtlasSmoke -{ - technique - { - pass - { - lighting off - scene_blend alpha_blend - depth_write off - - texture_unit - { - texture pump_atlas_smoke.png - tex_address_mode clamp - } - } - } -} - -//--------------------------------------------------------------------- -material PUMediaPack/Snow_01 -{ - technique - { - pass - { - lighting off - scene_blend alpha_blend - depth_write off - - texture_unit - { - texture pump_snow_01.png - tex_address_mode clamp - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/BBal -{ - technique - { - pass - { - lighting off - depth_write off - - texture_unit - { - texture pu_bbal.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/BioHazzard -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_biohazzard.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/CelticKnot -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_celticknot.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -material PUMediaPack/Pentagram_01 -{ - technique - { - pass - { - lighting off - scene_blend add - depth_write off - - texture_unit - { - texture pump_pentagram_01.png - tex_address_mode clamp - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -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 - } - } - } -} - -//----------------------------------------------------------------------------------------------------------------------- -// 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. -//----------------------------------------------------------------------------------------------------------------------- - -material mp_explosion_smoke_01 -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend alpha_blend - - texture_unit - { - texture mp_explosion_smoke_01.dds - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material mp_explosion_smoke_01_add -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend add - texture_unit - { - texture mp_explosion_smoke_01_add.dds - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material mp_explosion_flare_01 -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend add - - texture_unit - { - texture mp_explosion_flare_01.dds - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material mp_explosion_flare_02 -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend add - - texture_unit - { - texture mp_explosion_flare_02.dds - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material mp_explosion_dirt -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend alpha_blend - - texture_unit - { - texture mp_explosion_dirt.dds - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material mp_explosion_flame_01 -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend add - - texture_unit - { - texture mp_explosion_flame_01.dds - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material mp_explosion_flame_02 -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend add - - texture_unit - { - texture mp_explosion_flame_02.dds - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material mp_explosion_smoke_02 -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend alpha_blend - - texture_unit - { - texture mp_explosion_smoke_02.dds - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material mp_explosion_smoke_03 -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend alpha_blend - - texture_unit - { - texture mp_explosion_smoke_03.dds - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material mp_explosion_debris -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend add - - texture_unit - { - texture mp_explosion_debris.dds - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material mp_explosion_debris_large -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend alpha_blend - - texture_unit - { - texture mp_explosion_debris_large_4x4.dds - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material mp_explosion_04 -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend add - texture_unit - { - texture mp_explosion_04.dds - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material mp_explosion_trail -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend add - - texture_unit - { - texture mp_explosion_trail_01.dds - } - } - } -} -//----------------------------------------------------------------------------------------------------------------------- -material mp_explosion_water -{ - technique - { - pass - { - lighting off - depth_write off - scene_blend alpha_blend - - texture_unit - { - texture mp_explosion_water.dds - } - } - } -} - diff --git a/tests/cpp-tests/Resources/Particle3D/scripts/mp_explosion_04_blue.pu b/tests/cpp-tests/Resources/Particle3D/scripts/mp_explosion_04_blue.pu deleted file mode 100644 index c079bf9fa6..0000000000 --- a/tests/cpp-tests/Resources/Particle3D/scripts/mp_explosion_04_blue.pu +++ /dev/null @@ -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 - } - } - } diff --git a/tests/lua-tests/src/Particle3DTest/Particle3DTest.lua b/tests/lua-tests/src/Particle3DTest/Particle3DTest.lua index bcff7db00d..27090915c5 100644 --- a/tests/lua-tests/src/Particle3DTest/Particle3DTest.lua +++ b/tests/lua-tests/src/Particle3DTest/Particle3DTest.lua @@ -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()) diff --git a/tests/lua-tests/src/mainMenu.lua b/tests/lua-tests/src/mainMenu.lua index 2803651b26..b5cdf161f8 100644 --- a/tests/lua-tests/src/mainMenu.lua +++ b/tests/lua-tests/src/mainMenu.lua @@ -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 }, diff --git a/tools/jenkins-scripts/linux-build.sh b/tools/jenkins-scripts/linux-build.sh new file mode 100755 index 0000000000..fab6ac682c --- /dev/null +++ b/tools/jenkins-scripts/linux-build.sh @@ -0,0 +1,8 @@ +#put xctool.sh into your PATH +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +COCOS2DX_ROOT="$DIR"/../.. +cd ${COCOS2DX_ROOT} +mkdir linux-build +cd linux-build +cmake .. +make -j4 diff --git a/tools/jenkins-scripts/mac-build.sh b/tools/jenkins-scripts/mac-build.sh new file mode 100755 index 0000000000..f6c12cd604 --- /dev/null +++ b/tools/jenkins-scripts/mac-build.sh @@ -0,0 +1,8 @@ +#put xctool.sh into your PATH +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +COCOS2DX_ROOT="$DIR"/../.. +cd ${COCOS2DX_ROOT} +mkdir mac-build +cd mac-build +cmake .. +make -j4 diff --git a/tools/jenkins-scripts/pull-request-builder.py b/tools/jenkins-scripts/pull-request-builder.py index 7fefee835a..f6a6248704 100755 --- a/tools/jenkins-scripts/pull-request-builder.py +++ b/tools/jenkins-scripts/pull-request-builder.py @@ -23,7 +23,7 @@ def set_description(desc, url): req = urllib2.Request(url + 'submitDescription', req_data) #print(os.environ['BUILD_URL']) req.add_header('Content-Type', 'application/x-www-form-urlencoded') - base64string = base64.encodestring(os.environ['JENKINS_ADMIN']+ ":" + os.environ['JENKINS_ADMIN_PW']).replace('\n', '') + base64string = base64.encodestring(os.environ['JENKINS_ADMIN'] + ":" + os.environ['JENKINS_ADMIN_PW']).replace('\n', '') req.add_header("Authorization", "Basic " + base64string) try: urllib2.urlopen(req) @@ -35,11 +35,8 @@ def check_current_3rd_libs(branch): #get current_libs config backup_files = range(2) current_files = range(2) - config_file_paths = ['external/config.json','templates/lua-template-runtime/runtime/config.json'] - if (branch == 'v2'): - config_file_paths = ['external/config.json'] - backup_files = range(1) - current_files = range(1) + config_file_paths = ['external/config.json', 'templates/lua-template-runtime/runtime/config.json'] + for i, config_file_path in enumerate(config_file_paths): if not os.path.isfile(config_file_path): raise Exception("Could not find 'external/config.json'") @@ -55,7 +52,7 @@ def check_current_3rd_libs(branch): current_file = filename current_files[i] = current_file if os.path.isfile(backup_file): - copy(backup_file, current_file) + copy(backup_file, current_file) #run download-deps.py print("prepare to downloading ...") os.system('python download-deps.py -r no') @@ -68,7 +65,7 @@ def connect_db(): db_host = os.environ['db_host'] db_user = os.environ['db_user'] db_pw = os.environ['db_pw'] - db_name=os.environ['db_name'] + db_name = os.environ['db_name'] try: db = MySQLdb.connect(db_host, db_user, db_pw, db_name) except: @@ -95,26 +92,27 @@ def scan_all_libs(db, pr_num): stats = {} lib_path = './tests/cpp-tests/proj.android/obj/local/armeabi' for root, dirs, files in os.walk(lib_path): - for _file in files: - if not _file.endswith(".a"): - continue - print _file - libfile = lib_path + '/' + _file - _filename = _file.split('.')[0] - filesize = os.path.getsize(libfile)/1024 - stats[_filename]=filesize - save_build_stats(db, pr_num, _filename, filesize) + for _file in files: + if not _file.endswith(".a"): + continue + print _file + libfile = lib_path + '/' + _file + _filename = _file.split('.')[0] + filesize = os.path.getsize(libfile) / 1024 + stats[_filename] = filesize + save_build_stats(db, pr_num, _filename, filesize) return stats http_proxy = '' -if(os.environ.has_key('HTTP_PROXY')): + +if('HTTP_PROXY' in os.environ): http_proxy = os.environ['HTTP_PROXY'] -proxyDict = {'http':http_proxy,'https':http_proxy} +proxyDict = {'http': http_proxy, 'https': http_proxy} def main(): #get payload from os env payload_str = os.environ['payload'] - payload_str = payload_str.decode('utf-8','ignore') + payload_str = payload_str.decode('utf-8', 'ignore') #parse to json obj payload = json.loads(payload_str) @@ -130,9 +128,7 @@ def main(): url = payload['html_url'] print "url:" + url - pr_desc = '

pr#' + str(pr_num) + ' is '+ action +'

' - - + pr_desc = '

pr#' + str(pr_num) + ' is ' + action + '

' #get statuses url statuses_url = payload['statuses_url'] @@ -149,21 +145,20 @@ def main(): set_description(pr_desc, target_url) - - data = {"state":"pending", "target_url":target_url, "context":"Jenkins CI", "description":"Build started..."} + data = {"state": "pending", "target_url": target_url, "context": "Jenkins CI", "description": "Build started..."} access_token = os.environ['GITHUB_ACCESS_TOKEN'] - Headers = {"Authorization":"token " + access_token} + Headers = {"Authorization": "token " + access_token} try: - requests.post(statuses_url, data=json.dumps(data), headers=Headers, proxies = proxyDict) + requests.post(statuses_url, data=json.dumps(data), headers=Headers, proxies=proxyDict) except: traceback.print_exc() #reset path to workspace root - os.system("cd " + os.environ['WORKSPACE']); + os.system("cd " + os.environ['WORKSPACE']) #pull latest code - os.system("git pull origin v3") - os.system("git checkout v3") + os.system("git pull origin " + branch) + os.system("git checkout " + branch) os.system("git branch -D pull" + str(pr_num)) #clean workspace print "Before checkout: git clean -xdf -f" @@ -174,7 +169,7 @@ def main(): if(ret != 0): return(2) - #checkout a new branch from v3 + #checkout a new branch from v3 or v4-develop git_checkout = "git checkout -b " + "pull" + str(pr_num) os.system(git_checkout) #merge pull reqeust head @@ -199,119 +194,91 @@ def main(): check_current_3rd_libs(branch) # Generate binding glue codes - if(branch == 'v3'): - ret = os.system("python tools/jenkins-scripts/gen_jsb.py") - elif(branch == 'v2'): - os.chdir('tools/tojs') - if(platform.system() == 'Windows'): - os.environ['NDK_ROOT'] = os.environ['NDK_ROOT_R8E'] - ret = os.system("genbindings-win32.bat") - os.environ['NDK_ROOT'] = os.environ['NDK_ROOT_R9B'] - else: - ret = os.system("./genbindings.sh") - os.chdir('../..') + if(branch == 'v3' or branch == 'v4-develop'): + ret = os.system("python tools/jenkins-scripts/gen_jsb.py") + if(ret != 0): return(1) #make temp dir print "current dir is: " + os.environ['WORKSPACE'] - os.system("cd " + os.environ['WORKSPACE']); + os.system("cd " + os.environ['WORKSPACE']) os.mkdir("android_build_objs") #add symbol link - PROJECTS=["cpp-empty-test", "cpp-tests"] + PROJECTS = ["cpp-empty-test", "cpp-tests"] print platform.system() if(platform.system() == 'Darwin'): for item in PROJECTS: - cmd = "ln -s " + os.environ['WORKSPACE']+"/android_build_objs/ " + os.environ['WORKSPACE']+"/tests/"+item+"/proj.android/obj" - os.system(cmd) + cmd = "ln -s " + os.environ['WORKSPACE'] + "/android_build_objs/ " + os.environ['WORKSPACE'] + "/tests/" + item + "/proj.android/obj" + os.system(cmd) elif(platform.system() == 'Windows'): for item in PROJECTS: - p = item.replace("/", os.sep) - cmd = "mklink /J "+os.environ['WORKSPACE']+os.sep+"tests"+os.sep +p+os.sep+"proj.android"+os.sep+"obj " + os.environ['WORKSPACE']+os.sep+"android_build_objs" - print cmd - os.system(cmd) + p = item.replace("/", os.sep) + cmd = "mklink /J " + os.environ['WORKSPACE'] + os.sep + "tests" + os.sep + p + os.sep + "proj.android" + os.sep + "obj " + os.environ['WORKSPACE'] + os.sep + "android_build_objs" + print cmd + os.system(cmd) #build - #TODO: add android-linux build + # TODO: add wp8.1 universal build #TODO: add mac build node_name = os.environ['NODE_NAME'] - if(branch == 'v3'): - if(node_name == 'android_mac') or (node_name == 'android_win7'): - #modify tests/cpp-empty-test/Classes/AppDelegate.cpp to support Console - modify_file = 'tests/cpp-empty-test/Classes/AppDelegate.cpp' - data = codecs.open(modify_file, encoding='UTF-8').read() - data = re.sub("director->setDisplayStats\(true\);", "director->setDisplayStats(true); director->getConsole()->listenOnTCP(5678);", data) - codecs.open(modify_file, 'wb', encoding='UTF-8').write(data) - #modify tests/cpp-empty-test/proj.android/AndroidManifest.xml to support Console - modify_file = 'tests/cpp-empty-test/proj.android/AndroidManifest.xml' - data = codecs.open(modify_file, encoding='UTF-8').read() - data = re.sub('', ' ', data) - codecs.open(modify_file, 'wb', encoding='UTF-8').write(data) - print "Start build android..." - ret = os.system("python build/android-build.py -p 10 all") - # create and save apk - if(ret == 0): - sample_dir = 'tests/cpp-tests/proj.android/' - local_apk = sample_dir + 'bin/CppTests-debug.apk' - backup_apk = os.environ['BACKUP_PATH'] + 'CppTests_' + str(pr_num) + '.apk' - os.system('cp ' + local_apk + ' ' + backup_apk) - db = connect_db() - scan_all_libs(db, pr_num) - ret = os.system("python build/android-build.py -p 10 -b release cpp-empty-test") - if(ret == 0): - _path = 'tests/cpp-empty-test/proj.android/libs/armeabi/libcpp_empty_test.so' - filesize = os.path.getsize(_path) - pr_desc = pr_desc + '

size of libcpp_empty_test.so is:' + str(filesize/1024) + 'kb

' - set_description(pr_desc, target_url) - save_build_stats(db, pr_num, 'libcpp_empty_test', filesize/1024) - ret = os.system("python build/android-build.py -p 10 -b release lua-empty-test") - if(ret == 0): - _path = 'tests/lua-empty-test/project/proj.android/libs/armeabi/liblua_empty_test.so' - filesize = os.path.getsize(_path) - pr_desc = pr_desc + '

size of liblua_empty_test.so is:' + str(filesize/1024) + 'kb

' - set_description(pr_desc, target_url) - save_build_stats(db, pr_num, 'liblua_empty_test', filesize/1024) - close_db(db) - elif(node_name == 'win32_win7'): - ret = subprocess.call('"%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"', shell=True) - elif(node_name == 'ios_mac'): - ret = os.system("tools/jenkins-scripts/ios-build.sh") - elif(node_name == 'linux_centos'): - os.chdir("build/") - ret = os.system("cmake ../") - ret = os.system("make -j10") - os.chdir("../") - elif(branch == 'v2'): - SAMPLES_DIRS = ['Cpp/HelloCpp', 'Cpp/SimpleGame', 'Cpp/TestCpp', 'Javascript/TestJavascript', 'Lua/HelloLua', 'Lua/TestLua'] - SAMPLES_NAMES = ['HelloCpp', 'SimpleGame', 'TestCpp', 'TestJavascript', 'HelloLua', 'TestLua'] - if(node_name == 'android_mac'): - for item in SAMPLES_DIRS: - proj_dir = "samples/" + item + "/proj.android" - os.system('ln -s ../../../../android_build_objs obj') - os.system(proj_dir + "/build_native.sh") - if (ret != 0): - break - elif(node_name == 'win32_win7'): - ret = subprocess.call('"%VS110COMNTOOLS%..\IDE\devenv.com" "cocos2d-win32.vc2012.sln" /Build "Debug|Win32"', shell=True) - elif(node_name == 'ios_mac'): - for i, item in enumerate(SAMPLES_DIRS): - cmd = "xcodebuild -project samples/" + item + "/proj.ios/" + SAMPLES_NAMES[i] + ".xcodeproj -scheme " + SAMPLES_NAMES[i] + ' -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)"' - cmd_clean = cmd + ' clean' - cmd_build = cmd + ' build' - ret = os.system(cmd_clean) - if(ret != 0): - break - ret = os.system(cmd_build) - if(ret != 0): - break - elif(node_name == 'linux_centos'): - data = codecs.open('cocos2dx/proj.linux/cocos2dx.mk', encoding='UTF-8').read() - data = re.sub('-lglfw','-L$(GLFW_279_LIB) -lglfw', data) - codecs.open('cocos2dx/proj.linux/cocos2dx.mk', 'wb', encoding='UTF-8').write(data) - ret = os.system('make -j10') - else: - ret = 0 + jenkins_script_path = 'tools/jenkins-scripts/' + if(branch == 'v3' or branch == 'v4-develop'): + if(node_name == 'android') or (node_name == 'android_bak'): + #modify tests/cpp-empty-test/Classes/AppDelegate.cpp to support Console + # FIXME: We should use patch instead + modify_file = 'tests/cpp-empty-test/Classes/AppDelegate.cpp' + data = codecs.open(modify_file, encoding='UTF-8').read() + data = re.sub("director->setDisplayStats\(true\);", "director->setDisplayStats(true); director->getConsole()->listenOnTCP(5678);", data) + codecs.open(modify_file, 'wb', encoding='UTF-8').write(data) + + #modify tests/cpp-empty-test/proj.android/AndroidManifest.xml to support Console + modify_file = 'tests/cpp-empty-test/proj.android/AndroidManifest.xml' + data = codecs.open(modify_file, encoding='UTF-8').read() + data = re.sub('', ' ', data) + codecs.open(modify_file, 'wb', encoding='UTF-8').write(data) + print "Start build android..." + ret = os.system("python build/android-build.py -p 10 all") + + # create and save apk + if(ret == 0): + sample_dir = 'tests/cpp-tests/proj.android/' + local_apk = sample_dir + 'bin/CppTests-debug.apk' + backup_apk = os.environ['BACKUP_PATH'] + 'CppTests_' + str(pr_num) + '.apk' + os.system('cp ' + local_apk + ' ' + backup_apk) + db = connect_db() + scan_all_libs(db, pr_num) + ret = os.system("python build/android-build.py -p 10 -b release cpp-empty-test") + if(ret == 0): + _path = 'tests/cpp-empty-test/proj.android/libs/armeabi/libcpp_empty_test.so' + filesize = os.path.getsize(_path) + pr_desc = pr_desc + '

size of libcpp_empty_test.so is:' + str(filesize / 1024) + 'kb

' + set_description(pr_desc, target_url) + save_build_stats(db, pr_num, 'libcpp_empty_test', filesize / 1024) + + ret = os.system("python build/android-build.py -p 10 -b release lua-empty-test") + if(ret == 0): + _path = 'tests/lua-empty-test/project/proj.android/libs/armeabi/liblua_empty_test.so' + filesize = os.path.getsize(_path) + pr_desc = pr_desc + '

size of liblua_empty_test.so is:' + str(filesize / 1024) + 'kb

' + set_description(pr_desc, target_url) + save_build_stats(db, pr_num, 'liblua_empty_test', filesize / 1024) + + close_db(db) + elif(node_name == 'win32' or node_name == 'win32_win7' or node_name == 'win32_bak'): + build_vs_project_name = 'cocos2d-win32.vc2013.sln' + if(branch == 'v3'): + build_vs_project_name = 'cocos2d-win32.vc2012.sln' + ret = subprocess.call('"%VS120COMNTOOLS%..\IDE\devenv.com" "build\"' + build_vs_project_name + ' /Build "Debug|Win32"', shell=True) + elif(node_name == 'windows-universal' or node_name == 'windows-universal_bak'): + ret = subprocess.call('"%VS120COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win8.1-universal.sln" /Build "Debug|Win32"', shell=True) + elif(node_name == 'ios_mac' or node_name == 'ios' or node_name == 'ios_bak'): + ret = os.system(jenkins_script_path + "ios-build.sh") + elif(node_name == 'mac' or node_name == 'mac_bak'): + ret = os.system(jenkins_script_path + "mac-build.sh") + elif(node_name == 'linux_centos' or node_name == 'linux' or node_name == 'linux_bak'): + ret = os.system(jenkins_script_path + "linux-build.sh") #get build result print "build finished and return " + str(ret) @@ -326,7 +293,7 @@ def main(): os.system("cd " + os.environ['WORKSPACE']) os.system("git reset --hard") os.system("git clean -xdf -f") - os.system("git checkout v3") + os.system("git checkout " + branch) os.system("git branch -D pull" + str(pr_num)) return(exit_code)