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


C++ xml_node::begin方法代码示例

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


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

示例1: read_array_uint

//-----------------------------------------------------------------------------
void XMLMesh::read_array_uint(std::vector<std::size_t>& array,
                              const pugi::xml_node xml_array)
{
  // Check that we have an array
  const std::string name = xml_array.name();
  if (name != "array")
  {
    dolfin_error("XMLMesh.cpp",
                 "read mesh array data from XML file",
                 "Expecting an XML array node");
  }

  // Check type is unit
  const std::string type = xml_array.attribute("type").value();
  if (type != "uint")
  {
    dolfin_error("XMLMesh.cpp",
                 "read mesh array data from XML file",
                 "Expecting an XML array node");
  }

  // Get size and resize vector
  const std::size_t size = xml_array.attribute("size").as_uint();
  array.resize(size);

  // Iterate over array entries
  for (pugi::xml_node_iterator it = xml_array.begin(); it !=xml_array.end();
       ++it)
  {
    const std::size_t index = it->attribute("index").as_uint();
    const double value = it->attribute("value").as_uint();
    dolfin_assert(index < size);
    array[index] = value;
  }
}
开发者ID:YannCobigo,项目名称:dolfin,代码行数:36,代码来源:XMLMesh.cpp

示例2: FromXml

static
void FromXml(const pugi::xml_node& xmlNode, DataSetElement& parent)
{
    // ignore non-named XML nodes
    //
    // pugi::xml separates XML parts into more node types than we use
    //
    const string& label = xmlNode.name();
    if (label.empty())
        return;

    // label & text
    DataSetElement e(xmlNode.name(), FromInputXml());
    e.Text(xmlNode.text().get());

    // iterate attributes
    auto attrIter = xmlNode.attributes_begin();
    auto attrEnd  = xmlNode.attributes_end();
    for ( ; attrIter != attrEnd; ++attrIter )
        e.Attribute(attrIter->name(), attrIter->value());

    // iterate children, recursively building up subtree
    auto childIter = xmlNode.begin();
    auto childEnd = xmlNode.end();
    for ( ; childIter != childEnd; ++childIter ) {
        pugi::xml_node childNode = *childIter;
        FromXml(childNode, e);
    }

    // add our element to its parent
    parent.AddChild(e);
}
开发者ID:Debian,项目名称:pbbam,代码行数:32,代码来源:XmlReader.cpp

示例3: mergeNodes

void mergeNodes(pugi::xml_node toNode, pugi::xml_node& fromNode)
{
  // Base case = both nodes are text nodes
  pugi::xml_text fromNodeText = fromNode.text();
  pugi::xml_text toNodeText = toNode.text();
  if (fromNodeText && toNodeText) {
    SBLog::info() << "Overwriting template value of \"" << toNode.name() << "\" from \"" << toNodeText.get() << "\" to \"" << fromNodeText.get() << "\"." << std::endl;
    toNodeText.set(fromNodeText.get());
    return;
  }

  // Calculate number of children in toNode
  unsigned maxDistance = std::distance(toNode.begin(), toNode.end());

  // Merge children
  for (pugi::xml_node fromNodeChild = fromNode.first_child(); fromNodeChild; fromNodeChild = fromNodeChild.next_sibling()) {
    // Find appropriate merge point
    pugi::xml_node toNodeChild = findSimilarNode(fromNodeChild, toNode, maxDistance);
    if (toNodeChild) {
      mergeNodes(toNodeChild, fromNodeChild);
    } else {
      toNode.append_copy(fromNodeChild);
    }
  }

  // Erase fromNode
  removeNode(fromNode);
}
开发者ID:netroby,项目名称:WinObjC,代码行数:28,代码来源:vshelpers.cpp

示例4: Parse_WMS_1_3_0_Service_Node

