diff options
author | sanine <sanine.not@pm.me> | 2022-11-27 01:19:14 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-11-27 01:19:14 -0600 |
commit | 6053d87cd02cd5aec9da5bc46039ec4cca181dec (patch) | |
tree | 81dd8f2fd0fc5bef5951bee324a8ceb0bf419613 /src/transform.c | |
parent | c42d9264aed8da3a057719cab7390fa55904bda6 (diff) |
add scale parsing
Diffstat (limited to 'src/transform.c')
-rw-r--r-- | src/transform.c | 24 |
1 files changed, 24 insertions, 0 deletions
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) |