3DParticle Reader and tests

This commit is contained in:
Ray 2015-02-26 09:19:14 +08:00
parent ff07f62e83
commit 83a7b8012c
13 changed files with 323 additions and 7 deletions

View File

@ -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 = "<group>"; };
182C5CE31A9D725400C30D34 /* UserCameraReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UserCameraReader.cpp; path = UserCameraReader/UserCameraReader.cpp; sourceTree = "<group>"; };
182C5CE41A9D725400C30D34 /* UserCameraReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UserCameraReader.h; path = UserCameraReader/UserCameraReader.h; sourceTree = "<group>"; };
18956BB01A9DFBFD006E9155 /* Particle3DReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Particle3DReader.cpp; path = Particle3DReader/Particle3DReader.cpp; sourceTree = "<group>"; };
18956BB11A9DFBFD006E9155 /* Particle3DReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Particle3DReader.h; path = Particle3DReader/Particle3DReader.h; sourceTree = "<group>"; };
1A01C67618F57BE800EFE3A6 /* CCArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCArray.cpp; sourceTree = "<group>"; };
1A01C67718F57BE800EFE3A6 /* CCArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCArray.h; sourceTree = "<group>"; };
1A01C67818F57BE800EFE3A6 /* CCBool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBool.h; sourceTree = "<group>"; };
@ -3819,6 +3825,15 @@
name = UserCameraReader;
sourceTree = "<group>";
};
18956BAF1A9DFBEC006E9155 /* Particle3DReader */ = {
isa = PBXGroup;
children = (
18956BB01A9DFBFD006E9155 /* Particle3DReader.cpp */,
18956BB11A9DFBFD006E9155 /* Particle3DReader.h */,
);
name = Particle3DReader;
sourceTree = "<group>";
};
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 */,

View File

@ -490,7 +490,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\TextReader\TextReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\Node3DReader\Node3DReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\Sprite3DReader\Sprite3DReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\UserCameraReader\UserCameraReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\UserCameraReader\UserCameraReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\Particle3DReader\Particle3DReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\WidgetReader.cpp" />
<ClCompile Include="..\math\CCAffineTransform.cpp" />
<ClCompile Include="..\math\CCGeometry.cpp" />
@ -995,7 +996,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\TextReader\TextReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\Node3DReader\Node3DReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\Sprite3DReader\Sprite3DReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\UserCameraReader\UserCameraReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\UserCameraReader\UserCameraReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\Particle3DReader\Particle3DReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\WidgetReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\WidgetReaderProtocol.h" />
<ClInclude Include="..\math\CCAffineTransform.h" />

View File

@ -163,6 +163,9 @@
<Filter Include="cocostudio\reader\WidgetReader\UserCameraReader">
<UniqueIdentifier>{9421e104-69f8-4cee-8e59-51043ba06f15}</UniqueIdentifier>
</Filter>
<Filter Include="cocostudio\reader\WidgetReader\Particle3DReader">
<UniqueIdentifier>{9421e104-1028-4cee-8e59-51043ba06f15}</UniqueIdentifier>
</Filter>
<Filter Include="cocostudio\reader\WidgetReader\Sprite3DReader">
<UniqueIdentifier>{94210432-69f8-4cee-8e59-51043ba06f15}</UniqueIdentifier>
</Filter>
@ -994,6 +997,9 @@
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\UserCameraReader\UserCameraReader.cpp">
<Filter>cocostudio\reader\WidgetReader\UserCameraReader</Filter>
</ClCompile>
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\Particle3DReader\Particle3DReader.cpp">
<Filter>cocostudio\reader\WidgetReader\Particle3DReader</Filter>
</ClCompile>
<ClCompile Include="..\editor-support\cocostudio\CocoLoader.cpp">
<Filter>cocostudio\json</Filter>
</ClCompile>
@ -2461,6 +2467,9 @@
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\UserCameraReader\UserCameraReader.h">
<Filter>cocostudio\reader\WidgetReader\UserCameraReader</Filter>
</ClInclude>
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\Particle3DReader\Particle3DReader.h">
<Filter>cocostudio\reader\WidgetReader\Particle3DReader</Filter>
</ClInclude>
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\Sprite3DReader\Sprite3DReader.h">
<Filter>cocostudio\reader\WidgetReader\Sprite3DReader</Filter>
</ClInclude>

View File

@ -516,7 +516,8 @@
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\TextReader\TextReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\Node3DReader\Node3DReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\Sprite3DReader\Sprite3DReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\UserCameraReader\UserCameraReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\UserCameraReader\UserCameraReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\Particle3DReader\Particle3DReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\WidgetReader.h" />
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\WidgetReaderProtocol.h" />
<ClInclude Include="..\math\CCAffineTransform.h" />
@ -1098,7 +1099,8 @@
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\TextReader\TextReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\Node3DReader\Node3DReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\Sprite3DReader\Sprite3DReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\UserCameraReader\UserCameraReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\UserCameraReader\UserCameraReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\Particle3DReader\Particle3DReader.cpp" />
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\WidgetReader.cpp" />
<ClCompile Include="..\math\CCAffineTransform.cpp" />
<ClCompile Include="..\math\CCGeometry.cpp" />

View File

@ -131,6 +131,9 @@
<Filter Include="cocostudio\reader\WidgetReader\UserCameraReader">
<UniqueIdentifier>{89da718e-f2fa-1043-83e8-40104f6fc3a2}</UniqueIdentifier>
</Filter>
<Filter Include="cocostudio\reader\WidgetReader\Particle3DReader">
<UniqueIdentifier>{89da718e-102a-1043-83e8-40104f6fc3a2}</UniqueIdentifier>
</Filter>
<Filter Include="cocostudio\reader\WidgetReader\Sprite3DReader">
<UniqueIdentifier>{8910718e-f2fa-4437-83e8-40104f6fc3a2}</UniqueIdentifier>
</Filter>
@ -1037,6 +1040,9 @@
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\UserCameraReader\UserCameraReader.cpp">
<Filter>cocostudio\reader\WidgetReader\UserCameraReader</Filter>
</ClCompile>
<ClCompile Include="..\editor-support\cocostudio\WidgetReader\Particle3DReader\Particle3DReader.cpp">
<Filter>cocostudio\reader\WidgetReader\Particle3DReader</Filter>
</ClCompile>
<ClCompile Include="..\editor-support\cocostudio\CocoLoader.cpp">
<Filter>cocostudio\json</Filter>
</ClCompile>
@ -2540,6 +2546,9 @@
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\UserCameraReader\UserCameraReader.h">
<Filter>cocostudio\reader\WidgetReader\UserCameraReader</Filter>
</ClInclude>
<ClInclude Include="..\editor-support\cocostudio\WidgetReader\Particle3DReader\Particle3DReader.h">
<Filter>cocostudio\reader\WidgetReader\Particle3DReader</Filter>
</ClInclude>
<ClInclude Include="..\editor-support\cocostudio\CocoLoader.h">
<Filter>cocostudio\json</Filter>
</ClInclude>

View File

@ -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()

View File

@ -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 \

View File

@ -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

View File

@ -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<Table> Particle3DReader::createOptionsWithFlatBuffers(const tinyxml2::XMLElement *objectData,
flatbuffers::FlatBufferBuilder *builder)
{
auto temp = Node3DReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder);
auto node3DOptions = *(Offset<Node3DOption>*)(&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<Table>*)(&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;
}
}

View File

@ -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<flatbuffers::Table> 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__) */

View File

@ -40,7 +40,8 @@ static std::function<Layer*()> 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 "";
}
//------------------------------------------------------------------
//

View File

@ -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:

View File

@ -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())