void Parse_WMS_1_3_0_Service_Node( Capabilities::ptr_t capabilities,
                                   pugi::xml_node&     root_node,
                                   Status&             status )
{
    // Log Entry
    BOOST_LOG_TRIVIAL(debug) << "Parsing WMS 1.3.0 Service XML Node.";

    // Iterate over child nodes
    std::string node_name;
    pugi::xml_node_iterator nit = root_node.begin();
    for( ; nit != root_node.end(); nit++ )
    {
        node_name = nit->name();

        // Check if Name Node
        if( node_name == "Name" ){
            capabilities->Set_Service_Name( nit->value() );
        }

        // Otherwise, print warning
        else{
            BOOST_LOG_TRIVIAL(warning) << "Found unknown node: " << nit->name();
        }
    }

    // Return Success
    status = Status(StatusCode::SUCCESS);

}
开发者ID:marvins,项目名称:MapServerConnector,代码行数:29,代码来源:OGC_XML_Utilities.cpp

示例5: parseNode

bool Config::parseNode(const pugi::xml_node& node) {
    UnicodeString currentPath = StringConverter::fromUtf8(node.path('/'));
    currentPath.append("@");

    pugi::xml_node::attribute_iterator attrIter = node.attributes_begin();
    pugi::xml_node::attribute_iterator attrEnd = node.attributes_end();

    for (; attrIter != attrEnd; ++attrIter) {
        UnicodeString configKey = currentPath;
        configKey.append(attrIter->name());
        std::map<UnicodeString, Variable>::iterator itm = variablesMap_.find(configKey);
        if (itm != variablesMap_.end()) {
            if (!itm->second.parse(attrIter->value())) {
                return false;
            }
        } else {
            LOG_WARN << "Ignoring unknown config value " << configKey << std::endl;
        }
    }

    pugi::xml_node::iterator nodeIter = node.begin();
    pugi::xml_node::iterator nodeEnd = node.end();

    for (; nodeIter != nodeEnd; ++nodeIter) {
        if (nodeIter->type() == pugi::node_element) {
            if (!parseNode(*nodeIter)) {
                return false;
            }
        }
    }

    return true;
}
开发者ID:abnr,项目名称:fluorescence,代码行数:33,代码来源:config.cpp

示例6: loadTextureFromXml

//Creates and initializes a texture object from xml
Texture Visitor::loadTextureFromXml(pugi::xml_node& xml_text_data)
{
	Texture to_return;// = nullptr;
	if (std::strcmp(xml_text_data.name(), "Texture") == 0)
	{
		pugi::xml_attribute tex_path = xml_text_data.attribute("TexturePath");
		to_return = scene_objects.loadTexture(tex_path.as_string());
		if (glGetError() != 0)
			std::cout << "Illegal arguments set for texture";
		for (pugi::xml_node_iterator tex_parameter = xml_text_data.begin(); tex_parameter != xml_text_data.end(); ++tex_parameter)
			setGLCodeFromXml(*tex_parameter, to_return);
	}
	//TODO: Fix this, does not work because load3DTexture returns a pointer
	else if (std::strcmp(xml_text_data.name(), "Texture3D") == 0)
	{
		pugi::xml_attribute tex_path = xml_text_data.attribute("TexturePath");
		//to_return = scene_objects.load3DTexture(tex_path.as_string());
		for (pugi::xml_node_iterator tex_parameter = xml_text_data.begin(); tex_parameter != xml_text_data.end(); ++tex_parameter)
			setGLCodeFromXml(*tex_parameter, to_return);
	}
	else if (std::strcmp(xml_text_data.name(), "FrameBufferTexture") == 0)
	{
		int left = xml_text_data.attribute("left").as_int();
		int bottom = xml_text_data.attribute("Bottom").as_int();
		int width = xml_text_data.attribute("Width").as_int();
		int height = xml_text_data.attribute("Height").as_int();
		std::string name = xml_text_data.attribute("Name").as_string();

		//to_return = scene_objects.loadFramebufferTexture(left, bottom, width, height, name);

		for (pugi::xml_node_iterator tex_parameter = xml_text_data.begin(); tex_parameter != xml_text_data.end(); ++tex_parameter)
			setGLCodeFromXml(*tex_parameter, to_return);
		for (pugi::xml_node_iterator tex_parameter = xml_text_data.begin(); tex_parameter != xml_text_data.end(); ++tex_parameter)
		{
			//if (strcmp(tex_parameter->name(), "TriangleMesh") == 0)
			//	(static_cast<FrameBufferTexture*>(to_return))->addMesh(loadMeshFromXml(*tex_parameter));
		}
	}
	else
		std::cout << "Undefined XML node type, check resource file for errors." << std::endl;

	return to_return;
}
开发者ID:J-norton,项目名称:Cuda-Game-Engine,代码行数:44,代码来源:Visitor.cpp

