• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ XMLNodePtr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中XMLNodePtr的典型用法代码示例。如果您正苦于以下问题:C++ XMLNodePtr类的具体用法?C++ XMLNodePtr怎么用?C++ XMLNodePtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: throwInvalidArgumentException

XMLNodePtr XMLDoc::createNode(const XMLNodePtr &parent, const TCHAR *nodeName, bool force) {
  DEFINEMETHODNAME;
  if(parent == NULL) {
    throwInvalidArgumentException(method, _T("parent=NULL"));
  }
  if(nodeName == NULL || _tcsclen(nodeName) == 0) {
    throwInvalidArgumentException(method, _T("nodeName=%s"), nodeName?nodeName:_T("null"));
  }

  StringArray tokens(Tokenizer(nodeName,_T(".")));

  // Create path if we got any dots
  XMLNodePtr node = parent;
  size_t i;
  for(i = 0; i < tokens.size() - 1; i++) {
    XMLNodePtr tmp = findChild(node,tokens[i].cstr());
    if(tmp == NULL) {
      tmp  = m_doc->createElement(tokens[i].cstr());
      node = node->appendChild(tmp);
    }
  }

  XMLNodePtr result = findChild(node,tokens[i].cstr());
  if(result != NULL && !force) {
    throwException(_T("Node %s alredy exist. set force to true, if duplicates are allowed"), nodeName);
  } else {
    result = m_doc->createElement(tokens[i].cstr());
    result = node->appendChild(result);
  }
  return result;
}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:31,代码来源:XmlDoc.cpp


示例2: loadStatic

void loadStatic(XMLNodePtr node)
{
   XMLNodePtr pos = node->getChild("pos");
   XMLNodePtr rot = node->getChild("pos");
   std::string model_name = (*node->getChild("model")->getChildren().begin())->getCdata();
   model_name = trim(model_name);

   // Find the corresponding model type in the model menu list
   std::cout << "Looking for model '" << model_name << "'" << std::endl;
   model mod;
   for (std::vector<model>::iterator itr = modelsInMenu.begin();
        itr != modelsInMenu.end();
        ++itr)
   {
      model old_model = *itr;
      if (old_model.name == model_name)
      {
         mod = old_model;
         std::cout << "\tSuccess" << std::endl;
      }
   }


   mod.worldX = pos->getAttribute("x").getValue<float>();
   mod.worldZ = pos->getAttribute("y").getValue<float>();
   mod.worldY = pos->getAttribute("z").getValue<float>();
   mod.name = model_name;

   std::cout << "Adding model: " << mod.name << std::endl
             << "low:  (" << mod.xlo << ", " << mod.ylo << ")" << std::endl
             << "high: (" << mod.xhi << ", " << mod.yhi << ")" << std::endl
             << "pos:  (" << mod.worldX << ", " << mod.worldZ << ", " << mod.worldY << ")" << std::endl;
   modelsInWorld.push_back(mod);
}
开发者ID:chadaustin,项目名称:isugamedev,代码行数:34,代码来源:simpleGlutApp.cpp


示例3: setupOutputLevelFile

void setupOutputLevelFile(XMLNodePtr& mNode)
{
   XMLContextPtr mContext = XMLContextPtr(new XMLContext);
   mNode = XMLNodePtr(new XMLNode(mContext));
   mNode->setName("hi");
   mNode->setType(xml_nt_node);
   XMLNodePtr newNode(new XMLNode(mContext));
   newNode->setName("josh");
   newNode->setType(xml_nt_node);
   mNode->addChild(newNode);
}
开发者ID:chadaustin,项目名称:isugamedev,代码行数:11,代码来源:simpleGlutApp.cpp


示例4: processObjNode

void processObjNode(XMLNode &node)
{
   model* mModel = new model();
   std::string name = node.getName();
      
   std::cout << "This Node is a: " << name << std::endl;


   
   XMLNodePtr cNode = node.getChild(std::string("size"));
   std::cout << "node: " << cNode->getName() << std::endl;
   mModel->xhi = cNode->getAttribute("xhi").getValue<float>();
   mModel->xlo = cNode->getAttribute("xlo").getValue<float>();
   mModel->yhi = cNode->getAttribute("yhi").getValue<float>();
   mModel->ylo = cNode->getAttribute("ylo").getValue<float>();
   std::cout << "mModel.xlo: " << mModel->xlo << "  mModel.ylo: " << mModel->b << std::endl;
   std::cout << "type: " << cNode->getType() << std::endl;
   cNode = node.getChild(std::string("color"));
   mModel->r = cNode->getAttribute(std::string("r")).getValue<float>();
   mModel->g = cNode->getAttribute(std::string("g")).getValue<float>();
   mModel->b = cNode->getAttribute(std::string("b")).getValue<float>();
   cNode = node.getChild(std::string("type"));
   mModel->name = cNode->getAttribute(std::string("name")).getValue<std::string>();
   modelsInMenu.push_back(*mModel);
}
开发者ID:chadaustin,项目名称:isugamedev,代码行数:25,代码来源:simpleGlutApp.cpp


