|
15 | 15 | #include "Components/PrimitiveComponent.h" |
16 | 16 | #include "Engine/StaticMesh.h" |
17 | 17 |
|
| 18 | +PyObject *py_ue_set_material_by_name(ue_PyUObject *self, PyObject * args) |
| 19 | +{ |
| 20 | + |
| 21 | + ue_py_check(self); |
| 22 | + |
| 23 | + char *slot_name; |
| 24 | + PyObject *py_mat; |
| 25 | + if (!PyArg_ParseTuple(args, "sO:set_material_by_name", &slot_name, &py_mat)) |
| 26 | + { |
| 27 | + return nullptr; |
| 28 | + } |
| 29 | + |
| 30 | + UPrimitiveComponent *primitive = ue_py_check_type<UPrimitiveComponent>(self); |
| 31 | + if (!primitive) |
| 32 | + return PyErr_Format(PyExc_Exception, "uobject is not a UPrimitiveComponent"); |
| 33 | + |
| 34 | + UMaterialInterface *material = ue_py_check_type<UMaterialInterface>(py_mat); |
| 35 | + if (!material) |
| 36 | + return PyErr_Format(PyExc_Exception, "argument is not a UMaterialInterface"); |
| 37 | + |
| 38 | + primitive->SetMaterialByName(FName(UTF8_TO_TCHAR(slot_name)), material); |
| 39 | + |
| 40 | + Py_RETURN_NONE; |
| 41 | +} |
| 42 | + |
| 43 | +PyObject *py_ue_set_material(ue_PyUObject *self, PyObject * args) |
| 44 | +{ |
| 45 | + |
| 46 | + ue_py_check(self); |
| 47 | + |
| 48 | + int slot; |
| 49 | + PyObject *py_mat; |
| 50 | + if (!PyArg_ParseTuple(args, "iO:set_material", &slot, &py_mat)) |
| 51 | + { |
| 52 | + return nullptr; |
| 53 | + } |
| 54 | + |
| 55 | + UPrimitiveComponent *primitive = ue_py_check_type<UPrimitiveComponent>(self); |
| 56 | + if (!primitive) |
| 57 | + return PyErr_Format(PyExc_Exception, "uobject is not a UPrimitiveComponent"); |
| 58 | + |
| 59 | + UMaterialInterface *material = ue_py_check_type<UMaterialInterface>(py_mat); |
| 60 | + if (!material) |
| 61 | + return PyErr_Format(PyExc_Exception, "argument is not a UMaterialInterface"); |
| 62 | + |
| 63 | + primitive->SetMaterial(slot, material); |
| 64 | + |
| 65 | + Py_RETURN_NONE; |
| 66 | +} |
| 67 | + |
18 | 68 | PyObject *py_ue_set_material_scalar_parameter(ue_PyUObject *self, PyObject * args) |
19 | 69 | { |
20 | 70 |
|
@@ -308,44 +358,6 @@ PyObject *py_ue_create_material_instance_dynamic(ue_PyUObject *self, PyObject * |
308 | 358 | Py_RETURN_UOBJECT(material_dynamic); |
309 | 359 | } |
310 | 360 |
|
311 | | -PyObject *py_ue_set_material(ue_PyUObject *self, PyObject * args) |
312 | | -{ |
313 | | - |
314 | | - ue_py_check(self); |
315 | | - |
316 | | - int index; |
317 | | - PyObject *py_material = nullptr; |
318 | | - |
319 | | - if (!PyArg_ParseTuple(args, "iO:set_material", &index, &py_material)) |
320 | | - { |
321 | | - return NULL; |
322 | | - } |
323 | | - |
324 | | - if (!self->ue_object->IsA<UPrimitiveComponent>()) |
325 | | - { |
326 | | - return PyErr_Format(PyExc_Exception, "uobject is not a UPrimitiveComponent"); |
327 | | - } |
328 | | - |
329 | | - UPrimitiveComponent *component = (UPrimitiveComponent *)self->ue_object; |
330 | | - |
331 | | - if (!ue_is_pyuobject(py_material)) |
332 | | - { |
333 | | - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); |
334 | | - } |
335 | | - |
336 | | - ue_PyUObject *py_obj = (ue_PyUObject *)py_material; |
337 | | - |
338 | | - if (!py_obj->ue_object->IsA<UMaterialInterface>()) |
339 | | - { |
340 | | - return PyErr_Format(PyExc_Exception, "uobject is not a UMaterialInterface"); |
341 | | - } |
342 | | - |
343 | | - UMaterialInterface *material_interface = (UMaterialInterface *)py_obj->ue_object; |
344 | | - |
345 | | - component->SetMaterial(index, material_interface); |
346 | | - |
347 | | - Py_RETURN_NONE; |
348 | | -} |
349 | 361 |
|
350 | 362 |
|
351 | 363 | #if WITH_EDITOR |
|
0 commit comments