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


C++ Compound::loadTexture方法代码示例

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


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

示例1: loadObjects

bool SceneLoader::loadObjects(){ //Falta condicao para nao se repetirem ID's <--
	TiXmlElement* objectElement = root->FirstChildElement("objects");
	if(objectElement == NULL)
	{
		cout << "> Error: objects tag not found!" << endl;
		return false;
	}
	TiXmlElement* objectChild = objectElement->FirstChildElement();
	int i=1;
	for( ; objectChild != NULL; objectChild = objectChild->NextSiblingElement()){
		if(i <= maxObjects){
			if(!objectChild->Attribute("type")){
				cout << "	> Error: Could not load type of an Object!" << endl; //Sair imediatamente
				return NULL;
			}
			string type = objectChild->Attribute("type");
			if(type == "compound"){ //Tipo composto
				Compound* compound = new Compound();
				
				if((compound->loadAttributes(objectChild)) == NULL)
					return false;
				if(sceneManager->getObjectbyID(objectChild->Attribute("id")) != NULL){ //Objecto já existente no sistema
					cout << "	> Warning: object with ID " << objectChild->Attribute("id") << " is already in the system!!" << endl;
					continue;
				}

				string material;
				if((material = compound->loadMaterial(objectChild)).empty()) return NULL;
				if(material != "null"){
					Material* mat = this->sceneManager->getMaterialbyID(material);
					if(mat == NULL){
						cout << "	> Error: Material with ID: " << material << " not found for Object: " << compound->id << endl;
						return false;
					}
					compound->material = mat;
				} else{
					Material* mat = new Material();
					mat->id = "null";
					compound->material = mat;
				}

				string texture;
				if((texture = compound->loadTexture(objectChild)).empty()) return NULL;
				if(texture == "clear"){
					Texture* text = new Texture();
					text->id = "clear";
					compound->texture = text;
				} else if(texture != "null"){
					Texture* text = this->sceneManager->getTexturebyID(texture);
					if(text == NULL){
						cout << "	> Error: Texture with ID: " << texture << " not found for Object: " << compound->id << endl;
						return false;
					}
					compound->texture = text;
				} else{
					Texture* text = new Texture();
					text->id = "null";
					compound->texture = text;
				}

				if(objectChild->Attribute("id") == sceneManager->globals->root){
					sceneManager->root = compound;
				}

				sceneManager->addObject(compound);
			} else if(type == "simple"){ //Tipo simples
				Simple* simple = new Simple();
		
				if((simple->loadAttributes(objectChild)) == NULL)
						return false;
				if(sceneManager->getObjectbyID(objectChild->Attribute("id")) != NULL) //Objecto já existente no sistema
				{
					cout << "	> Warning: object with ID " << objectChild->Attribute("id") << " is already in the system!!" << endl;
					continue;
				}

				string material;
				if((material = simple->loadMaterial(objectChild)).empty()) return NULL;
				if(material != "null"){
					Material* mat = this->sceneManager->getMaterialbyID(material);
					if(mat == NULL){
						cout << "	> Error: Material with ID: " << material << " not found for Object: " << simple->id << endl;
						return false;
					}
					simple->material = mat;
				} else{
					Material* mat = new Material();
					mat->id = "null";
					simple->material = mat;
				}

				string texture;
				if((texture = simple->loadTexture(objectChild)).empty()) return NULL;
				if(texture == "clear"){
					Texture* text = new Texture();
					text->id = "clear";
					simple->texture = text;
				} else if(texture != "null"){
					Texture* text = this->sceneManager->getTexturebyID(texture);
					if(text == NULL){
//.........这里部分代码省略.........
开发者ID:zombobilium,项目名称:laig3,代码行数:101,代码来源:SceneLoader.cpp


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