• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ModelInstance函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ModelInstance函数的典型用法代码示例。如果您正苦于以下问题:C++ ModelInstance函数的具体用法?C++ ModelInstance怎么用?C++ ModelInstance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ModelInstance函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: fopen

bool StaticMapTree::InitMap(const std::string &fname, VMapManager2 *vm) {
    sLog->outDebug(LOG_FILTER_MAPS,
            "StaticMapTree::InitMap() : initializing StaticMapTree '%s'",
            fname.c_str());
    bool success = true;
    std::string fullname = iBasePath + fname;
    FILE *rf = fopen(fullname.c_str(), "rb");
    if (!rf)
        return false;
    else {
        char chunk[8];
        //general info
        if (!readChunk(rf, chunk, VMAP_MAGIC, 8))
            success = false;
        char tiled;
        if (success && fread(&tiled, sizeof(char), 1, rf) != 1)
            success = false;
        iIsTiled = bool(tiled);
        // Nodes
        if (success && !readChunk(rf, chunk, "NODE", 4))
            success = false;
        if (success)
            success = iTree.readFromFile(rf);
        if (success) {
            iNTreeValues = iTree.primCount();
            iTreeValues = new ModelInstance[iNTreeValues];
        }

        if (success && !readChunk(rf, chunk, "GOBJ", 4))
            success = false;
        // global model spawns
        // only non-tiled maps have them, and if so exactly one (so far at least...)
        ModelSpawn spawn;
#ifdef VMAP_DEBUG
        sLog->outDebug(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : map isTiled: %u", static_cast<uint32>(iIsTiled));
#endif
        if (!iIsTiled && ModelSpawn::readFromFile(rf, spawn)) {
            WorldModel *model = vm->acquireModelInstance(iBasePath, spawn.name);
            sLog->outDebug(LOG_FILTER_MAPS,
                    "StaticMapTree::InitMap() : loading %s",
                    spawn.name.c_str());
            if (model) {
                // assume that global model always is the first and only tree value (could be improved...)
                iTreeValues[0] = ModelInstance(spawn, model);
                iLoadedSpawns[0] = 1;
            } else {
                success = false;
                sLog->outError(
                        "StaticMapTree::InitMap() : could not acquire WorldModel pointer for '%s'",
                        spawn.name.c_str());
            }
        }

        fclose(rf);
    }
    return success;
}
开发者ID:BlueSellafield,项目名称:ArkCORE,代码行数:57,代码来源:MapTree.cpp


示例2: ModelAsset

bool MeshRenderComponent::VInit(TiXmlElement* _pData)
{
	Asset = WE_NEW ModelAsset();
	LoadAsset();
	Instance = WE_NEW ModelInstance();
	Instance->asset = Asset; 

	
	

	return true;
}
开发者ID:Ubuska,项目名称:WarpEngine,代码行数:12,代码来源:RenderComponent.cpp


示例3: fopen

    bool StaticMapTree::init(const std::string &fname, VMapManager2 *vm)
    {
        std::cout << "Initializing StaticMapTree '" << fname << "'\n";
        bool success=true;
        std::string fullname = iBasePath + fname;
        FILE *rf = fopen(fullname.c_str(), "rb");
        if(!rf)
            return false;
        else
        {
            char chunk[8];
            //general info
            char tiled;
            if (fread(&tiled, sizeof(char), 1, rf) != 1) success = false;
            iIsTiled = (bool(tiled));
            // Nodes
            if (success && !readChunk(rf, chunk, "NODE", 4)) success = false;
            if (success) success = iTree.readFromFile(rf);
            if (success)
            {
                iNTreeValues = iTree.primCount();
                iTreeValues = new ModelInstance[iNTreeValues];
            }

            if (success && !readChunk(rf, chunk, "GOBJ", 4)) success = false;
            // global model spawns
            // only non-tiled maps have them, and if so exactly one (so far at least...)
            ModelSpawn spawn;
#ifdef VMAP_DEBUG
            std::cout << "Map isTiled:" << bool(iIsTiled) << std::endl;
#endif
            if (!iIsTiled && ModelSpawn::readFromFile(rf, spawn))
            {
                WorldModel *model = vm->acquireModelInstance(iBasePath, spawn.name);
                std::cout << "StaticMapTree::init(): loading " << spawn.name << std::endl;
                if (model)
                {
                    // assume that global model always is the first and only tree value (could be improved...)
                    iTreeValues[0] = ModelInstance(spawn, model);
                    iLoadedSpawns[spawn.ID] = 1;
                }
                else
                {
                    success = false;
                    std::cout << "error: could not acquire WorldModel pointer!\n";
                }
            }

            fclose(rf);
        }
        return success;
    }
开发者ID:Bootz,项目名称:diamondcore,代码行数:52,代码来源:MapTree.cpp


示例4: VMAP_DEBUG_LOG

    bool StaticMapTree::InitMap(const std::string &fname, VMapManager2* vm)
    {
        VMAP_DEBUG_LOG("maps", "StaticMapTree::InitMap() : initializing StaticMapTree '%s'", fname.c_str());
        bool success = false;
        std::string fullname = iBasePath + fname;
        FILE* rf = fopen(fullname.c_str(), "rb");
        if (!rf)
            return false;

        char chunk[8];
        char tiled = '\0';

        if (readChunk(rf, chunk, VMAP_MAGIC, 8) && fread(&tiled, sizeof(char), 1, rf) == 1 &&
            readChunk(rf, chunk, "NODE", 4) && iTree.readFromFile(rf))
        {
            iNTreeValues = iTree.primCount();
            iTreeValues = new ModelInstance[iNTreeValues];
            success = readChunk(rf, chunk, "GOBJ", 4);
        }

        iIsTiled = tiled != '\0';

        // global model spawns
        // only non-tiled maps have them, and if so exactly one (so far at least...)
        ModelSpawn spawn;
#ifdef VMAP_DEBUG
        TC_LOG_DEBUG("maps", "StaticMapTree::InitMap() : map isTiled: %u", static_cast<uint32>(iIsTiled));
#endif
        if (!iIsTiled && ModelSpawn::readFromFile(rf, spawn))
        {
            WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name);
            VMAP_DEBUG_LOG("maps", "StaticMapTree::InitMap() : loading %s", spawn.name.c_str());
            if (model)
            {
                // assume that global model always is the first and only tree value (could be improved...)
                iTreeValues[0] = ModelInstance(spawn, model);
                iLoadedSpawns[0] = 1;
            }
            else
            {
                success = false;
                VMAP_ERROR_LOG("misc", "StaticMapTree::InitMap() : could not acquire WorldModel pointer for '%s'", spawn.name.c_str());
            }
        }

        fclose(rf);
        return success;
    }
