Add seperation between ROTMATRIX and TRANSFERVECTOR
This commit is contained in:
@@ -32,74 +32,6 @@ namespace JabyEngine {
|
||||
}
|
||||
}
|
||||
|
||||
static void test_gte() {
|
||||
#define gte_MulMatrix0(r1,r2,r3) \
|
||||
{ gte_SetRotMatrix(r1); \
|
||||
gte_ldclmv(r2); \
|
||||
gte_rtir(); \
|
||||
gte_stclmv(r3); \
|
||||
gte_ldclmv((char*)r2+2);\
|
||||
gte_rtir(); \
|
||||
gte_stclmv((char*)r3+2);\
|
||||
gte_ldclmv((char*)r2+4);\
|
||||
gte_rtir(); \
|
||||
gte_stclmv((char*)r3+4); }
|
||||
|
||||
const auto m0 = GTE::MATRIX::identity();
|
||||
const auto m1 = GTE::MATRIX::identity();
|
||||
auto m2 = GTE::MATRIX::identity();
|
||||
|
||||
asm("# PLANSCHI START");
|
||||
JabyEngine::GTE::multiply_matrix(m0, m1, m2);
|
||||
asm("# PLANSCHI END");
|
||||
|
||||
#define PI 3.14159265 // v 90°???
|
||||
|
||||
static const auto display_stuff = [](int32_t angle) {
|
||||
static const auto wanna_be_float = [](int32_t value) -> int32_t {
|
||||
return (value*10000)/(4096);
|
||||
};
|
||||
|
||||
const auto sin_value = sin(GTE::in_degree(angle));
|
||||
const auto cos_value = cos(GTE::in_degree(angle));
|
||||
|
||||
printf("Sine of %i = %i (%i)\n", angle, sin_value, wanna_be_float(sin_value));
|
||||
printf("Cos of %i = %i (%i)\n", angle, cos_value, wanna_be_float(cos_value));
|
||||
};
|
||||
|
||||
static const auto print_matrix = [](const GTE::MATRIX& matrix) {
|
||||
printf("{%i, %i, %i}\n", matrix.rot[0][0], matrix.rot[0][1], matrix.rot[0][2]);
|
||||
printf("{%i, %i, %i}\n", matrix.rot[1][0], matrix.rot[1][1], matrix.rot[1][2]);
|
||||
printf("{%i, %i, %i}\n", matrix.rot[2][0], matrix.rot[2][1], matrix.rot[2][2]);
|
||||
printf("{%i, %i, %i}\n", matrix.trans[0], matrix.trans[1], matrix.trans[2]);
|
||||
};
|
||||
|
||||
static const auto make_matrix = [](int16_t mult) -> GTE::MATRIX {
|
||||
return GTE::MATRIX {
|
||||
.rot = {
|
||||
{static_cast<int16_t>(1*mult), static_cast<int16_t>(2*mult), static_cast<int16_t>(3*mult)},
|
||||
{static_cast<int16_t>(2*mult), static_cast<int16_t>(3*mult), static_cast<int16_t>(1*mult)},
|
||||
{static_cast<int16_t>(3*mult), static_cast<int16_t>(1*mult), static_cast<int16_t>(2*mult)},
|
||||
},
|
||||
.trans = {6*mult, 7*mult, 8*mult}
|
||||
};
|
||||
};
|
||||
|
||||
display_stuff(25);
|
||||
display_stuff(45);
|
||||
display_stuff(75);
|
||||
display_stuff(90);
|
||||
|
||||
for(size_t n = 0; n < 3; n++) {
|
||||
GTE::push_matrix_and_set(make_matrix(n + 1));
|
||||
}
|
||||
|
||||
for(size_t n = 0; n < 3; n++) {
|
||||
print_matrix(GTE::get_and_pop_matrix());
|
||||
printf("---\n");
|
||||
}
|
||||
}
|
||||
|
||||
namespace boot {
|
||||
namespace Start {
|
||||
static void setup() {
|
||||
@@ -128,7 +60,6 @@ namespace JabyEngine {
|
||||
GPU::display_logo();
|
||||
GTE::setup();
|
||||
test_bios_font();
|
||||
test_gte();
|
||||
|
||||
//Pause??
|
||||
SPU::setup();
|
||||
|
@@ -53,7 +53,7 @@ namespace JabyEngine {
|
||||
return v1;
|
||||
}
|
||||
|
||||
MATRIX& multiply_matrix(const MATRIX& m0, const MATRIX& m1, MATRIX& result) {
|
||||
ROTMATRIX& multiply_matrix(const ROTMATRIX& m0, const ROTMATRIX& m1, ROTMATRIX& result) {
|
||||
set_rot_matrix(m0);
|
||||
|
||||
JabyEngine::GTE::ldclmv(m1, 0);
|
||||
@@ -72,15 +72,15 @@ namespace JabyEngine {
|
||||
}
|
||||
|
||||
void set_matrix(const MATRIX& matrix) {
|
||||
set_rot_matrix(matrix);
|
||||
set_trans_matrix(matrix);
|
||||
set_rot_matrix(matrix.rotation);
|
||||
set_trans_vector(matrix.transfer);
|
||||
}
|
||||
|
||||
MATRIX get_matrix() {
|
||||
MATRIX matrix;
|
||||
|
||||
get_rot_matrix(matrix);
|
||||
get_trans_matrix(matrix);
|
||||
get_rot_matrix(matrix.rotation);
|
||||
get_trans_vector(matrix.transfer);
|
||||
return matrix;
|
||||
}
|
||||
|
||||
@@ -106,24 +106,24 @@ namespace JabyEngine {
|
||||
return matrix;
|
||||
}
|
||||
|
||||
MATRIX MATRIX :: rotation(int32_t x, int32_t y, int32_t z) {
|
||||
ROTMATRIX ROTMATRIX :: rotated(int32_t x, int32_t y, int32_t z) {
|
||||
using namespace MatrixHelper;
|
||||
|
||||
const auto sincos_x = SinCosPair::create_for(x);
|
||||
const auto sincos_y = SinCosPair::create_for(y);
|
||||
const auto sincos_z = SinCosPair::create_for(z);
|
||||
|
||||
auto rotX = MATRIX::identity();
|
||||
rotX.rot[1][1] = sincos_x.cos; rotX.rot[1][2] = -sincos_x.sin;
|
||||
rotX.rot[2][1] = sincos_x.sin; rotX.rot[2][2] = sincos_x.cos;
|
||||
auto rotX = ROTMATRIX::identity();
|
||||
rotX.matrix[1][1] = sincos_x.cos; rotX.matrix[1][2] = -sincos_x.sin;
|
||||
rotX.matrix[2][1] = sincos_x.sin; rotX.matrix[2][2] = sincos_x.cos;
|
||||
|
||||
auto rotY = MATRIX::identity();
|
||||
rotY.rot[0][0] = sincos_y.cos; rotY.rot[0][2] = sincos_y.sin;
|
||||
rotY.rot[2][0] = -sincos_y.sin; rotY.rot[2][2] = sincos_y.cos;
|
||||
auto rotY = ROTMATRIX::identity();
|
||||
rotY.matrix[0][0] = sincos_y.cos; rotY.matrix[0][2] = sincos_y.sin;
|
||||
rotY.matrix[2][0] = -sincos_y.sin; rotY.matrix[2][2] = sincos_y.cos;
|
||||
|
||||
auto rotZ = MATRIX::identity();
|
||||
rotZ.rot[0][0] = sincos_z.cos; rotZ.rot[0][1] = -sincos_z.sin;
|
||||
rotZ.rot[1][0] = sincos_z.sin; rotZ.rot[1][1] = sincos_z.cos;
|
||||
auto rotZ = ROTMATRIX::identity();
|
||||
rotZ.matrix[0][0] = sincos_z.cos; rotZ.matrix[0][1] = -sincos_z.sin;
|
||||
rotZ.matrix[1][0] = sincos_z.sin; rotZ.matrix[1][1] = sincos_z.cos;
|
||||
|
||||
push_matrix();
|
||||
multiply_matrix(rotX, rotY, rotX);
|
||||
|
Reference in New Issue
Block a user