From 6053d87cd02cd5aec9da5bc46039ec4cca181dec Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 27 Nov 2022 01:19:14 -0600 Subject: add scale parsing --- src/transform.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/transform.c') diff --git a/src/transform.c b/src/transform.c index 6e4db56..465841d 100644 --- a/src/transform.c +++ b/src/transform.c @@ -83,6 +83,30 @@ int kai_parse_rotate(ka_matrix_t *m, ezxml_t tag) } +int kai_parse_scale(ka_matrix_t *m, ezxml_t tag) +{ + if (strcmp("scale", ezxml_name(tag)) != 0) + return -1; + + char *str = ezxml_txt(tag); + char *end; + int i; + double scale[3]; + for (i=0; i<3; i++) { + scale[i] = strtod(str, &end); + str = end; + } + + memset(*m, 0, 16*sizeof(double)); + (*m)[0] = scale[0]; + (*m)[5] = scale[1]; + (*m)[10] = scale[2]; + (*m)[15] = 1.0f; + + return 0; +} + + int kai_parse_translate(ka_matrix_t *m, ezxml_t tag) { if (strcmp("translate", ezxml_name(tag)) != 0) -- cgit v1.2.1