开发者ID:125125,项目名称:TrinityCore,代码行数:48,代码来源:MapTree.cpp


示例5: ERROR_LOG

    bool StaticMapTree::LoadMapTile(uint32 tileX, uint32 tileY, VMapManager2* vm)
    {
        if (!iIsTiled)
        {
            // currently, core creates grids for all maps, whether it has terrain tiles or not
            // so we need "fake" tile loads to know when we can unload map geometry
            iLoadedTiles[packTileID(tileX, tileY)] = false;
            return true;
        }
        if (!iTreeValues)
        {
            ERROR_LOG("StaticMapTree::LoadMapTile(): Tree has not been initialized! [%u,%u]", tileX, tileY);
            return false;
        }
        bool result = true;

        std::string tilefile = iBasePath + getTileFileName(iMapID, tileX, tileY);
        FILE* tf = fopen(tilefile.c_str(), "rb");
        if (tf)
        {
            char chunk[8];
            if (!readChunk(tf, chunk, VMAP_MAGIC, 8))
                { result = false; }
            uint32 numSpawns;
            if (result && fread(&numSpawns, sizeof(uint32), 1, tf) != 1)
                { result = false; }
            for (uint32 i = 0; i < numSpawns && result; ++i)
            {
                // read model spawns
                ModelSpawn spawn;
                result = ModelSpawn::readFromFile(tf, spawn);
                if (result)
                {
                    // acquire model instance
                    WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name);
                    if (!model)
                        { ERROR_LOG("StaticMapTree::LoadMapTile() could not acquire WorldModel pointer for '%s'!", spawn.name.c_str()); }

                    // update tree
                    uint32 referencedVal;

                    size_t fileRead = fread(&referencedVal, sizeof(uint32), 1, tf);
                    if (!iLoadedSpawns.count(referencedVal) || fileRead <= 0)
                    {
#ifdef VMAP_DEBUG
                        if (referencedVal > iNTreeValues)
                        {
                            DEBUG_LOG("invalid tree element! (%u/%u)", referencedVal, iNTreeValues);
                            continue;
                        }
#endif
                        iTreeValues[referencedVal] = ModelInstance(spawn, model);
                        iLoadedSpawns[referencedVal] = 1;
                    }
                    else
                    {
                        ++iLoadedSpawns[referencedVal];
#ifdef VMAP_DEBUG
                        if (iTreeValues[referencedVal].ID != spawn.ID)
                            { DEBUG_LOG("Error: trying to load wrong spawn in node!"); }
                        else if (iTreeValues[referencedVal].name != spawn.name)
                            { DEBUG_LOG("Error: name mismatch on GUID=%u", spawn.ID); }
#endif
                    }
                }
            }
            iLoadedTiles[packTileID(tileX, tileY)] = true;
            fclose(tf);
        }
        else
            { iLoadedTiles[packTileID(tileX, tileY)] = false; }
        return result;
    }
