本文整理汇总了C++中rapidxml::xml_node::first_attribute方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::first_attribute方法的具体用法?C++ xml_node::first_attribute怎么用?C++ xml_node::first_attribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidxml::xml_node
的用法示例。
在下文中一共展示了xml_node::first_attribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addCuboid
void Level::addCuboid(const rapidxml::xml_node<> &cuboidNode)
{
osg::Vec3 from = getVectorFromXMLNode("position", cuboidNode);
osg::Vec3 size = getVectorFromXMLNode("size", cuboidNode);
Cuboid *cuboid = NULL;
if(cuboidNode.first_attribute("type") != 0)
{
std::string type = cuboidNode.first_attribute("type")->value();
if(type == "accelerate")
cuboid = new AccelerationCuboid(from, size);
else if(type == "decelerate")
cuboid = new DecelerationCuboid(from, size);
}
if(cuboid == NULL)
{
cuboid = new Cuboid(from, size);
}
_level->addChild(cuboid->getNode());
_collisionObjects.push_back(cuboid->getRigidBody());
// save minimal x values for buckets of close y values
// needed for detection whether player is falling to dead
int yBucketIndex = (int)((from.y() + size.y()) / 20.0f);
while(_minZValues.size() <= yBucketIndex)
_minZValues.push_back(from.z());
// if current cuboid is lower then z -> adjust bucket value
if(from.z() < _minZValues[yBucketIndex])
_minZValues[yBucketIndex] = from.z();
}
示例2: parseItem
void parseItem( const rapidxml::xml_node<> &node, XmlTree *parent, XmlTree *result, const XmlTree::ParseOptions &options )
{
*result = XmlTree( node.name(), node.value(), parent );
for( const rapidxml::xml_node<> *item = node.first_node(); item; item = item->next_sibling() ) {
XmlTree::NodeType type;
switch( item->type() ) {
case rapidxml::node_element:
type = XmlTree::NODE_ELEMENT;
break;
case rapidxml::node_cdata: {
if( options.getCollapseCData() ) {
result->setValue( result->getValue() + item->value() );
continue;
}
else {
type = XmlTree::NODE_CDATA;
}
}
break;
case rapidxml::node_comment:
type = XmlTree::NODE_COMMENT;
break;
case rapidxml::node_doctype: {
result->setDocType( item->value() );
continue;
}
case rapidxml::node_data: {
if( ! options.getIgnoreDataChildren() )
type = XmlTree::NODE_DATA;
else
continue;
}
break;
default:
continue;
}
result->getChildren().push_back( unique_ptr<XmlTree>( new XmlTree ) );
parseItem( *item, result, result->getChildren().back().get(), options );
result->getChildren().back()->setNodeType( type );
}
for( rapidxml::xml_attribute<> *attr = node.first_attribute(); attr; attr = attr->next_attribute() )
result->getAttributes().push_back( XmlTree::Attr( result, attr->name(), attr->value() ) );
}
示例3: addTunnel
void Level::addTunnel(const rapidxml::xml_node<> &tunnelNode)
{
osg::Node *tunnelModel = osgDB::readNodeFile(TUNNEL_MODEL_FILE);
osg::PositionAttitudeTransform *tunnelTransform = new osg::PositionAttitudeTransform();
osg::Vec3 position = getVectorFromXMLNode("position", tunnelNode);
tunnelTransform->addChild(tunnelModel);
tunnelTransform->setPosition(position);
tunnelTransform->setScale(osg::Vec3f(1.0f, atof(tunnelNode.first_attribute("length")->value()), 1.0f));
tunnelTransform->setNodeMask(RECEIVE_SHADOW_MASK);
_level->addChild(tunnelTransform);
/*
btConvexTriangleMeshShape* mesh = osgbBullet::btConvexTriMeshCollisionShapeFromOSG(tunnelPat);
btTransform shapeTransform;
shapeTransform.setIdentity();
cs->addChildShape(shapeTransform, mesh);
*/
}
示例4: firstAttribute
//===========================================
// XmlNode::firstAttribute
//===========================================
inline XmlAttribute XmlNode::firstAttribute() const {
if (isNull()) throw XmlException("Node is NULL", __FILE__, __LINE__);
return XmlAttribute(m_doc, m_node->first_attribute(), m_file);
}