summaryrefslogtreecommitdiffstats
path: root/dimension/realize.c
diff options
context:
space:
mode:
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.");