ShockShapes/Geometry.cpp
int Geometry::saveGeometry(pugi::xml_node root)
{
	//Make sure document pointer is valid
	if(!root)
		return 1;

	//Create the geometry node
	pugi::xml_node geom_node = root.append_child("geometry");
	geom_node.append_attribute("name") = name.c_str();
	geom_node.append_attribute("id") = unique_id.c_str();

	//Add mesh node to store triangle data
	pugi::xml_node mesh_node = geom_node.append_child("mesh");
	
	//Add the source node containing vertex positions
	writeVertexData(mesh_node, VDT_POSITION);

	//Add the source node containing vertex normals
	writeVertexData(mesh_node, VDT_NORMAL);

	//Add the source node containing vertex uv coordinates
	writeVertexData(mesh_node, VDT_UV);

	//Add the vertex node
	pugi::xml_node vertex_node = mesh_node.append_child("vertices");
	vertex_node.append_attribute("id") = (unique_id + "-Vtx").c_str();

	pugi::xml_node vinput_node = vertex_node.append_child("input");
	vinput_node.append_attribute("semantic") = "POSITION";
	vinput_node.append_attribute("source") = (std::string("#") + unique_id + "-Pos").c_str();

	//Add the triangles node
	writeTriangleData(mesh_node);

	return 0;
}
//Saves this geometric object into the specified COLLADA file
Saves this geometric object into the specified COLLADA file
Saves this geometric object into the specified COLLADA file
int Geometry::saveGeometry(pugi::xml_node root)
{
	if(!root)
		return 1;
	pugi::xml_node geom_node = root.append_child("geometry");
	geom_node.append_attribute("name") = name.c_str();
	geom_node.append_attribute("id") = unique_id.c_str();
	pugi::xml_node mesh_node = geom_node.append_child("mesh");
	writeVertexData(mesh_node, VDT_POSITION);
	writeVertexData(mesh_node, VDT_NORMAL);
	writeVertexData(mesh_node, VDT_UV);
	pugi::xml_node vertex_node = mesh_node.append_child("vertices");
	vertex_node.append_attribute("id") = (unique_id + "-Vtx").c_str();
	pugi::xml_node vinput_node = vertex_node.append_child("input");
	vinput_node.append_attribute("semantic") = "POSITION";
	vinput_node.append_attribute("source") = (std::string("#") + unique_id + "-Pos").c_str();
	writeTriangleData(mesh_node);
	return 0;
}
int Geometry :: saveGeometry ( pugi :: xml_node root ) { if ( ! root ) return 1 ; pugi :: xml_node geom_node = root . append_child ( " " ) ; geom_node . append_attribute ( " " ) = name . c_str ( ) ; geom_node . append_attribute ( " " ) = unique_id . c_str ( ) ; pugi :: xml_node mesh_node = geom_node . append_child ( " " ) ; writeVertexData ( mesh_node , VDT_POSITION ) ; writeVertexData ( mesh_node , VDT_NORMAL ) ; writeVertexData ( mesh_node , VDT_UV ) ; pugi :: xml_node vertex_node = mesh_node . append_child ( " " ) ; vertex_node . append_attribute ( " " ) = ( unique_id + " " ) . c_str ( ) ; pugi :: xml_node vinput_node = vertex_node . append_child ( " " ) ; vinput_node . append_attribute ( " " ) = " " ; vinput_node . append_attribute ( " " ) = ( std :: string ( " " ) + unique_id + " " ) . c_str ( ) ; writeTriangleData ( mesh_node ) ; return 0 ; }
Saves this geometric object into the specified COLLADA file
Saves this geometric object into the specified COLLADA file
//Make sure document pointer is valid //Create the geometry node //Add mesh node to store triangle data //Add the source node containing vertex positions //Add the source node containing vertex normals //Add the source node containing vertex uv coordinates //Add the vertex node //Add the triangles node