+z as front

This commit is contained in:
Nishi 2026-01-27 22:27:20 +09:00
commit dd2ef93643
Signed by: nishi
GPG key ID: 27EF69B208EB9343
6 changed files with 62 additions and 36 deletions

View file

@ -98,6 +98,17 @@ void GSClientDestroy(GSClient client) {
static void scene(GSClient client) {
if(client->engine->param->render != NULL) client->engine->param->render(client->engine);
GSVector3 n = {0, 1, 0};
GSVector3 q[] = {
{-3, -1, 3},
{-3, -1, -3},
{3, -1, -3},
{3, -1, 3}};
GSGLTextureSet(client->gl, 2);
GSGLPolygon(client->gl, 4, q, NULL, n);
GSGLTextureSet(client->gl, 0);
}
void GSClientStep(GSClient client) {

View file

@ -52,17 +52,17 @@ void GSGLCameraLookAt(GSGL gl, GSVector3 camera, GSVector3 look_at) {
for(i = 0; i < 16; i++) matrix[i] = 0;
matrix[4 * 0 + 0] = s[0];
matrix[4 * 1 + 0] = s[1];
matrix[4 * 2 + 0] = s[2];
matrix[4 * 2 + 0] = -s[2];
matrix[4 * 0 + 1] = u[0];
matrix[4 * 1 + 1] = u[1];
matrix[4 * 2 + 1] = u[2];
matrix[4 * 2 + 1] = -u[2];
matrix[4 * 0 + 2] = -f[0];
matrix[4 * 1 + 2] = -f[1];
matrix[4 * 2 + 2] = -f[2];
matrix[4 * 2 + 2] = f[2];
matrix[4 * 3 + 3] = 1;
glMultMatrixd(matrix);
glTranslated(-camera[0], -camera[1], -camera[2]);
glTranslated(-camera[0], -camera[1], camera[2]);
}
void GSGLCameraSetup(GSGL gl) {

View file

@ -137,7 +137,7 @@ static void parse_obj(GSModel model, char* txt) {
if(arrlen(model->vertex) > varr[i] * 3) {
face.vertex[i][0] = (model->vertex[varr[i] * 3 + 0] - lm - lr / 2) / sc;
face.vertex[i][1] = (model->vertex[varr[i] * 3 + 1] - dm - ud / 2) / sc;
face.vertex[i][2] = (model->vertex[varr[i] * 3 + 2] - bm - bf / 2) / sc;
face.vertex[i][2] = -(model->vertex[varr[i] * 3 + 2] - bm - bf / 2) / sc;
}
if(arrlen(model->texcoord) > tarr[i] * 2) {
@ -147,8 +147,8 @@ static void parse_obj(GSModel model, char* txt) {
}
}
if(c == 3) GSMathNormal3x3(face.normal, face.vertex[0], face.vertex[1], face.vertex[2]);
if(c == 4) GSMathNormal3x4(face.normal, face.vertex[0], face.vertex[1], face.vertex[2], face.vertex[3]);
if(c == 3) GSMathNormal3x3(face.normal, face.vertex[2], face.vertex[1], face.vertex[0]);
if(c == 4) GSMathNormal3x4(face.normal, face.vertex[3], face.vertex[2], face.vertex[1], face.vertex[0]);
arrput(model->face, face);
}

View file

@ -100,45 +100,45 @@ void GSSkyBoxDraw(GSSkyBox skybox) {
if(i == 0) {
tex = skybox->left;
v[0][0] = -1, v[0][1] = 1 + s, v[0][2] = 1 + s;
v[1][0] = -1, v[1][1] = -1 - s, v[1][2] = 1 + s;
v[2][0] = -1, v[2][1] = -1 - s, v[2][2] = -1 - s;
v[3][0] = -1, v[3][1] = 1 + s, v[3][2] = -1 - s;
v[0][0] = -1, v[0][1] = 1 + s, v[0][2] = -1 - s;
v[1][0] = -1, v[1][1] = -1 - s, v[1][2] = -1 - s;
v[2][0] = -1, v[2][1] = -1 - s, v[2][2] = 1 + s;
v[3][0] = -1, v[3][1] = 1 + s, v[3][2] = 1 + s;
} else if(i == 1) {
tex = skybox->right;
v[0][0] = 1, v[0][1] = 1 + s, v[0][2] = -1 - s;
v[1][0] = 1, v[1][1] = -1 - s, v[1][2] = -1 - s;
v[2][0] = 1, v[2][1] = -1 - s, v[2][2] = 1 + s;
v[3][0] = 1, v[3][1] = 1 + s, v[3][2] = 1 + s;
v[0][0] = 1, v[0][1] = 1 + s, v[0][2] = 1 + s;
v[1][0] = 1, v[1][1] = -1 - s, v[1][2] = 1 + s;
v[2][0] = 1, v[2][1] = -1 - s, v[2][2] = -1 - s;
v[3][0] = 1, v[3][1] = 1 + s, v[3][2] = -1 - s;
} else if(i == 2) {
tex = skybox->front;
v[0][0] = -1 - s, v[0][1] = 1 + s, v[0][2] = -1;
v[1][0] = -1 - s, v[1][1] = -1 - s, v[1][2] = -1;
v[2][0] = 1 + s, v[2][1] = -1 - s, v[2][2] = -1;
v[3][0] = 1 + s, v[3][1] = 1 + s, v[3][2] = -1;
v[0][0] = -1 - s, v[0][1] = 1 + s, v[0][2] = 1;
v[1][0] = -1 - s, v[1][1] = -1 - s, v[1][2] = 1;
v[2][0] = 1 + s, v[2][1] = -1 - s, v[2][2] = 1;
v[3][0] = 1 + s, v[3][1] = 1 + s, v[3][2] = 1;
} else if(i == 3) {
tex = skybox->back;
v[0][0] = 1 + s, v[0][1] = 1 + s, v[0][2] = 1;
v[1][0] = 1 + s, v[1][1] = -1 - s, v[1][2] = 1;
v[2][0] = -1 - s, v[2][1] = -1 - s, v[2][2] = 1;
v[3][0] = -1 - s, v[3][1] = 1 + s, v[3][2] = 1;
v[0][0] = 1 + s, v[0][1] = 1 + s, v[0][2] = -1;
v[1][0] = 1 + s, v[1][1] = -1 - s, v[1][2] = -1;
v[2][0] = -1 - s, v[2][1] = -1 - s, v[2][2] = -1;
v[3][0] = -1 - s, v[3][1] = 1 + s, v[3][2] = -1;
} else if(i == 4) {
tex = skybox->up;
v[0][0] = -1 - s, v[0][1] = 1, v[0][2] = 1 + s;
v[1][0] = -1 - s, v[1][1] = 1, v[1][2] = -1 - s;
v[2][0] = 1 + s, v[2][1] = 1, v[2][2] = -1 - s;
v[3][0] = 1 + s, v[3][1] = 1, v[3][2] = 1 + s;
v[0][0] = -1 - s, v[0][1] = 1, v[0][2] = -1 - s;
v[1][0] = -1 - s, v[1][1] = 1, v[1][2] = 1 + s;
v[2][0] = 1 + s, v[2][1] = 1, v[2][2] = 1 + s;
v[3][0] = 1 + s, v[3][1] = 1, v[3][2] = -1 - s;
} else if(i == 5) {
tex = skybox->down;
v[0][0] = -1 - s, v[0][1] = -1, v[0][2] = -1 - s;
v[1][0] = -1 - s, v[1][1] = -1, v[1][2] = 1 + s;
v[2][0] = 1 + s, v[2][1] = -1, v[2][2] = 1 + s;
v[3][0] = 1 + s, v[3][1] = -1, v[3][2] = -1 - s;
v[0][0] = -1 - s, v[0][1] = -1, v[0][2] = 1 + s;
v[1][0] = -1 - s, v[1][1] = -1, v[1][2] = -1 - s;
v[2][0] = 1 + s, v[2][1] = -1, v[2][2] = -1 - s;
v[3][0] = 1 + s, v[3][1] = -1, v[3][2] = 1 + s;
}
GSGLTextureSet(gl, tex);
@ -159,10 +159,10 @@ void GSSkyBoxDraw(GSSkyBox skybox) {
n[1] = -1;
n[2] = 0;
vc[0][0] = -1 - s, vc[0][1] = 1, vc[0][2] = 1 - s;
vc[1][0] = -1 - s, vc[1][1] = 1, vc[1][2] = -1 + s;
vc[2][0] = 1 - s, vc[2][1] = 1, vc[2][2] = -1 + s;
vc[3][0] = 1 - s, vc[3][1] = 1, vc[3][2] = 1 - s;
vc[0][0] = -1 - s, vc[0][1] = 1, vc[0][2] = -1 - s;
vc[1][0] = -1 - s, vc[1][1] = 1, vc[1][2] = 1 + s;
vc[2][0] = 1 - s, vc[2][1] = 1, vc[2][2] = 1 + s;
vc[3][0] = 1 - s, vc[3][1] = 1, vc[3][2] = -1 - s;
tc[0][0] = -1, tc[0][1] = -1;
tc[1][0] = -1, tc[1][1] = 1;