summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-07-02 04:53:24 +0000
committerTavian Barnes <tavianator@gmail.com>2009-07-02 04:53:24 +0000
commit4d9f72b850c7a86af3a8fb36ff8d48220a6a0914 (patch)
tree3be778378e13e36e4be218668613a3a60fdae5cf /libdimension
parentc1accd2356394e8c905cc7de2eb6b8c453157708 (diff)
downloaddimension-4d9f72b850c7a86af3a8fb36ff8d48220a6a0914.tar.xz
Provide interface to modify a perspective camera's transformation
matrix.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/cameras.c19
-rw-r--r--libdimension/dimension/cameras.h3
2 files changed, 21 insertions, 1 deletions
diff --git a/libdimension/cameras.c b/libdimension/cameras.c
index c6dcf59..f346bbc 100644
--- a/libdimension/cameras.c
+++ b/libdimension/cameras.c
@@ -60,12 +60,29 @@ dmnsn_delete_perspective_camera(dmnsn_camera *camera)
}
}
+/* Get the transformation matrix */
+dmnsn_matrix
+dmnsn_get_perspective_camera_trans(const dmnsn_camera *camera)
+{
+ dmnsn_matrix *trans = camera->ptr;
+ return *trans;
+}
+
+/* Set the transformation matrix */
+void
+dmnsn_set_perspective_camera_trans(dmnsn_camera *camera, dmnsn_matrix T)
+{
+ dmnsn_matrix *trans = camera->ptr;
+ *trans = T;
+}
+
+/* Perspective camera ray callback */
static dmnsn_line
dmnsn_perspective_camera_ray_fn(const dmnsn_camera *camera,
const dmnsn_canvas *canvas,
unsigned int x, unsigned int y)
{
- dmnsn_matrix *trans = (dmnsn_matrix *)camera->ptr;
+ dmnsn_matrix *trans = camera->ptr;
dmnsn_line l;
/* Rays originate at the origin, oddly enough */
diff --git a/libdimension/dimension/cameras.h b/libdimension/dimension/cameras.h
index bd9d162..a75e9b9 100644
--- a/libdimension/dimension/cameras.h
+++ b/libdimension/dimension/cameras.h
@@ -31,4 +31,7 @@
dmnsn_camera *dmnsn_new_perspective_camera(dmnsn_matrix trans);
void dmnsn_delete_perspective_camera(dmnsn_camera *camera);
+dmnsn_matrix dmnsn_get_perspective_camera_trans(const dmnsn_camera *camera);
+void dmnsn_set_perspective_camera_trans(dmnsn_camera *camera, dmnsn_matrix T);
+
#endif /* DIMENSION_CAMERAS_H */