From 83a7b8012c52b302783f25f94b50022f28565285 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 26 Feb 2015 09:19:14 +0800 Subject: [PATCH] 3DParticle Reader and tests --- build/cocos2d_libs.xcodeproj/project.pbxproj | 20 +++ cocos/2d/libcocos2d.vcxproj | 6 +- cocos/2d/libcocos2d.vcxproj.filters | 9 + cocos/2d/libcocos2d_wp8.vcxproj | 6 +- cocos/2d/libcocos2d_wp8.vcxproj.filters | 9 + .../cocostudio/ActionTimeline/CSLoader.cpp | 2 + cocos/editor-support/cocostudio/Android.mk | 1 + .../editor-support/cocostudio/CMakeLists.txt | 3 +- .../Particle3DReader/Particle3DReader.cpp | 164 ++++++++++++++++++ .../Particle3DReader/Particle3DReader.h | 53 ++++++ .../CocosStudio3DTest/CocosStudio3DTest.cpp | 25 ++- .../CocosStudio3DTest/CocosStudio3DTest.h | 10 ++ .../CocosStudio3DTest/CocosStudio3DTest.lua | 22 ++- 13 files changed, 323 insertions(+), 7 deletions(-) create mode 100644 cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.cpp create mode 100644 cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index b92686e1c7..e3b3a9073c 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -832,6 +832,10 @@ 182C5CE61A9D725400C30D34 /* UserCameraReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 182C5CE31A9D725400C30D34 /* UserCameraReader.cpp */; }; 182C5CE71A9D725400C30D34 /* UserCameraReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 182C5CE41A9D725400C30D34 /* UserCameraReader.h */; }; 182C5CE81A9D725400C30D34 /* UserCameraReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 182C5CE41A9D725400C30D34 /* UserCameraReader.h */; }; + 18956BB21A9DFBFD006E9155 /* Particle3DReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18956BB01A9DFBFD006E9155 /* Particle3DReader.cpp */; }; + 18956BB31A9DFBFD006E9155 /* Particle3DReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18956BB01A9DFBFD006E9155 /* Particle3DReader.cpp */; }; + 18956BB41A9DFBFD006E9155 /* Particle3DReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 18956BB11A9DFBFD006E9155 /* Particle3DReader.h */; }; + 18956BB51A9DFBFD006E9155 /* Particle3DReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 18956BB11A9DFBFD006E9155 /* Particle3DReader.h */; }; 1A01C68418F57BE800EFE3A6 /* CCArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A01C67618F57BE800EFE3A6 /* CCArray.cpp */; }; 1A01C68518F57BE800EFE3A6 /* CCArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A01C67618F57BE800EFE3A6 /* CCArray.cpp */; }; 1A01C68618F57BE800EFE3A6 /* CCArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A01C67718F57BE800EFE3A6 /* CCArray.h */; }; @@ -2457,6 +2461,8 @@ 182C5CD51A98F30500C30D34 /* Sprite3DReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sprite3DReader.h; path = Sprite3DReader/Sprite3DReader.h; sourceTree = ""; }; 182C5CE31A9D725400C30D34 /* UserCameraReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UserCameraReader.cpp; path = UserCameraReader/UserCameraReader.cpp; sourceTree = ""; }; 182C5CE41A9D725400C30D34 /* UserCameraReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UserCameraReader.h; path = UserCameraReader/UserCameraReader.h; sourceTree = ""; }; + 18956BB01A9DFBFD006E9155 /* Particle3DReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Particle3DReader.cpp; path = Particle3DReader/Particle3DReader.cpp; sourceTree = ""; }; + 18956BB11A9DFBFD006E9155 /* Particle3DReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Particle3DReader.h; path = Particle3DReader/Particle3DReader.h; sourceTree = ""; }; 1A01C67618F57BE800EFE3A6 /* CCArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCArray.cpp; sourceTree = ""; }; 1A01C67718F57BE800EFE3A6 /* CCArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCArray.h; sourceTree = ""; }; 1A01C67818F57BE800EFE3A6 /* CCBool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBool.h; sourceTree = ""; }; @@ -3819,6 +3825,15 @@ name = UserCameraReader; sourceTree = ""; }; + 18956BAF1A9DFBEC006E9155 /* Particle3DReader */ = { + isa = PBXGroup; + children = ( + 18956BB01A9DFBFD006E9155 /* Particle3DReader.cpp */, + 18956BB11A9DFBFD006E9155 /* Particle3DReader.h */, + ); + name = Particle3DReader; + sourceTree = ""; + }; 1A01C67518F57BE800EFE3A6 /* deprecated */ = { isa = PBXGroup; children = ( @@ -5662,6 +5677,7 @@ 50FCEB6818C72017004AD434 /* WidgetReader */ = { isa = PBXGroup; children = ( + 18956BAF1A9DFBEC006E9155 /* Particle3DReader */, 182C5CE21A9D70C000C30D34 /* UserCameraReader */, 182C5CD31A98F2F400C30D34 /* Sprite3DReader */, 182C5CAF1A95961E00C30D34 /* Node3DReader */, @@ -6588,6 +6604,7 @@ B6877B2C1A8CA8A700643ABF /* CCPUParticle3DTextureRotator.h in Headers */, 15AE1A5619AAD40300C27E9E /* b2Math.h in Headers */, B68779BE1A8CA88500643ABF /* CCPUParticle3DEmitterManager.h in Headers */, + 18956BB41A9DFBFD006E9155 /* Particle3DReader.h in Headers */, 50ABBE9D1925AB6F00A911A9 /* CCRefPtr.h in Headers */, 15AE198319AAD36400C27E9E /* WidgetReader.h in Headers */, B257B461198A353E00D9A687 /* CCPrimitiveCommand.h in Headers */, @@ -7034,6 +7051,7 @@ 15AE198F19AAD36E00C27E9E /* CheckBoxReader.h in Headers */, 382384011A258FA7002C4610 /* util.h in Headers */, B6877AF11A8CA8A700643ABF /* CCPUParticle3DPathFollowerTranslator.h in Headers */, + 18956BB51A9DFBFD006E9155 /* Particle3DReader.h in Headers */, 50ABBED41925AB6F00A911A9 /* uthash.h in Headers */, B29A7E0A19EE1B7700872B35 /* AttachmentLoader.h in Headers */, B687794D1A8CA84900643ABF /* CCPUParticle3DRendererTranslator.h in Headers */, @@ -7634,6 +7652,7 @@ 1A5701B1180BCB590088DEC7 /* CCFontFNT.cpp in Sources */, 15AE181619AAD2F700C27E9E /* CCAttachNode.cpp in Sources */, B29A7DED19EE1B7700872B35 /* IkConstraint.c in Sources */, + 18956BB21A9DFBFD006E9155 /* Particle3DReader.cpp in Sources */, B6877B061A8CA8A700643ABF /* CCPUParticle3DScaleAffectorTranslator.cpp in Sources */, 1A5701B5180BCB590088DEC7 /* CCFontFreeType.cpp in Sources */, 1A5701B9180BCB5A0088DEC7 /* CCLabel.cpp in Sources */, @@ -8282,6 +8301,7 @@ 1A5701E3180BCB8C0088DEC7 /* CCScene.cpp in Sources */, 50ABBD611925AB0000A911A9 /* Vec4.cpp in Sources */, B60C5BD519AC68B10056FBDE /* CCBillBoard.cpp in Sources */, + 18956BB31A9DFBFD006E9155 /* Particle3DReader.cpp in Sources */, 15AE184519AAD2F700C27E9E /* CCSprite3DMaterial.cpp in Sources */, B6877A8F1A8CA8A700643ABF /* CCPUParticle3DBoxColliderTranslator.cpp in Sources */, 50ABBD9C1925AB4100A911A9 /* ccGLStateCache.cpp in Sources */, diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 7a549974e1..5feedbe33b 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -490,7 +490,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - + + @@ -995,7 +996,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - + + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index d47f298c14..96ccccddcf 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -163,6 +163,9 @@ {9421e104-69f8-4cee-8e59-51043ba06f15} + + {9421e104-1028-4cee-8e59-51043ba06f15} + {94210432-69f8-4cee-8e59-51043ba06f15} @@ -994,6 +997,9 @@ cocostudio\reader\WidgetReader\UserCameraReader + + cocostudio\reader\WidgetReader\Particle3DReader + cocostudio\json @@ -2461,6 +2467,9 @@ cocostudio\reader\WidgetReader\UserCameraReader + + cocostudio\reader\WidgetReader\Particle3DReader + cocostudio\reader\WidgetReader\Sprite3DReader diff --git a/cocos/2d/libcocos2d_wp8.vcxproj b/cocos/2d/libcocos2d_wp8.vcxproj index 4b40eb3939..f1cda959d3 100644 --- a/cocos/2d/libcocos2d_wp8.vcxproj +++ b/cocos/2d/libcocos2d_wp8.vcxproj @@ -516,7 +516,8 @@ - + + @@ -1098,7 +1099,8 @@ - + + diff --git a/cocos/2d/libcocos2d_wp8.vcxproj.filters b/cocos/2d/libcocos2d_wp8.vcxproj.filters index 6f60b19511..5451a62f2a 100644 --- a/cocos/2d/libcocos2d_wp8.vcxproj.filters +++ b/cocos/2d/libcocos2d_wp8.vcxproj.filters @@ -131,6 +131,9 @@ {89da718e-f2fa-1043-83e8-40104f6fc3a2} + + {89da718e-102a-1043-83e8-40104f6fc3a2} + {8910718e-f2fa-4437-83e8-40104f6fc3a2} @@ -1037,6 +1040,9 @@ cocostudio\reader\WidgetReader\UserCameraReader + + cocostudio\reader\WidgetReader\Particle3DReader + cocostudio\json @@ -2540,6 +2546,9 @@ cocostudio\reader\WidgetReader\UserCameraReader + + cocostudio\reader\WidgetReader\Particle3DReader + cocostudio\json diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp index b30a57d5b8..23a512ef06 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp @@ -62,6 +62,7 @@ #include "cocostudio/WidgetReader/Node3DReader/Node3DReader.h" #include "cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.h" #include "cocostudio/WidgetReader/UserCameraReader/UserCameraReader.h" +#include "cocostudio/WidgetReader/Particle3DReader/Particle3DReader.h" #include "flatbuffers/flatbuffers.h" #include "flatbuffers/util.h" @@ -210,6 +211,7 @@ CSLoader::CSLoader() CREATE_CLASS_NODE_READER_INFO(Node3DReader); CREATE_CLASS_NODE_READER_INFO(Sprite3DReader); CREATE_CLASS_NODE_READER_INFO(UserCameraReader); + CREATE_CLASS_NODE_READER_INFO(Particle3DReader); } void CSLoader::purge() diff --git a/cocos/editor-support/cocostudio/Android.mk b/cocos/editor-support/cocostudio/Android.mk index a31e05d5ff..e15606ad9a 100644 --- a/cocos/editor-support/cocostudio/Android.mk +++ b/cocos/editor-support/cocostudio/Android.mk @@ -64,6 +64,7 @@ WidgetReader/TextReader/TextReader.cpp \ WidgetReader/Node3DReader/Node3DReader.cpp \ WidgetReader/Sprite3DReader/Sprite3DReader.cpp \ WidgetReader/UserCameraReader/UserCameraReader.cpp \ +WidgetReader/Particle3DReader/Particle3DReader.cpp \ ActionTimeline/CCNodeReader.cpp \ ActionTimeline/CCActionTimelineCache.cpp \ ActionTimeline/CCFrame.cpp \ diff --git a/cocos/editor-support/cocostudio/CMakeLists.txt b/cocos/editor-support/cocostudio/CMakeLists.txt index cc374734ea..d380007eab 100644 --- a/cocos/editor-support/cocostudio/CMakeLists.txt +++ b/cocos/editor-support/cocostudio/CMakeLists.txt @@ -60,7 +60,8 @@ set(COCOS_CS_SRC editor-support/cocostudio/WidgetReader/PageViewReader/PageViewReader.cpp editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp editor-support/cocostudio/WidgetReader/Node3DReader/Node3DReader.cpp - editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp + editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp + editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.cpp editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp diff --git a/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.cpp new file mode 100644 index 0000000000..0f220dbb27 --- /dev/null +++ b/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** + Copyright (c) 2014 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "Particle3DReader.h" + +#include "cocostudio/CSParseBinary_generated.h" +#include "cocostudio/CSParse3DBinary_generated.h" +#include "cocostudio/FlatBuffersSerialize.h" +#include "cocostudio/WidgetReader/Node3DReader/Node3DReader.h" + +#include "tinyxml2.h" +#include "flatbuffers/flatbuffers.h" + +#include "Particle3D/ParticleUniverse/CCPUParticleSystem3D.h" + +USING_NS_CC; +using namespace flatbuffers; + +namespace cocostudio +{ + IMPLEMENT_CLASS_NODE_READER_INFO(Particle3DReader) + + Particle3DReader::Particle3DReader() + { + + } + + Particle3DReader::~Particle3DReader() + { + + } + + static Particle3DReader* _instanceParticle3DReader = nullptr; + + Particle3DReader* Particle3DReader::getInstance() + { + if (!_instanceParticle3DReader) + { + _instanceParticle3DReader = new Particle3DReader(); + } + + return _instanceParticle3DReader; + } + + void Particle3DReader::purge() + { + CC_SAFE_DELETE(_instanceParticle3DReader); + } + + Offset Particle3DReader::createOptionsWithFlatBuffers(const tinyxml2::XMLElement *objectData, + flatbuffers::FlatBufferBuilder *builder) + { + auto temp = Node3DReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder); + auto node3DOptions = *(Offset*)(&temp); + + std::string path; + int resourceType = 0; + + // FileData + const tinyxml2::XMLElement* child = objectData->FirstChildElement(); + while (child) + { + std::string name = child->Name(); + + if (name == "FileData") + { + const tinyxml2::XMLAttribute* attribute = child->FirstAttribute(); + + while (attribute) + { + name = attribute->Name(); + std::string value = attribute->Value(); + + if (name == "Path") + { + path = value; + } + else if (name == "Type") + { + if(value == "Normal") + { + resourceType = 1; + } + else if(value == "Default") + { + resourceType = 0; + } + } + + attribute = attribute->Next(); + } + } + + child = child->NextSiblingElement(); + } + + auto options = CreateParticle3DOptions(*builder, + node3DOptions, + CreateResourceData(*builder, + builder->CreateString(path), + builder->CreateString(""), + resourceType) + ); + + return *(Offset
*)(&options); + } + + void Particle3DReader::setPropsWithFlatBuffers(cocos2d::Node *node, + const flatbuffers::Table* particle3DOptions) + { + auto options = (Particle3DOptions*)particle3DOptions; + + auto node3DReader = Node3DReader::getInstance(); + node3DReader->setPropsWithFlatBuffers(node, (Table*)(options->node3DOption())); + } + + Node* Particle3DReader::createNodeWithFlatBuffers(const flatbuffers::Table *particle3DOptions) + { + auto options = (Particle3DOptions*)particle3DOptions; + + auto fileData = options->fileData(); + std::string path = fileData->path()->c_str(); + + ParticleSystem3D* ret = NULL; + if(!FileUtils::getInstance()->isFileExist(path)) + { + ret = PUParticleSystem3D::create(); + } + else + { + ret = PUParticleSystem3D::create(path); + } + + setPropsWithFlatBuffers(ret, particle3DOptions); + + if(ret) + { + ret->startParticleSystem(); + } + + return ret; + } +} diff --git a/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.h b/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.h new file mode 100644 index 0000000000..a3a5dfaa28 --- /dev/null +++ b/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.h @@ -0,0 +1,53 @@ +/**************************************************************************** + Copyright (c) 2014 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __cocos2d_libs__Particle3DReader__ +#define __cocos2d_libs__Particle3DReader__ + +#include "cocos2d.h" +#include "cocostudio/CocosStudioExport.h" +#include "cocostudio/WidgetReader/NodeReaderProtocol.h" +#include "cocostudio/WidgetReader/NodeReaderDefine.h" + +namespace cocostudio +{ + class CC_STUDIO_DLL Particle3DReader : public cocos2d::Ref, public NodeReaderProtocol + { + DECLARE_CLASS_NODE_READER_INFO + + public: + Particle3DReader(); + ~Particle3DReader(); + + static Particle3DReader* getInstance(); + static void purge(); + + flatbuffers::Offset createOptionsWithFlatBuffers(const tinyxml2::XMLElement* objectData, + flatbuffers::FlatBufferBuilder* builder); + void setPropsWithFlatBuffers(cocos2d::Node* node, const flatbuffers::Table* particle3DOptions); + cocos2d::Node* createNodeWithFlatBuffers(const flatbuffers::Table* particle3DOptions); + }; +} + +#endif /* defined(__cocos2d_libs__Particle3DReader__) */ diff --git a/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.cpp b/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.cpp index d17039d7b7..fa07c703a5 100644 --- a/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.cpp +++ b/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.cpp @@ -40,7 +40,8 @@ static std::function createFunctions[] = { CL(CSNode3DTest), CL(CSSprite3DTest), - CL(CSUserCameraTest) + CL(CSUserCameraTest), + CL(CSParticle3DTest) }; #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) @@ -204,6 +205,28 @@ std::string CSUserCameraTest::subtitle() const return ""; } +//------------------------------------------------------------------ +// +// CSParticle3DTest +// +//------------------------------------------------------------------ +CSParticle3DTest::CSParticle3DTest() +{ + auto node = CSLoader::createNode("ccs-res/CocosStudio3DTest/Particle3D.csb"); + + addChild(node); +} + +std::string CSParticle3DTest::title() const +{ + return "Particle3DReader Test"; +} + +std::string CSParticle3DTest::subtitle() const +{ + return ""; +} + //------------------------------------------------------------------ // diff --git a/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.h b/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.h index fc1ef849be..2061d5be13 100644 --- a/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.h +++ b/tests/cpp-tests/Classes/CocosStudio3DTest/CocosStudio3DTest.h @@ -76,6 +76,16 @@ public: virtual std::string subtitle() const override; }; +class CSParticle3DTest : public CocosStudio3DTestDemo +{ +public: + CREATE_FUNC(CSParticle3DTest); + CSParticle3DTest(); + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + + class CS3DTestScene : public TestScene { public: diff --git a/tests/lua-tests/src/CocosStudio3DTest/CocosStudio3DTest.lua b/tests/lua-tests/src/CocosStudio3DTest/CocosStudio3DTest.lua index 478f9932d5..3aff611273 100644 --- a/tests/lua-tests/src/CocosStudio3DTest/CocosStudio3DTest.lua +++ b/tests/lua-tests/src/CocosStudio3DTest/CocosStudio3DTest.lua @@ -66,6 +66,25 @@ function CSUserCameraTest.create() return layer end +---------------------------------------- +----CSParticle3DTest +---------------------------------------- + +local CSParticle3DTest = {} +CSParticle3DTest.__index = CSParticle3DTest + +function CSParticle3DTest.create() + local layer = cc.Layer:create() + Helper.initWithLayer(layer) + Helper.titleLabel:setString("Particle3DReader Test") + + local node = cc.CSLoader:createNode("ccs-res/CocosStudio3DTest/Particle3D.csb") + + layer:addChild(node) + + return layer +end + function CocosStudio3DTest() local scene = cc.Scene:create() @@ -73,7 +92,8 @@ function CocosStudio3DTest() { CSNode3DTest.create, CSSprite3DTest.create, - CSUserCameraTest.create + CSUserCameraTest.create, + CSParticle3DTest.create } scene:addChild(CSNode3DTest.create())