+ expose Material class to Python
This commit is contained in:
@@ -100,6 +100,7 @@
|
||||
#include "OriginFeature.h"
|
||||
#include "Origin.h"
|
||||
#include "MaterialObject.h"
|
||||
#include "MaterialPy.h"
|
||||
#include "Expression.h"
|
||||
|
||||
// If you stumble here, run the target "BuildExtractRevision" on Windows systems
|
||||
@@ -233,6 +234,8 @@ Application::Application(std::map<std::string,std::string> &mConfig)
|
||||
Base::Interpreter().addType(&Base::RotationPy ::Type,pBaseModule,"Rotation");
|
||||
Base::Interpreter().addType(&Base::AxisPy ::Type,pBaseModule,"Axis");
|
||||
|
||||
Base::Interpreter().addType(&App::MaterialPy::Type, pAppModule, "Material");
|
||||
|
||||
//insert Base and Console
|
||||
Py_INCREF(pBaseModule);
|
||||
PyModule_AddObject(pAppModule, "Base", pBaseModule);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
Namespace="App"
|
||||
FatherInclude="Base/PyObjectBase.h"
|
||||
FatherNamespace="Base"
|
||||
Constructor="true"
|
||||
Delete="true">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
|
||||
|
||||
@@ -31,6 +31,54 @@
|
||||
|
||||
using namespace App;
|
||||
|
||||
PyObject *MaterialPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// create a new instance of MaterialPy and the Twin object
|
||||
return new MaterialPy(new Material);
|
||||
}
|
||||
|
||||
// constructor method
|
||||
int MaterialPy::PyInit(PyObject* args, PyObject* kwds)
|
||||
{
|
||||
PyObject* diffuse = 0;
|
||||
PyObject* ambient = 0;
|
||||
PyObject* specular = 0;
|
||||
PyObject* emissive = 0;
|
||||
PyObject* shininess = 0;
|
||||
PyObject* transpareny = 0;
|
||||
static char* kwds_colors[] = { "DiffuseColor", "AmbientColor", "SpecularColor", "EmissiveColor", "Shininess", "Transparency", NULL };
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOO", kwds_colors,
|
||||
&diffuse, &ambient, &specular, &emissive, &shininess, &transpareny))
|
||||
return -1;
|
||||
|
||||
if (diffuse) {
|
||||
setDiffuseColor(Py::Tuple(diffuse));
|
||||
}
|
||||
|
||||
if (ambient) {
|
||||
setAmbientColor(Py::Tuple(ambient));
|
||||
}
|
||||
|
||||
if (specular) {
|
||||
setSpecularColor(Py::Tuple(specular));
|
||||
}
|
||||
|
||||
if (emissive) {
|
||||
setEmissiveColor(Py::Tuple(emissive));
|
||||
}
|
||||
|
||||
if (shininess) {
|
||||
setShininess(Py::Float(shininess));
|
||||
}
|
||||
|
||||
if (transpareny) {
|
||||
setTransparency(Py::Float(transpareny));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string MaterialPy::representation(void) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user