|
|
|
@ -78,8 +78,8 @@ typedef struct |
|
|
|
ps1texture_t front, back; |
|
|
|
} ps1skin_t; |
|
|
|
|
|
|
|
ps1mdl_t playerModel = { .position = { -200, 128, 64 }, .rotation = { 0 } }; |
|
|
|
ps1mdl_t shamblerModel = { .position = { -64, 96, 64 }, .rotation = { 0 } }; |
|
|
|
ps1mdl_t playerModel = { .position = { -128, 320, 400 }, .rotation = { 0 } }; |
|
|
|
ps1mdl_t shamblerModel = { .position = { 128, 320, 400 }, .rotation = { 0 } }; |
|
|
|
ps1skin_t playerSkin, shamblerSkin; |
|
|
|
|
|
|
|
MATRIX color_mtx = { |
|
|
|
@ -369,6 +369,9 @@ void drawModel(ps1mdl_t *model, ps1skin_t *skin, int xOffset, int frameCounter) |
|
|
|
int vertOffs = frameNum * model->header->vertexCount; |
|
|
|
short halfSkinWidth = model->halfSkinWidth; |
|
|
|
|
|
|
|
int *scale = model->header->scale; |
|
|
|
int *translate = model->header->translate; |
|
|
|
|
|
|
|
for (int triIdx = 0; triIdx < model->header->triangleCount; ++triIdx) |
|
|
|
{ |
|
|
|
ps1mdl_triangle_t *tri = &model->triangles[triIdx]; |
|
|
|
@ -378,9 +381,11 @@ void drawModel(ps1mdl_t *model, ps1skin_t *skin, int xOffset, int frameCounter) |
|
|
|
ps1mdl_vertex_t *v2 = &model->vertices[tri->vertexIndex[2] + vertOffs]; |
|
|
|
|
|
|
|
// Swizzle the coordinates because Quake Z is up |
|
|
|
SVECTOR pos0 = { v0->position[0], -v0->position[2], v0->position[1] }; |
|
|
|
SVECTOR pos1 = { v1->position[0], -v1->position[2], v1->position[1] }; |
|
|
|
SVECTOR pos2 = { v2->position[0], -v2->position[2], v2->position[1] }; |
|
|
|
// TODO: scale and translate should be done by the GTE instead of through software here |
|
|
|
// Finding the appropriate scale range here is tricky. Normalize with >> 12 as usual and the coordinates become so small that you lose depth precision. |
|
|
|
SVECTOR pos0 = { (v0->position[0] * scale[0] + translate[0]) >> 10, (-v0->position[2] * scale[2] + translate[2]) >> 10, (v0->position[1] * scale[1] + translate[1]) >> 10 }; |
|
|
|
SVECTOR pos1 = { (v1->position[0] * scale[0] + translate[0]) >> 10, (-v1->position[2] * scale[2] + translate[2]) >> 10, (v1->position[1] * scale[1] + translate[1]) >> 10 }; |
|
|
|
SVECTOR pos2 = { (v2->position[0] * scale[0] + translate[0]) >> 10, (-v2->position[2] * scale[2] + translate[2]) >> 10, (v2->position[1] * scale[1] + translate[1]) >> 10 }; |
|
|
|
|
|
|
|
gte_ldv3(&pos0, &pos1, &pos2); |
|
|
|
gte_rtpt(); // Rotation, Translation and Perspective triplet (all three vertices at once) |
|
|
|
|