当前位置: 首页>>代码示例>>C++>>正文


C++ MEngine::getPackageManager方法代码示例

本文整理汇总了C++中MEngine::getPackageManager方法的典型用法代码示例。如果您正苦于以下问题:C++ MEngine::getPackageManager方法的具体用法?C++ MEngine::getPackageManager怎么用?C++ MEngine::getPackageManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MEngine的用法示例。


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

示例1: open

/*--------------------------------------------------------------------------------
 * MPackageFileOpenHook::open
 * File open callback
 *-------------------------------------------------------------------------------*/
MFile* MPackageFileOpenHook::open(const char* path, const char* mode)
{
	MEngine* engine = MEngine::getInstance();
	MSystemContext * system = engine->getSystemContext();
	
	char localFilename[256];
	getLocalFilename(localFilename, system->getWorkingDirectory(), path);
	
	
	if(strstr(mode, "w") != 0)
		return MStdFile::getNew(path, mode);
	
	// look within the package for a file with the requested name
	if(MPackageEnt ent = engine->getPackageManager()->findEntity(localFilename))
		return MPackageFile::getNew(ent);
	
	// give up, just look for a new file using stdio
	return MStdFile::getNew(path, mode);
}
开发者ID:UPO33,项目名称:Maratis-4,代码行数:23,代码来源:MPackageManagerNPK.cpp

示例2: openProjectPackage

MPackage openProjectPackage(const char* projName)
{
	MEngine* engine = MEngine::getInstance();
	MSystemContext* system = engine->getSystemContext();

	char projFile[256];
	getLocalFilename(projFile, system->getWorkingDirectory(), projName);
	char* ext = strstr(projFile, ".mproj");
	if(ext == 0)
	{
		return 0;
	}

	sprintf(ext, ".npk");
	char packFile[256];

	getGlobalFilename(packFile, getDataDir(), projFile);

	MPackageManager* packageManager = engine->getPackageManager();
	MPackage package = packageManager->openPackage(packFile);

	return package;
}
开发者ID:Keedu,项目名称:maratis,代码行数:23,代码来源:MPublishEvent.cpp

示例3: execute

	void execute(const char* projName)
	{
		MEngine* engine = MEngine::getInstance();
		MSystemContext* system = engine->getSystemContext();
		MPackageManager* packageManager = engine->getPackageManager();

		char directory[256], localFilename[256];
		getGlobalFilename(directory, system->getWorkingDirectory(), "meshs");
		vector<string> files;
		readDirectory(directory, &files, 1, 1);

		MLevel* currentLevel = engine->getLevel();
		MLevel* tempLevel = new MLevel();
		engine->setLevel(tempLevel);

		MMesh* mesh = MMesh::getNew();
		MArmatureAnim* armAnim = MArmatureAnim::getNew();
		MTexturesAnim* texAnim = MTexturesAnim::getNew();
		MMaterialsAnim* matAnim = MMaterialsAnim::getNew();

		// open package and scan meshes
		MPackage package = openProjectPackage(projName);
		for(int i = 0; i < files.size(); ++i)
		{
			bool binarized = false;
			
			if(strstr(files[i].c_str(), "._bin") != 0)
				continue;
			
			// export bin
			if(strstr(files[i].c_str(), ".mesh") != 0)
			{
				if(engine->getMeshLoader()->loadData(files[i].c_str(), mesh))
					binarized = exportMeshBin((files[i] + "._bin").c_str(), mesh);
			}
			else if (strstr(files[i].c_str(), ".maa") != 0)
			{
				if(engine->getArmatureAnimLoader()->loadData(files[i].c_str(), armAnim))
					binarized = exportArmatureAnimBin((files[i] + "._bin").c_str(), armAnim);
			}
			else if (strstr(files[i].c_str(), ".mma") != 0)
			{
				if(engine->getMaterialsAnimLoader()->loadData(files[i].c_str(), matAnim))
					binarized = exportMaterialsAnimBin((files[i] + "._bin").c_str(), matAnim);
			}
			else if (strstr(files[i].c_str(), ".mta") != 0)
			{
				if(engine->getTexturesAnimLoader()->loadData(files[i].c_str(), texAnim))
					binarized = exportTexturesAnimBin((files[i] + "._bin").c_str(), texAnim);
			}
			else
			{
				// try to export unknow format
				if(engine->getMeshLoader()->loadData(files[i].c_str(), mesh))
				{
					binarized = exportMeshBin((files[i] + "._bin").c_str(), mesh);
					
					// try to export animation
					MArmatureAnimRef * maaRef = mesh->getArmatureAnimRef();
					if(maaRef)
					{
						exportArmatureAnimBin((files[i] + ".maa._bin").c_str(), maaRef->getArmatureAnim());
						getLocalFilename(localFilename, system->getWorkingDirectory(), (files[i] + ".maa").c_str());
						packageManager->addFileToPackage((files[i] + ".maa._bin").c_str(), package, localFilename);
					}
				}
			}

			tempLevel->clear();

			// pack file
			getLocalFilename(localFilename, system->getWorkingDirectory(), files[i].c_str());
			
			if(binarized)
				packageManager->addFileToPackage((files[i] + "._bin").c_str(), package, localFilename); // pack bin file
			else
				packageManager->addFileToPackage(files[i].c_str(), package, localFilename); // pack original file
		}
		packageManager->closePackage(package);

		
		// clear mesh
		mesh->destroy();
		armAnim->destroy();
		texAnim->destroy();
		matAnim->destroy();

		// remove bin
		for(int i = 0; i < files.size(); ++i)
		{
			remove((files[i] + "._bin").c_str());
			remove((files[i] + ".maa._bin").c_str());
		}

		// restore level
		engine->setLevel(currentLevel);
		SAFE_DELETE(tempLevel);
	}
开发者ID:Keedu,项目名称:maratis,代码行数:98,代码来源:MPublishEvent.cpp


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