update reader with new skybox

This commit is contained in:
Liam 2015-08-25 13:20:19 +08:00
parent ee5ec09e87
commit 650a5c2318
3 changed files with 34 additions and 21 deletions

View File

@ -62,6 +62,11 @@ namespace cocostudio
return _instanceNode3DReader;
}
static CameraBackgroundSkyBoxBrush* _sceneBrushInstance = nullptr;
CameraBackgroundSkyBoxBrush* GameNode3DReader::getSceneBrushInstance()
{
return _sceneBrushInstance;
}
void GameNode3DReader::purge()
{
@ -376,6 +381,7 @@ namespace cocostudio
std::string name = options->name()->c_str();
node->setName(name);
_sceneBrushInstance = nullptr;
bool skyBoxEnabled = options->skyBoxEnabled() != 0;
if (skyBoxEnabled)
{
@ -387,19 +393,15 @@ namespace cocostudio
std::string backFileData = options->backFileData()->path()->c_str();
FileUtils *fileUtils = FileUtils::getInstance();
if (!fileUtils->isFileExist(leftFileData)
|| !fileUtils->isFileExist(rightFileData)
|| !fileUtils->isFileExist(upFileData)
|| !fileUtils->isFileExist(downFileData)
|| !fileUtils->isFileExist(forwardFileData)
|| !fileUtils->isFileExist(backFileData))
if (fileUtils->isFileExist(leftFileData)
&& fileUtils->isFileExist(rightFileData)
&& fileUtils->isFileExist(upFileData)
&& fileUtils->isFileExist(downFileData)
&& fileUtils->isFileExist(forwardFileData)
&& fileUtils->isFileExist(backFileData))
{
return;
_sceneBrushInstance = CameraBackgroundSkyBoxBrush::create(leftFileData, rightFileData, upFileData, downFileData, forwardFileData, backFileData);
}
Skybox* childBox = Skybox::create(leftFileData,rightFileData,upFileData,downFileData,forwardFileData,backFileData);
unsigned short cameraFlag = 1 << 10;
childBox->setCameraMask(cameraFlag);
node->addChild(childBox,0,"_innerSkyBox");
}
std::string customProperty = options->customProperty()->c_str();

View File

@ -26,6 +26,7 @@
#define __cocos2d_libs__GameNode3DReader__
#include "cocos2d.h"
#include "2d/CCCameraBackgroundBrush.h"
#include "cocostudio/CocosStudioExport.h"
#include "cocostudio/WidgetReader/NodeReaderProtocol.h"
#include "cocostudio/WidgetReader/NodeReaderDefine.h"
@ -46,6 +47,7 @@ namespace cocostudio
~GameNode3DReader();
static GameNode3DReader* getInstance();
static cocos2d::CameraBackgroundSkyBoxBrush* getSceneBrushInstance();
/** @deprecated Use method destroyInstance() instead */
CC_DEPRECATED_ATTRIBUTE static void purge();
static void destroyInstance();

View File

@ -28,6 +28,7 @@
#include "cocostudio/CSParse3DBinary_generated.h"
#include "cocostudio/FlatBuffersSerialize.h"
#include "cocostudio/WidgetReader/Node3DReader/Node3DReader.h"
#include "cocostudio/WidgetReader/GameNode3DReader/GameNode3DReader.h"
#include "tinyxml2.h"
#include "flatbuffers/flatbuffers.h"
@ -431,18 +432,26 @@ namespace cocostudio
std::string backFileData = options->backFileData()->path()->c_str();
FileUtils *fileUtils = FileUtils::getInstance();
if (!fileUtils->isFileExist(leftFileData)
|| !fileUtils->isFileExist(rightFileData)
|| !fileUtils->isFileExist(upFileData)
|| !fileUtils->isFileExist(downFileData)
|| !fileUtils->isFileExist(forwardFileData)
|| !fileUtils->isFileExist(backFileData))
if (fileUtils->isFileExist(leftFileData)
&& fileUtils->isFileExist(rightFileData)
&& fileUtils->isFileExist(upFileData)
&& fileUtils->isFileExist(downFileData)
&& fileUtils->isFileExist(forwardFileData)
&& fileUtils->isFileExist(backFileData))
{
return;
CameraBackgroundSkyBoxBrush* brush = CameraBackgroundSkyBoxBrush::create(leftFileData, rightFileData, upFileData, downFileData, forwardFileData, backFileData);
camera->setBackgroundBrush(brush);
}
Skybox* childBox = Skybox::create(leftFileData, rightFileData, upFileData, downFileData, forwardFileData, backFileData);
childBox->setCameraMask(cameraFlag);
node->addChild(childBox, 0, "_innerSkyBox");
else
{
if (GameNode3DReader::getSceneBrushInstance() != nullptr)
camera->setBackgroundBrush(GameNode3DReader::getSceneBrushInstance());
}
}
else
{
if (GameNode3DReader::getSceneBrushInstance() != nullptr)
camera->setBackgroundBrush(GameNode3DReader::getSceneBrushInstance());
}
}