diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-06-14 18:18:19 +0000 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-06-14 18:18:19 +0000 |
commit | 5c73e21b426ed381a1ae8d1bcac6fc78e5952b8f (patch) | |
tree | 979b425b4ef93e1492b45700c4ac3f899d4fc60e /libdimension/raytrace.c | |
parent | 5e8d0c611681d866d903a087ea238aeb5fbb5508 (diff) | |
download | dimension-5c73e21b426ed381a1ae8d1bcac6fc78e5952b8f.tar.xz |
Add a transformation matrix to objects.
Diffstat (limited to 'libdimension/raytrace.c')
-rw-r--r-- | libdimension/raytrace.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libdimension/raytrace.c b/libdimension/raytrace.c index 469ac66..316157a 100644 --- a/libdimension/raytrace.c +++ b/libdimension/raytrace.c @@ -68,7 +68,7 @@ dmnsn_raytrace_scene_thread(void *arg) { unsigned int i, j, k; dmnsn_object *object; - dmnsn_line ray; + dmnsn_line ray, ray_trans; dmnsn_raytrace_thread_payload *payload = (dmnsn_raytrace_thread_payload *)arg; dmnsn_scene *scene = payload->scene; dmnsn_array *intersections; @@ -83,11 +83,15 @@ dmnsn_raytrace_scene_thread(void *arg) /* Get the ray corresponding to the (i,j)th pixel */ ray = (*scene->camera->ray_fn)(scene->camera, scene->canvas, i, j); - + for (k = 0; k < scene->objects->length; ++k) { dmnsn_array_get(scene->objects, k, &object); + + /* Transform the ray according to the object */ + ray_trans = dmnsn_matrix_line_mul(object->trans, ray); + /* Test for an intersection with an object */ - intersections = (*object->intersections_fn)(object, ray); + intersections = (*object->intersections_fn)(object, ray_trans); if (intersections->length > 0) { /* Mark intersections white */ dmnsn_set_pixel(scene->canvas, i, j, |