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


C++ XmlElement::getNextSiblingElement方法代码示例

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


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

示例1: 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

示例2: parseProgramsTag

//==============================================================================
void MaterialProgramCreator::parseProgramsTag(const XmlElement& el)
{
	//
	// First gather all the inputs
	//
	XmlElement programEl = el.getChildElement("program"_cstr);
	do
	{
		parseInputsTag(programEl);

		programEl = programEl.getNextSiblingElement("program"_cstr);
	} while(programEl);

	// Sort them by name to decrease the change of creating unique shaders
	std::sort(m_inputs.begin(), m_inputs.end(), InputSortFunctor());

	//
	// Then parse the includes, operations and other parts of the program
	//
	programEl = el.getChildElement("program"_cstr);
	do
	{
		parseProgramTag(programEl);

		programEl = programEl.getNextSiblingElement("program"_cstr);
	} while(programEl);

	//
	// Sanity checks
	//

	// Check that all input is referenced
	for(Input& in : m_inputs)
	{
		if(in.m_shaderDefinedMask != in.m_shaderReferencedMask)
		{
			throw ANKI_EXCEPTION("Variable not referenced or not defined %s", 
				&in.m_name[0]);
		}
	}
}
开发者ID:ezhangle,项目名称:anki-3d-engine,代码行数:42,代码来源:MaterialProgramCreator.cpp

示例3: load

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

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

	// count the bones count
	XmlElement boneEl;
	U32 bonesCount = 0;

	ANKI_CHECK(bonesEl.getChildElement("bone", boneEl));
	ANKI_CHECK(boneEl.getSiblingElementsCount(bonesCount));
	++bonesCount;

	m_bones.create(getAllocator(), bonesCount);

	// Load every bone
	bonesCount = 0;
	do
	{
		Bone& bone = m_bones[bonesCount++];

		// <name>
		XmlElement nameEl;
		ANKI_CHECK(boneEl.getChildElement("name", nameEl));
		CString tmp;
		ANKI_CHECK(nameEl.getText(tmp));
		bone.m_name.create(getAllocator(), tmp);

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

		// Advance
		ANKI_CHECK(boneEl.getNextSiblingElement("bone", boneEl));
	} while(boneEl);

	return ErrorCode::NONE;
}
开发者ID:,项目名称:,代码行数:44,代码来源:

示例4: parseOperationTag


//.........这里部分代码省略.........
			for(Input& in : m_inputs)
			{
				// Check that the first part of the string is equal to the 
				// variable and the following char is '['
				if(in.m_name == arg)
				{
					input = &in;
					in.m_shaderReferencedMask = glshaderbit;
					break;
				}
			}

			// The argument should be an input variable or an outXX
			if(!(input != nullptr 
				|| std::strncmp(&arg[0], OUT, sizeof(OUT) - 1) == 0))
			{
				throw ANKI_EXCEPTION("Incorrect argument: %s", &arg[0]);
			}

			// Add to a list and do something special if instanced
			if(input && input->m_instanced)
			{
				if(glshader == GL_VERTEX_SHADER)
				{
					argsList.push_back(ANKI_STRL(argEl.getText()) 
						+ "[gl_InstanceID]");

					m_instanceIdMask |= glshaderbit;
				}
				else if(glshader == GL_TESS_CONTROL_SHADER)
				{
					argsList.push_back(ANKI_STRL(argEl.getText()) 
						+ "[vInstanceId[0]]");

					m_instanceIdMask |= glshaderbit;
				}
				else if(glshader == GL_TESS_EVALUATION_SHADER)
				{
					argsList.push_back(ANKI_STRL(argEl.getText()) 
						+ "[commonPatch.instanceId]");
					
					m_instanceIdMask |= glshaderbit;
				}
				else if(glshader == GL_FRAGMENT_SHADER)
				{
					argsList.push_back(ANKI_STRL(argEl.getText()) 
						+ "[vInstanceId]");
					
					m_instanceIdMask |= glshaderbit;
				}
				else
				{
					throw ANKI_EXCEPTION(
						"Cannot access the instance ID in all shaders");
				}
			}
			else
			{
				argsList.push_back(MPString(argEl.getText(), m_alloc));
			}

			// Advance
			argEl = argEl.getNextSiblingElement("argument");
		} while(argEl);
	}

	// Now write everything
	MPString lines(m_alloc);
	lines.reserve(256);
	lines += "#if defined(" + funcName + "_DEFINED)";

	// Write the defines for the operationOuts
	for(const MPString& arg : argsList)
	{
		if(arg.find(OUT) == 0)
		{
			lines += " && defined(" + arg + "_DEFINED)";
		}
	}
	lines += "\n";

	if(retType != "void")
	{
		lines += "#\tdefine " + operationOut + "_DEFINED\n\t"
			+ retTypeEl.getText() + " " + operationOut + " = ";
	}
	else
	{
		lines += "\t";
	}
	
	// write the blah = func(args...)
	lines += funcName + "(";
	lines += argsList.join(", ");
	lines += ");\n";
	lines += "#endif";

	// Done
	out = std::move(lines);
}
开发者ID:ezhangle,项目名称:anki-3d-engine,代码行数:101,代码来源:MaterialProgramCreator.cpp

示例5: parseInputsTag


