void ColladaSerializer::ColladaExporter::ColladaMaterials::write() {
	effects.close();
	for (std::vector<IfcGeom::Material>::const_iterator it = materials.begin(); it != materials.end(); ++it) {
		const std::string& material_name = collada_id((*it).name());
		openMaterial(material_name);
		addInstanceEffect("#" + material_name + "-fx");
		closeMaterial();
	}
	closeLibrary();
}
Example #2
0
void MaterialsExporter::operator()(Material *ma, Object *ob)
{
	std::string name(id_name(ma));

	openMaterial(get_material_id(ma), translate_id(name));

	std::string efid = translate_id(name) + "-effect";
	addInstanceEffect(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, efid));

	closeMaterial();
}
Example #3
0
void MaterialExporter::doExport()
{
	vgLogDebug("Exporting materials");
	openLibrary();
	
	if( m_exportSettings.getLevel() > GEOMETRY )
	{
		typedef collectedMapType::right_map::const_iterator right_const_iterator;

		for( right_const_iterator right_iter = m_collectedMap.right.begin(), iend = m_collectedMap.right.end();
			 right_iter != iend; ++right_iter )
		{
			vgd::Shp< vge::technique::CollectedMaterial > collectedMaterial = right_iter->first;
			
			if( collectedMaterial->getMaterial() )
			{
				std::string effectName = collectedMaterial->getEffectId();
				std::string materialName = effectName + MATERIAL_ID_SUFFIX;
				collectedMaterial->setMaterialId( materialName );

				openMaterial ( materialName, COLLADABU::Utils::checkNCName(materialName) );
				addInstanceEffect ( "#" + effectName );
				closeMaterial ();
			}
		}
	}
	else
	{
		std::string effectName = "DefaultWhole";
		std::string materialName = effectName + MATERIAL_ID_SUFFIX;

		openMaterial ( materialName, COLLADABU::Utils::checkNCName(materialName) );
		addInstanceEffect ( "#" + effectName );
		closeMaterial ();
	}
	closeLibrary();
}
Example #4
0
void MaterialExporter::add()
{
    char tempStr[1024];

    openLibrary();
    for (int i = 0; i < m_bsp->numShaders; ++i)
    {
        sprintf(tempStr, "material%d", i);
        std::string matId = tempStr;

        sprintf(tempStr, "material%d-fx", i);
        std::string fxId = tempStr;

        openMaterial(matId, matId);
        addInstanceEffect(COLLADASW::URI(EMPTY_STRING, fxId));
        closeMaterial();
    }
    closeLibrary();
}
Example #5
0
void MaterialsExporter::exportMaterials(Scene *sce)
{
	if (this->export_settings->export_texture_type == BC_TEXTURE_TYPE_MAT)
	{
		if (hasMaterials(sce)) {
			openLibrary();

			MaterialFunctor mf;
			mf.forEachMaterialInExportSet<MaterialsExporter>(sce, *this, this->export_settings->export_set);

			closeLibrary();
		}
	}

	else {
		std::set<Image *> uv_images = bc_getUVImages(sce, !this->export_settings->active_uv_only);
		if (uv_images.size() > 0) {
			openLibrary();
			std::set<Image *>::iterator uv_images_iter;
			for (uv_images_iter = uv_images.begin();
				uv_images_iter != uv_images.end();
				uv_images_iter++) {

				Image *ima = *uv_images_iter;
				std::string matid(id_name(ima));

				openMaterial(get_material_id_from_id(matid), translate_id(matid));
				std::string efid = translate_id(matid) + "-effect";
				addInstanceEffect(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, efid));
				closeMaterial();
			}
			closeLibrary();
		}
	}

}