Raytracing: Added function to write shapes as luxrender strings

This commit is contained in:
Yorik van Havre
2013-09-22 19:30:07 -03:00
parent 1c51aea58a
commit 382a12f55f
3 changed files with 104 additions and 2 deletions

View File

@@ -29,6 +29,7 @@
#include <Base/Console.h>
#include "PovTools.h"
#include "LuxTools.h"
// automatically generated.....
#include "FreeCADpov.h"
@@ -92,6 +93,32 @@ getPartAsPovray(PyObject *self, PyObject *args)
return Py::new_reference_to(Py::String(out.str()));
}
/// get part as lux string
static PyObject *
getPartAsLux(PyObject *self, PyObject *args)
{
float r=0.5,g=0.5,b=0.5;
PyObject *ShapeObject;
const char *PartName;
if (! PyArg_ParseTuple(args, "sO!|fff",&PartName,
&(Part::TopoShapePy::Type), &ShapeObject,&r,&g,&b))
return NULL;
std::stringstream out;
TopoDS_Shape &aShape = static_cast<Part::TopoShapePy *>(ShapeObject)->getTopoShapePtr()->_Shape;
// write a material entry
// This must not be done in PovTools::writeShape!
out << "MakeNamedMaterial \"FreeCADMaterial_" << PartName << "\"" << endl;
out << " \"color Kd\" [" << r << " " << g << " " << b << "]" << endl;
out << " \"float sigma\" [0.000000000000000]" << endl;
out << " \"string type\" [\"matte\"]" << endl << endl;
LuxTools::writeShape(out,PartName,aShape,(float)0.1);
return Py::new_reference_to(Py::String(out.str()));
}
/// write part file
static PyObject *
writePartFile(PyObject *self, PyObject *args)
@@ -218,6 +245,7 @@ struct PyMethodDef Raytracing_methods[] = {
{"writePartFile", writePartFile , 1},
{"writePartFileCSV", writePartFileCSV, 1},
{"getPartAsPovray", getPartAsPovray , 1},
{"getPartAsLux", getPartAsLux , 1},
{"writeDataFile", writeDataFile , 1},
{"writeCameraFile", writeCameraFile , 1},
{"copyResource", copyResource , 1},