summaryrefslogtreecommitdiffstats
path: root/libdimension-python/Sphere.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-05-29 12:43:00 -0600
committerTavian Barnes <tavianator@gmail.com>2011-05-29 12:43:00 -0600
commit54585ba35adc6afc46201b746401c5a8a66ab6fa (patch)
tree0932e8b7bb7c3a590180a22d3b268c4d66ca9dca /libdimension-python/Sphere.c
parent4479d25609e26253c4e5fcfc78b093c0b45cefb8 (diff)
downloaddimension-54585ba35adc6afc46201b746401c5a8a66ab6fa.tar.xz
Add transform() to Python Objects.
Diffstat (limited to 'libdimension-python/Sphere.c')
-rw-r--r--libdimension-python/Sphere.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libdimension-python/Sphere.c b/libdimension-python/Sphere.c
index c2d5157..c6ec6a6 100644
--- a/libdimension-python/Sphere.c
+++ b/libdimension-python/Sphere.c
@@ -42,6 +42,20 @@ dmnsn_py_Sphere_init(dmnsn_py_Sphere *self, PyObject *args, PyObject *kwds)
static PyObject *
dmnsn_py_Sphere_initialize(dmnsn_py_Sphere *self)
{
+ dmnsn_matrix trans = dmnsn_scale_matrix(
+ dmnsn_new_vector(self->radius, self->radius, self->radius)
+ );
+ trans = dmnsn_matrix_mul(dmnsn_translation_matrix(self->center), trans);
+
+ dmnsn_object *object = self->base.object;
+ object->trans = dmnsn_matrix_mul(object->trans, trans);
+
+ dmnsn_texture *texture = object->texture;
+ if (texture) {
+ dmnsn_matrix trans_inv = dmnsn_matrix_inverse(trans);
+ texture->trans = dmnsn_matrix_mul(trans_inv, texture->trans);
+ }
+
Py_INCREF(Py_None);
return Py_None;
}