コード例 #1
0
void ColladaSerializer::ColladaExporter::ColladaMaterials::ColladaEffects::write(const IfcGeom::Material& material) {
	openEffect(collada_id(material.name()) + "-fx");
	COLLADASW::EffectProfile effect(mSW);
	effect.setShaderType(COLLADASW::EffectProfile::LAMBERT);
	if (material.hasDiffuse()) {
		const double* diffuse = material.diffuse();
		effect.setDiffuse(COLLADASW::ColorOrTexture(COLLADASW::Color(diffuse[0],diffuse[1],diffuse[2])));
	}
	if (material.hasSpecular()) {
		const double* specular = material.specular();
		effect.setSpecular(COLLADASW::ColorOrTexture(COLLADASW::Color(specular[0],specular[1],specular[2])));
	}
	if (material.hasSpecularity()) {
		effect.setShininess(material.specularity());
	}
	if (material.hasTransparency()) {
		const double transparency = material.transparency();
		if (transparency > 0) {
			// The default opacity mode for Collada is A_ONE, which apparently indicates a
			// transparency value of 1 to be fully opaque. Hence transparency is inverted.
			effect.setTransparency(1.0 - transparency);
		}
	}
	addEffectProfile(effect);
	closeEffect();
}
コード例 #2
0
void WaveFrontOBJSerializer::writeMaterial(const IfcGeom::Material& style)
{
    std::string material_name = (settings().get(IfcGeom::IteratorSettings::USE_MATERIAL_NAMES)
        ? style.original_name() : style.name());
    IfcUtil::sanitate_material_name(material_name);
    mtl_stream << "newmtl " << material_name << "\n";
	if (style.hasDiffuse()) {
		const double* diffuse = style.diffuse();
		mtl_stream << "Kd " << diffuse[0] << " " << diffuse[1] << " " << diffuse[2] << "\n";
	}
	if (style.hasSpecular()) {
		const double* specular = style.specular();
		mtl_stream << "Ks " << specular[0] << " " << specular[1] << " " << specular[2] << "\n";
	}
	if (style.hasSpecularity()) {
		mtl_stream << "Ns " << style.specularity() << "\n";
	}
	if (style.hasTransparency()) {
		const double transparency = 1.0 - style.transparency();
		if (transparency < 1) {
			mtl_stream << "Tr " << transparency << "\n";
			mtl_stream << "d "  << transparency << "\n";
			mtl_stream << "D "  << transparency << "\n";
		}
	}
}
コード例 #3
0
void WaveFrontOBJSerializer::writeMaterial(const IfcGeom::Material& style) {
    mtl_stream << "newmtl " << style.name() << "\n";
    if (style.hasDiffuse()) {
        const double* diffuse = style.diffuse();
        mtl_stream << "Kd " << diffuse[0] << " " << diffuse[1] << " " << diffuse[2] << "\n";
    }
    if (style.hasSpecular()) {
        const double* specular = style.specular();
        mtl_stream << "Ks " << specular[0] << " " << specular[1] << " " << specular[2] << "\n";
    }
    if (style.hasSpecularity()) {
        mtl_stream << "Ns " << style.specularity() << "\n";
    }
    if (style.hasTransparency()) {
        const double transparency = 1.0 - style.transparency();
        if (transparency < 1) {
            mtl_stream << "Tr " << transparency << "\n";
            mtl_stream << "d "  << transparency << "\n";
            mtl_stream << "D "  << transparency << "\n";
        }
    }
}