diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-11-19 20:30:14 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-11-19 20:31:06 -0500 |
commit | d47af986a7832add1c149235f44fa8f57b56e6d8 (patch) | |
tree | 40fbd4a5e84afa188c2f23a7727d3d9d2acb6840 /dimension/realize.c | |
parent | 6137aed0179476eaa626660885f01ea3f04f988a (diff) | |
download | dimension-d47af986a7832add1c149235f44fa8f57b56e6d8.tar.xz |
Implement sky spheres.
Diffstat (limited to 'dimension/realize.c')
-rw-r--r-- | dimension/realize.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/dimension/realize.c b/dimension/realize.c index d4b45cb..2f74ce0 100644 --- a/dimension/realize.c +++ b/dimension/realize.c @@ -680,6 +680,37 @@ dmnsn_realize_pigment(dmnsn_astnode astnode) return pigment; } +static dmnsn_sky_sphere * +dmnsn_realize_sky_sphere(dmnsn_astnode astnode) +{ + dmnsn_assert(astnode.type == DMNSN_AST_SKY_SPHERE, "Expected a sky sphere."); + + dmnsn_sky_sphere *sky_sphere = dmnsn_new_sky_sphere(); + + DMNSN_ARRAY_FOREACH (dmnsn_astnode *, item, astnode.children) { + switch (item->type) { + case DMNSN_AST_PIGMENT: + { + dmnsn_pigment *pigment = dmnsn_realize_pigment(*item); + dmnsn_array_push(sky_sphere->pigments, &pigment); + break; + } + + case DMNSN_AST_TRANSFORMATION: + sky_sphere->trans = dmnsn_matrix_mul( + dmnsn_realize_transformation(*item), + sky_sphere->trans + ); + break; + + default: + dmnsn_assert(false, "Invalid sky sphere item."); + } + } + + return sky_sphere; +} + static dmnsn_finish * dmnsn_realize_reflection(dmnsn_astnode astnode) { @@ -1295,6 +1326,10 @@ dmnsn_realize_astree(const dmnsn_astree *astree) dmnsn_array_get(astnode->children, 0, &child); scene->background = dmnsn_realize_color(child); break; + case DMNSN_AST_SKY_SPHERE: + dmnsn_delete_sky_sphere(scene->sky_sphere); + scene->sky_sphere = dmnsn_realize_sky_sphere(*astnode); + break; case DMNSN_AST_CAMERA: dmnsn_delete_camera(scene->camera); |