57 "Class defining a material.\n"
59 ".. method:: __init__()\n"
60 " __init__(brother)\n"
61 " __init__(line, diffuse, ambient, specular, emission, shininess, priority)\n"
63 " Creates a :class:`FrsMaterial` using either default constructor,\n"
64 " copy constructor, or an overloaded constructor\n"
66 " :arg brother: A Material object to be used as a copy constructor.\n"
67 " :type brother: :class:`Material`\n"
68 " :arg line: The line color.\n"
69 " :type line: :class:`mathutils.Vector`, list or tuple of 4 float values\n"
70 " :arg diffuse: The diffuse color.\n"
71 " :type diffuse: :class:`mathutils.Vector`, list or tuple of 4 float values\n"
72 " :arg ambient: The ambient color.\n"
73 " :type ambient: :class:`mathutils.Vector`, list or tuple of 4 float values\n"
74 " :arg specular: The specular color.\n"
75 " :type specular: :class:`mathutils.Vector`, list or tuple of 4 float values\n"
76 " :arg emission: The emissive color.\n"
77 " :type emission: :class:`mathutils.Vector`, list or tuple of 4 float values\n"
78 " :arg shininess: The shininess coefficient.\n"
79 " :type shininess: float\n"
80 " :arg priority: The line color priority.\n"
81 " :type priority: int");
85 static const char *kwlist_1[] = {
"brother",
nullptr};
86 static const char *kwlist_2[] = {
87 "line",
"diffuse",
"ambient",
"specular",
"emission",
"shininess",
"priority",
nullptr};
88 PyObject *brother =
nullptr;
89 float line[4], diffuse[4], ambient[4], specular[4], emission[4], shininess;
92 if (PyArg_ParseTupleAndKeywords(
100 PyErr_SetString(PyExc_RuntimeError,
"invalid Material object");
106 else if ((
void)PyErr_Clear(),
107 PyArg_ParseTupleAndKeywords(args,
123 self->m =
new FrsMaterial(line, diffuse, ambient, specular, emission, shininess, priority);
126 PyErr_SetString(PyExc_TypeError,
"invalid argument(s)");
135 Py_TYPE(
self)->tp_free((PyObject *)
self);
140 return PyUnicode_FromFormat(
"Material - address: %p",
self->m);
146 #define MATHUTILS_SUBTYPE_DIFFUSE 1
147 #define MATHUTILS_SUBTYPE_SPECULAR 2
148 #define MATHUTILS_SUBTYPE_AMBIENT 3
149 #define MATHUTILS_SUBTYPE_EMISSION 4
150 #define MATHUTILS_SUBTYPE_LINE 5
165 bmo->data[0] =
self->m->lineR();
166 bmo->data[1] =
self->m->lineG();
167 bmo->data[2] =
self->m->lineB();
168 bmo->data[3] =
self->m->lineA();
171 bmo->data[0] =
self->m->diffuseR();
172 bmo->data[1] =
self->m->diffuseG();
173 bmo->data[2] =
self->m->diffuseB();
174 bmo->data[3] =
self->m->diffuseA();
177 bmo->data[0] =
self->m->specularR();
178 bmo->data[1] =
self->m->specularG();
179 bmo->data[2] =
self->m->specularB();
180 bmo->data[3] =
self->m->specularA();
183 bmo->data[0] =
self->m->ambientR();
184 bmo->data[1] =
self->m->ambientG();
185 bmo->data[2] =
self->m->ambientB();
186 bmo->data[3] =
self->m->ambientA();
189 bmo->data[0] =
self->m->emissionR();
190 bmo->data[1] =
self->m->emissionG();
191 bmo->data[2] =
self->m->emissionB();
192 bmo->data[3] =
self->m->emissionA();
205 self->m->setLine(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]);
208 self->m->setDiffuse(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]);
211 self->m->setSpecular(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]);
214 self->m->setAmbient(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]);
217 self->m->setEmission(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]);
230 const float *color =
self->m->line();
231 bmo->data[index] = color[index];
234 const float *color =
self->m->diffuse();
235 bmo->data[index] = color[index];
238 const float *color =
self->m->specular();
239 bmo->data[index] = color[index];
242 const float *color =
self->m->ambient();
243 bmo->data[index] = color[index];
246 const float *color =
self->m->emission();
247 bmo->data[index] = color[index];
262 color[index] = bmo->data[index];
263 self->m->setLine(color[0], color[1], color[2], color[3]);
267 color[index] = bmo->data[index];
268 self->m->setDiffuse(color[0], color[1], color[2], color[3]);
272 color[index] = bmo->data[index];
273 self->m->setSpecular(color[0], color[1], color[2], color[3]);
277 color[index] = bmo->data[index];
278 self->m->setAmbient(color[0], color[1], color[2], color[3]);
282 color[index] = bmo->data[index];
283 self->m->setEmission(color[0], color[1], color[2], color[3]);
309 "RGBA components of the line color of the material.\n"
311 ":type: :class:`mathutils.Vector`");
325 self->m->setLine(color[0], color[1], color[2], color[3]);
330 "RGBA components of the diffuse color of the material.\n"
332 ":type: :class:`mathutils.Vector`");
346 self->m->setDiffuse(color[0], color[1], color[2], color[3]);
351 "RGBA components of the specular color of the material.\n"
353 ":type: :class:`mathutils.Vector`");
367 self->m->setSpecular(color[0], color[1], color[2], color[3]);
372 "RGBA components of the ambient color of the material.\n"
374 ":type: :class:`mathutils.Color`");
388 self->m->setAmbient(color[0], color[1], color[2], color[3]);
393 "RGBA components of the emissive color of the material.\n"
395 ":type: :class:`mathutils.Color`");
409 self->m->setEmission(color[0], color[1], color[2], color[3]);
414 "Shininess coefficient of the material.\n"
420 return PyFloat_FromDouble(
self->m->shininess());
426 if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
428 PyErr_SetString(PyExc_TypeError,
"value must be a number");
431 self->m->setShininess(scalar);
436 "Line color priority of the material.\n"
442 return PyLong_FromLong(
self->m->priority());
448 if ((scalar = PyLong_AsLong(value)) == -1 && PyErr_Occurred()) {
449 PyErr_SetString(PyExc_TypeError,
"value must be an integer");
452 self->m->setPriority(scalar);
460 FrsMaterial_line_doc,
465 FrsMaterial_diffuse_doc,
470 FrsMaterial_specular_doc,
475 FrsMaterial_ambient_doc,
480 FrsMaterial_emission_doc,
485 FrsMaterial_shininess_doc,
490 FrsMaterial_priority_doc,
492 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
503 if (comparison_type == Py_NE) {
513 switch (comparison_type) {
515 result = (*matA->
m) != (*matB->m);
518 result = (*matA->
m) == (*matB->m);
521 PyErr_SetString(PyExc_TypeError,
"Material does not support this comparison type");
534 return (Py_uhash_t)
BLI_hash_mm2((
const unsigned char *)
self,
sizeof(*
self), 0);
539 PyVarObject_HEAD_INIT(
nullptr, 0)
"Material",
557 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
uint32_t BLI_hash_mm2(const unsigned char *data, size_t len, uint32_t seed)
MINLINE void copy_v4_v4(float r[4], const float a[4])
int convert_v4(PyObject *obj, void *v)
void FrsMaterial_mathutils_register_callback()
int FrsMaterial_Init(PyObject *module)
#define MATHUTILS_SUBTYPE_DIFFUSE
static PyGetSetDef BPy_FrsMaterial_getseters[]
static PyObject * FrsMaterial_priority_get(BPy_FrsMaterial *self, void *UNUSED(closure))
static int FrsMaterial_line_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure))
static PyObject * FrsMaterial_diffuse_get(BPy_FrsMaterial *self, void *UNUSED(closure))
static PyObject * FrsMaterial_ambient_get(BPy_FrsMaterial *self, void *UNUSED(closure))
static void FrsMaterial_dealloc(BPy_FrsMaterial *self)
static int FrsMaterial_shininess_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure))
static int FrsMaterial_priority_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure))
PyDoc_STRVAR(FrsMaterial_doc, "Class defining a material.\n" "\n" ".. method:: __init__()\n" " __init__(brother)\n" " __init__(line, diffuse, ambient, specular, emission, shininess, priority)\n" "\n" " Creates a :class:`FrsMaterial` using either default constructor,\n" " copy constructor, or an overloaded constructor\n" "\n" " :arg brother: A Material object to be used as a copy constructor.\n" " :type brother: :class:`Material`\n" " :arg line: The line color.\n" " :type line: :class:`mathutils.Vector`, list or tuple of 4 float values\n" " :arg diffuse: The diffuse color.\n" " :type diffuse: :class:`mathutils.Vector`, list or tuple of 4 float values\n" " :arg ambient: The ambient color.\n" " :type ambient: :class:`mathutils.Vector`, list or tuple of 4 float values\n" " :arg specular: The specular color.\n" " :type specular: :class:`mathutils.Vector`, list or tuple of 4 float values\n" " :arg emission: The emissive color.\n" " :type emission: :class:`mathutils.Vector`, list or tuple of 4 float values\n" " :arg shininess: The shininess coefficient.\n" " :type shininess: float\n" " :arg priority: The line color priority.\n" " :type priority: int")
static int FrsMaterial_mathutils_get_index(BaseMathObject *bmo, int subtype, int index)
static PyObject * FrsMaterial_specular_get(BPy_FrsMaterial *self, void *UNUSED(closure))
static int FrsMaterial_init(BPy_FrsMaterial *self, PyObject *args, PyObject *kwds)
#define MATHUTILS_SUBTYPE_EMISSION
#define MATHUTILS_SUBTYPE_LINE
static Mathutils_Callback FrsMaterial_mathutils_cb
PyTypeObject FrsMaterial_Type
static int FrsMaterial_mathutils_set(BaseMathObject *bmo, int subtype)
#define MATHUTILS_SUBTYPE_SPECULAR
#define MATHUTILS_SUBTYPE_AMBIENT
static unsigned char FrsMaterial_mathutils_cb_index
static PyObject * BPy_FrsMaterial_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type)
static int FrsMaterial_diffuse_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure))
static int FrsMaterial_mathutils_get(BaseMathObject *bmo, int subtype)
static int FrsMaterial_emission_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure))
static PyObject * FrsMaterial_repr(BPy_FrsMaterial *self)
static int FrsMaterial_mathutils_set_index(BaseMathObject *bmo, int subtype, int index)
static int FrsMaterial_ambient_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure))
static PyObject * FrsMaterial_shininess_get(BPy_FrsMaterial *self, void *UNUSED(closure))
static int FrsMaterial_mathutils_check(BaseMathObject *bmo)
static Py_hash_t FrsMaterial_hash(PyObject *self)
static PyObject * FrsMaterial_emission_get(BPy_FrsMaterial *self, void *UNUSED(closure))
static int FrsMaterial_specular_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure))
static PyObject * FrsMaterial_line_get(BPy_FrsMaterial *self, void *UNUSED(closure))
#define BPy_FrsMaterial_Check(v)
static struct PyModuleDef module
uchar Mathutils_RegisterCallback(Mathutils_Callback *cb)
int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
PyObject * Vector_CreatePyObject_cb(PyObject *cb_user, int size, uchar cb_type, uchar cb_subtype)
PyObject_HEAD Freestyle::FrsMaterial * m