本文整理汇总了C++中TextParser::GetNode方法的典型用法代码示例。如果您正苦于以下问题:C++ TextParser::GetNode方法的具体用法?C++ TextParser::GetNode怎么用?C++ TextParser::GetNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextParser
的用法示例。
在下文中一共展示了TextParser::GetNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromText
void Sprite::LoadFromText(const char *text)
{
TextParser parser;
parser.Parse(text);
TextParser::NODE *node = NULL;
if ((node = parser.GetNode("FILETYPE")) && node->values[0] == "SPRITE")
{
if ((node = parser.GetNode("RESOURCE")))
{
_texture = static_cast<Texture*>(LE_ResourceManager.GetResourceWithRegister(node->values[0].GetCharPtr())->data);
}
if ((node = parser.GetNode("FRAMES")))
{
for (size_t i = 0; i<node->children.count(); i++)
{
TextParser::NODE *child = node->children[i];
if (child)
{
TextParser::NODE *node_rect = child->FindChild("RECT");
if (node_rect)
{
AddFrame(iRect(node_rect->values[0].ToInt(),
node_rect->values[1].ToInt(),
node_rect->values[2].ToInt(),
node_rect->values[3].ToInt()
));
}
}
}
}
}
}
示例2: LoadFromText
void SceneManager::LoadFromText(const char *text)
{
TextParser parser;
parser.Parse(text);
TextParser::NODE *node = NULL;
if ((node = parser.GetNode("FILETYPE")) && node->values[0] == "SCENE")
{
TextParser::NODE *node_data = parser.GetNode("DATA");
if (node_data)
{
// Models
TextParser::NODE *node_models = node_data->FindChild("MODELS");
if (node_models)
{
for(size_t i=0;i<node_models->children.size();i++)
{
TextParser::NODE *child = node_models->children[i];
TextParser::NODE *node_filename = NULL;
if ( child->name == "MODEL" &&
(node_filename = child->FindChild("FILENAME")))
{ // MODEL
Model *model = new Model(node_filename->values[0].GetCharPtr());
TextParser::NODE *node_position = child->FindChild("POSITION");
if (node_position) model->SetPosition(node_position->ToFVector3());
TextParser::NODE *node_scale = child->FindChild("SCALE");
if (node_scale) model->SetScale(node_scale->ToFVector3());
TextParser::NODE *node_rotation = child->FindChild("ROTATION");
if (node_rotation) model->SetRotation(node_rotation->ToFVector3());
mModels.push_back(model);
}
}
}
// Lights
TextParser::NODE *node_lights = node_data->FindChild("LIGHTS");
if (node_lights)
{
for(size_t i=0;i<node_lights->children.size();i++)
{
Light *light = NULL;
TextParser::NODE *child = node_lights->children[i];
TextParser::NODE *node_type = child->FindChild("TYPE");
if (node_type->values[0] == "Point")
{
light = new PointLight();
}
else if (node_type->values[0] == "Directional")
{
light = new DirectionalLight();
}
else if (node_type->values[0] == "Ambient")
{
light = new AmbientLight();
}
if (!light) continue;
TextParser::NODE *node_color = child->FindChild("COLOR");
if (node_color)
{
light->SetColor(node_color->ToFVector3());
}
TextParser::NODE *node_intensity = child->FindChild("INTENSITY");
if (node_intensity)
{
light->SetIntensity(node_intensity->values[0].ToFloat());
}
TextParser::NODE *node_pos = child->FindChild("POSITION");
if (node_pos && light->GetType() == Light::TYPE_POINT)
{
((PointLight*)light)->SetPosition(node_pos->ToFVector3());
}
TextParser::NODE *node_scl = child->FindChild("SCALE");
if (node_scl && light->GetType() == Light::TYPE_POINT)
{
((PointLight*)light)->SetScale(node_scl->ToFVector3());
}
switch(light->GetType())
{
case Light::TYPE_POINT:
{
TextParser::NODE *node_range = child->FindChild("RANGE");
if (node_range)
{
((PointLight*)light)->SetRange(node_range->values[0].ToFloat());
}
TextParser::NODE *node_exp = child->FindChild("EXPONENT");
if (node_exp)
{
((PointLight*)light)->SetExponent(node_exp->values[0].ToFloat());
}
} break;
}
AddLight(light);
}
}
}
}
}