ShockShapes/Instance.cpp
int Instance::saveInstance(pugi::xml_node root, int *id, Transform *parent)
{
	//Make sure node pointer is valid
	if(!root)
		return 1;

	std::ostringstream name_stream;
	name_stream << original->getUniqueId() << "-Inst-" << (*id);
	*id = *id + 1;

	pugi::xml_node node = root.append_child("node");
	node.append_attribute("name") = name_stream.str().c_str();

	//Compound parent transform into the group's transform
	Transform total_t(t);
	if(parent)
		total_t.combine(parent);

	//Add the transform element
	total_t.save(node);

	//Add the geometry instance element
	pugi::xml_node instance_node = node.append_child("instance_geometry");
	instance_node.append_attribute("url") = (std::string("#") + original->getUniqueId()).c_str();

	return 0;
}
//Saves an instance of the original object
Saves an instance of the original object
Saves an instance of the original object
int Instance::saveInstance(pugi::xml_node root, int *id, Transform *parent)
{
	if(!root)
		return 1;
	std::ostringstream name_stream;
	name_stream << original->getUniqueId() << "-Inst-" << (*id);
	*id = *id + 1;
	pugi::xml_node node = root.append_child("node");
	node.append_attribute("name") = name_stream.str().c_str();
	Transform total_t(t);
	if(parent)
		total_t.combine(parent);
	total_t.save(node);
	pugi::xml_node instance_node = node.append_child("instance_geometry");
	instance_node.append_attribute("url") = (std::string("#") + original->getUniqueId()).c_str();
	return 0;
}
int Instance :: saveInstance ( pugi :: xml_node root , int * id , Transform * parent ) { if ( ! root ) return 1 ; std :: ostringstream name_stream ; name_stream << original -> getUniqueId ( ) << " " << ( * id ) ; * id = * id + 1 ; pugi :: xml_node node = root . append_child ( " " ) ; node . append_attribute ( " " ) = name_stream . str ( ) . c_str ( ) ; Transform total_t ( t ) ; if ( parent ) total_t . combine ( parent ) ; total_t . save ( node ) ; pugi :: xml_node instance_node = node . append_child ( " " ) ; instance_node . append_attribute ( " " ) = ( std :: string ( " " ) + original -> getUniqueId ( ) ) . c_str ( ) ; return 0 ; }
Saves an instance of the original object
Saves an instance of the original object
//Make sure node pointer is valid //Compound parent transform into the group's transform //Add the transform element //Add the geometry instance element