Blender  V2.93
BPy_BlenderTextureShader.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
22 
23 #include "../../stroke/BasicStrokeShaders.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include "../../../../python/generic/py_capi_utils.h"
30 
31 using namespace Freestyle;
32 
34 
35 //------------------------INSTANCE METHODS ----------------------------------
36 
38  "Class hierarchy: :class:`freestyle.types.StrokeShader` > :class:`BlenderTextureShader`\n"
39  "\n"
40  "[Texture shader]\n"
41  "\n"
42  ".. method:: __init__(texture)\n"
43  "\n"
44  " Builds a BlenderTextureShader object.\n"
45  "\n"
46  " :arg texture: A line style texture slot or a shader node tree to define\n"
47  " a set of textures.\n"
48  " :type texture: :class:`bpy.types.LineStyleTextureSlot` or\n"
49  " :class:`bpy.types.ShaderNodeTree`\n"
50  "\n"
51  ".. method:: shade(stroke)\n"
52  "\n"
53  " Assigns a blender texture slot to the stroke shading in order to\n"
54  " simulate marks.\n"
55  "\n"
56  " :arg stroke: A Stroke object.\n"
57  " :type stroke: :class:`freestyle.types.Stroke`\n";
58 
60  PyObject *args,
61  PyObject *kwds)
62 {
63  static const char *kwlist[] = {"texture", nullptr};
64  PyObject *obj;
65  MTex *_mtex;
66  bNodeTree *_nodetree;
67 
68  if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj)) {
69  return -1;
70  }
71  _mtex = (MTex *)PyC_RNA_AsPointer(obj, "LineStyleTextureSlot");
72  if (_mtex) {
73  self->py_ss.ss = new StrokeShaders::BlenderTextureShader(_mtex);
74  return 0;
75  }
76  PyErr_Clear();
77  _nodetree = (bNodeTree *)PyC_RNA_AsPointer(obj, "ShaderNodeTree");
78  if (_nodetree) {
79  self->py_ss.ss = new StrokeShaders::BlenderTextureShader(_nodetree);
80  return 0;
81  }
82  PyErr_Format(PyExc_TypeError,
83  "expected either 'LineStyleTextureSlot' or 'ShaderNodeTree', "
84  "found '%.200s' instead",
85  Py_TYPE(obj)->tp_name);
86  return -1;
87 }
88 
89 /*-----------------------BPy_BlenderTextureShader type definition ------------------------------*/
90 
91 PyTypeObject BlenderTextureShader_Type = {
92  PyVarObject_HEAD_INIT(nullptr, 0) "BlenderTextureShader", /* tp_name */
93  sizeof(BPy_BlenderTextureShader), /* tp_basicsize */
94  0, /* tp_itemsize */
95  nullptr, /* tp_dealloc */
96  0, /* tp_vectorcall_offset */
97  nullptr, /* tp_getattr */
98  nullptr, /* tp_setattr */
99  nullptr, /* tp_reserved */
100  nullptr, /* tp_repr */
101  nullptr, /* tp_as_number */
102  nullptr, /* tp_as_sequence */
103  nullptr, /* tp_as_mapping */
104  nullptr, /* tp_hash */
105  nullptr, /* tp_call */
106  nullptr, /* tp_str */
107  nullptr, /* tp_getattro */
108  nullptr, /* tp_setattro */
109  nullptr, /* tp_as_buffer */
110  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
111  BlenderTextureShader___doc__, /* tp_doc */
112  nullptr, /* tp_traverse */
113  nullptr, /* tp_clear */
114  nullptr, /* tp_richcompare */
115  0, /* tp_weaklistoffset */
116  nullptr, /* tp_iter */
117  nullptr, /* tp_iternext */
118  nullptr, /* tp_methods */
119  nullptr, /* tp_members */
120  nullptr, /* tp_getset */
121  &StrokeShader_Type, /* tp_base */
122  nullptr, /* tp_dict */
123  nullptr, /* tp_descr_get */
124  nullptr, /* tp_descr_set */
125  0, /* tp_dictoffset */
126  (initproc)BlenderTextureShader___init__, /* tp_init */
127  nullptr, /* tp_alloc */
128  nullptr, /* tp_new */
129 };
130 
132 
133 #ifdef __cplusplus
134 }
135 #endif
static int BlenderTextureShader___init__(BPy_BlenderTextureShader *self, PyObject *args, PyObject *kwds)
PyTypeObject BlenderTextureShader_Type
static char BlenderTextureShader___doc__[]
PyTypeObject StrokeShader_Type
inherits from class Rep
Definition: AppCanvas.cpp:32
void * PyC_RNA_AsPointer(PyObject *value, const char *type_name)