|
|
@ -76,8 +76,8 @@ typedef struct |
|
|
ps1texture_t front, back; |
|
|
ps1texture_t front, back; |
|
|
} ps1skin_t; |
|
|
} ps1skin_t; |
|
|
|
|
|
|
|
|
ps1mdl_t playerModel = { .position = { -200, 200, -160 }, .rotation = { 0 } }; |
|
|
|
|
|
ps1mdl_t shamblerModel = { .position = { 100, 200, -160 }, .rotation = { 0 } }; |
|
|
|
|
|
|
|
|
ps1mdl_t playerModel = { .position = { -150, 0, 0 }, .rotation = { 0 } }; |
|
|
|
|
|
ps1mdl_t shamblerModel = { .position = { 150, 0, 0 }, .rotation = { 0, 0, ONE >> 1, 0 } }; |
|
|
ps1skin_t playerSkin, shamblerSkin; |
|
|
ps1skin_t playerSkin, shamblerSkin; |
|
|
|
|
|
|
|
|
const MATRIX identity = { |
|
|
const MATRIX identity = { |
|
|
@ -368,6 +368,8 @@ static int fakeLight(const int *norm) |
|
|
|
|
|
|
|
|
SVECTOR outPos; |
|
|
SVECTOR outPos; |
|
|
|
|
|
|
|
|
|
|
|
#define SCTR(v, i) (short)((scale[i]*(v)->position[i]+translate[i])>>10) |
|
|
|
|
|
|
|
|
void drawModel(MATRIX *view_matrix, ps1mdl_t *model, ps1skin_t *skin, int frameCounter) |
|
|
void drawModel(MATRIX *view_matrix, ps1mdl_t *model, ps1skin_t *skin, int frameCounter) |
|
|
{ |
|
|
{ |
|
|
ps1texture_t *tex; |
|
|
ps1texture_t *tex; |
|
|
@ -394,6 +396,12 @@ void drawModel(MATRIX *view_matrix, ps1mdl_t *model, ps1skin_t *skin, int frameC |
|
|
|
|
|
|
|
|
PushMatrix(); |
|
|
PushMatrix(); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: this idea is good but it's missing the >> 12 fraction divide after transformation. Hmmmm... |
|
|
|
|
|
// MATRIX mesh_mtx = identity; |
|
|
|
|
|
// ScaleMatrixL(&mesh_mtx, (VECTOR*)scale); |
|
|
|
|
|
// TransMatrix(&mesh_mtx, (VECTOR*)translate); |
|
|
|
|
|
// CompMatrixLV(&model_mtx, &mesh_mtx, &mesh_mtx); |
|
|
|
|
|
|
|
|
gte_SetRotMatrix(&model_mtx); |
|
|
gte_SetRotMatrix(&model_mtx); |
|
|
gte_SetTransMatrix(&model_mtx); |
|
|
gte_SetTransMatrix(&model_mtx); |
|
|
|
|
|
|
|
|
@ -405,9 +413,12 @@ void drawModel(MATRIX *view_matrix, ps1mdl_t *model, ps1skin_t *skin, int frameC |
|
|
ps1mdl_vertex_t *v1 = &baseVert[tri->vertexIndex[1]]; |
|
|
ps1mdl_vertex_t *v1 = &baseVert[tri->vertexIndex[1]]; |
|
|
ps1mdl_vertex_t *v2 = &baseVert[tri->vertexIndex[2]]; |
|
|
ps1mdl_vertex_t *v2 = &baseVert[tri->vertexIndex[2]]; |
|
|
|
|
|
|
|
|
SVECTOR pos0 = { v0->position[0], v0->position[1], v0->position[2], 0 }; |
|
|
|
|
|
SVECTOR pos1 = { v1->position[0], v1->position[1], v1->position[2], 0 }; |
|
|
|
|
|
SVECTOR pos2 = { v2->position[0], v2->position[1], v2->position[2], 0 }; |
|
|
|
|
|
|
|
|
// SVECTOR pos0 = { v0->position[0], v0->position[1], v0->position[2], 0 }; |
|
|
|
|
|
// SVECTOR pos1 = { v1->position[0], v1->position[1], v1->position[2], 0 }; |
|
|
|
|
|
// SVECTOR pos2 = { v2->position[0], v2->position[1], v2->position[2], 0 }; |
|
|
|
|
|
SVECTOR pos0 = { SCTR(v0,0), SCTR(v0,1), SCTR(v0,2), 0 }; |
|
|
|
|
|
SVECTOR pos1 = { SCTR(v1,0), SCTR(v1,1), SCTR(v1,2), 0 }; |
|
|
|
|
|
SVECTOR pos2 = { SCTR(v2,0), SCTR(v2,1), SCTR(v2,2), 0 }; |
|
|
|
|
|
|
|
|
gte_ldv3(&pos0, &pos1, &pos2); |
|
|
gte_ldv3(&pos0, &pos1, &pos2); |
|
|
gte_rtpt(); // Rotation, Translation and Perspective triplet (all three vertices at once) |
|
|
gte_rtpt(); // Rotation, Translation and Perspective triplet (all three vertices at once) |
|
|
@ -509,7 +520,7 @@ void drawStuff(int counter) |
|
|
|
|
|
|
|
|
MATRIX view_matrix; |
|
|
MATRIX view_matrix; |
|
|
SVECTOR trot = { 0, 0, 0, 0 }; // TODO: camera rotation (in Quake coordinates) |
|
|
SVECTOR trot = { 0, 0, 0, 0 }; // TODO: camera rotation (in Quake coordinates) |
|
|
VECTOR tpos = { 0, 0, 0 }; // TODO: camera position (in Quake coordinates) |
|
|
|
|
|
|
|
|
VECTOR tpos = { 0, 400, -100 }; // TODO: camera position (in Quake coordinates) |
|
|
RotMatrix(&trot, &view_matrix); // Set camera rotation part of the view matrix |
|
|
RotMatrix(&trot, &view_matrix); // Set camera rotation part of the view matrix |
|
|
ApplyMatrixLV(&view_matrix, &tpos, &tpos); // Apply camera rotation to camera position |
|
|
ApplyMatrixLV(&view_matrix, &tpos, &tpos); // Apply camera rotation to camera position |
|
|
TransMatrix(&view_matrix, &tpos); // Apply transformed position to the translation part of the view matrix |
|
|
TransMatrix(&view_matrix, &tpos); // Apply transformed position to the translation part of the view matrix |
|
|
@ -536,6 +547,8 @@ int main(int argc, const char *argv[]) |
|
|
counter = 0; |
|
|
counter = 0; |
|
|
while(1) |
|
|
while(1) |
|
|
{ |
|
|
{ |
|
|
|
|
|
//playerModel.rotation.vz = (counter << 2) % ONE; |
|
|
|
|
|
|
|
|
drawStuff(counter); |
|
|
drawStuff(counter); |
|
|
|
|
|
|
|
|
// Update display |
|
|
// Update display |
|
|
|