+ fixes #0001580: Adding transparency to povray output

This commit is contained in:
wmayer 2014-06-14 14:19:29 +02:00
parent 3523741e96
commit 00e041ffb3
3 changed files with 13 additions and 3 deletions

View File

@ -47,6 +47,7 @@ RayFeature::RayFeature(void)
{ {
ADD_PROPERTY(Source,(0)); ADD_PROPERTY(Source,(0));
ADD_PROPERTY(Color,(App::Color(0.5f,0.5f,0.5f))); ADD_PROPERTY(Color,(App::Color(0.5f,0.5f,0.5f)));
ADD_PROPERTY(Transparency,(0));
} }
App::DocumentObjectExecReturn *RayFeature::execute(void) App::DocumentObjectExecReturn *RayFeature::execute(void)
@ -67,12 +68,19 @@ App::DocumentObjectExecReturn *RayFeature::execute(void)
PovTools::writeShape(result,Name.c_str(),shape); PovTools::writeShape(result,Name.c_str(),shape);
// This must not be done in PovTools::writeShape! // This must not be done in PovTools::writeShape!
long t = Transparency.getValue();
const App::Color& c = Color.getValue(); const App::Color& c = Color.getValue();
result << "// instance to render" << endl result << "// instance to render" << endl
<< "object {" << Name << endl << "object {" << Name << endl
<< " texture {" << endl << " texture {" << endl;
<< " pigment {color rgb <"<<c.r<<","<<c.g<<","<<c.b<<">}" << endl if (t == 0) {
<< " finish {StdFinish } //definition on top of the project" << endl result << " pigment {color rgb <"<<c.r<<","<<c.g<<","<<c.b<<">}" << endl;
}
else {
float trans = t/100.0f;
result << " pigment {color rgb <"<<c.r<<","<<c.g<<","<<c.b<<"> transmit "<<trans<<"}" << endl;
}
result << " finish {StdFinish } //definition on top of the project" << endl
<< " }" << endl << " }" << endl
<< "}" << endl ; << "}" << endl ;

View File

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

View File

@ -462,6 +462,7 @@ void CmdRaytracingNewPartSegment::activated(int iMsg)
doCommand(Doc,"App.activeDocument().addObject('Raytracing::%s','%s')",FeatType,FeatName.c_str()); doCommand(Doc,"App.activeDocument().addObject('Raytracing::%s','%s')",FeatType,FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",FeatName.c_str(),(*it)->getNameInDocument()); doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",FeatName.c_str(),(*it)->getNameInDocument());
doCommand(Doc,"App.activeDocument().%s.Color = Gui.activeDocument().%s.ShapeColor",FeatName.c_str(),(*it)->getNameInDocument()); doCommand(Doc,"App.activeDocument().%s.Color = Gui.activeDocument().%s.ShapeColor",FeatName.c_str(),(*it)->getNameInDocument());
doCommand(Doc,"App.activeDocument().%s.Transparency = Gui.activeDocument().%s.Transparency",FeatName.c_str(),(*it)->getNameInDocument());
doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)",ProjName.c_str(), FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)",ProjName.c_str(), FeatName.c_str());
} }
updateActive(); updateActive();