Beispiel #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);
    }
}
Beispiel #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;
}
Beispiel #3
0
		void initFrom(const DataKeyImpl& key) {
			initFrom(key.getElements());
		}
Beispiel #4
0
		DataKeyImpl(const DataKeyImpl& key) {
			initFrom(key);
		}
Beispiel #5
0
		DataKeyImpl(const std::set<DataKeyElement>& elements) {
			initFrom(elements);
		}
Beispiel #6
0
		EastNorthCoordImpl(const EastNorthCoord& coord) {
			initFrom(coord);
		}
Beispiel #7
0
Block::Block(const std::shared_ptr<Block>& b){
	initFrom(b->begin(), b->size());
}
Beispiel #8
0
Block::Block(const Block& b){
	initFrom(b.begin(), b.size());
}
Beispiel #9
0
Block::Block(const char* str){
	initFrom(str, strlen(str) + 1);
}
Beispiel #10
0
Block::Block(const std::string& str) {
	initFrom(str.c_str(), str.size() + 1);
}
Beispiel #11
0
Block::Block(const void* src, size_t sz){
	initFrom(src, sz);
}
Beispiel #12
0
		TileKeyImpl(const TileKey& tileKey) {
			initFrom(tileKey);
		}
Beispiel #13
0
		ImageBoxImpl(const ImageBox& box) {
			initFrom(box);
		}
Beispiel #14
0
		void initFrom(const DataKeyBuilderImpl& builder) {
			initFrom(builder.m_elements);
		}
Beispiel #15
0
		DataKeyBuilderImpl(const DataKeyBuilderImpl& builder) {
			initFrom(builder);
		}