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


C++ XmlDocument::getChildElement方法代码示例

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


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

示例1: load

//==============================================================================
void Material::load(const CString& filename, ResourceInitializer& init)
{
	try
	{
		m_vars = std::move(ResourceVector<MaterialVariable*>(init.m_alloc));

		Dictionary<MaterialVariable*> dict(10, 
			Dictionary<MaterialVariable*>::hasher(),
			Dictionary<MaterialVariable*>::key_equal(),
			init.m_alloc);
		m_varDict = std::move(dict);

		m_progs = 
			std::move(ResourceVector<ProgramResourcePointer>(init.m_alloc));
		m_pplines = 
			std::move(ResourceVector<GlProgramPipelineHandle>(init.m_alloc));

		XmlDocument doc;
		doc.loadFile(filename, init.m_tempAlloc);
		parseMaterialTag(doc.getChildElement("material"), init);
	}
	catch(std::exception& e)
	{
		throw ANKI_EXCEPTION("Failed to load material") << e;
	}
}
开发者ID:ezhangle,项目名称:anki-3d-engine,代码行数:27,代码来源:Material.cpp

示例2: load

//==============================================================================
Error Material::load(const CString& filename, ResourceInitializer& init)
{
	Error err = ErrorCode::NONE;

	m_resources = &init.m_resources;

	XmlDocument doc;
	ANKI_CHECK(doc.loadFile(filename, init.m_tempAlloc));

	XmlElement el;
	ANKI_CHECK(doc.getChildElement("material", el));
	ANKI_CHECK(parseMaterialTag(el , init));

	return err;
}
开发者ID:swq0553,项目名称:anki-3d-engine,代码行数:16,代码来源:Material.cpp

示例3: load

//==============================================================================
void Skeleton::load(const CString& filename, ResourceInitializer& init)
{
	XmlDocument doc;
	doc.loadFile(filename, init.m_tempAlloc);

	XmlElement rootEl = doc.getChildElement("skeleton");
	XmlElement bonesEl = rootEl.getChildElement("bones");

	// count the bones count
	U bonesCount = 0;

	XmlElement boneEl = bonesEl.getChildElement("bone");

	do
	{
		++bonesCount;
		boneEl = boneEl.getNextSiblingElement("bone");
	} while(boneEl);

	// Alloc the vector
	m_bones = std::move(ResourceVector<Bone>(init.m_alloc));
	m_bones.resize(bonesCount, Bone(init.m_alloc));

	// Load every bone
	boneEl = bonesEl.getChildElement("bone");
	bonesCount = 0;
	do
	{
		Bone& bone = m_bones[bonesCount++];

		// <name>
		XmlElement nameEl = boneEl.getChildElement("name");
		bone.m_name = nameEl.getText();

		// <transform>
		XmlElement trfEl = boneEl.getChildElement("transform");
		bone.m_transform = trfEl.getMat4();

		// Advance 
		boneEl = boneEl.getNextSiblingElement("bone");
	} while(boneEl);
}
开发者ID:ezhangle,项目名称:anki-3d-engine,代码行数:43,代码来源:Skeleton.cpp

示例4: load