示例5: loadGroup

void loadGroup(XMLNodePtr node)
{
   XMLNodeList children = node->getChildren();
   for (XMLNodeList::iterator itr = children.begin();
        itr != children.end();
        ++itr)
   {
      XMLNodePtr node = *itr;
      if (node->getName() == "static" || node->getName() == "turret" || node->getName() == "security_droid" || node->getName() == "navNode" )
      {
         loadStatic(node);
      }
   }
}
开发者ID:chadaustin,项目名称:isugamedev,代码行数:14,代码来源:simpleGlutApp.cpp


示例6: LoadPlatformConfig

Offline::OfflineRenderDeviceCaps LoadPlatformConfig(std::string const & platform)
{
	ResIdentifierPtr plat = ResLoader::Instance().Open("PlatConf/" + platform + ".plat");

	KlayGE::XMLDocument doc;
	XMLNodePtr root = doc.Parse(plat);

	Offline::OfflineRenderDeviceCaps caps;

	caps.platform = RetrieveAttrValue(root, "name", "");
	caps.major_version = static_cast<uint8_t>(RetrieveAttrValue(root, "major_version", 0));
	caps.minor_version = static_cast<uint8_t>(RetrieveAttrValue(root, "minor_version", 0));

	caps.requires_flipping = RetrieveNodeValue(root, "requires_flipping", 0) ? true : false;
	std::string const fourcc_str = RetrieveNodeValue(root, "native_shader_fourcc", "");
	caps.native_shader_fourcc = (fourcc_str[0] << 0) + (fourcc_str[1] << 8) + (fourcc_str[2] << 16) + (fourcc_str[3] << 24);
	caps.native_shader_version = RetrieveNodeValue(root, "native_shader_version", 0);

	XMLNodePtr max_shader_model_node = root->FirstNode("max_shader_model");
	caps.max_shader_model = ShaderModel(static_cast<uint8_t>(RetrieveAttrValue(max_shader_model_node, "major", 0)),
		static_cast<uint8_t>(RetrieveAttrValue(max_shader_model_node, "minor", 0)));

	caps.max_texture_depth = RetrieveNodeValue(root, "max_texture_depth", 0);
	caps.max_texture_array_length = RetrieveNodeValue(root, "max_texture_array_length", 0);
	caps.max_pixel_texture_units = static_cast<uint8_t>(RetrieveNodeValue(root, "max_pixel_texture_units", 0));
	caps.max_simultaneous_rts = static_cast<uint8_t>(RetrieveNodeValue(root, "max_simultaneous_rts", 0));

	caps.standard_derivatives_support = RetrieveNodeValue(root, "standard_derivatives_support", 0) ? true : false;
	caps.shader_texture_lod_support = RetrieveNodeValue(root, "shader_texture_lod_support", 0) ? true : false;
	caps.fp_color_support = RetrieveNodeValue(root, "fp_color_support", 0) ? true : false;
	caps.pack_to_rgba_required = RetrieveNodeValue(root, "pack_to_rgba_required", 0) ? true : false;

	caps.gs_support = RetrieveNodeValue(root, "gs_support", 0) ? true : false;
	caps.cs_support = RetrieveNodeValue(root, "cs_support", 0) ? true : false;
	caps.hs_support = RetrieveNodeValue(root, "hs_support", 0) ? true : false;
	caps.ds_support = RetrieveNodeValue(root, "ds_support", 0) ? true : false;

	caps.bc4_support = RetrieveNodeValue(root, "bc4_support", 0) ? true : false;
	caps.bc5_support = RetrieveNodeValue(root, "bc5_support", 0) ? true : false;
	caps.frag_depth_support = RetrieveNodeValue(root, "frag_depth_support", 0) ? true : false;
	caps.ubo_support = RetrieveNodeValue(root, "ubo_support", 0) ? true : false;

	return caps;
}
开发者ID:BitYorkie,项目名称:KlayGE,代码行数:44,代码来源:FXMLJIT.cpp


示例7: RetrieveNodeValue

int RetrieveNodeValue(XMLNodePtr root, std::string const & node_name, int default_value)
{
	XMLNodePtr node = root->FirstNode(node_name);
	if (node)
	{
		return RetrieveAttrValue(node, "value", default_value);
	}

	return default_value;
}
开发者ID:BitYorkie,项目名称:KlayGE,代码行数:10,代码来源:FXMLJIT.cpp


示例8: RetrieveAttrValue

std::string RetrieveAttrValue(XMLNodePtr node, std::string const & attr_name, std::string const & default_value)
{
	XMLAttributePtr attr = node->Attrib(attr_name);
	if (attr)
	{
		return attr->ValueString();
	}

	return default_value;
}
开发者ID:BitYorkie,项目名称:KlayGE,代码行数:10,代码来源:FXMLJIT.cpp


