本文整理汇总了C++中CXMLNode::GetChildNode方法的典型用法代码示例。如果您正苦于以下问题:C++ CXMLNode::GetChildNode方法的具体用法?C++ CXMLNode::GetChildNode怎么用?C++ CXMLNode::GetChildNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CXMLNode
的用法示例。
在下文中一共展示了CXMLNode::GetChildNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
Bool CMaterialResource::Init()
{
CXMLDocument document;
document.Load( m_FilePath.c_str() );
CXMLNode rootNode = document.GetRootNode();
//Read out textures
CXMLNode childNode = rootNode.GetChildNode( "Texture2D" );
while ( childNode.IsEmpty() == false )
{
CXMLAttribute attribute = childNode.GetAttribute( "Hash" );
const Uint hash = (Uint)strtoul( attribute.GetValue(), NULL, 0 );
AddDependentHash( hash );
childNode = childNode.GetNextSibling();
}
if ( m_DependenciesLeft == 0 )
{
return true;
}
return false;
}
示例2: Load
void CMaterialResource::Load()
{
m_IsLoaded = true;
CXMLDocument document;
document.Load( m_FilePath.c_str() );
CXMLNode rootNode = document.GetRootNode();
//Read out shaders
CXMLNode childNode = rootNode.GetChildNode( "Shader" );
CXMLAttribute attribute = childNode.GetAttribute( "File" );
std::string shaderPath; shaderPath += "../Content/";
shaderPath += attribute.GetValue();
//Read out defines
childNode = rootNode.GetChildNode( "ShaderDefine" );
while ( childNode.IsEmpty() == false )
{
attribute = childNode.GetAttribute( "Name" );
const Char* name = attribute.GetValue( "" );
if ( strcmp( name, "" ) != 0 )
{
m_ShaderDefines.push_back( name );
}
childNode = childNode.GetNextSibling();
}
//Build hash
Uint hash = HashString( shaderPath.c_str() );
hash += m_ShaderDefines.size();
for ( Uint i = 0; i < m_ShaderDefines.size(); ++i )
{
hash += HashString( m_ShaderDefines[i].c_str() );
}
CResource* shaderResource;
if ( ( shaderResource = CResourceManager::GetInstance()->GetResourceByHash( hash ) ) == NULL )
{
shaderResource = CResourceManager::GetInstance()->AddShaderResource( shaderPath.c_str(), hash, m_ShaderDefines );
}
m_ShaderResource = (CShaderResource*)shaderResource;
m_Shader = m_ShaderResource->GetShader();
//Read terms
childNode = rootNode.GetChildNode( "Terms" );
//Emmisive
CXMLNode termNode = childNode.GetChildNode( "Emissive" );
attribute = termNode.GetAttribute( "R" ); m_EmissiveTerm.X = (Float)atof( attribute.GetValue() );
attribute = termNode.GetAttribute( "G" ); m_EmissiveTerm.Y = (Float)atof( attribute.GetValue() );
attribute = termNode.GetAttribute( "B" ); m_EmissiveTerm.Z = (Float)atof( attribute.GetValue() );
//Diffuse
termNode = childNode.GetChildNode( "Diffuse" );
attribute = termNode.GetAttribute( "R" ); m_DiffuseTerm.X = (Float)atof( attribute.GetValue() );
attribute = termNode.GetAttribute( "G" ); m_DiffuseTerm.Y = (Float)atof( attribute.GetValue() );
attribute = termNode.GetAttribute( "B" ); m_DiffuseTerm.Z = (Float)atof( attribute.GetValue() );
//Specular
termNode = childNode.GetChildNode( "Specular" );
attribute = termNode.GetAttribute( "R" ); m_SpecularTerm.X = (Float)atof( attribute.GetValue() );
attribute = termNode.GetAttribute( "G" ); m_SpecularTerm.Y = (Float)atof( attribute.GetValue() );
attribute = termNode.GetAttribute( "B" ); m_SpecularTerm.Z = (Float)atof( attribute.GetValue() );
//Ambient
termNode = childNode.GetChildNode( "Ambient" );
attribute = termNode.GetAttribute( "R" ); m_AmbientTerm.X = (Float)atof( attribute.GetValue() );
attribute = termNode.GetAttribute( "G" ); m_AmbientTerm.Y = (Float)atof( attribute.GetValue() );
attribute = termNode.GetAttribute( "B" ); m_AmbientTerm.Z = (Float)atof( attribute.GetValue() );
//Specular power
termNode = childNode.GetChildNode( "SpecularPower" );
if ( termNode.IsEmpty() == false )
{
attribute = termNode.GetAttribute( "Value" );
m_SpecularPower = (Float)atof( attribute.GetValue( "1.0f" ) );
}
termNode = childNode.GetChildNode( "Reflection" );
if ( termNode.IsEmpty() == false )
{
attribute = termNode.GetAttribute( "Value" );
m_Reflection = (Float)atof( attribute.GetValue( "0.0f" ) );
}
termNode = childNode.GetChildNode( "Refraction" );
if ( termNode.IsEmpty() == false )
{
attribute = termNode.GetAttribute( "Value" );
m_Refraction = (Float)atof( attribute.GetValue( "0.0f" ) );
}
termNode = childNode.GetChildNode( "Transmittance" );
if ( termNode.IsEmpty() == false )
{
attribute = termNode.GetAttribute( "Value" );
m_Transmittance = (Float)atof( attribute.GetValue( "0.0f" ) );
}
termNode = childNode.GetChildNode( "FresnelPower" );
if ( termNode.IsEmpty() == false )
{
attribute = termNode.GetAttribute( "Value" );
//.........这里部分代码省略.........