//==============================================================================
Error ParticleEmitterResource::load(const CString& filename)
{
	U32 tmp;

	XmlDocument doc;
	ANKI_CHECK(doc.loadFile(filename, getTempAllocator()));
	XmlElement rel; // Root element
	ANKI_CHECK(doc.getChildElement("particleEmitter", rel));

	// XML load
	//
	ANKI_CHECK(xmlF32(rel, "life", m_particle.m_life));
	ANKI_CHECK(xmlF32(rel, "lifeDeviation", m_particle.m_lifeDeviation));

	ANKI_CHECK(xmlF32(rel, "mass", m_particle.m_mass));
	ANKI_CHECK(xmlF32(rel, "massDeviation", m_particle.m_massDeviation));

	ANKI_CHECK(xmlF32(rel, "size", m_particle.m_size));
	ANKI_CHECK(xmlF32(rel, "sizeDeviation", m_particle.m_sizeDeviation));
	ANKI_CHECK(xmlF32(rel, "sizeAnimation", m_particle.m_sizeAnimation));

	ANKI_CHECK(xmlF32(rel, "alpha", m_particle.m_alpha));
	ANKI_CHECK(xmlF32(rel, "alphaDeviation", m_particle.m_alphaDeviation));

	tmp = m_particle.m_alphaAnimation;
	ANKI_CHECK(xmlU32(rel, "alphaAnimationEnabled", tmp));
	m_particle.m_alphaAnimation = tmp;

	ANKI_CHECK(xmlVec3(rel, "forceDirection", m_particle.m_forceDirection));
	ANKI_CHECK(xmlVec3(rel, "forceDirectionDeviation",
		m_particle.m_forceDirectionDeviation));
	ANKI_CHECK(xmlF32(rel, "forceMagnitude", m_particle.m_forceMagnitude));
	ANKI_CHECK(xmlF32(rel, "forceMagnitudeDeviation",
		m_particle.m_forceMagnitudeDeviation));

	ANKI_CHECK(xmlVec3(rel, "gravity", m_particle.m_gravity));
	ANKI_CHECK(xmlVec3(rel, "gravityDeviation", m_particle.m_gravityDeviation));

	ANKI_CHECK(xmlVec3(rel, "startingPosition", m_particle.m_startingPos));
	ANKI_CHECK(xmlVec3(rel, "startingPositionDeviation",
		m_particle.m_startingPosDeviation));

	ANKI_CHECK(xmlU32(rel, "maxNumberOfParticles", m_maxNumOfParticles));

	ANKI_CHECK(xmlF32(rel, "emissionPeriod", m_emissionPeriod));
	ANKI_CHECK(xmlU32(rel, "particlesPerEmittion", m_particlesPerEmittion));
	tmp = m_usePhysicsEngine;
	ANKI_CHECK(xmlU32(rel, "usePhysicsEngine", tmp));
	m_usePhysicsEngine = tmp;

	XmlElement el;
	CString cstr;
	ANKI_CHECK(rel.getChildElement("material", el));
	ANKI_CHECK(el.getText(cstr));
	ANKI_CHECK(m_material.load(cstr, &getManager()));

	// sanity checks
	//

	static const char* ERROR = "Particle emmiter: "
		"Incorrect or missing value %s";

	if(m_particle.m_life <= 0.0)
	{
		ANKI_LOGE(ERROR, "life");
		return ErrorCode::USER_DATA;
	}

	if(m_particle.m_life - m_particle.m_lifeDeviation <= 0.0)
	{
		ANKI_LOGE(ERROR, "lifeDeviation");
		return ErrorCode::USER_DATA;
	}

	if(m_particle.m_size <= 0.0)
	{
		ANKI_LOGE(ERROR, "size");
		return ErrorCode::USER_DATA;
	}

	if(m_maxNumOfParticles < 1)
	{
		ANKI_LOGE(ERROR, "maxNumOfParticles");
		return ErrorCode::USER_DATA;
	}

	if(m_emissionPeriod <= 0.0)
	{
		ANKI_LOGE(ERROR, "emissionPeriod");
		return ErrorCode::USER_DATA;
	}

	if(m_particlesPerEmittion < 1)
	{
		ANKI_LOGE(ERROR, "particlesPerEmission");
		return ErrorCode::USER_DATA;
	}

	// Calc some stuff
//.........这里部分代码省略.........
开发者ID:zhouxh1023,项目名称:anki-3d-engine,代码行数:101,代码来源:ParticleEmitterResource.cpp

示例5: load

//==============================================================================
Error Animation::load(const ResourceFilename& filename)
{
	XmlElement el;
	I64 tmp;
	F64 ftmp;

	m_startTime = MAX_F32;
	F32 maxTime = MIN_F32;

	// Document
	XmlDocument doc;
	ANKI_CHECK(openFileParseXml(filename, doc));
	XmlElement rootel;
	ANKI_CHECK(doc.getChildElement("animation", rootel));

	// Count the number of identity keys. If all of the keys are identities
	// drop a vector
	U identPosCount = 0;
	U identRotCount = 0;
	U identScaleCount = 0;

	// <repeat>
	XmlElement repel;
	ANKI_CHECK(rootel.getChildElementOptional("repeat", repel));
	if(repel)
	{
		ANKI_CHECK(repel.getI64(tmp));
		m_repeat = tmp;
	}
	else
	{
		m_repeat = false;
	}

	// <channels>
	XmlElement channelsEl;
	ANKI_CHECK(rootel.getChildElement("channels", channelsEl));
	XmlElement chEl;
	ANKI_CHECK(channelsEl.getChildElement("channel", chEl));

	U32 channelCount = 0;
	ANKI_CHECK(chEl.getSiblingElementsCount(channelCount));
	if(channelCount == 0)
	{
		ANKI_LOGE("Didn't found any channels");
		return ErrorCode::USER_DATA;
	}
	m_channels.create(getAllocator(), channelCount);

	// For all channels
	channelCount = 0;
	do
	{
		AnimationChannel& ch = m_channels[channelCount];

		// <name>
		ANKI_CHECK(chEl.getChildElement("name", el));
		CString strtmp;
		ANKI_CHECK(el.getText(strtmp));
		ch.m_name.create(getAllocator(), strtmp);

		XmlElement keysEl, keyEl;

		// <positionKeys>
		ANKI_CHECK(chEl.getChildElementOptional("positionKeys", keysEl));
		if(keysEl)
		{
			ANKI_CHECK(keysEl.getChildElement("key", keyEl));

			U32 count = 0;
			ANKI_CHECK(keyEl.getSiblingElementsCount(count));
			ch.m_positions.create(getAllocator(), count);

			count = 0;
			do
			{
				Key<Vec3>& key = ch.m_positions[count++];

				// <time>
				ANKI_CHECK(keyEl.getChildElement("time", el));
				ANKI_CHECK(el.getF64(ftmp));
				key.m_time = ftmp;
				m_startTime = std::min(m_startTime, key.m_time);
				maxTime = std::max(maxTime, key.m_time);

				// <value>
				ANKI_CHECK(keyEl.getChildElement("value", el));
				ANKI_CHECK(el.getVec3(key.m_value));

				// Check ident
				if(key.m_value == Vec3(0.0))
				{
					++identPosCount;
				}

				// Move to next
				ANKI_CHECK(keyEl.getNextSiblingElement("key", keyEl));
			} while(keyEl);
		}
//.........这里部分代码省略.........
开发者ID:Al1a123,项目名称:anki-3d-engine,代码行数:101,代码来源:Animation.cpp

示例6: load

Error TextureAtlasResource::load(const ResourceFilename& filename, Bool async)
{
	XmlDocument doc;
	ANKI_CHECK(openFileParseXml(filename, doc));

	XmlElement rootel, el;

	//
	// <textureAtlas>
	//
	ANKI_CHECK(doc.getChildElement("textureAtlas", rootel));

	//
	// <texture>
	//
	ANKI_CHECK(rootel.getChildElement("texture", el));
	CString texFname;
	ANKI_CHECK(el.getText(texFname));
	ANKI_CHECK(getManager().loadResource<TextureResource>(texFname, m_tex, async));

	m_size[0] = m_tex->getWidth();
	m_size[1] = m_tex->getHeight();

	//
	// <subTextureMargin>
	//
	ANKI_CHECK(rootel.getChildElement("subTextureMargin", el));
	I64 margin = 0;
	ANKI_CHECK(el.getNumber(margin));
	if(margin >= I(m_tex->getWidth()) || margin >= I(m_tex->getHeight()) || margin < 0)
	{
		ANKI_RESOURCE_LOGE("Too big margin %d", U(margin));
		return Error::USER_DATA;
	}
	m_margin = margin;

	//
	// <subTextures>
	//

	// Get counts
	PtrSize namesSize = 0;
	PtrSize subTexesCount = 0;
	XmlElement subTexesEl, subTexEl;
	ANKI_CHECK(rootel.getChildElement("subTextures", subTexesEl));
	ANKI_CHECK(subTexesEl.getChildElement("subTexture", subTexEl));
	do
	{
		ANKI_CHECK(subTexEl.getChildElement("name", el));
		CString name;
		ANKI_CHECK(el.getText(name));

		if(name.getLength() < 1)
		{
			ANKI_RESOURCE_LOGE("Something wrong with the <name> tag. Probably empty");
			return Error::USER_DATA;
		}

		namesSize += name.getLength() + 1;
		++subTexesCount;

		ANKI_CHECK(subTexEl.getNextSiblingElement("subTexture", subTexEl));
	} while(subTexEl);

	// Allocate
	m_subTexNames.create(getAllocator(), namesSize);
	m_subTexes.create(getAllocator(), subTexesCount);

	// Iterate again and populate
	subTexesCount = 0;
	char* names = &m_subTexNames[0];
	ANKI_CHECK(subTexesEl.getChildElement("subTexture", subTexEl));
	do
	{
		ANKI_CHECK(subTexEl.getChildElement("name", el));
		CString name;
		ANKI_CHECK(el.getText(name));

		memcpy(names, &name[0], name.getLength() + 1);

		m_subTexes[subTexesCount].m_name = names;

		ANKI_CHECK(subTexEl.getChildElement("uv", el));
		Vec4 uv;
		ANKI_CHECK(el.getVec4(uv));
		m_subTexes[subTexesCount].m_uv = {{uv[0], uv[1], uv[2], uv[3]}};

		names += name.getLength() + 1;
		++subTexesCount;

		ANKI_CHECK(subTexEl.getNextSiblingElement("subTexture", subTexEl));
	} while(subTexEl);

	return Error::NONE;
}
开发者ID:godlikepanos,项目名称:anki-3d-engine,代码行数:95,代码来源:TextureAtlasResource.cpp


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