示例7: Parse_WMS_1_3_0_Capability_Node

void Parse_WMS_1_3_0_Capability_Node( Capabilities::ptr_t capabilities,
                                      pugi::xml_node&     root_node,
                                      Status&             status )
{
    // Log Entry
    BOOST_LOG_TRIVIAL(debug) << "Parsing WMS 1.3.0 Capability XML Node.";

    // Iterate over child nodes
    std::string node_name;
    pugi::xml_node_iterator nit = root_node.begin();
    for( ; nit != root_node.end(); nit++ )
    {
        node_name = nit->name();

        // Check if Request Node
        if( node_name == "Request" )
        {
             
            // Parse the Request Node
            Parse_WMS_1_3_0_Request_Node( capabilities,
                                         (*nit),
                                          status );
            
        }
        
        // Check if Layer Node
        else if( node_name == "Layer" )
        {

            // Parse the Layer Node
            Parse_WMS_1_3_0_Layer_Node( capabilities,
                                        (*nit),
                                        status );

        }

        // Otherwise, print warning
        else{
            BOOST_LOG_TRIVIAL(warning) << "Found unknown node: " << nit->name();
        }
    }
    
    
    // Log Exit
    BOOST_LOG_TRIVIAL(debug) << "Finished Parsing WMS 1.3.0 Capability XML Node.";

    // Return Success
    status = Status(StatusCode::SUCCESS);

}
开发者ID:marvins,项目名称:MapServerConnector,代码行数:50,代码来源:OGC_XML_Utilities.cpp

示例8: Parse_WMS_1_3_0_Layer_Node

void Parse_WMS_1_3_0_Layer_Node( Capabilities::ptr_t capabilities,
                                 OGC_Layer::ptr_t    layer_node,
                                 pugi::xml_node&     root_node,
                                 Status&             status )
{
     // Log Entry
    BOOST_LOG_TRIVIAL(debug) << "Parsing WMS 1.3.0 Layer XML Node.";

    // Iterate over child nodes
    std::string node_name;
    pugi::xml_node_iterator nit = root_node.begin();
    for( ; nit != root_node.end(); nit++ )
    {
        node_name = nit->name();
        
        // Check Name
        if( node_name == "Name" )
        {
            layer_node->Set_Name( nit->text().as_string() );
        }

        // Check Title
        else if( node_name == "Title" )
        {
            layer_node->Set_Title( nit->text().as_string() );
        }

        // Check CRS
        else if( node_name == "CRS" )
        {
            layer_node->Add_CRS( nit->text().as_string() );
        }

        // Check Bounding Box
        else if( node_name == "BoundingBox" )
        {
            layer_node->Add_BBox( Parse_WMS_1_3_0_BoundingBox_Node((*nit), status));
        }
        
        // Otherwise, print warning
        else{
            BOOST_LOG_TRIVIAL(warning) << "Found unknown node: " << nit->name();
        }
    }

    // Return Success
    status = Status(StatusCode::SUCCESS);


}
开发者ID:marvins,项目名称:MapServerConnector,代码行数:50,代码来源:OGC_XML_Utilities.cpp

示例9: print_node

