Raytracing: added transparency to lux feature - fixes #1771

This commit is contained in:
Yorik van Havre 2015-01-02 16:48:35 -02:00
parent 393d64d53c
commit 1dd069ec7f
2 changed files with 22 additions and 4 deletions

View File

@ -47,6 +47,7 @@ LuxFeature::LuxFeature(void)
{
ADD_PROPERTY(Source,(0));
ADD_PROPERTY(Color,(App::Color(0.5f,0.5f,0.5f)));
ADD_PROPERTY(Transparency,(0));
}
App::DocumentObjectExecReturn *LuxFeature::execute(void)
@ -67,10 +68,26 @@ App::DocumentObjectExecReturn *LuxFeature::execute(void)
// write a material entry
// This must not be done in LuxTools::writeShape!
const App::Color& c = Color.getValue();
result << "MakeNamedMaterial \"FreeCADMaterial_" << Name << "\"" << endl
<< " \"color Kd\" [" << c.r << " " << c.g << " " << c.b << "]" << endl
<< " \"float sigma\" [0.000000000000000]" << endl
<< " \"string type\" [\"matte\"]" << endl << endl;
long t = Transparency.getValue();
if (t == 0) {
result << "MakeNamedMaterial \"FreeCADMaterial_" << Name << "\"" << endl
<< " \"color Kd\" [" << c.r << " " << c.g << " " << c.b << "]" << endl
<< " \"float sigma\" [0.000000000000000]" << endl
<< " \"string type\" [\"matte\"]" << endl << endl;
} else {
float trans = t/100.0f;
result << "MakeNamedMaterial \"FreeCADMaterial_Base_" << Name << "\"" << endl
<< " \"color Kd\" [" << c.r << " " << c.g << " " << c.b << "]" << endl
<< " \"float sigma\" [0.000000000000000]" << endl
<< " \"string type\" [\"matte\"]" << endl << endl
<< "MakeNamedMaterial \"FreeCADMaterial_Null_" << Name << "\"" << endl
<< " \"string type\" [\"null\"]" << endl << endl
<< "MakeNamedMaterial \"FreeCADMaterial_" << Name << "\"" << endl
<< " \"string namedmaterial1\" [\"FreeCADMaterial_Null_" << Name << "\"]" << endl
<< " \"string namedmaterial2\" [\"FreeCADMaterial_Base_" << Name << "\"]" << endl
<< " \"float amount\" [" << trans << "]" << endl
<< " \"string type\" [\"mix\"]" << endl << endl;
}
LuxTools::writeShape(result,Name.c_str(),shape);

View File

@ -49,6 +49,7 @@ public:
App::PropertyLink Source;
App::PropertyColor Color;
App::PropertyPercent Transparency;
/** @name methods overide Feature */
//@{