summaryrefslogtreecommitdiffstats
path: root/dimension/realize.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-11-25 02:38:41 -0500
committerTavian Barnes <tavianator@gmail.com>2009-11-25 02:38:41 -0500
commit70379f85feb3b294742d880a75fabd4452c5ecf3 (patch)
tree7c969e5b1982cbd8f766f46805581b1140c2a96b /dimension/realize.c
parent7bbc14551b0513ec94bdac0eff0d64842fe55b2b (diff)
downloaddimension-70379f85feb3b294742d880a75fabd4452c5ecf3.tar.xz
Support scaling and translation transformations.
Diffstat (limited to 'dimension/realize.c')
-rw-r--r--dimension/realize.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/dimension/realize.c b/dimension/realize.c
index 2c5bd81..3b1d327 100644
--- a/dimension/realize.c
+++ b/dimension/realize.c
@@ -87,6 +87,31 @@ dmnsn_realize_rotation(dmnsn_astnode astnode, dmnsn_object *object)
}
static dmnsn_object *
+dmnsn_realize_scale(dmnsn_astnode astnode, dmnsn_object *object)
+{
+ dmnsn_astnode scale_node;
+ dmnsn_array_get(astnode.children, 0, &scale_node);
+ dmnsn_vector scale = dmnsn_realize_vector(scale_node);
+
+ object->trans = dmnsn_matrix_mul(dmnsn_scale_matrix(scale), object->trans);
+ return object;
+}
+
+static dmnsn_object *
+dmnsn_realize_translation(dmnsn_astnode astnode, dmnsn_object *object)
+{
+ dmnsn_astnode trans_node;
+ dmnsn_array_get(astnode.children, 0, &trans_node);
+ dmnsn_vector trans = dmnsn_realize_vector(trans_node);
+
+ object->trans = dmnsn_matrix_mul(
+ dmnsn_translation_matrix(trans),
+ object->trans
+ );
+ return object;
+}
+
+static dmnsn_object *
dmnsn_realize_object_modifiers(dmnsn_astnode astnode, dmnsn_object *object)
{
unsigned int i;
@@ -98,6 +123,12 @@ dmnsn_realize_object_modifiers(dmnsn_astnode astnode, dmnsn_object *object)
case DMNSN_AST_ROTATION:
object = dmnsn_realize_rotation(modifier, object);
break;
+ case DMNSN_AST_SCALE:
+ object = dmnsn_realize_scale(modifier, object);
+ break;
+ case DMNSN_AST_TRANSLATION:
+ object = dmnsn_realize_translation(modifier, object);
+ break;
default:
dmnsn_error(DMNSN_SEVERITY_HIGH, "Invalid object modifier.");