void xmlManager::print_node(pugi::xml_node source_node, string prefix) {

    cout << prefix << source_node.name() << ": " << source_node.value() << endl;

    for (pugi::xml_attribute_iterator it = source_node.attributes_begin();
         it != source_node.attributes_end();
         it++)
        cout << prefix + "\t" << it->name() << " : " << it->value() << endl;

    for (pugi::xml_node_iterator it = source_node.begin();
         it != source_node.end();
         it++)
        print_node(*it, prefix + "\t");

}
开发者ID:intel-ctrlsys,项目名称:sensys,代码行数:15,代码来源:xmlManager.cpp

示例10: mergeNodes

	void SettingsManager::mergeNodes(pugi::xml_node _nodeTarget, pugi::xml_node _nodeSource)
	{
		bool listElement = MyGUI::utility::endWith(_nodeTarget.name(), ".List");

		// затираем текст у цели потому что любое значение текста источника является конечным
		pugi::xml_node targetTextNode = _nodeTarget.first_child();
		if (!targetTextNode.empty() && targetTextNode.type() == pugi::node_pcdata)
			targetTextNode.set_value("");

		pugi::xml_node sourceTextNode = _nodeSource.first_child();
		if (!sourceTextNode.empty() && sourceTextNode.type() == pugi::node_pcdata)
		{
			targetTextNode = _nodeTarget.first_child();
			if (targetTextNode.empty())
				targetTextNode = _nodeTarget.append_child(pugi::node_pcdata);
			targetTextNode.set_value(sourceTextNode.value());
		}

		for (pugi::xml_node::iterator child = _nodeSource.begin(); child != _nodeSource.end(); child ++)
		{
			if ((*child).type() != pugi::node_element)
				continue;

			pugi::xml_node targetChildNode;

			if (listElement)
			{
				targetChildNode = _nodeTarget.append_child((*child).name());
			}
			else
			{
				targetChildNode = _nodeTarget.child((*child).name());
				if (targetChildNode.empty())
					targetChildNode = _nodeTarget.append_child((*child).name());
			}

			mergeAttributes(targetChildNode, (*child));
			mergeNodes(targetChildNode, (*child));
		}
	}
开发者ID:chhawk,项目名称:MyGUI,代码行数:40,代码来源:SettingsManager.cpp

示例11: Parse_WMS_1_3_0_Request_Node

void Parse_WMS_1_3_0_Request_Node( Capabilities::ptr_t capabilities,
                                   pugi::xml_node&     root_node,
                                   Status&             status )
{
    // Log Entry
    BOOST_LOG_TRIVIAL(debug) << "Parsing WMS 1.3.0 Request XML Node.";

    // Iterate over child nodes
    std::string node_name;
    pugi::xml_node_iterator nit = root_node.begin();
    for( ; nit != root_node.end(); nit++ )
    {
        node_name = nit->name();

        // Otherwise, print warning
        //else{
        //    BOOST_LOG_TRIVIAL(warning) << "Found unknown node: " << nit->name();
        //}
    }

    // Return Success
    status = Status(StatusCode::SUCCESS);

}
开发者ID:marvins,项目名称:MapServerConnector,代码行数:24,代码来源:OGC_XML_Utilities.cpp

示例12: AddNode

