summaryrefslogtreecommitdiffstats
path: root/libdimension-python/dimension.pyx
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-09-18 11:26:35 -0400
committerTavian Barnes <tavianator@gmail.com>2011-09-18 11:26:35 -0400
commitca6ed9f1a186c79a17d03050d737b29f6f0edc94 (patch)
treeafc6d4708457e8b2daa6568c01e50a27df8ce947 /libdimension-python/dimension.pyx
parent5e13aa2d3c8a0ed11b061641eb0f6bc8b81a6f4c (diff)
downloaddimension-ca6ed9f1a186c79a17d03050d737b29f6f0edc94.tar.xz
Add .scale(), .translate(), and .rotate() methods to transformable objects.
Diffstat (limited to 'libdimension-python/dimension.pyx')
-rw-r--r--libdimension-python/dimension.pyx20
1 files changed, 14 insertions, 6 deletions
diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx
index 60daf43..601fb69 100644
--- a/libdimension-python/dimension.pyx
+++ b/libdimension-python/dimension.pyx
@@ -347,6 +347,14 @@ def rotate(*args, **kwargs):
cdef Vector rad = dmnsn_radians(1.0)*Vector(*args, **kwargs)
return _Matrix(dmnsn_rotation_matrix(rad._v))
+cdef class _Transformable:
+ def scale(self, *args, **kwargs):
+ return self.transform(scale(*args, **kwargs))
+ def translate(self, *args, **kwargs):
+ return self.transform(translate(*args, **kwargs))
+ def rotate(self, *args, **kwargs):
+ return self.transform(rotate(*args, **kwargs))
+
##########
# Colors #
##########
@@ -617,7 +625,7 @@ cdef class Leopard(Pattern):
# Pigments #
############
-cdef class Pigment:
+cdef class Pigment(_Transformable):
"""Object surface coloring."""
cdef dmnsn_pigment *_pigment
@@ -788,7 +796,7 @@ cdef class Reflection(Finish):
# Textures #
############
-cdef class Texture:
+cdef class Texture(_Transformable):
"""Object surface properties."""
cdef dmnsn_texture *_texture
@@ -888,7 +896,7 @@ cdef Interior _Interior(dmnsn_interior *interior):
# Objects #
###########
-cdef class Object:
+cdef class Object(_Transformable):
"""Physical objects."""
cdef dmnsn_object *_object
@@ -1247,7 +1255,7 @@ cdef class PointLight(Light):
# Cameras #
###########
-cdef class Camera:
+cdef class Camera(_Transformable):
"""A camera."""
cdef dmnsn_camera *_camera
@@ -1283,7 +1291,7 @@ cdef class PerspectiveCamera(Camera):
Camera.__init__(self)
# Apply the field of view angle
- self.transform(scale(tan(dmnsn_radians(angle))*(X + Y) + Z))
+ self.scale(tan(dmnsn_radians(angle))*(X + Y) + Z)
cdef Vector dir = Vector(look_at) - Vector(location)
cdef Vector vsky = Vector(sky)
@@ -1299,7 +1307,7 @@ cdef class PerspectiveCamera(Camera):
vsky._v, right._v)))
# Move the camera into position
- self.transform(translate(Vector(location)))
+ self.translate(Vector(location))
##########
# Scenes #