开发者ID:Numielle,项目名称:server,代码行数:73,代码来源:MapTree.cpp


示例6: getTileFileName

    bool StaticMapTree::LoadMapTile(uint32 tileX, uint32 tileY, VMapManager2* vm)
    {
        if (!iIsTiled)
        {
            // currently, core creates grids for all maps, whether it has terrain tiles or not
            // so we need "fake" tile loads to know when we can unload map geometry
            iLoadedTiles[packTileID(tileX, tileY)] = false;
            return true;
        }
        if (!iTreeValues)
        {
            sLog->outError(LOG_FILTER_GENERAL, "StaticMapTree::LoadMapTile() : tree has not been initialized [%u, %u]", tileX, tileY);
            return false;
        }
        bool result = true;

        std::string tilefile = iBasePath + getTileFileName(iMapID, tileX, tileY);
        FILE* tf = fopen(tilefile.c_str(), "rb");
        if (tf)
        {
            char chunk[8];

            if (!readChunk(tf, chunk, VMAP_MAGIC, 8))
                result = false;
            uint32 numSpawns = 0;
            if (result && fread(&numSpawns, sizeof(uint32), 1, tf) != 1)
                result = false;
            for (uint32 i=0; i<numSpawns && result; ++i)
            {
                // read model spawns
                ModelSpawn spawn;
                result = ModelSpawn::readFromFile(tf, spawn);
                if (result)
                {
                    // acquire model instance
                    WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name);
                    if (!model)
                        sLog->outError(LOG_FILTER_GENERAL, "StaticMapTree::LoadMapTile() : could not acquire WorldModel pointer [%u, %u]", tileX, tileY);

                    // update tree
                    uint32 referencedVal;

                    if (fread(&referencedVal, sizeof(uint32), 1, tf) == 1)
                    {
                        if (!iLoadedSpawns.count(referencedVal))
                        {
#ifdef VMAP_DEBUG
                            if (referencedVal > iNTreeValues)
                            {
                                sLog->outDebug(LOG_FILTER_MAPS, "StaticMapTree::LoadMapTile() : invalid tree element (%u/%u)", referencedVal, iNTreeValues);
                                continue;
                            }
#endif
                            iTreeValues[referencedVal] = ModelInstance(spawn, model);
                            iLoadedSpawns[referencedVal] = 1;
                        }
                        else
                        {
                            ++iLoadedSpawns[referencedVal];
#ifdef VMAP_DEBUG
                            if (iTreeValues[referencedVal].ID != spawn.ID)
                                sLog->outDebug(LOG_FILTER_MAPS, "StaticMapTree::LoadMapTile() : trying to load wrong spawn in node");
                            else if (iTreeValues[referencedVal].name != spawn.name)
                                sLog->outDebug(LOG_FILTER_MAPS, "StaticMapTree::LoadMapTile() : name collision on GUID=%u", spawn.ID);
#endif
                        }
                    }
                    else
                        result = false;
                }
            }
            iLoadedTiles[packTileID(tileX, tileY)] = true;
            fclose(tf);
        }
        else
            iLoadedTiles[packTileID(tileX, tileY)] = false;
        return result;
    }
开发者ID:8Infinity8,项目名称:InfinityCore,代码行数:78,代码来源:MapTree.cpp


示例7: theFile