void XMLFile::AddNode(const pugi::xml_node& patch, const pugi::xpath_node& original) const
{
    // If pos is null, append or prepend add as a child, otherwise add before or after, the default is to append as a child
    pugi::xml_attribute pos = patch.attribute("pos");
    if (!pos || strlen(pos.value()) <= 0 || strcmp(pos.value(), "append") == 0)
    {
        pugi::xml_node::iterator start = patch.begin();
        pugi::xml_node::iterator end = patch.end();

        // There can not be two consecutive text nodes, so check to see if they need to be combined
        // If they have been we can skip the first node of the nodes to add
        if (CombineText(patch.first_child(), original.node().last_child(), false))
            start++;

        for (; start != end; start++)
            original.node().append_copy(*start);
    }
    else if (strcmp(pos.value(), "prepend") == 0)
    {
        pugi::xml_node::iterator start = patch.begin();
        pugi::xml_node::iterator end = patch.end();

        // There can not be two consecutive text nodes, so check to see if they need to be combined
        // If they have been we can skip the last node of the nodes to add
        if (CombineText(patch.last_child(), original.node().first_child(), true))
            end--;

        pugi::xml_node pos = original.node().first_child();
        for (; start != end; start++)
            original.node().insert_copy_before(*start, pos);
    }
    else if (strcmp(pos.value(), "before") == 0)
    {
        pugi::xml_node::iterator start = patch.begin();
        pugi::xml_node::iterator end = patch.end();

        // There can not be two consecutive text nodes, so check to see if they need to be combined
        // If they have been we can skip the first node of the nodes to add
        if (CombineText(patch.first_child(), original.node().previous_sibling(), false))
            start++;

        // There can not be two consecutive text nodes, so check to see if they need to be combined
        // If they have been we can skip the last node of the nodes to add
        if (CombineText(patch.last_child(), original.node(), true))
            end--;

        for (; start != end; start++)
            original.parent().insert_copy_before(*start, original.node());
    }
    else if (strcmp(pos.value(), "after") == 0)
    {
        pugi::xml_node::iterator start = patch.begin();
        pugi::xml_node::iterator end = patch.end();

        // There can not be two consecutive text nodes, so check to see if they need to be combined
        // If they have been we can skip the first node of the nodes to add
        if (CombineText(patch.first_child(), original.node(), false))
            start++;

        // There can not be two consecutive text nodes, so check to see if they need to be combined
        // If they have been we can skip the last node of the nodes to add
        if (CombineText(patch.last_child(), original.node().next_sibling(), true))
            end--;

        pugi::xml_node pos = original.node();
        for (; start != end; start++)
            pos = original.parent().insert_copy_after(*start, pos);
    }
}
开发者ID:03050903,项目名称:Urho3D,代码行数:69,代码来源:XMLFile.cpp

示例13: synthesizeBlock

UniformBlock Visitor::synthesizeBlock(pugi::xml_node xml_data)
{
	int binding_pt = xml_data.attribute("BindingPoint").as_int();

	UniformBlock to_add = UniformBlock(xml_data.attribute("Name").as_string(), binding_pt);

	for (pugi::xml_node_iterator uniform = xml_data.begin(); uniform != xml_data.end(); ++uniform)
	{
		std::string uniform_name = uniform->attribute("Name").as_string();
		//Keep track of the running total size in bytes of the uniform block
		int block_size = 0;

		std::string type = uniform->attribute("Type").as_string();
		float* uniform_data;
		if (strcmp(type.c_str(), "float") == 0)
		{
			block_size = 1;
			float data_str = uniform->attribute("Data0").as_float();
			uniform_data = new float[block_size];
			uniform_data[0] = data_str;
		}
		else if (strcmp(type.c_str(), "vec2") == 0)
		{
			block_size = 2;
			float data_str = uniform->attribute("Data0").as_float();
			float data_str1 = uniform->attribute("Data1").as_float();
			uniform_data = new float[block_size];
			uniform_data[0] = data_str;
			uniform_data[1] = data_str1;
		}
		else if (strcmp(type.c_str(), "vec3") == 0)
		{
			block_size = 3;
			float data_str0 = uniform->attribute("Data0").as_float();
			float data_str1 = uniform->attribute("Data1").as_float();
			float data_str2 = uniform->attribute("Data2").as_float();
			uniform_data = new float[block_size];
			uniform_data[0] = data_str0;
			uniform_data[1] = data_str1;
			uniform_data[2] = data_str2;
		}
		else if (strcmp(type.c_str(), "vec4") == 0)
		{
			block_size = 4;
			float data_str0 = uniform->attribute("Data0").as_float();
			float data_str1 = uniform->attribute("Data1").as_float();
			float data_str2 = uniform->attribute("Data2").as_float();
			float data_str3 = uniform->attribute("Data3").as_float();
			uniform_data = new float[block_size];
			uniform_data[0] = data_str0;
			uniform_data[1] = data_str1;
			uniform_data[2] = data_str2;
			uniform_data[3] = data_str3;
		}
		//TODO: Check for other types

		ShaderParameter next_uniform = ShaderParameter(uniform_name, block_size * 4, block_size, uniform_data, true);
		to_add.addParameter(next_uniform);
	}
	return to_add;
}
开发者ID:J-norton,项目名称:Cuda-Game-Engine,代码行数:61,代码来源:Visitor.cpp

