mirror of https://github.com/axmolengine/axmol.git
parent
1b482b2c3f
commit
2f01deee89
|
@ -818,6 +818,12 @@
|
|||
15EFA212198A2BB5000C57D3 /* CCProtectedNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15EFA20F198A2BB5000C57D3 /* CCProtectedNode.cpp */; };
|
||||
15EFA213198A2BB5000C57D3 /* CCProtectedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */; };
|
||||
15EFA214198A2BB5000C57D3 /* CCProtectedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */; };
|
||||
182C5CAE1A95961600C30D34 /* CSParse3DBinary_generated.h in Headers */ = {isa = PBXBuildFile; fileRef = 182C5CAD1A95961600C30D34 /* CSParse3DBinary_generated.h */; };
|
||||
182C5CB21A95964700C30D34 /* Node3DReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 182C5CB01A95964700C30D34 /* Node3DReader.cpp */; };
|
||||
182C5CB31A95964700C30D34 /* Node3DReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 182C5CB11A95964700C30D34 /* Node3DReader.h */; };
|
||||
182C5CB41A95964C00C30D34 /* Node3DReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 182C5CB01A95964700C30D34 /* Node3DReader.cpp */; };
|
||||
182C5CB51A95964F00C30D34 /* Node3DReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 182C5CB11A95964700C30D34 /* Node3DReader.h */; };
|
||||
182C5CB61A95965500C30D34 /* CSParse3DBinary_generated.h in Headers */ = {isa = PBXBuildFile; fileRef = 182C5CAD1A95961600C30D34 /* CSParse3DBinary_generated.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 */; };
|
||||
|
@ -2436,6 +2442,9 @@
|
|||
15B3707719EE414C00ABE682 /* Manifest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Manifest.h; sourceTree = "<group>"; };
|
||||
15EFA20F198A2BB5000C57D3 /* CCProtectedNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCProtectedNode.cpp; sourceTree = "<group>"; };
|
||||
15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProtectedNode.h; sourceTree = "<group>"; };
|
||||
182C5CAD1A95961600C30D34 /* CSParse3DBinary_generated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSParse3DBinary_generated.h; sourceTree = "<group>"; };
|
||||
182C5CB01A95964700C30D34 /* Node3DReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Node3DReader.cpp; path = Node3DReader/Node3DReader.cpp; sourceTree = "<group>"; };
|
||||
182C5CB11A95964700C30D34 /* Node3DReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Node3DReader.h; path = Node3DReader/Node3DReader.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>"; };
|
||||
|
@ -3771,6 +3780,15 @@
|
|||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
182C5CAF1A95961E00C30D34 /* Node3DReader */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
182C5CB01A95964700C30D34 /* Node3DReader.cpp */,
|
||||
182C5CB11A95964700C30D34 /* Node3DReader.h */,
|
||||
);
|
||||
name = Node3DReader;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1A01C67518F57BE800EFE3A6 /* deprecated */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -4391,6 +4409,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
382384021A259005002C4610 /* CSParseBinary_generated.h */,
|
||||
182C5CAD1A95961600C30D34 /* CSParse3DBinary_generated.h */,
|
||||
382384051A25900F002C4610 /* FlatBuffersSerialize.cpp */,
|
||||
382384061A25900F002C4610 /* FlatBuffersSerialize.h */,
|
||||
38ACD1FA1A27111900C3093D /* WidgetCallBackHandlerProtocol.cpp */,
|
||||
|
@ -5613,6 +5632,7 @@
|
|||
50FCEB6818C72017004AD434 /* WidgetReader */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
182C5CAF1A95961E00C30D34 /* Node3DReader */,
|
||||
38F5263A1A48363B000DB7F7 /* ArmatureNodeReader */,
|
||||
382384251A2590F9002C4610 /* NodeReader */,
|
||||
3823843A1A259140002C4610 /* SingleNodeReader */,
|
||||
|
@ -6181,6 +6201,7 @@
|
|||
15AE188719AAD33D00C27E9E /* CCBSequenceProperty.h in Headers */,
|
||||
B68779F61A8CA88500643ABF /* CCPUParticle3DVertexEmitter.h in Headers */,
|
||||
1A01C69A18F57BE800EFE3A6 /* CCSet.h in Headers */,
|
||||
182C5CB31A95964700C30D34 /* Node3DReader.h in Headers */,
|
||||
1A570083180BC5A10088DEC7 /* CCActionManager.h in Headers */,
|
||||
1A570087180BC5A10088DEC7 /* CCActionPageTurn3D.h in Headers */,
|
||||
50ABBD911925AB4100A911A9 /* CCGLProgramCache.h in Headers */,
|
||||
|
@ -6614,6 +6635,7 @@
|
|||
50ABC00F1926664800A911A9 /* CCFileUtils.h in Headers */,
|
||||
B68779BA1A8CA88500643ABF /* CCPUParticle3DEmitter.h in Headers */,
|
||||
15AE1A3719AAD3D500C27E9E /* b2PolygonShape.h in Headers */,
|
||||
182C5CAE1A95961600C30D34 /* CSParse3DBinary_generated.h in Headers */,
|
||||
B6877AA41A8CA8A700643ABF /* CCPUParticle3DFlockCenteringAffector.h in Headers */,
|
||||
15AE1B5419AADA9900C27E9E /* UIRichText.h in Headers */,
|
||||
50ABBE3B1925AB6F00A911A9 /* CCData.h in Headers */,
|
||||
|
@ -6809,6 +6831,7 @@
|
|||
B6877B311A8CA8A700643ABF /* CCPUParticle3DTextureRotatorTranslator.h in Headers */,
|
||||
B29A7E2419EE1B7700872B35 /* IkConstraint.h in Headers */,
|
||||
1A01C68918F57BE800EFE3A6 /* CCBool.h in Headers */,
|
||||
182C5CB61A95965500C30D34 /* CSParse3DBinary_generated.h in Headers */,
|
||||
15AE184319AAD2F700C27E9E /* CCSprite3D.h in Headers */,
|
||||
50CB247E19D9C5A100687767 /* AudioPlayer.h in Headers */,
|
||||
1A57007C180BC5A10088DEC7 /* CCActionInstant.h in Headers */,
|
||||
|
@ -7212,6 +7235,7 @@
|
|||
299CF1FE19A434BC00C378C1 /* ccRandom.h in Headers */,
|
||||
50ABBDBC1925AB4100A911A9 /* CCTextureAtlas.h in Headers */,
|
||||
15AE182319AAD2F700C27E9E /* CCBundleReader.h in Headers */,
|
||||
182C5CB51A95964F00C30D34 /* Node3DReader.h in Headers */,
|
||||
50ABBE541925AB6F00A911A9 /* CCEventDispatcher.h in Headers */,
|
||||
1A12775A18DFCC4F0005F345 /* CCTweenFunction.h in Headers */,
|
||||
15AE192819AAD35100C27E9E /* TriggerBase.h in Headers */,
|
||||
|
@ -7582,6 +7606,7 @@
|
|||
292DB13D19B4574100A80320 /* UIEditBox.cpp in Sources */,
|
||||
50ABBE551925AB6F00A911A9 /* CCEventFocus.cpp in Sources */,
|
||||
15AE1A8819AAD40300C27E9E /* b2PrismaticJoint.cpp in Sources */,
|
||||
182C5CB21A95964700C30D34 /* Node3DReader.cpp in Sources */,
|
||||
50ABBE491925AB6F00A911A9 /* CCEventAcceleration.cpp in Sources */,
|
||||
3823843D1A259140002C4610 /* SingleNodeReader.cpp in Sources */,
|
||||
B6877A8E1A8CA8A700643ABF /* CCPUParticle3DBoxColliderTranslator.cpp in Sources */,
|
||||
|
@ -8447,6 +8472,7 @@
|
|||
15AE180919AAD2F700C27E9E /* CCAABB.cpp in Sources */,
|
||||
15AE1AA719AAD40300C27E9E /* b2Island.cpp in Sources */,
|
||||
3E6176741960F89B00DE83F5 /* CCEventController.cpp in Sources */,
|
||||
182C5CB41A95964C00C30D34 /* Node3DReader.cpp in Sources */,
|
||||
B63990CD1A490AFE00B07923 /* CCAsyncTaskPool.cpp in Sources */,
|
||||
50ABBE361925AB6F00A911A9 /* CCConsole.cpp in Sources */,
|
||||
B29A7E1419EE1B7700872B35 /* Bone.c in Sources */,
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
#ifndef FLATBUFFERS_GENERATED_CSPARSE3DBINARY_FLATBUFFERS_H_
|
||||
#define FLATBUFFERS_GENERATED_CSPARSE3DBINARY_FLATBUFFERS_H_
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
struct CSParseBinary;
|
||||
struct NodeTree;
|
||||
struct Options;
|
||||
struct WidgetOptions;
|
||||
struct LayoutComponentTable;
|
||||
struct SingleNodeOptions;
|
||||
struct SpriteOptions;
|
||||
struct ParticleSystemOptions;
|
||||
struct GameMapOptions;
|
||||
struct ButtonOptions;
|
||||
struct CheckBoxOptions;
|
||||
struct ImageViewOptions;
|
||||
struct TextAtlasOptions;
|
||||
struct TextBMFontOptions;
|
||||
struct TextOptions;
|
||||
struct TextFieldOptions;
|
||||
struct LoadingBarOptions;
|
||||
struct SliderOptions;
|
||||
struct PanelOptions;
|
||||
struct ScrollViewOptions;
|
||||
struct PageViewOptions;
|
||||
struct ListViewOptions;
|
||||
struct ProjectNodeOptions;
|
||||
struct ComponentOptions;
|
||||
struct ComAudioOptions;
|
||||
struct AnimationInfo;
|
||||
struct NodeAction;
|
||||
struct TimeLine;
|
||||
struct Frame;
|
||||
struct PointFrame;
|
||||
struct ScaleFrame;
|
||||
struct ColorFrame;
|
||||
struct TextureFrame;
|
||||
struct EventFrame;
|
||||
struct IntFrame;
|
||||
struct BoolFrame;
|
||||
struct InnerActionFrame;
|
||||
struct RotationSkew;
|
||||
struct Position;
|
||||
struct Scale;
|
||||
struct AnchorPoint;
|
||||
struct Color;
|
||||
struct ColorVector;
|
||||
struct FlatSize;
|
||||
struct CapInsets;
|
||||
struct ResourceData;
|
||||
} // namespace flatbuffers
|
||||
|
||||
namespace flatbuffers {
|
||||
|
||||
struct Node3DOption;
|
||||
struct Vector3;
|
||||
|
||||
MANUALLY_ALIGNED_STRUCT(4) Vector3 {
|
||||
private:
|
||||
float x_;
|
||||
float y_;
|
||||
float z_;
|
||||
|
||||
public:
|
||||
Vector3(float x, float y, float z)
|
||||
: x_(flatbuffers::EndianScalar(x)), y_(flatbuffers::EndianScalar(y)), z_(flatbuffers::EndianScalar(z)) { }
|
||||
|
||||
float x() const { return flatbuffers::EndianScalar(x_); }
|
||||
float y() const { return flatbuffers::EndianScalar(y_); }
|
||||
float z() const { return flatbuffers::EndianScalar(z_); }
|
||||
};
|
||||
STRUCT_END(Vector3, 12);
|
||||
|
||||
struct Node3DOption : private flatbuffers::Table {
|
||||
const flatbuffers::WidgetOptions *nodeOptions() const { return GetPointer<const flatbuffers::WidgetOptions *>(4); }
|
||||
const Vector3 *position3D() const { return GetStruct<const Vector3 *>(6); }
|
||||
const Vector3 *rotation3D() const { return GetStruct<const Vector3 *>(8); }
|
||||
const Vector3 *scale3D() const { return GetStruct<const Vector3 *>(10); }
|
||||
int32_t cameramask() const { return GetField<int32_t>(12, 0); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) &&
|
||||
verifier.VerifyTable(nodeOptions()) &&
|
||||
VerifyField<Vector3>(verifier, 6 /* position3D */) &&
|
||||
VerifyField<Vector3>(verifier, 8 /* rotation3D */) &&
|
||||
VerifyField<Vector3>(verifier, 10 /* scale3D */) &&
|
||||
VerifyField<int32_t>(verifier, 12 /* cameramask */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct Node3DOptionBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_nodeOptions(flatbuffers::Offset<flatbuffers::WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); }
|
||||
void add_position3D(const Vector3 *position3D) { fbb_.AddStruct(6, position3D); }
|
||||
void add_rotation3D(const Vector3 *rotation3D) { fbb_.AddStruct(8, rotation3D); }
|
||||
void add_scale3D(const Vector3 *scale3D) { fbb_.AddStruct(10, scale3D); }
|
||||
void add_cameramask(int32_t cameramask) { fbb_.AddElement<int32_t>(12, cameramask, 0); }
|
||||
Node3DOptionBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
Node3DOptionBuilder &operator=(const Node3DOptionBuilder &);
|
||||
flatbuffers::Offset<Node3DOption> Finish() {
|
||||
auto o = flatbuffers::Offset<Node3DOption>(fbb_.EndTable(start_, 5));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Node3DOption> CreateNode3DOption(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<flatbuffers::WidgetOptions> nodeOptions = 0,
|
||||
const Vector3 *position3D = 0,
|
||||
const Vector3 *rotation3D = 0,
|
||||
const Vector3 *scale3D = 0,
|
||||
int32_t cameramask = 0) {
|
||||
Node3DOptionBuilder builder_(_fbb);
|
||||
builder_.add_cameramask(cameramask);
|
||||
builder_.add_scale3D(scale3D);
|
||||
builder_.add_rotation3D(rotation3D);
|
||||
builder_.add_position3D(position3D);
|
||||
builder_.add_nodeOptions(nodeOptions);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline const Node3DOption *GetNode3DOption(const void *buf) { return flatbuffers::GetRoot<Node3DOption>(buf); }
|
||||
|
||||
inline bool VerifyNode3DOptionBuffer(flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer<Node3DOption>(); }
|
||||
|
||||
inline void FinishNode3DOptionBuffer(flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<Node3DOption> root) { fbb.Finish(root); }
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
#endif // FLATBUFFERS_GENERATED_CSPARSE3DBINARY_FLATBUFFERS_H_
|
|
@ -0,0 +1,205 @@
|
|||
/****************************************************************************
|
||||
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 "Node3DReader.h"
|
||||
|
||||
#include "cocostudio/CSParseBinary_generated.h"
|
||||
#include "cocostudio/CSParse3DBinary_generated.h"
|
||||
#include "cocostudio/FlatBuffersSerialize.h"
|
||||
#include "cocostudio/WidgetReader/NodeReader/NodeReader.h"
|
||||
|
||||
#include "tinyxml2.h"
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
USING_NS_CC;
|
||||
using namespace flatbuffers;
|
||||
|
||||
namespace cocostudio
|
||||
{
|
||||
IMPLEMENT_CLASS_NODE_READER_INFO(Node3DReader)
|
||||
|
||||
Node3DReader::Node3DReader()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Node3DReader::~Node3DReader()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static Node3DReader* _instanceNode3DReader = nullptr;
|
||||
|
||||
Node3DReader* Node3DReader::getInstance()
|
||||
{
|
||||
if (!_instanceNode3DReader)
|
||||
{
|
||||
_instanceNode3DReader = new Node3DReader();
|
||||
}
|
||||
|
||||
return _instanceNode3DReader;
|
||||
}
|
||||
|
||||
void Node3DReader::purge()
|
||||
{
|
||||
CC_SAFE_DELETE(_instanceNode3DReader);
|
||||
}
|
||||
|
||||
Vec3 Node3DReader::getVec3Attribute(const tinyxml2::XMLAttribute* attribute) const
|
||||
{
|
||||
if(!attribute)
|
||||
return Vec3::ZERO;
|
||||
|
||||
Vec3 ret(Vec3::ZERO);
|
||||
std::string attriname;
|
||||
|
||||
while (attribute)
|
||||
{
|
||||
attriname = attribute->Name();
|
||||
std::string value = attribute->Value();
|
||||
|
||||
if (attriname == "ValueX")
|
||||
{
|
||||
ret.x = atof(value.c_str());
|
||||
}
|
||||
else if (attriname == "ValueY")
|
||||
{
|
||||
ret.y = atof(value.c_str());
|
||||
}
|
||||
else if(attriname == "ValueZ")
|
||||
{
|
||||
ret.z = atof(value.c_str());
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Offset<Table> Node3DReader::createOptionsWithFlatBuffers(const tinyxml2::XMLElement *objectData,
|
||||
flatbuffers::FlatBufferBuilder *builder)
|
||||
{
|
||||
auto temp = NodeReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder);
|
||||
auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
|
||||
|
||||
Vec3 position(Vec3::ZERO);
|
||||
Vec3 rotation(Vec3::ZERO);
|
||||
Vec3 scale(Vec3::ZERO);
|
||||
int cameraMask = 0;
|
||||
|
||||
std::string attriname;
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while(attribute)
|
||||
{
|
||||
attriname = attribute->Name();
|
||||
std::string value = attribute->Value();
|
||||
|
||||
if(attriname == "CameraFlagMode")
|
||||
{
|
||||
cameraMask = atoi(value.c_str());
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
|
||||
|
||||
while (child)
|
||||
{
|
||||
std::string name = child->Name();
|
||||
|
||||
if (name == "Position3D")
|
||||
{
|
||||
position = getVec3Attribute(child->FirstAttribute());
|
||||
}
|
||||
else if(name == "Rotation3D")
|
||||
{
|
||||
rotation = getVec3Attribute(child->FirstAttribute());
|
||||
}
|
||||
else if(name == "Scale3D")
|
||||
{
|
||||
scale = getVec3Attribute(child->FirstAttribute());
|
||||
}
|
||||
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
|
||||
Vector3 postion3D(position.x, position.y, position.z);
|
||||
Vector3 rotation3D(rotation.x, rotation.y, rotation.z);
|
||||
Vector3 scale3D(scale.x, scale.y, scale.z);
|
||||
|
||||
auto options = CreateNode3DOption(*builder,
|
||||
nodeOptions,
|
||||
&postion3D,
|
||||
&rotation3D,
|
||||
&scale3D,
|
||||
cameraMask
|
||||
);
|
||||
|
||||
return *(Offset<Table>*)(&options);
|
||||
}
|
||||
|
||||
void Node3DReader::setPropsWithFlatBuffers(cocos2d::Node *node,
|
||||
const flatbuffers::Table* node3DOptions)
|
||||
{
|
||||
auto options = (Node3DOption*)node3DOptions;
|
||||
|
||||
const Vector3* position = options->position3D();
|
||||
const Vector3* rotation = options->rotation3D();
|
||||
const Vector3* scale = options->scale3D();
|
||||
int cameraMask = options->cameramask();
|
||||
|
||||
if(position)
|
||||
{
|
||||
node->setPosition3D(Vec3(position->x(), position->y(), position->z()));
|
||||
}
|
||||
|
||||
if(rotation)
|
||||
{
|
||||
node->setRotation3D(Vec3(rotation->x(), rotation->y(), rotation->z()));
|
||||
}
|
||||
|
||||
if(scale)
|
||||
{
|
||||
node->setScaleX(scale->x());
|
||||
node->setScaleY(scale->y());
|
||||
node->setScaleZ(scale->z());
|
||||
}
|
||||
|
||||
node->setCameraMask(cameraMask, false);
|
||||
|
||||
auto nodeReader = NodeReader::getInstance();
|
||||
nodeReader->setPropsWithFlatBuffers(node, (Table*)(options->nodeOptions()));
|
||||
}
|
||||
|
||||
Node* Node3DReader::createNodeWithFlatBuffers(const flatbuffers::Table *node3DOptions)
|
||||
{
|
||||
Node* node = Node::create();
|
||||
|
||||
setPropsWithFlatBuffers(node, (Table*)node3DOptions);
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/****************************************************************************
|
||||
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__Node3DReader__
|
||||
#define __cocos2d_libs__Node3DReader__
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "cocostudio/CocosStudioExport.h"
|
||||
#include "cocostudio/WidgetReader/NodeReaderProtocol.h"
|
||||
#include "cocostudio/WidgetReader/NodeReaderDefine.h"
|
||||
|
||||
namespace tinyxml2
|
||||
{
|
||||
class XMLAttribute;
|
||||
}
|
||||
|
||||
namespace cocostudio
|
||||
{
|
||||
class CC_STUDIO_DLL Node3DReader : public cocos2d::Ref, public NodeReaderProtocol
|
||||
{
|
||||
DECLARE_CLASS_NODE_READER_INFO
|
||||
|
||||
public:
|
||||
Node3DReader();
|
||||
~Node3DReader();
|
||||
|
||||
static Node3DReader* getInstance();
|
||||
static void purge();
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Table> createOptionsWithFlatBuffers(const tinyxml2::XMLElement* objectData,
|
||||
flatbuffers::FlatBufferBuilder* builder);
|
||||
void setPropsWithFlatBuffers(cocos2d::Node* node, const flatbuffers::Table* node3DOptions);
|
||||
cocos2d::Node* createNodeWithFlatBuffers(const flatbuffers::Table* node3DOptions);
|
||||
|
||||
protected:
|
||||
|
||||
cocos2d::Vec3 getVec3Attribute(const tinyxml2::XMLAttribute* attribute) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* defined(__cocos2d_libs__SpriteReader__) */
|
Loading…
Reference in New Issue