The code assumes a completely unmodified GLQuake baseline, and all code changes come from the software Quake source. You should be able to compare this with GLQuake's original, quickly and easily identify the changes made, and port them to any other engine based on that.
Code: Select all
void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
{
float l;
int i, j;
trivertx_t *verts;
int *order;
float *normal;
int count;
float baselight = ambientlight * (1.0f / 200.0f);
float temp;
float alias_forward[3], alias_right[3], alias_up[3];
float r_plightvec[3], lightvec[3] = {-1, 0, 0};
currententity->angles[0] = -currententity->angles[0]; // stupid quake bug
AngleVectors (currententity->angles, alias_forward, alias_right, alias_up);
currententity->angles[0] = -currententity->angles[0]; // stupid quake bug
// rotate the lighting vector into the model's frame of reference
r_plightvec[0] = DotProduct (lightvec, alias_forward);
r_plightvec[1] = -DotProduct (lightvec, alias_right);
r_plightvec[2] = DotProduct (lightvec, alias_up);
lastposenum = posenum;
verts = (trivertx_t *)((byte *)paliashdr + paliashdr->posedata);
verts += posenum * paliashdr->poseverts;
order = (int *)((byte *)paliashdr + paliashdr->commands);
while (1)
{
// get the vertex count and primitive type
count = *order++;
if (!count)
break; // done
if (count < 0)
{
count = -count;
glBegin (GL_TRIANGLE_FAN);
}
else
glBegin (GL_TRIANGLE_STRIP);
do
{
// texture coordinates come from the draw list
glTexCoord2f (((float *)order)[0], ((float *)order)[1]);
order += 2;
// normals and vertexes come from the frame list
temp = baselight;
l = DotProduct (r_avertexnormals[verts->lightnormalindex], r_plightvec);
if (l < 0)
temp -= shadelight * l;
glColor3f (temp, temp, temp);
glVertex3f (verts->v[0], verts->v[1], verts->v[2]);
verts++;
} while (--count);
glEnd ();
}
}
The key differences are that MDLs now look a LOT more coherent, like they fit into the world better, that angle quantization is totally gone, and that shading changes as you look up and down as well as right and left.