示例14: read_data

//-----------------------------------------------------------------------------
void XMLMesh::read_data(MeshData& data, const Mesh& mesh,
                        const pugi::xml_node mesh_node)
{
  // Check if we have any mesh data
  const pugi::xml_node xml_data = mesh_node.child("data");
  if (!xml_data)
    return;

  // Iterate over data
  for (pugi::xml_node_iterator it = xml_data.begin();
       it != xml_data.end(); ++it)
  {
    // Get node name
    const std::string node_name = it->name();

    // Read data stored as a MeshFunction (new style)
    if (node_name == "mesh_function")
    {
      // Create MeshFunction to read data into
      MeshFunction<std::size_t> mf(mesh);

      // Read  MeshFunction
      //const std::string data_type = it->attribute("type").value();
      XMLMeshFunction::read(mf, "uint", *it);

      // Create mesh domain array
      std::vector<std::size_t>& _data
        = data.create_array(mf.name(), mf.dim());
      _data.resize(mf.size());

      // Copy MeshFunction into MeshDomain array
      for (std::size_t i = 0; i < _data.size(); ++i)
        _data[i] = mf[i];
    }
    else if (node_name != "data_entry")
    {
      dolfin_error("XMLMesh.cpp",
                   "read mesh data from XML file",
                   "Expecting XML node <data_entry> but got <%s>",
                   node_name.c_str());
    }
    else // Old-style storage
    {
      // Get name of data set
      const std::string data_set_name = it->attribute("name").value();

      // Check that there is only one data set
      if (it->first_child().next_sibling())
      {
        dolfin_error("XMLMesh.cpp",
                     "read mesh data from XML file",
                     "XML file contains too many data sets");
      }

      // Get type of data set
      pugi::xml_node data_set = it->first_child();
      const std::string data_set_type = data_set.name();
      if (data_set_type == "array")
      {
        dolfin_error("XMLMesh.cpp",
                     "read mesh data from XML file",
                     "Only MeshFunction data can be read");
      }
      else if (data_set_type == "mesh_function")
      {
        // Create MeshFunction to read data into
        MeshFunction<std::size_t> mf(mesh);

        // Read  MeshFunction
        const std::string data_type = data_set.attribute("type").value();
        XMLMeshFunction::read(mf, data_type, *it);

        // Create mesh domain array
        std::vector<std::size_t>& _data
          = data.create_array(data_set_name, mf.dim());
        _data.resize(mf.size());

        // Copy MeshFunction into MeshDomain array
        for (std::size_t i = 0; i < _data.size(); ++i)
          _data[i] = mf[i];
      }
      else if (data_set_type == "meshfunction")
      {
        dolfin_error("XMLMesh.cpp",
                     "read mesh data from XML file",
                     "The XML tag <meshfunction> has been changed to <mesh_function>");
      }
      else
      {
        dolfin_error("XMLMesh.cpp",
                     "read mesh data from XML file",
                     "Reading of MeshData \"%s\" is not yet supported",
                     data_set_type.c_str());
      }
    }
  }
}
开发者ID:YannCobigo,项目名称:dolfin,代码行数:98,代码来源:XMLMesh.cpp

示例15: loadMeshFromXml

