scaling and printing confirmed working, rotation does something

This commit is contained in:
farisawan-2000 committed 2020-12-12 16:20:37 -05:00
1 parent b081365e42
commit aef2b9c8af
2 files changed
+18 -15

No files matched your search

+11 -12
View File
@@ -33,6 +33,8 @@ void setup_font(int idx) {
extern void mat2_translate_vec(uObjMtx *m, f32 degrees, f32 mag);
// Original Mtx Pipeline
// Doesnt work with rotation, but is faster
void mtx_pipeline(uObjMtx *m, int x, int y) {
// init
mat2_ident(m, 1);
@@ -42,22 +44,11 @@ void mtx_pipeline(uObjMtx *m, int x, int y) {
mat2_rotate(&rot_mtx, (myDegrees) * (M_PI / 180.0f));
// mat2_translate_with_rotation(m, &rot_mtx, x, y);
// scale m
mat2_scale(m, myScale);
// m = rot_mtx * m
// bypass the above by just copying the rot matrix
// mat2_copy(m, &rot_mtx);
mat2_dst_mul(m,m, &rot_mtx);
mat2_translate(m, x, y);
// mat2_translate_vec(m, (-myDegrees) * (M_PI / 180.0f), 1.0f);
// testing a stackoverflow answer
// mat2_translate(m, -TEX_X * myScale, -TEX_Y * myScale);
// mat2_dst_mul(m, m, &rot_mtx);
// mat2_translate(m, TEX_X * myScale, TEX_Y * myScale);
// yeah
gSPObjMatrix(gDisplayListHead++, m);
@@ -66,6 +57,9 @@ void mtx_pipeline(uObjMtx *m, int x, int y) {
#include <PR/gu.h>
typedef float Mat4[4][4];
// New matrix pipeline
// Works with both rotation and scale,
// but is slow due to more float operations being performed
void mtx_pipeline2(uObjMtx *m, int x, int y) {
// init
Mat4 tmp, rot, scal, translate;
@@ -80,15 +74,20 @@ void mtx_pipeline2(uObjMtx *m, int x, int y) {
gu_to_gs2dex(m, tmp);
if (myDegrees != 0) {
mat2_translate_vec(m, -(myDegrees) * M_DTOR, myScale);
}
// yeah
gSPObjMatrix(gDisplayListHead++, m);
}
void draw_s2d_glyph(char c, int x, int y, uObjMtx *mt) {
setup_font(c);
// mtx_pipeline(mt, x, y);
mtx_pipeline2(mt, x, y);
// gSPObjMatrix(gDisplayListHead++, &s2d_mat);
gSPObjSprite(gDisplayListHead++, &s2d_font);
}
+7 -3
View File
@@ -1,5 +1,6 @@
#include <ultra64.h>
#include <PR/gs2dex.h>
#include <PR/gu.h>
#include "s2d_draw.h"
#include "s2d_print.h"
@@ -28,10 +29,13 @@ void s2d_print(int x, int y, const char *str, uObjMtx *buf) {
break;
default:
draw_s2d_glyph(r, x += (8 * myScale), y, (buf++));
if (myDegrees == 0)
draw_s2d_glyph(r, x += (8 * myScale), y, (buf++));
else
draw_s2d_glyph(r, x += ((8 * myScale)), y, (buf++));
}
myDegrees += saved_degrees;
} while (*(p++) != '\0');
// myDegrees += saved_degrees;
} while (*(++p) != '\0');
myScale = 1;
myDegrees = 0;
saved_degrees = 0;