本文整理汇总了C++中XMLElement类的典型用法代码示例。如果您正苦于以下问题:C++ XMLElement类的具体用法?C++ XMLElement怎么用?C++ XMLElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XMLElement类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: SetMemoryUse
bool Technique::BeginLoad(Deserializer& source)
{
passes_.Clear();
SetMemoryUse(sizeof(Technique));
SharedPtr<XMLFile> xml(new XMLFile(context_));
if (!xml->Load(source))
return false;
XMLElement rootElem = xml->GetRoot();
if (rootElem.HasAttribute("desktop"))
isDesktop_ = rootElem.GetBool("desktop");
String globalVS = rootElem.GetAttribute("vs");
String globalPS = rootElem.GetAttribute("ps");
String globalVSDefines = rootElem.GetAttribute("vsdefines");
String globalPSDefines = rootElem.GetAttribute("psdefines");
// End with space so that the pass-specific defines can be appended
if (!globalVSDefines.Empty())
globalVSDefines += ' ';
if (!globalPSDefines.Empty())
globalPSDefines += ' ';
bool globalAlphaMask = false;
if (rootElem.HasAttribute("alphamask"))
globalAlphaMask = rootElem.GetBool("alphamask");
XMLElement passElem = rootElem.GetChild("pass");
while (passElem)
{
if (passElem.HasAttribute("name"))
{
Pass* newPass = CreatePass(passElem.GetAttribute("name"));
if (passElem.HasAttribute("desktop"))
newPass->SetIsDesktop(passElem.GetBool("desktop"));
// Append global defines only when pass does not redefine the shader
if (passElem.HasAttribute("vs"))
{
newPass->SetVertexShader(passElem.GetAttribute("vs"));
newPass->SetVertexShaderDefines(passElem.GetAttribute("vsdefines"));
}
else
{
newPass->SetVertexShader(globalVS);
newPass->SetVertexShaderDefines(globalVSDefines + passElem.GetAttribute("vsdefines"));
}
if (passElem.HasAttribute("ps"))
{
newPass->SetPixelShader(passElem.GetAttribute("ps"));
newPass->SetPixelShaderDefines(passElem.GetAttribute("psdefines"));
}
else
{
newPass->SetPixelShader(globalPS);
newPass->SetPixelShaderDefines(globalPSDefines + passElem.GetAttribute("psdefines"));
}
if (passElem.HasAttribute("lighting"))
{
String lighting = passElem.GetAttributeLower("lighting");
newPass->SetLightingMode((PassLightingMode)GetStringListIndex(lighting.CString(), lightingModeNames,
LIGHTING_UNLIT));
}
if (passElem.HasAttribute("blend"))
{
String blend = passElem.GetAttributeLower("blend");
newPass->SetBlendMode((BlendMode)GetStringListIndex(blend.CString(), blendModeNames, BLEND_REPLACE));
}
if (passElem.HasAttribute("depthtest"))
{
String depthTest = passElem.GetAttributeLower("depthtest");
if (depthTest == "false")
newPass->SetDepthTestMode(CMP_ALWAYS);
else
newPass->SetDepthTestMode((CompareMode)GetStringListIndex(depthTest.CString(), compareModeNames, CMP_LESS));
}
if (passElem.HasAttribute("depthwrite"))
newPass->SetDepthWrite(passElem.GetBool("depthwrite"));
if (passElem.HasAttribute("alphamask"))
newPass->SetAlphaMask(passElem.GetBool("alphamask"));
else
newPass->SetAlphaMask(globalAlphaMask);
}
else
LOGERROR("Missing pass name");
passElem = passElem.GetNext("pass");
}
return true;
}
开发者ID:Boshin,项目名称:Urho3D,代码行数:97,代码来源:Technique.cpp
示例2: switch
void RenderPathCommand::Load(const XMLElement& element)
{
type_ = (RenderCommandType)GetStringListIndex(element.GetAttributeLower("type").CString(), commandTypeNames, CMD_NONE);
tag_ = element.GetAttribute("tag");
if (element.HasAttribute("enabled"))
enabled_ = element.GetBool("enabled");
if (element.HasAttribute("metadata"))
metadata_ = element.GetAttribute("metadata");
switch (type_)
{
case CMD_CLEAR:
if (element.HasAttribute("color"))
{
clearFlags_ |= CLEAR_COLOR;
if (element.GetAttributeLower("color") == "fog")
useFogColor_ = true;
else
clearColor_ = element.GetColor("color");
}
if (element.HasAttribute("depth"))
{
clearFlags_ |= CLEAR_DEPTH;
clearDepth_ = element.GetFloat("depth");
}
if (element.HasAttribute("stencil"))
{
clearFlags_ |= CLEAR_STENCIL;
clearStencil_ = (unsigned)element.GetInt("stencil");
}
break;
case CMD_SCENEPASS:
pass_ = element.GetAttribute("pass");
sortMode_ =
(RenderCommandSortMode)GetStringListIndex(element.GetAttributeLower("sort").CString(), sortModeNames, SORT_FRONTTOBACK);
if (element.HasAttribute("marktostencil"))
markToStencil_ = element.GetBool("marktostencil");
if (element.HasAttribute("vertexlights"))
vertexLights_ = element.GetBool("vertexlights");
break;
case CMD_FORWARDLIGHTS:
pass_ = element.GetAttribute("pass");
if (element.HasAttribute("uselitbase"))
useLitBase_ = element.GetBool("uselitbase");
break;
case CMD_LIGHTVOLUMES:
case CMD_QUAD:
vertexShaderName_ = element.GetAttribute("vs");
pixelShaderName_ = element.GetAttribute("ps");
if (type_ == CMD_QUAD && element.HasAttribute("blend"))
{
String blend = element.GetAttributeLower("blend");
blendMode_ = ((BlendMode)GetStringListIndex(blend.CString(), blendModeNames, BLEND_REPLACE));
}
break;
case CMD_SENDEVENT:
eventName_ = element.GetAttribute("name");
break;
default:
break;
}
// By default use 1 output, which is the viewport
outputs_.Resize(1);
outputs_[0] = MakePair(String("viewport"), FACE_POSITIVE_X);
if (element.HasAttribute("output"))
outputs_[0].first_ = element.GetAttribute("output");
if (element.HasAttribute("face"))
outputs_[0].second_ = (CubeMapFace)element.GetInt("face");
if (element.HasAttribute("depthstencil"))
depthStencilName_ = element.GetAttribute("depthstencil");
// Check for defining multiple outputs
XMLElement outputElem = element.GetChild("output");
while (outputElem)
{
unsigned index = (unsigned)outputElem.GetInt("index");
if (index < MAX_RENDERTARGETS)
{
if (index >= outputs_.Size())
outputs_.Resize(index + 1);
outputs_[index].first_ = outputElem.GetAttribute("name");
outputs_[index].second_ = outputElem.HasAttribute("face") ? (CubeMapFace)outputElem.GetInt("face") : FACE_POSITIVE_X;
}
outputElem = outputElem.GetNext("output");
}
// Shader compile flags & parameters
vertexShaderDefines_ = element.GetAttribute("vsdefines");
pixelShaderDefines_ = element.GetAttribute("psdefines");
XMLElement parameterElem = element.GetChild("parameter");
while (parameterElem)
{
String name = parameterElem.GetAttribute("name");
shaderParameters_[name] = Material::ParseShaderParameterValue(parameterElem.GetAttribute("value"));
//.........这里部分代码省略.........
开发者ID:1vanK,项目名称:Urho3D,代码行数:101,代码来源:RenderPath.cpp
示例3: if
std::shared_ptr<XMLElement> JointElement::childElementForName(const std::string& name) {
// As an alternative for simple elements, instead of creating other classes,
// I implement the simple functions of the generic element
if (name == "origin") {
return std::make_shared<OriginElement>(m_jointFrame);
} else if (name == "parent" || name == "child") {
std::string& ref = (name == "parent") ? m_parentLink : m_childLink;
XMLElement* element = new XMLElement(name);
element->setAttributeCallback([&ref](const std::unordered_map<std::string, std::shared_ptr<XMLAttribute>>& attributes) {
auto linkName = attributes.find("link");
if (linkName != attributes.end()) {
ref = linkName->second->value();
}
return true;
});
return std::shared_ptr<XMLElement>(element);
} else if (name == "axis") {
XMLElement* element = new XMLElement(name);
element->setAttributeCallback([this](const std::unordered_map<std::string, std::shared_ptr<XMLAttribute>>& attributes) {
auto xyz = attributes.find("xyz");
if (xyz != attributes.end()) {
Vector3 direction;
if (vector3FromString(xyz->second->value(), direction)) {
m_axis = Axis(Direction(direction(0), direction(1), direction(2)),
Position(0.0, 0.0, 0.0));
}
}
return true;
});
return std::shared_ptr<XMLElement>(element);
} else if (name == "limit") {
m_limits = std::make_shared<Limits>();
m_limits->positionLower = .0;
m_limits->positionUpper = .0;
// TODO: check how the defaults/required works
XMLElement* element = new XMLElement(name);
element->setAttributeCallback([this](const std::unordered_map<std::string, std::shared_ptr<XMLAttribute>>& attributes) {
auto found = attributes.find("lower");
if (found != attributes.end()) {
double value = 0;
if (stringToDoubleWithClassicLocale(found->second->value(), value)) {
m_limits->positionLower = value;
}
}
found = attributes.find("upper");
if (found != attributes.end()) {
double value = 0;
if (stringToDoubleWithClassicLocale(found->second->value(), value)) {
m_limits->positionUpper = value;
}
}
found = attributes.find("effort");
if (found != attributes.end()) {
double value = 0;
if (stringToDoubleWithClassicLocale(found->second->value(), value)) {
m_limits->effort = value;
}
}
found = attributes.find("velocity");
if (found != attributes.end()) {
double value = 0;
if (stringToDoubleWithClassicLocale(found->second->value(), value)) {
m_limits->velocity = value;
}
}
// TODO: check if we need to impose restrictions on the joint type
return true;
});
return std::shared_ptr<XMLElement>(element);
}
return std::make_shared<XMLElement>(name);
}
开发者ID:robotology,项目名称:idyntree,代码行数:75,代码来源:JointElement.cpp
注:本文中的XMLElement类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论