diff options
author | Tavian Barnes <tavianator@gmail.com> | 2011-05-29 12:43:00 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2011-05-29 12:43:00 -0600 |
commit | 54585ba35adc6afc46201b746401c5a8a66ab6fa (patch) | |
tree | 0932e8b7bb7c3a590180a22d3b268c4d66ca9dca /libdimension-python/Object.c | |
parent | 4479d25609e26253c4e5fcfc78b093c0b45cefb8 (diff) | |
download | dimension-54585ba35adc6afc46201b746401c5a8a66ab6fa.tar.xz |
Add transform() to Python Objects.
Diffstat (limited to 'libdimension-python/Object.c')
-rw-r--r-- | libdimension-python/Object.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libdimension-python/Object.c b/libdimension-python/Object.c index 5942d3d..b44ff1a 100644 --- a/libdimension-python/Object.c +++ b/libdimension-python/Object.c @@ -43,9 +43,29 @@ dmnsn_py_Object_initialize(dmnsn_py_Object *self) return NULL; } +static PyObject * +dmnsn_py_Object_transform(dmnsn_py_Object *self, PyObject *args) +{ + dmnsn_py_Matrix *trans; + if (!PyArg_ParseTuple(args, "O!", &dmnsn_py_MatrixType, &trans)) + return NULL; + + if (!self->object) { + PyErr_SetString(PyExc_TypeError, "Attempt to transform base Object"); + return NULL; + } + + self->object->trans = dmnsn_matrix_mul(trans->m, self->object->trans); + + Py_INCREF(self); + return (PyObject *)self; +} + static PyMethodDef dmnsn_py_Object_methods[] = { { "initialize", (PyCFunction)dmnsn_py_Object_initialize, METH_NOARGS, "Initialize an object" }, + { "transform", (PyCFunction)dmnsn_py_Object_transform, METH_VARARGS, + "Transform an object" }, { NULL } }; |