示例9: findText

void XMLDoc::setText(const XMLNodePtr &node, const TCHAR *value) {
  if(node == NULL) {
    return;
  }
  XMLNodePtr Text = findText(node);
  if(Text == NULL) {
    node->appendChild(m_doc->createTextNode(value));
  } else {
    Text->nodeValue = value;
  }
}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:11,代码来源:XmlDoc.cpp


示例10: PackJTML

void PackJTML(std::string const & jtml_name)
{
	Timer timer;

	ResIdentifierPtr jtml = ResLoader::Instance().Open(jtml_name);

	KlayGE::XMLDocument doc;
	XMLNodePtr root = doc.Parse(jtml);

	uint32_t n = root->AttribInt("num_tiles", 2048);
	uint32_t num_tiles = 1;
	while (num_tiles * 2 <= n)
	{
		num_tiles *= 2;
	}

	uint32_t tile_size = root->AttribInt("tile_size", 128);
	std::string fmt_str = root->AttribString("format", "");
	ElementFormat format = EF_ARGB8;
	if ("ARGB8" == fmt_str)
	{
		format = EF_ARGB8;
	}
	else if ("ABGR8" == fmt_str)
	{
		format = EF_ABGR8;
	}
	uint32_t pixel_size = NumFormatBytes(format);

	JudaTexturePtr juda_tex = MakeSharedPtr<JudaTexture>(num_tiles, tile_size, format);

	uint32_t level = juda_tex->TreeLevels() - 1;

	RenderFactory& rf = Context::Instance().RenderFactoryInstance();
	uint32_t attr = 0;
	for (XMLNodePtr node = root->FirstNode("image"); node; node = node->NextSibling("image"), ++ attr)
	{
		timer.restart();

		std::string name = node->AttribString("name", "");
		int32_t x = node->AttribInt("x", 0);
		int32_t y = node->AttribInt("y", 0);
		std::string address_u_str = node->AttribString("address_u", "wrap");
		std::string address_v_str = node->AttribString("address_v", "wrap");
		Color border_clr;
		border_clr.r() = node->AttribFloat("border_r", 0.0f);
		border_clr.g() = node->AttribFloat("border_g", 0.0f);
		border_clr.b() = node->AttribFloat("border_b", 0.0f);
		border_clr.a() = node->AttribFloat("border_a", 0.0f);
		uint32_t border_clr_u8;
		switch (format)
		{
		case EF_ARGB8:
			border_clr_u8 = border_clr.ARGB();
			break;

		case EF_ABGR8:
			border_clr_u8 = border_clr.ABGR();
			break;

		default:
			border_clr_u8 = 0;
			break;
		}

		TexAddressingMode addr_u, addr_v;
		std::shared_ptr<address_calculator> calc_u, calc_v;
		if ("mirror" == address_u_str)
		{
			addr_u = TAM_Mirror;
			calc_u = address_calculators[TAM_Mirror];
		}
		else if ("clamp" == address_u_str)
		{
			addr_u = TAM_Clamp;
			calc_u = address_calculators[TAM_Clamp];
		}
		else if ("border" == address_u_str)
		{
			addr_u = TAM_Border;
			calc_u = address_calculators[TAM_Border];
		}
		else
		{
			addr_u = TAM_Wrap;
			calc_u = address_calculators[TAM_Wrap];
		}
		if ("mirror" == address_v_str)
		{
			addr_v = TAM_Mirror;
			calc_v = address_calculators[TAM_Mirror];
		}
		else if ("clamp" == address_v_str)
		{
			addr_v = TAM_Clamp;
			calc_v = address_calculators[TAM_Clamp];
		}
		else if ("border" == address_v_str)
		{
			addr_v = TAM_Border;
//.........这里部分代码省略.........
开发者ID:zsnake1209,项目名称:KlayGE,代码行数:101,代码来源:JudaTexPacker.cpp


示例11: LoadDocumentRoot

//-------------------------------------------------------------
VCNAnim* VCNAnimLoader::LoadAnimXML( const VCNString& filename )
{
	// Create the new mesh to be filled!
	VCNAnim* newAnim = NULL;

	// Open the XML document
	XMLElementPtr pRootElem = LoadDocumentRoot( filename );
	VCN_ASSERT_MSG( pRootElem != NULL, "Could not load XML Animation!" );

	// Go through all the MeshElement nodes
	XMLNodeListPtr elementNodes;
	pRootElem->selectNodes( (VCNTChar*)kAttrAnimNode, &elementNodes );
	VCNLong animNodeCount;
	elementNodes->get_length( &animNodeCount );
	for( VCNLong i=0; i<animNodeCount; i++ )
	{
		// Create the new mesh to be filled!
		newAnim = new VCNAnim();

		// Get the element's node
		XMLNodePtr elementNode;
		elementNodes->get_item( i, &elementNode );

		// Load the base properties
		LoadResourceBaseProperties( elementNode, newAnim );

		// Go through all the joints that compose this anims
		XMLNodeListPtr jointNodes;
		elementNode->selectNodes( (VCNTChar*)kNodeAnimJoint, &jointNodes );
		VCNLong jointNodeCount;
		jointNodes->get_length( &jointNodeCount );
		for( VCNLong i=0; i<jointNodeCount; i++ )
		{
			// Get the mesh's node
			XMLNodePtr jointNode;
			jointNodes->get_item( i, &jointNode );

			// Load the joint
			VCNAnimJoint* animJoint = LoadJointXML( jointNode );

			// The name of the joint will be the name of the anim + the target joint
			animJoint->SetName( newAnim->GetName() + VCNTXT("_") + animJoint->GetTargetName() );

			// Add it to the resource manager
			VCNResID jointID = VCNResourceCore::GetInstance()->AddResource( animJoint->GetName(), animJoint );

			// Add it to the animation
			newAnim->AddJoint( jointID );
		}

		// Make sure we aren't loading it twice
		VCN_ASSERT( !VCNResourceCore::GetInstance()->GetResource<VCNAnim>( newAnim->GetName() ) );

		// Add it
		VCNResourceCore::GetInstance()->AddResource( newAnim->GetName(), newAnim );
	}

	// Free up the doc memory
	ReleaseDocument();

	return newAnim;
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:63,代码来源:AnimLoader.cpp


示例12: GetAttributeUInt

//-------------------------------------------------------------
/// A lighting array is composed of normals and colors
//-------------------------------------------------------------
VCNResID VCNMeshLoader::LoadMeshElementLightingXML( XMLNodePtr elementNode )
{
  // Fetch the normals from the element node
  XMLNodePtr normals = 0;
  elementNode->selectSingleNode( (VCNTChar*)kNodeVertexNormals, &normals );
  bool hasNormals = (normals != NULL);

  // Fetch the colors from the element node
  XMLNodePtr colors = 0;
  elementNode->selectSingleNode( (VCNTChar*)kNodeVertexColors, &colors );
  bool hasColors = (colors != NULL);

  // Get the expected size of the normals
  VCNUInt normalSize = 0;
  if( hasNormals )
  {
    GetAttributeUInt( normals, kAttrVertexNormalsSize, normalSize );
    if( normalSize == 0 )
      hasNormals = false;
  }

  // Get the expected size of the colors
  VCNUInt colorSize = 0;
  if( hasColors )
  {
    GetAttributeUInt( colors, kAttrVertexColorsSize, colorSize );
    if( colorSize == 0 )
      hasColors = false;
  }

  // If we have neither, then no lighting information at all
  if( !hasColors && !hasNormals )
    return kInvalidResID;

  // If we have both, they MUST be of same size!
  if( hasColors && hasNormals && (normalSize != colorSize) )
  {
    VCN_ASSERT_FAIL( "LIGHTING REJECTED!" );
    return kInvalidResID;
  }

  // Now just retain one of the sizes
  VCNLong size = (VCNLong)(hasNormals?normalSize:colorSize);
  
  // Create an array to contain all of this (6 floats per vertex)
  VCNUInt stride = size * (kNormalFloats+kColorFloats);
  VCNFloat* buffer = new VCNFloat[ stride ];

  // Create some tools...
  VCNFloat* ptrFloat = buffer;
  VCNInt safety = 0;

  // Pick out the nodes of every normal (if we have them)
  XMLNodeListPtr normalElements;
  if( hasNormals )
  {
    normalElements = 0;
    normals->selectNodes( (VCNTChar*)kNodeVertexNormal, &normalElements );
    VCNLong normalElementsLength = 0;
    normalElements->get_length( &normalElementsLength );
    VCN_ASSERT( normalElementsLength == size && "FILE IS CORRUPTED!" );
  }

  // Pick out the nodes of every color (if we have them)
  XMLNodeListPtr colorsElements;
  if( hasColors )
  {
    colorsElements = 0;
    colors->selectNodes( (VCNTChar*)kNodeVertexColor, &colorsElements );
    VCNLong colorElementsLength = 0;
    normalElements->get_length( &colorElementsLength );
    VCN_ASSERT( colorElementsLength == size && "FILE IS CORRUPTED!" );
  }

  // Now read it in!
  for( VCNLong i=0; i<size; i++ )
  {
    // Normals
    if( hasNormals )
    {
      // Get the element's node
      XMLNodePtr normalNode = 0;
      normalElements->get_item( i, &normalNode );

      // Read the X
      GetAttributeFloat( normalNode, kAttrVertexNormalX, *ptrFloat );
      ptrFloat++;

      // Read the Y
      GetAttributeFloat( normalNode, kAttrVertexNormalY, *ptrFloat );
      ptrFloat++;

      // Read the Z
      GetAttributeFloat( normalNode, kAttrVertexNormalZ, *ptrFloat );
      ptrFloat++;

      // Verify the safety to make sure we're reading in the right order
//.........这里部分代码省略.........
开发者ID:artemeliy,项目名称:inf4715,代码行数:101,代码来源:MeshLoader.cpp


示例13: SaveRenderMaterial

	void SaveRenderMaterial(RenderMaterialPtr const & mtl, std::string const & mtlml_name)
	{
		KlayGE::XMLDocument doc;

		XMLNodePtr root = doc.AllocNode(XNT_Element, "material");
		doc.RootNode(root);

		{
			XMLNodePtr albedo_node = doc.AllocNode(XNT_Element, "albedo");

			std::string color_str = boost::lexical_cast<std::string>(mtl->albedo.x())
				+ ' ' + boost::lexical_cast<std::string>(mtl->albedo.y())
				+ ' ' + boost::lexical_cast<std::string>(mtl->albedo.z())
				+ ' ' + boost::lexical_cast<std::string>(mtl->albedo.w());
			albedo_node->AppendAttrib(doc.AllocAttribString("color", color_str));

			if (!mtl->tex_names[RenderMaterial::TS_Albedo].empty())
			{
				albedo_node->AppendAttrib(doc.AllocAttribString("texture", mtl->tex_names[RenderMaterial::TS_Albedo]));
			}

			root->AppendNode(albedo_node);
		}

		if ((mtl->metalness > 0) || !mtl->tex_names[RenderMaterial::TS_Metalness].empty())
		{
			XMLNodePtr metalness_node = doc.AllocNode(XNT_Element, "metalness");

			if (mtl->metalness > 0)
			{
				metalness_node->AppendAttrib(doc.AllocAttribFloat("value", mtl->metalness));
			}
			if (!mtl->tex_names[RenderMaterial::TS_Metalness].empty())
			{
				metalness_node->AppendAttrib(doc.AllocAttribString("texture", mtl->tex_names[RenderMaterial::TS_Metalness]));
			}

			root->AppendNode(metalness_node);
		}

		if ((mtl->glossiness > 0) || !mtl->tex_names[RenderMaterial::TS_Glossiness].empty())
		{
			XMLNodePtr glossiness_node = doc.AllocNode(XNT_Element, "glossiness");

			if (mtl->glossiness > 0)
			{
				glossiness_node->AppendAttrib(doc.AllocAttribFloat("value", mtl->glossiness));
			}
			if (!mtl->tex_names[RenderMaterial::TS_Glossiness].empty())
			{
				glossiness_node->AppendAttrib(doc.AllocAttribString("texture", mtl->tex_names[RenderMaterial::TS_Glossiness]));
			}

			root->AppendNode(glossiness_node);
		}

		if ((mtl->emissive.x() > 0) || (mtl->emissive.y() > 0) || (mtl->emissive.z() > 0)
			|| (!mtl->tex_names[RenderMaterial::TS_Emissive].empty()))
		{
			XMLNodePtr emissive_node = doc.AllocNode(XNT_Element, "emissive");

			if ((mtl->emissive.x() > 0) || (mtl->emissive.y() > 0) || (mtl->emissive.z() > 0))
			{
				std::string color_str = boost::lexical_cast<std::string>(mtl->emissive.x())
					+ ' ' + boost::lexical_cast<std::string>(mtl->emissive.y())
					+ ' ' + boost::lexical_cast<std::string>(mtl->emissive.z());
				emissive_node->AppendAttrib(doc.AllocAttribString("color", color_str));
			}
			if (!mtl->tex_names[RenderMaterial::TS_Emissive].empty())
			{
				emissive_node->AppendAttrib(doc.AllocAttribString("texture", mtl->tex_names[RenderMaterial::TS_Emissive]));
			}

			root->AppendNode(emissive_node);
		}

		if (!mtl->tex_names[RenderMaterial::TS_Normal].empty())
		{
			XMLNodePtr normal_node = doc.AllocNode(XNT_Element, "normal");

			normal_node->AppendAttrib(doc.AllocAttribString("texture", mtl->tex_names[RenderMaterial::TS_Normal]));

			root->AppendNode(normal_node);
		}

		if (!mtl->tex_names[RenderMaterial::TS_Height].empty())
		{
			XMLNodePtr height_node = doc.AllocNode(XNT_Element, "height");

			height_node->AppendAttrib(doc.AllocAttribString("texture", mtl->tex_names[RenderMaterial::TS_Height]));
			height_node->AppendAttrib(doc.AllocAttribFloat("offset", mtl->height_offset_scale.x()));
			height_node->AppendAttrib(doc.AllocAttribFloat("scale", mtl->height_offset_scale.y()));

			root->AppendNode(height_node);
		}

		if (mtl->detail_mode != RenderMaterial::SDM_Parallax)
		{
			XMLNodePtr detail_node = doc.AllocNode(XNT_Element, "detail");

//.........这里部分代码省略.........
开发者ID:zsnake1209,项目名称:KlayGE,代码行数:101,代码来源:RenderMaterial.cpp


示例14: VCN_ASSERT

//-------------------------------------------------------------
VCNResID VCNMeshLoader::LoadMeshElementPositionXML( XMLNodePtr elementNode, VCNSphere* bounding, VCNAabb* aabb /*= NULL*/  )
{
  // Fetch the node we need from the element node
  XMLNodePtr node = 0;
  elementNode->selectSingleNode( (VCNTChar*)kNodeVertexPositions, &node );
  VCN_ASSERT( node != NULL && "No positions in mesh!" );

  // Get the expected size of the array
  VCNUInt size = 0;
  GetAttributeUInt( node, kAttrVertexPositionsSize, size );

  // If we don't have any, leave.
  if( size == 0 )
    return kInvalidResID;

  // Create an array to contain all of this (3 floats per position)
  VCNUInt stride = size * kPositionFloats;
  VCNFloat* buffer = new VCNFloat[ stride ];

  // Create some tools...
  VCNFloat* ptrFloat = buffer;
  VCNInt safety = 0;

  // Keep track of the min and max
  VCNFloat minX, maxX;
  VCNFloat minY, maxY;
  VCNFloat minZ, maxZ;
  minX = minY = minZ = kMaxFloat;
  maxX = maxY = maxZ = kMinFloat;

  // Read the XML and fill the array!
  XMLNodeListPtr positions = 0;
  node->selectNodes( (VCNTChar*)kNodeVertexPosition, &positions );
  VCN_ASSERT( positions != 0 && "FILE IS CORRUPTED!" );
  VCNLong positionsLength = 0;
  positions->get_length( &positionsLength );
  VCN_ASSERT( positionsLength == size && "FILE IS CORRUPTED!" );
  for( VCNLong i=0; i<positionsLength; i++ )
  {
    // Get the element's node
    XMLNodePtr positionNode = 0;
    positions->get_item( i, &positionNode );

    // Read the X
    GetAttributeFloat( positionNode, kAttrVertexPositionX, *ptrFloat );
    if( *ptrFloat < minX )
      minX = *ptrFloat;
    if( *ptrFloat > maxX )
      maxX = *ptrFloat;
    ptrFloat++;

    // Read the Y
    GetAttributeFloat( positionNode, kAttrVertexPositionY, *ptrFloat );
    if( *ptrFloat < minY )
      minY = *ptrFloat;
    if( *ptrFloat > maxY )
      maxY = *ptrFloat;
    ptrFloat++;

    // Read the Z
    GetAttributeFloat( positionNode, kAttrVertexPositionZ, *ptrFloat );
    if( *ptrFloat < minZ )
      minZ = *ptrFloat;
    if( *ptrFloat > maxZ )
      maxZ = *ptrFloat;
    ptrFloat++;

    // Verify the safety to make sure we're reading in the right order
    GetAttributeInt( positionNode, kAttrVertexPositionID, safety );
    VCN_ASSERT( safety==i && "VERTEX AREN'T READ IN ORDER!" );
  }

  // Now give the information to the cache manager 
  // (he'll take care of making this data API specific)
  VCNResID cacheID = VCNRenderCore::GetInstance()->CreateCache( VT_POSITION, buffer, stride*sizeof(VCNFloat) );

  // Clear the buffer
  delete [] buffer;

  Vector3 minVect ( minX, minY, minZ );
  Vector3 maxVect ( maxX, maxY, maxZ );
  Vector3 diagonal = (maxVect - minVect) / 2.0f;
  // If he wants us to fill the AABB, we'll do it for him
  if( bounding )
  {
    VCNSphere tmpSphere( diagonal.Length(), minVect + diagonal );
    *bounding = tmpSphere;
  }
  if (aabb)
  {
	  VCNAabb tempAabb(minVect, maxVect);
	  *aabb = tempAabb;
  }

  // Return the cache ID
  return cacheID;
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:98,代码来源:MeshLoader.cpp


示例15: NowWeCanReallyAddTheLevel

void NowWeCanReallyAddTheLevel(XMLNodePtr& levelNode, XMLContextPtr& context)
{
   std::string temp;
   char namePostFix = 'A';  // a postfix character to add as a name so we can distinguish between different navNodes. -- this is an ugly hack.
   std::cout << "writing out models..." << std::endl;

   

   for(unsigned int i=0;i<modelsInWorld.size();i++)
   {
      XMLNodePtr staticNode(new XMLNode(context));
      XMLNodePtr posNode(new XMLNode(context));
      XMLNodePtr rotNode(new XMLNode(context));
      XMLNodePtr nameNode(new XMLNode(context));
      XMLNodePtr realNameNode(new XMLNode(context));
      
      
      staticNode->setName("static");
      posNode->setName("pos");
      rotNode->setName("rot");
      nameNode->setName("model");

               
      
      staticNode->setType(xml_nt_node);
      posNode->setType(xml_nt_leaf);
      nameNode->setType(xml_nt_node);
      rotNode->setType(xml_nt_leaf);
      realNameNode->setType(xml_nt_cdata);
      
      
      levelNode->addChild(staticNode);
      
      posNode->setAttribute("x", modelsInWorld[i].worldX);
      posNode->setAttribute("y", modelsInWorld[i].worldZ);
      posNode->setAttribute("z", modelsInWorld[i].worldY);
      
      staticNode->addChild(posNode);
      rotNode->setAttribute("x", 0.0f);
      rotNode->setAttribute("y", 0.0f);
      rotNode->setAttribute("z", 0.0f);
      staticNode->addChild(rotNode);

      realNameNode->setCdata(modelsInWorld[i].name);
      nameNode->addChild(realNameNode);
      staticNode->addChild(nameNode);

      if(modelsInWorld[i].name==std::string("turret"))
      {
         std::cout << "adding turret info to xml node" << std::endl;
         staticNode->setName("turret");
         XMLNodePtr turretNameNode(new XMLNode(context));
         XMLNodePtr maxChildNode(new XMLNode(context));
         XMLNodePtr aiLevelNode(new XMLNode(context));
         XMLNodePtr parentNode(new XMLNode(context));
         XMLNodePtr realParentNode(new XMLNode(context));
         XMLNodePtr realTurretNameNode(new XMLNode(context));

         turretNameNode->setType(xml_nt_node);
         realTurretNameNode->setType(xml_nt_cdata);
         parentNode->setType(xml_nt_node);
         realParentNode->setType(xml_nt_cdata);
         aiLevelNode->setType(xml_nt_leaf);
         maxChildNode->setType(xml_nt_leaf);

         turretNameNode->setName("name");
         parentNode->setName("parent");
         aiLevelNode->setName("level");
         maxChildNode->setName("maxChildren");
         
         realParentNode->setCdata("null");
         realTurretNameNode->setCdata("turret");
         
         aiLevelNode->setAttribute("nu", -1);
         maxChildNode->setAttribute("num", 0);
         parentNode->addChild(realParentNode);
         turretNameNode->addChild(realTurretNameNode);

         staticNode->addChild(aiLevelNode);
         staticNode->addChild(parentNode);
         staticNode->addChild(turretNameNode);
         staticNode->addChild(maxChildNode);
      }
      else if(modelsInWorld[i].name==std::string("security_droid"))
      {
         std::cout << "adding droid info to xml node" << std::endl;
         staticNode->setName("security_droid");

         XMLNodePtr droidNameNode(new XMLNode(context));
         XMLNodePtr maxChildNode(new XMLNode(context));
         XMLNodePtr aiLevelNode(new XMLNode(context));
         XMLNodePtr parentNode(new XMLNode(context));
         XMLNodePtr realParentNode(new XMLNode(context));
         XMLNodePtr realDroidNameNode(new XMLNode(context));

         droidNameNode->setType(xml_nt_node);
         realDroidNameNode->setType(xml_nt_cdata);
         parentNode->setType(xml_nt_node);
         realParentNode->setType(xml_nt_cdata);
         aiLevelNode->setType(xml_nt_leaf);
//.........这里部分代码省略.........
开发者ID:chadaustin,项目名称:isugamedev,代码行数:101,代码来源:simpleGlutApp.cpp


示例16: switch

//-------------------------------------------------------------
VCNResID VCNMeshLoader::LoadMeshElementTextureCoordXML( XMLNodePtr elementNode, VCNCacheType coordType )
{
  XMLNodePtr node = NULL;

  // Fetch the node we need from the element node
  switch( coordType )
  {
  case VT_DIFFUSE_TEX_COORDS:
    elementNode->selectSingleNode( (VCNTChar*)kNodeDiffuseTexCoords, &node );
    break;
  case VT_NORMAL_TEX_COORDS:
    elementNode->selectSingleNode( (VCNTChar*)kNodeNormalTexCoords, &node );
    break;

  default:
    VCN_ASSERT( false && "Trying to load unrecognized coord type!" );
  }

  // If we didn't find it, we don't have it
  if( node == NULL )
    return kInvalidResID;

  // Get the expected size of the array
  VCNUInt size = 0;
  GetAttributeUInt( node, kAttrVertexTexCoordsSize, size );

  // If we don't have any, leave.
  if( size == 0 )
    return kInvalidResID;

  // Create an array to contain all of this (2 floats per position)
  VCNUInt stride = size * kTexCoordFloats;
  VCNFloat* buffer = new VCNFloat[ stride ];

  // Create some tools...
  VCNFloat* ptrFloat = buffer;
  VCNInt safety = 0;

  // Read the XML and fill the array!
  XMLNodeListPtr textureCoords = 0;
  node->selectNodes( (VCNTChar*)kNodeVertexTexCoord, &textureCoords );
  VCNLong textureCoordsLength = 0;
  textureCoords->get_length( &textureCoordsLength );
  VCN_ASSERT( textureCoordsLength == size && "FILE IS CORRUPTED!" );
  for( VCNLong i=0; i<textureCoordsLength; i++ )
  {
    // Get the first one
    XMLNodePtr textureCoordNode = 0;
    textureCoords->get_item( i, &textureCoordNode );

    // Read the U
    GetAttributeFloat( textureCoordNode, kAttrVertexTexCoordU, *ptrFloat );
    ptrFloat++;

    // Read the V
    GetAttributeFloat( textureCoordNode, kAttrVertexTexCoordV, *ptrFloat );
    ptrFloat++;

    // Verify the safety to make sure we're reading in the right order
    GetAttributeInt( textureCoordNode, kAttrVertexTexCoordID, safety );
    VCN_ASSERT( safety==i && "VERTEX AREN'T READ IN ORDER!" );
  }

  // Now give the information to the cache manager 
  // (he'll take care of making this data API specific)
  VCNResID cacheID = VCNRenderCore::GetInstance()->CreateCache( coordType, buffer, stride*sizeof(VCNFloat) );

  // Clear the buffer
  delete [] buffer;

  // Return the cache ID
  return cacheID;
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:74,代码来源:MeshLoader.cpp


示例17: SubThreadStage

		void SubThreadStage()
		{
			ResIdentifierPtr psmm_input = ResLoader::Instance().Open(ps_desc_.res_name);

			KlayGE::XMLDocument doc;
			XMLNodePtr root = doc.Parse(psmm_input);

			{
				XMLNodePtr particle_node = root->FirstNode("particle");
				{
					XMLNodePtr alpha_node = particle_node->FirstNode("alpha");
					ps_desc_.ps_data->particle_alpha_from_tex = alpha_node->Attrib("from")->ValueString();
					ps_desc_.ps_data->particle_alpha_to_tex = alpha_node->Attrib("to")->ValueString();
				}
				{
					XMLNodePtr color_node = particle_node->FirstNode("color");
					{
						Color from;
						XMLAttributePtr attr = color_node->Attrib("from");
						if (attr)
						{
							std::vector<std::string> strs;
							boost::algorithm::split(strs, attr->ValueString(), boost::is_any_of(" "));
							for (size_t i = 0; i < 3; ++ i)
							{
								if (i < strs.size())
								{
									boost::algorithm::trim(strs[i]);
									from[i] = static_cast<float>(atof(strs[i].c_str()));
								}
								else
								{
									from[i] = 0;
								}
							}
						}
						from.a() = 1;
						ps_desc_.ps_data->particle_color_from = from;

						Color to;
						attr = color_node->Attrib("to");
						if (attr)
						{
							std::vector<std::string> strs;
							boost::algorithm::split(strs, attr->ValueString(), boost::is_any_of(" "));
							for (size_t i = 0; i < 3; ++ i)
							{
								if (i < strs.size())
								{
									boost::algorithm::trim(strs[i]);
									to[i] = static_cast<float>(atof(strs[i].c_str()));
								}
								else
								{
									to[i] = 0;
								}
							}
						}
						to.a() = 1;
						ps_desc_.ps_data->particle_color_to = to;
					}
				}
			}

			{
				XMLNodePtr emitter_node = root->FirstNode("emitter");

				XMLAttributePtr type_attr = emitter_node->Attrib("type");
				if (type_attr)
				{
					ps_desc_.ps_data->emitter_type = type_attr->ValueString();
				}
				else
				{
					ps_desc_.ps_data->emitter_type = "point";
				}

				XMLNodePtr freq_node = emitter_node->FirstNode("frequency");
				if (freq_node)
				{
					XMLAttributePtr attr = freq_node->Attrib("value");
					ps_desc_.ps_data->frequency = attr->ValueFloat();
				}

				XMLNodePtr angle_node = emitter_node->FirstNode("angle");
				if (angle_node)
				{
					XMLAttributePtr attr = angle_node->Attrib("value");
					ps_desc_.ps_data->angle = attr->ValueInt() * DEG2RAD;
				}

				XMLNodePtr pos_node = emitter_node->FirstNode("pos");
				if (pos_node)
				{
					float3 min_pos(0, 0, 0);
					XMLAttributePtr attr = pos_node->Attrib("min");
					if (attr)
					{
						std::vector<std::string> strs;
						boost::algorithm::split(strs, attr->ValueString(), boost::is_any_of(" "));
//.........这里部分代码省略.........
开发者ID:ImNaohaing,项目名称:KlayGE,代码行数:101,代码来源:ParticleSystem.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ teuchos::XMLObject类代码示例发布时间:2022-05-31
下一篇:
C++ XMLNode类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap