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


C++ ModelLoader::loadAsset方法代码示例

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


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

示例1: main

int main(int argc, char** argv)
{
	if (argc == 3 && strncmp(argv[1], "--convert", 9) == 0)
	{
		Configuration* config = new IniConfig(argv[2]);
		Heightmap* map = new Heightmap(config->getFloatValue("terrain","spacing"));
		if (map->loadFromImage(config->getValue("terrain","heightmap").c_str()))
		{
			std::cout << "Generating Terrain.." << std::endl;
			TerrainGenerator(map, config->getIntValue("terrain","chunksize"), config->getValue("out","filename").c_str());
			std::cout << "..done" << std::endl;
			std::cout.flush();
		}
		else
			std::cout << "Generation failed." << std::endl;
		return 0;
	}
	if (argc == 4 && strncmp(argv[1], "--load", 6) == 0)
	{
		int id = atoi(argv[3]);
		TerrainFileReader* reader = new TerrainFileReader();
		reader->openFile(argv[2]);

		TerrainChunk* tc = reader->readId(id);
		if (tc == NULL || tc->getInfo()->getQuadId() != id)
		{
			std::cout << "Got ID" << tc->getInfo()->getQuadId()
					<< " instead of " << id << std::endl;
			return 1;
		}
		else
		{
			std::cout << "Successfully got Terrainchunk " << id << std::endl;
			std::cout << "Spacing of Heightmap is "
					<< tc->getHeightmap()->getSpacing() << " where origin is "
					<< tc->getOrigin().x << "," << tc->getOrigin().y << " and center at "
					<< tc->getCenter().x << "," << tc->getCenter().y << std::endl;
		}
		reader->closeFile();
		delete tc;
		delete reader;
	}
	if (argc != 2 || strncmp(argv[1], "--run", 5) != 0)
	{
		std::cout << "Usage of '" << argv[0] << "'" <<std::endl;
		std::cout << "\nAvailable Parameter:"
				<< "\n\t--convert terrain.desc"
				<< "\n\t--load terrain.terr chunkid(=0)"
				<< "\n\t--run" << std::endl;
		return 1;
	}

	int width, height;
	Configuration * win_config = new IniConfig("config.ini");
	WindowHints* hints = new WindowHints();
	hints->Fullscreen = win_config->getBooleanValue("Window","fullscreen");
	hints->Width = win_config->getIntValue("Window","width");
	hints->Height = win_config->getIntValue("Window","height");
	GraphicsSystem* GSystem = new GraphicsSystem(GraphicsSystem::PROFILE_GL3,
			hints);
	if (GSystem->isError())
		return -1;
	GraphicsContext* grctx = GSystem->getGraphicsContext();
	Window* win = GSystem->getWindow();
	TextureManager* tmgr = new TextureManager(grctx);
	ModelLoader* mmgr = new ModelLoader(grctx, tmgr);
	TerrainManager* terrmgr = new TerrainManager(grctx);
	Model* mdl, *mdl2;
	Camera* cam = new Camera();
	win->getSize(&width, &height);
	cam->setScreen(width,height);
	cam->setupLens(65.0f, 1.0f, 1000.0f);

	if ((mdl = mmgr->loadAsset("Resources/Models/ant01.ms3d")) == NULL)
		std::cerr << "Could not load Model" << std::endl;
	if ((mdl2 = mmgr->loadAsset("Resources/Models/dwarf1.ms3d")) == NULL)
		std::cerr << "Could not load Model" << std::endl;
	ModelAnimationController mdlanictrl(mdl), mdlanictrl2(mdl2);
	mdlanictrl.addAnimation("idle", 52, 67, 0.25f, true);
	mdlanictrl.addAnimation("die", 30, 49, 0.25f, false);
	mdlanictrl2.addAnimation("begin_walk", 1, 2, 0.25f, false, "walk");
	mdlanictrl2.addAnimation("walk", 2, 14, 0.25f, true);
	mdlanictrl2.addAnimation("jump", 28, 40, 0.5f, false, "begin_walk");
	mdlanictrl2.addAnimation("idle", 292, 325, 0.25f, false, "idle2");
	mdlanictrl2.addAnimation("idle2", 327, 360, 0.25f, true);
	mdlanictrl2.addAnimation("die", 230, 251, 0.25f, false);
	std::cout << "Using DesktopMode: " << width << "x" << height << std::endl;
	win->setTitle("Xng?! -> Yeah!");

	Shader* sh = grctx->createShader();
	if (!sh->loadFromFile("Shader/Animation.vs", "Shader/Animation.fs"))
		return 1;

	Shader* tsh = grctx->createShader();
	if (!tsh->loadFromFile("Shader/Terrain.vs", "Shader/Terrain.fs"))
			return 1;

	Timer* t = new Timer();
	double frames = 0;

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


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