summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-08-01 21:28:45 +1000
committerquou <quou@disroot.org>2024-08-01 21:28:45 +1000
commite0a2f217634c7e0133378a23c94e60c7f74c77fb (patch)
treeaa3a49d03de5e82adf55fc2c313d0791cdd06e18
parent205f7d49530e6c32ec0a09045d9cb45dcf9b1752 (diff)
scale matrix
-rw-r--r--3de.c3
-rw-r--r--maths.c14
-rw-r--r--maths.h2
3 files changed, 18 insertions, 1 deletions
diff --git a/3de.c b/3de.c
index bf114ec..1c10e03 100644
--- a/3de.c
+++ b/3de.c
@@ -47,11 +47,12 @@ void draw_gun(Renderer* r) {
const Texture* tex = get_texture(asset_id_gun_texture);
int p[] = { f1 * 7, 0, f1 * 5, f1 };
mtx_push_trans(p);
+ mtx_push_scale(0xff);
/*mtx_push_rot_x(a);
mtx_push_rot_y(a);
mtx_push_rot_z(a);*/
ren_mesh(r, m, tex);
- mtx_popn(1);
+ mtx_popn(2);
a++;
}
diff --git a/maths.c b/maths.c
index a0c9ed5..5ade946 100644
--- a/maths.c
+++ b/maths.c
@@ -180,6 +180,12 @@ void mtx_push_rot_z(int a) {
mtx_push(m);
}
+void mtx_push_scale(int s) {
+ int m[0x10];
+ mtx_scale(m, s);
+ mtx_push(m);
+}
+
int* mtx_pop(void) {
assert(mtx_stack_top > 0);
return mtx_stack[--mtx_stack_top];
@@ -234,6 +240,14 @@ int* mtx_rot_z(int* d, int a) {
return d;
}
+int* mtx_scale(int* d, int s) {
+ mtx_iden(d);
+ d[0] = s;
+ d[5] = s;
+ d[10] = s;
+ return d;
+}
+
int* mtx_apply(const int* m, int* v) {
int s[4];
vec_cpy(s, v, 4);
diff --git a/maths.h b/maths.h
index 725e401..a31c3da 100644
--- a/maths.h
+++ b/maths.h
@@ -31,6 +31,7 @@ void mtx_push_trans(int* v);
void mtx_push_rot_x(int a);
void mtx_push_rot_y(int a);
void mtx_push_rot_z(int a);
+void mtx_push_scale(int a);
int* mtx_pop(void);
int* mtx_popn(int n);
int* mtx_peek(void);
@@ -38,6 +39,7 @@ int* mtx_trans(int* d, int* v);
int* mtx_rot_x(int* d, int a);
int* mtx_rot_y(int* d, int a);
int* mtx_rot_z(int* d, int a);
+int* mtx_scale(int* d, int s);
int* mtx_apply(const int* m, int* v);
int* vec_cpy(int* d, const int* s, int c);
int* vec_ref(int* d, const int* i, const int* n, int c);