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


C++ TiXmlElement::QueryUIntAttribute方法代码示例

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


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

示例1: xmlMeshLoad

bool xmlMeshLoad(const char * filename, void * data)
{
    MLOG_DEBUG("xmlMeshLoad " << filename?filename:"NULL");
	
	MLevel * level = MEngine::getInstance()->getLevel();

	// read document
	TiXmlDocument doc(filename);
	if(! doc.LoadFile())
	{
	    MLOG_WARNING("TiXmlDocument load failed : " << doc.ErrorDesc() << " line " << doc.ErrorRow());
	    return false;
	}

	TiXmlHandle hDoc(&doc);
	TiXmlElement * pRootNode;
	TiXmlHandle hRoot(0);

	// Maratis
	pRootNode = hDoc.FirstChildElement().Element();
	if(! pRootNode)
	{
	    MLOG_WARNING("Cannot find any root node");
	    return false;
	}

	if(strcmp(pRootNode->Value(), "Maratis") != 0)
	{
	    MLOG_WARNING("Cannot find Maratis root node");
	    return false;
	}

	hRoot = TiXmlHandle(pRootNode);


	// Mesh
	TiXmlElement * pMeshNode = pRootNode->FirstChildElement("Mesh");
	if(! pMeshNode)
	{
	    MLOG_WARNING("Cannot find a Mesh node");
	    return false;
	}

	// create new mesh
	MMesh * mesh = (MMesh *)data;
	mesh->clear();

	char path[256];
	char meshRep[256];
	char vertShadPath[256];
	char fragShadPath[256];

	// mesh rep
	getRepertory(meshRep, filename);

	// animation
	if(! loadAnim(pMeshNode, meshRep, mesh))
	{
		// load external anim file (depracated)
		char animFilename[256];
		strcpy(animFilename, filename);
		strcpy(animFilename + strlen(animFilename) - 4, "anim");
		loadAnimFile(mesh, animFilename, meshRep);
	}

	// Textures
	TiXmlElement * texturesNode = pMeshNode->FirstChildElement("Textures");
	if(texturesNode)
	{
	    MLOG_DEBUG("entering Textures node");
		
		unsigned int numTextures = 0;
		texturesNode->QueryUIntAttribute("num", &numTextures);
		mesh->allocTextures(numTextures);

		// Texture
		TiXmlElement * textureNode = texturesNode->FirstChildElement("Texture");
		for(textureNode; textureNode; textureNode=textureNode->NextSiblingElement("Texture"))
		{
			const char * file = NULL;
			bool mipmap = true;

			// image
			TiXmlElement * imageNode = textureNode->FirstChildElement("image");
			if(imageNode)
			{
				int value = 1;
				file = imageNode->Attribute("filename");
				imageNode->QueryIntAttribute("mipmap", &value);
				mipmap = (value == 1);
			}

			if(! file)
			{
				mesh->addNewTexture(NULL);
				continue;
			}

			// load texture
			getGlobalFilename(path, meshRep, file);
//.........这里部分代码省略.........
开发者ID:Keedu,项目名称:maratis,代码行数:101,代码来源:MMeshLoad.cpp

示例2: loadAnim

bool loadAnim(TiXmlElement * rootNode, const char * repertory, MMesh * mesh)
{
	MLevel * level = MEngine::getInstance()->getLevel();


	// Animation
	TiXmlElement * animationNode = rootNode->FirstChildElement("Animation");
	if(! animationNode)
		return false;

	// TextureAnim
	TiXmlElement * texAnimNode = animationNode->FirstChildElement("TextureAnim");
	if(texAnimNode)
	{
		const char * file = texAnimNode->Attribute("file");
		if(file)
		{
			// path
			char path[256];
			getGlobalFilename(path, repertory, file);

			// load textures anim
			MTexturesAnimRef * texturesAnim = level->loadTexturesAnim(path);
			mesh->setTexturesAnimRef(texturesAnim);
		}
	}

	// MaterialAnim
	TiXmlElement * matAnimNode = animationNode->FirstChildElement("MaterialAnim");
	if(matAnimNode)
	{
		const char * file = matAnimNode->Attribute("file");
		if(file)
		{
			// path
			char path[256];
			getGlobalFilename(path, repertory, file);

			// load materials anim
			MMaterialsAnimRef * materialsAnim = level->loadMaterialsAnim(path);
			mesh->setMaterialsAnimRef(materialsAnim);
		}
	}

	// ArmatureAnim
	TiXmlElement * armAnimNode = animationNode->FirstChildElement("ArmatureAnim");
	if(armAnimNode)
	{
		const char * file = armAnimNode->Attribute("file");
		if(file)
		{
			// path
			char path[256];
			getGlobalFilename(path, repertory, file);

			// load armature anim
			MArmatureAnimRef * armatureAnim = level->loadArmatureAnim(path);
			mesh->setArmatureAnimRef(armatureAnim);
		}
	}

	// Anims
	TiXmlElement * animsNode = animationNode->FirstChildElement("Anims");
	if(animsNode)
	{
		unsigned int animsNumber = 0;
		animsNode->QueryUIntAttribute("num", &animsNumber);
		if(animsNumber > 0)
		{
			MAnimRange * animsRanges = mesh->allocAnimsRanges(animsNumber);

			TiXmlElement * animNode = animsNode->FirstChildElement("anim");
			for(animNode; animNode; animNode=animNode->NextSiblingElement("anim"))
			{
				animNode->QueryIntAttribute("start", &animsRanges->start);
				animNode->QueryIntAttribute("end", &animsRanges->end);
				animNode->QueryIntAttribute("loops", &animsRanges->loops);

				animsRanges++;
			}
		}
	}

	return true;
}
开发者ID:Keedu,项目名称:maratis,代码行数:85,代码来源:MMeshLoad.cpp

示例3: xmlTextureAnimLoad

bool xmlTextureAnimLoad(const char * filename, void * data)
{
	TiXmlDocument doc(filename);
	if(! doc.LoadFile())
		return false;

	TiXmlHandle hDoc(&doc);
	TiXmlElement * pRootNode;
	TiXmlHandle hRoot(0);

	// Maratis
	pRootNode = hDoc.FirstChildElement().Element();
	if(! pRootNode)
		return false;

	if(strcmp(pRootNode->Value(), "Maratis") != 0)
		return false;

	hRoot = TiXmlHandle(pRootNode);

	// TextureAnim
	TiXmlElement * textureAnimNode = pRootNode->FirstChildElement("TextureAnim");
	if(! textureAnimNode)
		return false;

	unsigned int texturesAnimNumber = 0;
	textureAnimNode->QueryUIntAttribute("num", &texturesAnimNumber);
	if(texturesAnimNumber == 0)
		return false;

	// create textures anim
	MTexturesAnim * texturesAnim = (MTexturesAnim *)data;
	MTextureAnim * texAnims = texturesAnim->allocTexturesAnim(texturesAnimNumber);

	// Texture
	TiXmlElement * textureNode = textureAnimNode->FirstChildElement("Texture");
	for(textureNode; textureNode; textureNode=textureNode->NextSiblingElement("Texture"))
	{
		// translate
		TiXmlElement * translateNode = textureNode->FirstChildElement("translate");
		if(translateNode)
		{
			unsigned int kSize = 0;
			translateNode->QueryUIntAttribute("num", &kSize);
			MKey * keys = texAnims->allocTranslateKeys(kSize);
			readVector2Keys(translateNode, keys);
		}

		// scale
		TiXmlElement * scaleNode = textureNode->FirstChildElement("scale");
		if(scaleNode)
		{
			unsigned int kSize = 0;
			scaleNode->QueryUIntAttribute("num", &kSize);
			MKey * keys = texAnims->allocScaleKeys(kSize);
			readVector2Keys(scaleNode, keys);
		}

		// rotate
		TiXmlElement * rotateNode = textureNode->FirstChildElement("rotate");
		if(rotateNode)
		{
			unsigned int kSize = 0;
			rotateNode->QueryUIntAttribute("num", &kSize);
			MKey * keys = texAnims->allocRotationKeys(kSize);
			readFloatKeys(rotateNode, keys);
		}

		texAnims++;
	}

	return true;
}
开发者ID:Keedu,项目名称:maratis,代码行数:73,代码来源:MMeshLoad.cpp

示例4: xmlMaterialAnimLoad

bool xmlMaterialAnimLoad(const char * filename, void * data)
{
	TiXmlDocument doc(filename);
	if(! doc.LoadFile())
		return false;

	TiXmlHandle hDoc(&doc);
	TiXmlElement * pRootNode;
	TiXmlHandle hRoot(0);

	// Maratis
	pRootNode = hDoc.FirstChildElement().Element();
	if(! pRootNode)
		return false;

	if(strcmp(pRootNode->Value(), "Maratis") != 0)
		return false;

	hRoot = TiXmlHandle(pRootNode);

	// TextureAnim
	TiXmlElement * materialAnimNode = pRootNode->FirstChildElement("MaterialAnim");
	if(! materialAnimNode)
		return false;

	unsigned int materialsAnimNumber = 0;
	materialAnimNode->QueryUIntAttribute("num", &materialsAnimNumber);
	if(materialsAnimNumber == 0)
		return false;

	// create materials anim
	MMaterialsAnim * materialsAnim = (MMaterialsAnim *)data;
	MMaterialAnim * matAnims = materialsAnim->allocMaterialsAnim(materialsAnimNumber);

	// Material
	TiXmlElement * materialNode = materialAnimNode->FirstChildElement("Material");
	for(materialNode; materialNode; materialNode=materialNode->NextSiblingElement("Material"))
	{
		// opacity
		TiXmlElement * opacityNode = materialNode->FirstChildElement("opacity");
		if(opacityNode)
		{
			unsigned int kSize = 0;
			opacityNode->QueryUIntAttribute("num", &kSize);
			MKey * keys = matAnims->allocOpacityKeys(kSize);
			readFloatKeys(opacityNode, keys);
		}

		// shininess
		TiXmlElement * shininessNode = materialNode->FirstChildElement("shininess");
		if(shininessNode)
		{
			unsigned int kSize = 0;
			shininessNode->QueryUIntAttribute("num", &kSize);
			MKey * keys = matAnims->allocShininessKeys(kSize);
			readFloatKeys(shininessNode, keys);
		}

		// customValue
		TiXmlElement * customValueNode = materialNode->FirstChildElement("customValue");
		if(customValueNode)
		{
			unsigned int kSize = 0;
			customValueNode->QueryUIntAttribute("num", &kSize);
			MKey * keys = matAnims->allocCustomValueKeys(kSize);
			readFloatKeys(customValueNode, keys);
		}

		// diffuseColor
		TiXmlElement * diffuseColorNode = materialNode->FirstChildElement("diffuseColor");
		if(diffuseColorNode)
		{
			unsigned int kSize = 0;
			diffuseColorNode->QueryUIntAttribute("num", &kSize);
			MKey * keys = matAnims->allocDiffuseKeys(kSize);
			readVector3Keys(diffuseColorNode, keys);
		}

		// specularColor
		TiXmlElement * specularColorNode = materialNode->FirstChildElement("specularColor");
		if(specularColorNode)
		{
			unsigned int kSize = 0;
			specularColorNode->QueryUIntAttribute("num", &kSize);
			MKey * keys = matAnims->allocSpecularKeys(kSize);
			readVector3Keys(specularColorNode, keys);
		}

		// emitColor
		TiXmlElement * emitColorNode = materialNode->FirstChildElement("emitColor");
		if(emitColorNode)
		{
			unsigned int kSize = 0;
			emitColorNode->QueryUIntAttribute("num", &kSize);
			MKey * keys = matAnims->allocEmitKeys(kSize);
			readVector3Keys(emitColorNode, keys);
		}

		// customColor
		TiXmlElement * customColorNode = materialNode->FirstChildElement("customColor");
//.........这里部分代码省略.........
开发者ID:Keedu,项目名称:maratis,代码行数:101,代码来源:MMeshLoad.cpp

示例5: xmlArmatureAnimLoad

bool xmlArmatureAnimLoad(const char * filename, void * data)
{
	TiXmlDocument doc(filename);
	if(! doc.LoadFile())
		return false;

	TiXmlHandle hDoc(&doc);
	TiXmlElement * pRootNode;
	TiXmlHandle hRoot(0);

	// Maratis
	pRootNode = hDoc.FirstChildElement().Element();
	if(! pRootNode)
		return false;

	if(strcmp(pRootNode->Value(), "Maratis") != 0)
		return false;

	hRoot = TiXmlHandle(pRootNode);

	// BonesAnim
	TiXmlElement * armatureAnimNode = pRootNode->FirstChildElement("ArmatureAnim");
	if(! armatureAnimNode)
		return false;

	unsigned int bonesAnimNumber = 0;
	armatureAnimNode->QueryUIntAttribute("num", &bonesAnimNumber);
	if(bonesAnimNumber == 0)
		return false;

	// create armature anim
	MArmatureAnim * armatureAnim = (MArmatureAnim *)data;
	MObject3dAnim * objAnims = armatureAnim->allocBonesAnim(bonesAnimNumber);

	// Bone
	TiXmlElement * boneNode = armatureAnimNode->FirstChildElement("Bone");
	for(boneNode; boneNode; boneNode=boneNode->NextSiblingElement("Bone"))
	{
		// position
		TiXmlElement * positionNode = boneNode->FirstChildElement("position");
		if(positionNode)
		{
			unsigned int kSize = 0;
			positionNode->QueryUIntAttribute("num", &kSize);
			MKey * keys = objAnims->allocPositionKeys(kSize);
			readVector3Keys(positionNode, keys);
		}

		// rotation
		TiXmlElement * rotationNode = boneNode->FirstChildElement("rotation");
		if(rotationNode)
		{
			unsigned int kSize = 0;
			rotationNode->QueryUIntAttribute("num", &kSize);
			MKey * keys = objAnims->allocRotationKeys(kSize);

			// k
			TiXmlElement * kNode = rotationNode->FirstChildElement("k");
			for(kNode; kNode; kNode=kNode->NextSiblingElement("k"))
			{
				int t = 0;
				MVector3 euler;
				MQuaternion * rotation = keys->createQuaternionData();

				kNode->QueryIntAttribute("t", &t);
				kNode->QueryFloatAttribute("x", &euler.x);
				kNode->QueryFloatAttribute("y", &euler.y);
				kNode->QueryFloatAttribute("z", &euler.z);

				rotation->setFromAngles(euler.x, euler.y, euler.z);

				keys->setT(t);
				keys++;
			}
		}

		// scale
		TiXmlElement * scaleNode = boneNode->FirstChildElement("scale");
		if(scaleNode)
		{
			unsigned int kSize = 0;
			scaleNode->QueryUIntAttribute("num", &kSize);
			MKey * keys = objAnims->allocScaleKeys(kSize);
			readVector3Keys(scaleNode, keys);
		}

		objAnims++;
	}

	return true;
}
开发者ID:Keedu,项目名称:maratis,代码行数:91,代码来源:MMeshLoad.cpp


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