2015-02-25 14:19:08 +08:00
|
|
|
/****************************************************************************
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-03-16 14:02:08 +08:00
|
|
|
#include "base/CCDirector.h"
|
|
|
|
#include "2d/CCCamera.h"
|
|
|
|
#include "platform/CCFileUtils.h"
|
2020-08-03 17:51:40 +08:00
|
|
|
#include "cocostudio/WidgetReader/UserCameraReader/UserCameraReader.h"
|
2015-02-25 14:19:08 +08:00
|
|
|
|
2020-08-03 17:51:40 +08:00
|
|
|
#include "cocostudio/CSParseBinary_generated.h"
|
|
|
|
#include "cocostudio/CSParse3DBinary_generated.h"
|
|
|
|
#include "cocostudio/FlatBuffersSerialize.h"
|
|
|
|
#include "cocostudio/WidgetReader/Node3DReader/Node3DReader.h"
|
|
|
|
#include "cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.h"
|
2015-02-25 14:19:08 +08:00
|
|
|
|
|
|
|
#include "flatbuffers/flatbuffers.h"
|
|
|
|
|
|
|
|
USING_NS_CC;
|
|
|
|
using namespace flatbuffers;
|
|
|
|
|
|
|
|
namespace cocostudio
|
|
|
|
{
|
|
|
|
IMPLEMENT_CLASS_NODE_READER_INFO(UserCameraReader)
|
|
|
|
|
|
|
|
UserCameraReader::UserCameraReader()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UserCameraReader::~UserCameraReader()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static UserCameraReader* _instanceUserCameraReader = nullptr;
|
|
|
|
|
|
|
|
UserCameraReader* UserCameraReader::getInstance()
|
|
|
|
{
|
|
|
|
if (!_instanceUserCameraReader)
|
|
|
|
{
|
2015-12-16 14:02:55 +08:00
|
|
|
_instanceUserCameraReader = new (std::nothrow) UserCameraReader();
|
2015-02-25 14:19:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return _instanceUserCameraReader;
|
|
|
|
}
|
|
|
|
|
2015-03-31 14:56:24 +08:00
|
|
|
void UserCameraReader::purge()
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(_instanceUserCameraReader);
|
|
|
|
}
|
|
|
|
|
2015-03-30 16:46:33 +08:00
|
|
|
void UserCameraReader::destroyInstance()
|
2015-02-25 14:19:08 +08:00
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(_instanceUserCameraReader);
|
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
Vec2 UserCameraReader::getVec2Attribute(pugi::xml_attribute attribute) const
|
2015-02-25 14:19:08 +08:00
|
|
|
{
|
|
|
|
if(!attribute)
|
|
|
|
return Vec2::ZERO;
|
|
|
|
|
2015-04-20 01:40:52 +08:00
|
|
|
Vec2 ret;
|
2015-02-25 14:19:08 +08:00
|
|
|
std::string attriname;
|
|
|
|
|
|
|
|
while (attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
attriname = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2015-02-25 14:19:08 +08:00
|
|
|
|
2015-06-23 11:31:16 +08:00
|
|
|
if (attriname == "X")
|
2015-02-25 14:19:08 +08:00
|
|
|
{
|
|
|
|
ret.x = atof(value.c_str());
|
|
|
|
}
|
2015-06-23 11:31:16 +08:00
|
|
|
else if (attriname == "Y")
|
2015-02-25 14:19:08 +08:00
|
|
|
{
|
|
|
|
ret.y = atof(value.c_str());
|
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2015-02-25 14:19:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
Offset<Table> UserCameraReader::createOptionsWithFlatBuffers(pugi::xml_node objectData,
|
2015-02-25 14:19:08 +08:00
|
|
|
flatbuffers::FlatBufferBuilder *builder)
|
|
|
|
{
|
|
|
|
auto temp = Node3DReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder);
|
|
|
|
auto node3DOptions = *(Offset<Node3DOption>*)(&temp);
|
|
|
|
|
|
|
|
float fov = 60.f;
|
|
|
|
unsigned int cameraFlag = 0;
|
2015-07-03 17:52:42 +08:00
|
|
|
bool skyBoxEnabled = false;
|
2015-08-26 10:22:20 +08:00
|
|
|
bool skyBoxValid = true;
|
2015-07-03 17:52:42 +08:00
|
|
|
|
2015-02-25 14:19:08 +08:00
|
|
|
std::string attriname;
|
2019-11-24 23:15:56 +08:00
|
|
|
auto attribute = objectData.first_attribute();
|
2015-02-25 14:19:08 +08:00
|
|
|
while(attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
attriname = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2015-02-25 14:19:08 +08:00
|
|
|
|
|
|
|
if(attriname == "Fov")
|
|
|
|
{
|
|
|
|
fov = atof(value.c_str());
|
|
|
|
}
|
|
|
|
else if(attriname == "UserCameraFlagMode")
|
|
|
|
{
|
2015-07-03 17:52:42 +08:00
|
|
|
if (cameraFlag == 0)
|
|
|
|
{
|
|
|
|
if (value == "DEFAULT") cameraFlag = 1;
|
|
|
|
else if (value == "USER1") cameraFlag = 1 << 1;
|
|
|
|
else if (value == "USER2") cameraFlag = 1 << 2;
|
|
|
|
else if (value == "USER3") cameraFlag = 1 << 3;
|
2015-07-22 14:11:20 +08:00
|
|
|
else if (value == "USER4") cameraFlag = 1 << 4;
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (attriname == "CameraFlagData")
|
|
|
|
{
|
2015-08-17 14:37:28 +08:00
|
|
|
int flag = atoi(value.c_str());
|
|
|
|
if (flag != 0)
|
2015-08-17 17:16:26 +08:00
|
|
|
cameraFlag = flag;
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
else if (attriname == "SkyBoxEnabled")
|
|
|
|
{
|
|
|
|
skyBoxEnabled = (value == "True") ? true : false;
|
2015-02-25 14:19:08 +08:00
|
|
|
}
|
2015-08-26 10:22:20 +08:00
|
|
|
else if (attriname == "SkyBoxValid")
|
|
|
|
{
|
|
|
|
skyBoxValid = (value == "True") ? true : false;
|
|
|
|
}
|
2015-02-25 14:19:08 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2015-02-25 14:19:08 +08:00
|
|
|
}
|
|
|
|
|
2015-08-26 10:22:20 +08:00
|
|
|
if (!skyBoxValid)
|
|
|
|
skyBoxEnabled = false;
|
|
|
|
|
2015-02-25 14:19:08 +08:00
|
|
|
Vec2 clipPlane(1, 1000);
|
2015-07-03 17:52:42 +08:00
|
|
|
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string leftPath;
|
|
|
|
std::string leftPlistFile;
|
2015-07-03 17:52:42 +08:00
|
|
|
int leftResourceType = 0;
|
|
|
|
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string rightPath;
|
|
|
|
std::string rightPlistFile;
|
2015-07-03 17:52:42 +08:00
|
|
|
int rightResourceType = 0;
|
|
|
|
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string upPath;
|
|
|
|
std::string upPlistFile;
|
2015-07-03 17:52:42 +08:00
|
|
|
int upResourceType = 0;
|
|
|
|
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string downPath;
|
|
|
|
std::string downPlistFile;
|
2015-07-03 17:52:42 +08:00
|
|
|
int downResourceType = 0;
|
|
|
|
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string forwardPath;
|
|
|
|
std::string forwardPlistFile;
|
2015-07-03 17:52:42 +08:00
|
|
|
int forwardResourceType = 0;
|
|
|
|
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string backPath;
|
|
|
|
std::string backPlistFile;
|
2015-07-03 17:52:42 +08:00
|
|
|
int backResourceType = 0;
|
2015-02-25 14:19:08 +08:00
|
|
|
|
|
|
|
// FileData
|
2019-11-24 23:15:56 +08:00
|
|
|
auto child = objectData.first_child();
|
2015-02-25 14:19:08 +08:00
|
|
|
while (child)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
std::string name = child.name();
|
2015-02-25 14:19:08 +08:00
|
|
|
|
|
|
|
if (name == "ClipPlane")
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2015-02-25 14:19:08 +08:00
|
|
|
clipPlane = getVec2Attribute(attribute);
|
|
|
|
}
|
2015-07-03 17:52:42 +08:00
|
|
|
else if (name == "LeftImage")
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2015-07-03 17:52:42 +08:00
|
|
|
|
|
|
|
while (attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
name = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2015-07-03 17:52:42 +08:00
|
|
|
|
|
|
|
if (name == "Path")
|
|
|
|
{
|
|
|
|
leftPath = value;
|
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
2016-09-12 09:45:34 +08:00
|
|
|
leftResourceType = getResourceType(value);
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
|
|
|
leftPlistFile = value;
|
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (leftResourceType == 1)
|
|
|
|
{
|
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
2015-07-13 10:29:22 +08:00
|
|
|
fbs->_textures.push_back(builder->CreateString(leftPlistFile));
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "RightImage")
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2015-07-03 17:52:42 +08:00
|
|
|
|
|
|
|
while (attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
name = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2015-07-03 17:52:42 +08:00
|
|
|
|
|
|
|
if (name == "Path")
|
|
|
|
{
|
|
|
|
rightPath = value;
|
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
2016-09-12 09:45:34 +08:00
|
|
|
rightResourceType = getResourceType(value);
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
|
|
|
rightPlistFile = value;
|
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rightResourceType == 1)
|
|
|
|
{
|
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
2015-07-13 10:29:22 +08:00
|
|
|
fbs->_textures.push_back(builder->CreateString(rightPlistFile));
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "UpImage")
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2015-07-03 17:52:42 +08:00
|
|
|
|
|
|
|
while (attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
name = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2015-07-03 17:52:42 +08:00
|
|
|
|
|
|
|
if (name == "Path")
|
|
|
|
{
|
|
|
|
upPath = value;
|
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
2016-09-12 09:45:34 +08:00
|
|
|
upResourceType = getResourceType(value);
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
|
|
|
upPlistFile = value;
|
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (upResourceType == 1)
|
|
|
|
{
|
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
2015-07-13 10:29:22 +08:00
|
|
|
fbs->_textures.push_back(builder->CreateString(upPlistFile));
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "DownImage")
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2015-07-03 17:52:42 +08:00
|
|
|
|
|
|
|
while (attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
name = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2015-07-03 17:52:42 +08:00
|
|
|
|
|
|
|
if (name == "Path")
|
|
|
|
{
|
|
|
|
downPath = value;
|
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
2016-09-12 09:45:34 +08:00
|
|
|
downResourceType = getResourceType(value);
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
|
|
|
downPlistFile = value;
|
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (downResourceType == 1)
|
|
|
|
{
|
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
2015-07-13 10:29:22 +08:00
|
|
|
fbs->_textures.push_back(builder->CreateString(downPlistFile));
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "ForwardImage")
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2015-07-03 17:52:42 +08:00
|
|
|
|
|
|
|
while (attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
name = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2015-07-03 17:52:42 +08:00
|
|
|
|
|
|
|
if (name == "Path")
|
|
|
|
{
|
|
|
|
forwardPath = value;
|
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
2016-09-12 09:45:34 +08:00
|
|
|
forwardResourceType = getResourceType(value);
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
|
|
|
forwardPlistFile = value;
|
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (forwardResourceType == 1)
|
|
|
|
{
|
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
2015-07-13 10:29:22 +08:00
|
|
|
fbs->_textures.push_back(builder->CreateString(forwardPlistFile));
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "BackImage")
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2015-07-03 17:52:42 +08:00
|
|
|
|
|
|
|
while (attribute)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
name = attribute.name();
|
|
|
|
std::string value = attribute.value();
|
2015-07-03 17:52:42 +08:00
|
|
|
|
|
|
|
if (name == "Path")
|
|
|
|
{
|
|
|
|
backPath = value;
|
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
2016-09-12 09:45:34 +08:00
|
|
|
backResourceType = getResourceType(value);
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
|
|
|
backPlistFile = value;
|
|
|
|
}
|
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (backResourceType == 1)
|
|
|
|
{
|
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
2015-07-13 10:29:22 +08:00
|
|
|
fbs->_textures.push_back(builder->CreateString(backPlistFile));
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
|
|
|
}
|
2015-02-25 14:19:08 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
child = child.next_sibling();
|
2015-02-25 14:19:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
auto options = CreateUserCameraOptions(*builder,
|
|
|
|
node3DOptions,
|
|
|
|
fov,
|
|
|
|
clipPlane.x,
|
|
|
|
clipPlane.y,
|
2015-07-03 17:52:42 +08:00
|
|
|
cameraFlag,
|
|
|
|
skyBoxEnabled,
|
|
|
|
CreateResourceData(*builder,
|
|
|
|
builder->CreateString(leftPath),
|
|
|
|
builder->CreateString(leftPlistFile),
|
|
|
|
leftResourceType),
|
|
|
|
CreateResourceData(*builder,
|
|
|
|
builder->CreateString(rightPath),
|
|
|
|
builder->CreateString(rightPlistFile),
|
|
|
|
rightResourceType),
|
|
|
|
CreateResourceData(*builder,
|
|
|
|
builder->CreateString(upPath),
|
|
|
|
builder->CreateString(upPlistFile),
|
|
|
|
upResourceType),
|
|
|
|
CreateResourceData(*builder,
|
|
|
|
builder->CreateString(downPath),
|
|
|
|
builder->CreateString(downPlistFile),
|
|
|
|
downResourceType),
|
|
|
|
CreateResourceData(*builder,
|
|
|
|
builder->CreateString(forwardPath),
|
|
|
|
builder->CreateString(forwardPlistFile),
|
|
|
|
forwardResourceType),
|
|
|
|
CreateResourceData(*builder,
|
|
|
|
builder->CreateString(backPath),
|
|
|
|
builder->CreateString(backPlistFile),
|
|
|
|
backResourceType)
|
2015-02-25 14:19:08 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
return *(Offset<Table>*)(&options);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UserCameraReader::setPropsWithFlatBuffers(cocos2d::Node *node,
|
|
|
|
const flatbuffers::Table* userCameraDOptions)
|
|
|
|
{
|
|
|
|
auto options = (UserCameraOptions*)userCameraDOptions;
|
|
|
|
|
|
|
|
Camera* camera = static_cast<Camera*>(node);
|
|
|
|
int cameraFlag = options->cameraFlag();
|
|
|
|
camera->setCameraFlag((CameraFlag)cameraFlag);
|
|
|
|
|
2015-08-12 18:40:29 +08:00
|
|
|
auto node3DReader = Node3DReader::getInstance();
|
|
|
|
node3DReader->setPropsWithFlatBuffers(node, (Table*)(options->node3DOption()));
|
|
|
|
|
2015-07-03 17:52:42 +08:00
|
|
|
bool skyBoxEnabled = options->skyBoxEnabled() != 0;
|
|
|
|
if (skyBoxEnabled)
|
|
|
|
{
|
2015-08-12 18:40:29 +08:00
|
|
|
std::string leftFileData = options->leftFileData()->path()->c_str();
|
|
|
|
std::string rightFileData = options->rightFileData()->path()->c_str();
|
|
|
|
std::string upFileData = options->upFileData()->path()->c_str();
|
|
|
|
std::string downFileData = options->downFileData()->path()->c_str();
|
|
|
|
std::string forwardFileData = options->forwardFileData()->path()->c_str();
|
|
|
|
std::string backFileData = options->backFileData()->path()->c_str();
|
2015-08-24 10:00:22 +08:00
|
|
|
FileUtils *fileUtils = FileUtils::getInstance();
|
|
|
|
|
2015-08-25 13:20:19 +08:00
|
|
|
if (fileUtils->isFileExist(leftFileData)
|
|
|
|
&& fileUtils->isFileExist(rightFileData)
|
|
|
|
&& fileUtils->isFileExist(upFileData)
|
|
|
|
&& fileUtils->isFileExist(downFileData)
|
|
|
|
&& fileUtils->isFileExist(forwardFileData)
|
|
|
|
&& fileUtils->isFileExist(backFileData))
|
2015-08-24 10:00:22 +08:00
|
|
|
{
|
2015-08-25 13:20:19 +08:00
|
|
|
CameraBackgroundSkyBoxBrush* brush = CameraBackgroundSkyBoxBrush::create(leftFileData, rightFileData, upFileData, downFileData, forwardFileData, backFileData);
|
|
|
|
camera->setBackgroundBrush(brush);
|
2015-08-24 10:00:22 +08:00
|
|
|
}
|
2015-08-25 13:20:19 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (GameNode3DReader::getSceneBrushInstance() != nullptr)
|
|
|
|
camera->setBackgroundBrush(GameNode3DReader::getSceneBrushInstance());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (GameNode3DReader::getSceneBrushInstance() != nullptr)
|
|
|
|
camera->setBackgroundBrush(GameNode3DReader::getSceneBrushInstance());
|
2015-07-03 17:52:42 +08:00
|
|
|
}
|
2015-02-25 14:19:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Node* UserCameraReader::createNodeWithFlatBuffers(const flatbuffers::Table *userCameraDOptions)
|
|
|
|
{
|
|
|
|
auto options = (UserCameraOptions*)userCameraDOptions;
|
|
|
|
|
|
|
|
float fov = options->fov();
|
|
|
|
float nearClip = options->nearClip();
|
|
|
|
float farClip = options->farClip();
|
|
|
|
|
|
|
|
auto size = Director::getInstance()->getWinSize();
|
|
|
|
Camera* camera = Camera::createPerspective(fov, size.width / size.height, nearClip, farClip);
|
|
|
|
|
|
|
|
setPropsWithFlatBuffers(camera, userCameraDOptions);
|
|
|
|
|
|
|
|
return camera;
|
|
|
|
}
|
2015-07-03 17:52:42 +08:00
|
|
|
|
|
|
|
int UserCameraReader::getResourceType(std::string key)
|
|
|
|
{
|
|
|
|
if (key == "Normal" || key == "Default")
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
|
|
|
if (fbs->_isSimulator)
|
|
|
|
{
|
|
|
|
if (key == "MarkedSubImage")
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2015-02-25 14:19:08 +08:00
|
|
|
}
|