//Creates a TriangleMesh instance from provided xml data
TriangleMesh Visitor::loadMeshFromXml(pugi::xml_node& resource, Node& container)
{
	bool static_mesh = false;
	Shader mesh_shader;
	Texture mesh_texture;
	pugi::xml_node scenario_texture = resource.child("Texture");

	if (resource.attribute("StaticObject"))
	{
		static_mesh = true;
	}

	if (resource.child("Texture") || resource.child("Texture3D") || resource.child("FrameBufferTexture"))
		for (pugi::xml_node_iterator textures = resource.begin(); textures != resource.end(); ++textures)
		{
			//mesh_texture = loadTextureFromXml(*textures);
			mesh_texture = loadTextureFromXml(resource.child("Texture"));
			//if (mesh_texture != nullptr)
			break;
		}
	else
		mesh_texture = scene_objects.getTextureByKey(resource.attribute("Texture").as_string());

	std::string fs_path = resource.attribute("FSPath").as_string();
	std::string vs_path = resource.attribute("VSPath").as_string();
	mesh_shader = scene_objects.getShaderByKey(vs_path.append(fs_path));

	std::string obj_path = resource.attribute("ObjFile").as_string();
	//mesh_buffers = scene_objects.getBufferByKey(obj_path);
	pugi::xml_attribute instance = resource.attribute("InstanceCount");

	vec3 position;
	vec3 velocity;

	//Now gather all information for uniforms to the shaders
	for (pugi::xml_node_iterator uniforms = resource.begin(); uniforms != resource.end(); ++uniforms)
	{
		if (std::strcmp(uniforms->name(), "UniformBlock") == 0)
		{
			UniformBlock to_add = synthesizeBlock(*uniforms);
			mesh_shader.addUniformBlock(to_add);
		}
		if (std::strcmp(uniforms->name(), "Uniform") == 0)
		{
			ShaderParameter uniform = parseUniform(*uniforms);
			if (strcmp(uniform.name.c_str(), "velocity") == 0)
			{
				velocity.x = uniform.client_data[0];
				velocity.y = uniform.client_data[1];
				velocity.z = uniform.client_data[2];
			}
			else
				mesh_shader.addUniform(uniform);

			if (strcmp(uniform.name.c_str(), "translation") == 0)
			{
				position.x = uniform.client_data[0];
				position.y = uniform.client_data[1];
				position.z = uniform.client_data[2];
			}
		}
	}


	//Now loop over all nodes to determine which blocks the shader should bind to 
	for (pugi::xml_node_iterator uniforms = resource.begin(); uniforms != resource.end(); ++uniforms)
	{
		if (std::strcmp(uniforms->name(), "ShaderUniforms") == 0)
		{
			std::string block_name = uniforms->attribute("Name").as_string();
			int block_index = uniforms->attribute("BindingPoint").as_int();
		}
	}

	//Lava.png
	//dry_clay.jpg
	//Redbrick.jpg
	//rock04.jpg
	//Rosewood.jpg

	//Checkered Marble.png
	//Ocean Texture.png
	//Stonewall.jpg
	//Ambient Green.jpg
	//Red Pattern.jpg
	//Green Wall.jpg
	//Red Fuzzy Pattern.jpg
	//Brick Circle Pattern.jpg
	ObjFileReader* mesh_reader = scene_objects.getFileReader(obj_path);
	int num_buffers = mesh_reader->getNumSubMeshes();
	Texture second = scene_objects.getTextureByKey("Lava.png");
	Texture third = scene_objects.getTextureByKey("Redbrick.jpg");
	Texture fourth = scene_objects.getTextureByKey("Rosewood.jpg");
	Texture fifth = scene_objects.getTextureByKey("Checkered Marble.png");

	Texture sixth = scene_objects.getTextureByKey("Lava.png");
	Texture seventh = scene_objects.getTextureByKey("Ocean Texture.png");
	Texture eighth= scene_objects.getTextureByKey("Stonewall.jpg");
	Texture ninth = scene_objects.getTextureByKey("Ambient Green.jpg");
//.........这里部分代码省略.........
开发者ID:J-norton,项目名称:Cuda-Game-Engine,代码行数:101,代码来源:Visitor.cpp


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