diff --git a/cocos/3d/CCBillBoard.cpp b/cocos/3d/CCBillBoard.cpp index 79fc733553..26112ca572 100644 --- a/cocos/3d/CCBillBoard.cpp +++ b/cocos/3d/CCBillBoard.cpp @@ -36,7 +36,7 @@ BillBoard::BillBoard() , _mode(Mode::VIEW_POINT_ORIENTED) , _modeDirty(false) { - + Node::setAnchorPoint(Vec2(0.5f,0.5f)); } BillBoard::~BillBoard() diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index e79ea7bc8b..dcb3ecc012 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -90,7 +90,9 @@ bool Sprite3D::loadFromCache(const std::string& path) } } - genGLProgramState(); + for (ssize_t i = 0; i < _meshes.size(); i++) { + _meshes.at(i)->setGLProgramState(spritedata->glProgramStates.at(i)); + } return true; } @@ -113,6 +115,10 @@ bool Sprite3D::loadFromObj(const std::string& path) data->materialdatas = materialdatas; data->nodedatas = nodeDatas; data->meshVertexDatas = _meshVertexDatas; + for (const auto mesh : _meshes) { + data->glProgramStates.pushBack(mesh->getGLProgramState()); + } + Sprite3DCache::getInstance()->addSprite3DData(path, data); return true; } @@ -143,6 +149,9 @@ bool Sprite3D::loadFromC3x(const std::string& path) data->materialdatas = materialdatas; data->nodedatas = nodeDatas; data->meshVertexDatas = _meshVertexDatas; + for (const auto mesh : _meshes) { + data->glProgramStates.pushBack(mesh->getGLProgramState()); + } Sprite3DCache::getInstance()->addSprite3DData(path, data); return true; } diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index c7ab28893c..97c20681ee 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -32,6 +32,7 @@ #include "base/CCProtocols.h" #include "2d/CCNode.h" #include "renderer/CCMeshCommand.h" +#include "renderer/CCGLProgramState.h" #include "3d/CCSkeleton3D.h" // need to include for lua-binding #include "3d/CCAABB.h" #include "3d/CCBundle3DData.h" @@ -41,7 +42,6 @@ NS_CC_BEGIN -class GLProgramState; class Mesh; class Texture2D; class MeshSkin; @@ -171,6 +171,7 @@ public: struct Sprite3DData { Vector meshVertexDatas; + Vector glProgramStates; NodeDatas* nodedatas; MaterialDatas* materialdatas; ~Sprite3DData() @@ -180,6 +181,7 @@ public: if (materialdatas) delete materialdatas; meshVertexDatas.clear(); + glProgramStates.clear(); } };