summaryrefslogtreecommitdiffstats
path: root/libdimension-python
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension-python')
-rw-r--r--libdimension-python/dimension.pxd7
-rw-r--r--libdimension-python/dimension.pyx47
2 files changed, 47 insertions, 7 deletions
diff --git a/libdimension-python/dimension.pxd b/libdimension-python/dimension.pxd
index 9bfe5a9..411be3f 100644
--- a/libdimension-python/dimension.pxd
+++ b/libdimension-python/dimension.pxd
@@ -372,10 +372,15 @@ cdef extern from "../libdimension/dimension.h":
dmnsn_texture *default_texture
dmnsn_interior *default_interior
+ dmnsn_canvas *canvas
+ size_t region_x
+ size_t region_y
+ size_t outer_width
+ size_t outer_height
+
dmnsn_array *objects
dmnsn_array *lights
dmnsn_camera *camera
- dmnsn_canvas *canvas
dmnsn_quality quality
unsigned int reclimit
diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx
index 2197edd..baafcd6 100644
--- a/libdimension-python/dimension.pyx
+++ b/libdimension-python/dimension.pyx
@@ -1298,6 +1298,8 @@ cdef class Scene:
self._scene.canvas = canvas._canvas
DMNSN_INCREF(self._scene.canvas)
+ self.outer_width = self._scene.canvas.width
+ self.outer_height = self._scene.canvas.height
cdef dmnsn_object *o
for obj in objects:
@@ -1311,14 +1313,35 @@ cdef class Scene:
DMNSN_INCREF(l)
dmnsn_array_push(self._scene.lights, &l)
- # Account for image dimensions in the camera
- camera._camera.trans = dmnsn_matrix_mul(
- camera._camera.trans,
- dmnsn_scale_matrix(dmnsn_new_vector(canvas.width/canvas.height, 1.0, 1.0))
- )
self._scene.camera = camera._camera
DMNSN_INCREF(self._scene.camera)
+ # Subregion render support
+ property region_x:
+ """The x-coordinate of the subregion in the broader image."""
+ def __get__(self):
+ return self._scene.region_x
+ def __set__(self, x):
+ self._scene.region_x = x
+ property region_y:
+ """The y-coordinate of the subregion in the broader image."""
+ def __get__(self):
+ return self._scene.region_y
+ def __set__(self, y):
+ self._scene.region_y = y
+ property outer_width:
+ """The width of the broader image."""
+ def __get__(self):
+ return self._scene.outer_width
+ def __set__(self, width):
+ self._scene.outer_width = width
+ property outer_height:
+ """The height of the broader image."""
+ def __get__(self):
+ return self._scene.outer_height
+ def __set__(self, height):
+ self._scene.outer_height = height
+
property default_texture:
"""The default Texture for objects."""
def __get__(self):
@@ -1400,8 +1423,20 @@ cdef class Scene:
self.raytrace_async().finish()
def raytrace_async(self):
"""Render the scene, in the background."""
+ # Account for image dimensions in the camera
+ # Do this here so subregion renders can tell us the broader image size
+ self._scene.camera.trans = dmnsn_matrix_mul(
+ self._scene.camera.trans,
+ dmnsn_scale_matrix(
+ dmnsn_new_vector(
+ self.outer_width/self.outer_height,
+ 1.0,
+ 1.0
+ )
+ )
+ )
# Ensure the default texture is complete
- cdef Texture default = Texture(Black)
+ cdef Texture default = Texture(pigment = Black)
dmnsn_texture_cascade(default._texture, &self._scene.default_texture)
return _Progress(dmnsn_raytrace_scene_async(self._scene))