예제 #1
0
void Sprite3D::afterAsyncLoad(void* param)
{
    Sprite3D::AsyncLoadParam* asyncParam = (Sprite3D::AsyncLoadParam*)param;
    autorelease();
    if (asyncParam)
    {
        if (asyncParam->result)
        {
            _meshes.clear();
            _meshVertexDatas.clear();
            CC_SAFE_RELEASE_NULL(_skeleton);
            removeAllAttachNode();
            
            //create in the main thread
            auto& meshdatas = asyncParam->meshdatas;
            auto& materialdatas = asyncParam->materialdatas;
            auto&   nodeDatas = asyncParam->nodeDatas;
            if (initFrom(*nodeDatas, *meshdatas, *materialdatas))
            {
                auto spritedata = Sprite3DCache::getInstance()->getSpriteData(asyncParam->modlePath);
                if (spritedata == nullptr)
                {
                    //add to cache
                    auto data = new (std::nothrow) Sprite3DCache::Sprite3DData();
                    data->materialdatas = materialdatas;
                    data->nodedatas = nodeDatas;
                    data->meshVertexDatas = _meshVertexDatas;
                    for (const auto mesh : _meshes) {
                        data->glProgramStates.pushBack(mesh->getGLProgramState());
                    }
                    
                    Sprite3DCache::getInstance()->addSprite3DData(asyncParam->modlePath, data);
                    meshdatas = nullptr;
                    materialdatas = nullptr;
                    nodeDatas = nullptr;
                }
            }
            delete meshdatas;
            delete materialdatas;
            delete nodeDatas;
            
            if (asyncParam->texPath != "")
            {
                setTexture(asyncParam->texPath);
            }
        }
        else
        {
            CCLOG("file load failed: %s ", asyncParam->modlePath.c_str());
        }
        asyncParam->afterLoadCallback(this, asyncParam->callbackParam);
    }
}
예제 #2
0
bool Sprite3D::initWithFile(const std::string& path)
{
    _aabbDirty = true;
    _meshes.clear();
    _meshVertexDatas.clear();
    CC_SAFE_RELEASE_NULL(_skeleton);
    removeAllAttachNode();
    
    if (loadFromCache(path))
        return true;
    
    MeshDatas* meshdatas = new (std::nothrow) MeshDatas();
    MaterialDatas* materialdatas = new (std::nothrow) MaterialDatas();
    NodeDatas* nodeDatas = new (std::nothrow) NodeDatas();
    if (loadFromFile(path, nodeDatas, meshdatas, materialdatas))
    {
        if (initFrom(*nodeDatas, *meshdatas, *materialdatas))
        {
            //add to cache
            auto data = new (std::nothrow) Sprite3DCache::Sprite3DData();
            data->materialdatas = materialdatas;
            data->nodedatas = nodeDatas;
            data->meshVertexDatas = _meshVertexDatas;
            for (const auto mesh : _meshes) {
                data->glProgramStates.pushBack(mesh->getGLProgramState());
            }
            
            Sprite3DCache::getInstance()->addSprite3DData(path, data);
            CC_SAFE_DELETE(meshdatas);
            _contentSize = getBoundingBox().size;
            return true;
        }
    }
    CC_SAFE_DELETE(meshdatas);
    CC_SAFE_DELETE(materialdatas);
    CC_SAFE_DELETE(nodeDatas);
    
    return false;
}
예제 #3
0
파일: DataKey.cpp 프로젝트: Andy-Amoy/mr4c
		void initFrom(const DataKeyImpl& key) {
			initFrom(key.getElements());
		}
예제 #4
0
파일: DataKey.cpp 프로젝트: Andy-Amoy/mr4c
		DataKeyImpl(const DataKeyImpl& key) {
			initFrom(key);
		}
예제 #5
0
파일: DataKey.cpp 프로젝트: Andy-Amoy/mr4c
		DataKeyImpl(const std::set<DataKeyElement>& elements) {
			initFrom(elements);
		}
예제 #6
0
		EastNorthCoordImpl(const EastNorthCoord& coord) {
			initFrom(coord);
		}
예제 #7
0
Block::Block(const std::shared_ptr<Block>& b){
	initFrom(b->begin(), b->size());
}
예제 #8
0
Block::Block(const Block& b){
	initFrom(b.begin(), b.size());
}
예제 #9
0
Block::Block(const char* str){
	initFrom(str, strlen(str) + 1);
}
예제 #10
0
Block::Block(const std::string& str) {
	initFrom(str.c_str(), str.size() + 1);
}
예제 #11
0
Block::Block(const void* src, size_t sz){
	initFrom(src, sz);
}
예제 #12
0
파일: TileKey.cpp 프로젝트: Andy-Amoy/mr4c
		TileKeyImpl(const TileKey& tileKey) {
			initFrom(tileKey);
		}
예제 #13
0
파일: ImageBox.cpp 프로젝트: Andy-Amoy/mr4c
		ImageBoxImpl(const ImageBox& box) {
			initFrom(box);
		}
예제 #14
0
		void initFrom(const DataKeyBuilderImpl& builder) {
			initFrom(builder.m_elements);
		}
예제 #15
0
		DataKeyBuilderImpl(const DataKeyBuilderImpl& builder) {
			initFrom(builder);
		}