//.........这里部分代码省略.........
		for(Input& in : m_inputs)
		{
			if(in.m_name == inpvar.m_name)
			{
				duplicateInp = &in;
				break;
			}
		}

		if(duplicateInp != nullptr)
		{
			// Duplicate. Make sure it's the same as the other shader
			Bool same = duplicateInp->m_type == inpvar.m_type
				|| duplicateInp->m_value == inpvar.m_value
				|| duplicateInp->m_constant == inpvar.m_constant
				|| duplicateInp->m_arraySize == inpvar.m_arraySize
				|| duplicateInp->m_instanced == inpvar.m_instanced;

			if(!same)
			{
				throw ANKI_EXCEPTION("Variable defined differently between "
					"shaders: %s", &inpvar.m_name[0]);
			}

			duplicateInp->m_shaderDefinedMask |= glshaderbit;

			goto advance;
		}

		if(inpvar.m_constant == false)
		{
			// Handle NON-consts

			inpvar.m_line = inpvar.m_type + " " + inpvar.m_name;
				
			if(inpvar.m_arraySize > 1)
			{
				MPString tmp(MPString::toString(inpvar.m_arraySize, m_alloc));
				inpvar.m_line += "[" + tmp + "U]";
			}

			if(inpvar.m_instanced)
			{
				MPString tmp(
					MPString::toString(ANKI_GL_MAX_INSTANCES, m_alloc));
				inpvar.m_line += "[" +  tmp + "U]";
			}

			inpvar.m_line += ";";

			// Can put it block
			if(inpvar.m_type == "sampler2D" || inpvar.m_type == "samplerCube")
			{
				MPString tmp(
					MPString::toString(m_texBinding++, m_alloc));

				inpvar.m_line = ANKI_STRL("layout(binding = ") 
					+ tmp + ") uniform " + inpvar.m_line;
		
				inpvar.m_inBlock = false;
			}
			else
			{
				inpvar.m_inBlock = true;

				m_uniformBlock.push_back(inpvar.m_line);
				m_uniformBlockReferencedMask |= glshaderbit;
			}
		}
		else
		{
			// Handle consts

			if(inpvar.m_value.size() == 0)
			{
				throw ANKI_EXCEPTION("Empty value and const is illogical");
			}

			if(inpvar.m_arraySize > 0)
			{
				throw ANKI_EXCEPTION("Const arrays currently cannot "
					"be handled");
			}

			inpvar.m_inBlock = false;

			inpvar.m_line = ANKI_STRL("const ") 
				+ inpvar.m_type + " " + inpvar.m_name 
				+ " = " + inpvar.m_type + "(" + inpvar.m_value.join(", ") 
				+  ");";
		}

		inpvar.m_shaderDefinedMask = glshaderbit;
		m_inputs.push_back(inpvar);

advance:
		// Advance
		inputEl = inputEl.getNextSiblingElement("input");
	} while(inputEl);
}
开发者ID:ezhangle,项目名称:anki-3d-engine,代码行数:101,代码来源:MaterialProgramCreator.cpp

示例6: parseProgramTag

//==============================================================================
void MaterialProgramCreator::parseProgramTag(
	const XmlElement& programEl)
{
	// <type>
	CString type = programEl.getChildElement("type"_cstr).getText();
	GLbitfield glshaderbit;
	GLenum glshader;
	U shaderidx;
	getShaderInfo(type, glshader, glshaderbit, shaderidx);

	m_source[shaderidx] = MPStringList(m_alloc);
	auto& lines = m_source[shaderidx];
	lines.push_back(ANKI_STRL("#pragma anki type "_cstr) + type);

	if(glshader == GL_TESS_CONTROL_SHADER 
		|| glshader == GL_TESS_EVALUATION_SHADER)
	{
		m_tessellation = true;
	}

	// <includes></includes>
	XmlElement includesEl = programEl.getChildElement("includes"_cstr);
	XmlElement includeEl = includesEl.getChildElement("include"_cstr);

	do
	{
		MPString fname(includeEl.getText(), m_alloc);
		lines.push_back(
			ANKI_STRL("#pragma anki include \""_cstr) + fname + "\""_cstr);

		includeEl = includeEl.getNextSiblingElement("include"_cstr);
	} while(includeEl);

	// Inputs

	// Block
	if(m_uniformBlock.size() > 0 
		&& (m_uniformBlockReferencedMask | glshaderbit))
	{
		// TODO Make block SSB when driver bug is fixed
		lines.push_back(ANKI_STRL(
			"\nlayout(binding = 0, std140) uniform bDefaultBlock\n{"_cstr));

		lines.insert(
			lines.end(), m_uniformBlock.begin(), m_uniformBlock.end());

		lines.push_back(ANKI_STRL("};"));
	}

	// Other variables
	for(Input& in : m_inputs)
	{
		if(!in.m_inBlock && (in.m_shaderDefinedMask | glshaderbit))
		{
			lines.push_back(in.m_line);
		}
	}

	// <operations></operations>
	lines.push_back(ANKI_STRL("\nvoid main()\n{"));

	XmlElement opsEl = programEl.getChildElement("operations");
	XmlElement opEl = opsEl.getChildElement("operation");
	do
	{
		MPString out(m_alloc);
		parseOperationTag(opEl, glshader, glshaderbit, out);
		lines.push_back(out);

		// Advance
		opEl = opEl.getNextSiblingElement("operation");
	} while(opEl);

	lines.push_back(ANKI_STRL("}\n"));
}
开发者ID:ezhangle,项目名称:anki-3d-engine,代码行数:76,代码来源:MaterialProgramCreator.cpp

示例7: 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


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