MapTile::MapTile(int pX, int pZ, const std::string& pFilename, bool pBigAlpha)
{
	this->modelCount = 0;
	this->mPositionX = pX;
	this->mPositionZ = pZ;

	this->changed = 0;
	this->xbase = mPositionX * TILESIZE;
	this->zbase = mPositionZ * TILESIZE;

	this->mBigAlpha = pBigAlpha;

	for (int i = 0; i < 16; ++i)
	{
		for (int j = 0; j < 16; j++)
		{
			mChunks[i][j] = NULL;
		}
	}

	mFilename = pFilename;

	MPQFile theFile(mFilename);

	Log << "Opening tile " << mPositionX << ", " << mPositionZ << " (\"" << mFilename << "\") from " << (theFile.isExternal() ? "disk" : "MPQ") << "." << std::endl;

	// - Parsing the file itself. --------------------------

	// We store this data to load it at the end.
	uint32_t lMCNKOffsets[256];
	std::vector<ENTRY_MDDF> lModelInstances;
	std::vector<ENTRY_MODF> lWMOInstances;

	uint32_t fourcc;
	uint32_t size;

	MHDR Header;

	// - MVER ----------------------------------------------

	uint32_t version;

	theFile.read(&fourcc, 4);
	theFile.seekRelative(4);
	theFile.read(&version, 4);

	assert(fourcc == 'MVER' && version == 18);

	// - MHDR ----------------------------------------------

	theFile.read(&fourcc, 4);
	theFile.seekRelative(4);

	assert(fourcc == 'MHDR');

	theFile.read(&Header, sizeof(MHDR));

	mFlags = Header.flags;

	// - MCIN ----------------------------------------------

	theFile.seek(Header.mcin + 0x14);
	theFile.read(&fourcc, 4);
	theFile.seekRelative(4);

	assert(fourcc == 'MCIN');

	for (int i = 0; i < 256; ++i)
	{
		theFile.read(&lMCNKOffsets[i], 4);
		theFile.seekRelative(0xC);
	}

	// - MTEX ----------------------------------------------

	theFile.seek(Header.mtex + 0x14);
	theFile.read(&fourcc, 4);
	theFile.read(&size, 4);

	assert(fourcc == 'MTEX');

	{
		char* lCurPos = reinterpret_cast<char*>(theFile.getPointer());
		char* lEnd = lCurPos + size;

		while (lCurPos < lEnd)
		{
			mTextureFilenames.push_back(std::string(lCurPos));
			lCurPos += strlen(lCurPos) + 1;
		}
	}

	// - MMDX ----------------------------------------------

	theFile.seek(Header.mmdx + 0x14);
	theFile.read(&fourcc, 4);
	theFile.read(&size, 4);

	assert(fourcc == 'MMDX');

//.........这里部分代码省略.........
开发者ID:Ikesters,项目名称:noggit,代码行数:101,代码来源:MapTile.cpp


示例8: getTileFileName

    bool StaticMapTree::loadMap(uint32 tileX, uint32 tileY, VMapManager2 *vm)
    {
        if (!iIsTiled)
            return true;
        if (!iTreeValues)
        {
            std::cout << "Tree has not been initialized!\n";
            return false;
        }
        bool result = true;

        std::string tilefile = iBasePath + getTileFileName(iMapID, tileX, tileY);
        FILE* tf = fopen(tilefile.c_str(), "rb");
        if(tf)
        {
            while(result)
            {
                // read model spawns
                ModelSpawn spawn;
                result = ModelSpawn::readFromFile(tf, spawn);
                if(result)
                {
                    // acquire model instance
                    WorldModel *model = vm->acquireModelInstance(iBasePath, spawn.name);
                    if(!model) std::cout << "error: could not acquire WorldModel pointer!\n";

                    // update tree
                    uint32 nNodeVal=0, referencedVal;
                    fread(&nNodeVal, sizeof(uint32), 1, tf);
#ifdef VMAP_DEBUG
                    if(nNodeVal != 1)
                        std::cout << "unexpected amount of affected NodeVals! (" << nNodeVal << ")\n";
#endif
                    for (uint32 i=0; i<nNodeVal; ++i)
                    {
                        fread(&referencedVal, sizeof(uint32), 1, tf);
                        if (!iLoadedSpawns.count(spawn.ID))
                        {
#ifdef VMAP_DEBUG
                            if (referencedVal > iNTreeValues)
                            {
                                std::cout << "invalid tree element! (" << referencedVal << "/" << iNTreeValues << ")\n";
                                continue;
                            }
#endif
                            iTreeValues[referencedVal] = ModelInstance(spawn, model);
                            iLoadedSpawns[spawn.ID] = 1;
                        }
                        else
                        {
                            ++iLoadedSpawns[spawn.ID];
#ifdef VMAP_DEBUG
                            if (iTreeValues[referencedVal].ID != spawn.ID) std::cout << "error: trying to load wrong spawn in node!\n";
                            else if (iTreeValues[referencedVal].name != spawn.name) std::cout << "error: name collision on GUID="<< spawn.ID << "\n";
#endif
                        }
                    }
                }
            }
            iLoadedTiles[packTileID(tileX, tileY)] = true;
            fclose(tf);
        }
        else
            iLoadedTiles[packTileID(tileX, tileY)] = false;
        return result;
    }
开发者ID:Bootz,项目名称:diamondcore,代码行数:66,代码来源:MapTree.cpp


示例9: TC_LOG_ERROR

    bool StaticMapTree::LoadMapTile(uint32 tileX, uint32 tileY, VMapManager2* vm)
    {
        if (!iTreeValues)
        {
            TC_LOG_ERROR("misc", "StaticMapTree::LoadMapTile() : tree has not been initialized [%u, %u]", tileX, tileY);
            return false;
        }
        bool result = true;

        TileFileOpenResult fileResult = OpenMapTileFile(iBasePath, iMapID, tileX, tileY, vm);
        if (fileResult.File)
        {
            char chunk[8];

            if (!readChunk(fileResult.File, chunk, VMAP_MAGIC, 8))
                result = false;
            uint32 numSpawns = 0;
            if (result && fread(&numSpawns, sizeof(uint32), 1, fileResult.File) != 1)
                result = false;
            for (uint32 i=0; i<numSpawns && result; ++i)
            {
                // read model spawns
                ModelSpawn spawn;
                result = ModelSpawn::readFromFile(fileResult.File, spawn);
                if (result)
                {
                    // acquire model instance
                    WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name, spawn.flags);
                    if (!model)
                        TC_LOG_ERROR("misc", "StaticMapTree::LoadMapTile() : could not acquire WorldModel pointer [%u, %u]", tileX, tileY);

                    // update tree
                    auto spawnIndex = iSpawnIndices.find(spawn.ID);
                    if (spawnIndex != iSpawnIndices.end())
                    {
                        uint32 referencedVal = spawnIndex->second;
                        if (!iLoadedSpawns.count(referencedVal))
                        {
                            if (referencedVal >= iNTreeValues)
                            {
                                TC_LOG_ERROR("maps", "StaticMapTree::LoadMapTile() : invalid tree element (%u/%u) referenced in tile %s", referencedVal, iNTreeValues, fileResult.Name.c_str());
                                continue;
                            }

                            iTreeValues[referencedVal] = ModelInstance(spawn, model);
                            iLoadedSpawns[referencedVal] = 1;
                        }
                        else
                        {
                            ++iLoadedSpawns[referencedVal];
#ifdef VMAP_DEBUG
                            if (iTreeValues[referencedVal].ID != spawn.ID)
                                TC_LOG_DEBUG("maps", "StaticMapTree::LoadMapTile() : trying to load wrong spawn in node");
                            else if (iTreeValues[referencedVal].name != spawn.name)
                                TC_LOG_DEBUG("maps", "StaticMapTree::LoadMapTile() : name collision on GUID=%u", spawn.ID);
#endif
                        }
                    }
                    else
                        result = false;
                }
            }
            iLoadedTiles[packTileID(tileX, tileY)] = true;
            fclose(fileResult.File);
        }
        else
            iLoadedTiles[packTileID(tileX, tileY)] = false;
        TC_METRIC_EVENT("map_events", "LoadMapTile",
            "Map: " + std::to_string(iMapID) + " TileX: " + std::to_string(tileX) + " TileY: " + std::to_string(tileY));
        return result;
    }
开发者ID:welder1976,项目名称:TrinityCore,代码行数:71,代码来源:MapTree.cpp



注:本文中的ModelInstance函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ModelNode函数代码示例发布时间:2022-05-30
下一篇:
C++ ModelException函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap