2001-10-23 17:20:56 +00:00
|
|
|
/*
|
|
|
|
gl_mod_alias.c
|
|
|
|
|
|
|
|
(description)
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
static const char rcsid[] =
|
|
|
|
"$Id$";
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "QF/console.h"
|
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/locs.h"
|
|
|
|
#include "QF/mathlib.h"
|
|
|
|
#include "QF/qargs.h"
|
|
|
|
#include "QF/render.h"
|
|
|
|
#include "QF/skin.h"
|
|
|
|
#include "QF/sound.h"
|
|
|
|
#include "QF/sys.h"
|
|
|
|
#include "QF/vid.h"
|
|
|
|
#include "QF/GL/defines.h"
|
|
|
|
#include "QF/GL/funcs.h"
|
|
|
|
#include "QF/GL/qf_rlight.h"
|
|
|
|
#include "QF/GL/qf_rmain.h"
|
|
|
|
#include "QF/GL/qf_rsurf.h"
|
|
|
|
#include "QF/GL/qf_screen.h"
|
|
|
|
#include "QF/GL/qf_vid.h"
|
|
|
|
|
|
|
|
#include "compat.h"
|
|
|
|
#include "r_cvar.h"
|
|
|
|
#include "r_dynamic.h"
|
|
|
|
#include "r_local.h"
|
|
|
|
#include "view.h"
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
vec3_t vert;
|
|
|
|
float lightdot;
|
|
|
|
} blended_vert_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
blended_vert_t *verts;
|
|
|
|
int *order;
|
|
|
|
} vert_order_t;
|
|
|
|
|
|
|
|
float r_avertexnormals[NUMVERTEXNORMALS][3] = {
|
|
|
|
#include "anorms.h"
|
|
|
|
};
|
|
|
|
|
|
|
|
// precalculated dot products for quantized angles
|
|
|
|
#define SHADEDOT_QUANT 16
|
|
|
|
float r_avertexnormal_dots[SHADEDOT_QUANT][256] =
|
|
|
|
#include "anorm_dots.h"
|
|
|
|
;
|
|
|
|
|
|
|
|
float shadelight;
|
|
|
|
float *shadedots = r_avertexnormal_dots[0];
|
|
|
|
int lastposenum, lastposenum0;
|
|
|
|
vec3_t shadevector;
|
|
|
|
|
2001-10-30 19:58:01 +00:00
|
|
|
|
2001-10-23 17:20:56 +00:00
|
|
|
static void
|
2002-01-02 19:23:09 +00:00
|
|
|
GL_DrawAliasFrame (vert_order_t *vo)
|
2001-10-23 17:20:56 +00:00
|
|
|
{
|
|
|
|
float color[4];
|
|
|
|
int count;
|
|
|
|
int *order;
|
|
|
|
blended_vert_t *verts;
|
|
|
|
|
|
|
|
verts = vo->verts;
|
|
|
|
order = vo->order;
|
|
|
|
|
|
|
|
color[3] = modelalpha;
|
|
|
|
|
|
|
|
while ((count = *order++)) {
|
|
|
|
// get the vertex count and primitive type
|
|
|
|
if (count < 0) {
|
|
|
|
count = -count;
|
|
|
|
qfglBegin (GL_TRIANGLE_FAN);
|
|
|
|
} else {
|
|
|
|
qfglBegin (GL_TRIANGLE_STRIP);
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
// texture coordinates come from the draw list
|
|
|
|
qfglTexCoord2fv ((float *) order);
|
|
|
|
order += 2;
|
|
|
|
|
2002-01-02 19:23:09 +00:00
|
|
|
// normals and vertexes come from the frame list
|
|
|
|
VectorScale (shadecolor, verts->lightdot, color);
|
2001-10-23 17:20:56 +00:00
|
|
|
|
2002-01-02 19:23:09 +00:00
|
|
|
qfglColor4fv (color);
|
2001-10-23 17:20:56 +00:00
|
|
|
|
|
|
|
qfglVertex3fv (verts->vert);
|
|
|
|
verts++;
|
|
|
|
} while (--count);
|
|
|
|
|
|
|
|
qfglEnd ();
|
|
|
|
}
|
2002-01-02 19:23:09 +00:00
|
|
|
}
|
2001-10-23 17:20:56 +00:00
|
|
|
|
2002-01-02 19:23:09 +00:00
|
|
|
static void
|
|
|
|
GL_DrawAliasFrame_fb (vert_order_t *vo)
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
int *order;
|
|
|
|
blended_vert_t *verts;
|
|
|
|
|
|
|
|
verts = vo->verts;
|
|
|
|
order = vo->order;
|
|
|
|
|
|
|
|
color_white[3] = modelalpha * 255;
|
|
|
|
qfglColor4ubv (color_white);
|
|
|
|
|
|
|
|
while ((count = *order++)) {
|
|
|
|
// get the vertex count and primitive type
|
|
|
|
if (count < 0) {
|
|
|
|
count = -count;
|
|
|
|
qfglBegin (GL_TRIANGLE_FAN);
|
|
|
|
} else {
|
|
|
|
qfglBegin (GL_TRIANGLE_STRIP);
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
// texture coordinates come from the draw list
|
|
|
|
qfglTexCoord2fv ((float *) order);
|
|
|
|
order += 2;
|
|
|
|
|
|
|
|
qfglVertex3fv (verts->vert);
|
|
|
|
verts++;
|
|
|
|
} while (--count);
|
|
|
|
|
|
|
|
qfglEnd ();
|
|
|
|
}
|
2001-10-23 17:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
GL_DrawAliasShadow
|
|
|
|
|
|
|
|
Standard shadow drawing
|
|
|
|
*/
|
|
|
|
static void
|
2001-12-30 04:16:25 +00:00
|
|
|
GL_DrawAliasShadow (aliashdr_t *paliashdr, vert_order_t *vo)
|
2001-10-23 17:20:56 +00:00
|
|
|
{
|
|
|
|
float height, lheight;
|
|
|
|
int count;
|
|
|
|
int *order;
|
|
|
|
vec3_t point;
|
2001-12-30 04:16:25 +00:00
|
|
|
blended_vert_t *verts;
|
2001-10-23 17:20:56 +00:00
|
|
|
|
2001-12-30 04:16:25 +00:00
|
|
|
verts = vo->verts;
|
|
|
|
order = vo->order;
|
2001-10-23 17:20:56 +00:00
|
|
|
|
2002-01-02 19:23:09 +00:00
|
|
|
lheight = currententity->origin[2] - lightspot[2];
|
2001-10-23 17:20:56 +00:00
|
|
|
height = -lheight + 1.0;
|
|
|
|
|
|
|
|
while ((count = *order++)) {
|
|
|
|
// get the vertex count and primitive type
|
|
|
|
|
|
|
|
if (count < 0) {
|
|
|
|
count = -count;
|
|
|
|
qfglBegin (GL_TRIANGLE_FAN);
|
|
|
|
} else
|
|
|
|
qfglBegin (GL_TRIANGLE_STRIP);
|
|
|
|
|
|
|
|
do {
|
2002-01-02 19:23:09 +00:00
|
|
|
order += 2; // skip texture coords
|
2001-10-23 17:20:56 +00:00
|
|
|
|
|
|
|
// normals and vertexes come from the frame list
|
|
|
|
point[0] =
|
2001-12-30 04:16:25 +00:00
|
|
|
verts->vert[0] * paliashdr->mdl.scale[0] +
|
2001-10-23 17:20:56 +00:00
|
|
|
paliashdr->mdl.scale_origin[0];
|
|
|
|
point[1] =
|
2001-12-30 04:16:25 +00:00
|
|
|
verts->vert[1] * paliashdr->mdl.scale[1] +
|
2001-10-23 17:20:56 +00:00
|
|
|
paliashdr->mdl.scale_origin[1];
|
|
|
|
point[2] =
|
2001-12-30 04:16:25 +00:00
|
|
|
verts->vert[2] * paliashdr->mdl.scale[2] +
|
2001-10-23 17:20:56 +00:00
|
|
|
paliashdr->mdl.scale_origin[2];
|
|
|
|
|
|
|
|
point[0] -= shadevector[0] * (point[2] + lheight);
|
|
|
|
point[1] -= shadevector[1] * (point[2] + lheight);
|
|
|
|
point[2] = height;
|
|
|
|
qfglVertex3fv (point);
|
|
|
|
|
|
|
|
verts++;
|
|
|
|
} while (--count);
|
|
|
|
|
|
|
|
qfglEnd ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vert_order_t *
|
|
|
|
GL_GetAliasFrameVerts (int frame, aliashdr_t *paliashdr, entity_t *e)
|
|
|
|
{
|
|
|
|
float interval;
|
2002-01-05 16:20:38 +00:00
|
|
|
int count, numposes, pose, i, j;
|
2001-10-23 17:20:56 +00:00
|
|
|
trivertx_t *verts;
|
|
|
|
vert_order_t *vo;
|
2001-12-18 05:50:57 +00:00
|
|
|
blended_vert_t *vo_v;
|
2001-10-23 17:20:56 +00:00
|
|
|
|
|
|
|
if ((frame >= paliashdr->mdl.numframes) || (frame < 0)) {
|
2001-12-08 20:58:09 +00:00
|
|
|
if (developer->int_val)
|
|
|
|
Con_Printf ("R_AliasSetupFrame: no such frame %d %s\n", frame,
|
|
|
|
currententity->model->name);
|
2001-10-23 17:20:56 +00:00
|
|
|
frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pose = paliashdr->frames[frame].firstpose;
|
|
|
|
numposes = paliashdr->frames[frame].numposes;
|
|
|
|
|
|
|
|
verts = (trivertx_t *) ((byte *) paliashdr + paliashdr->posedata);
|
|
|
|
|
|
|
|
count = paliashdr->poseverts;
|
|
|
|
vo = Hunk_TempAlloc (sizeof (*vo) + count * sizeof (blended_vert_t));
|
|
|
|
vo->order = (int *) ((byte *) paliashdr + paliashdr->commands);
|
|
|
|
vo->verts = (blended_vert_t*)&vo[1];
|
|
|
|
|
|
|
|
if (numposes > 1) {
|
|
|
|
interval = paliashdr->frames[frame].interval;
|
|
|
|
pose += (int) (r_realtime / interval) % numposes;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
One tenth of a second is good for most Quake animations. If
|
|
|
|
the nextthink is longer then the animation is usually meant
|
|
|
|
to pause (e.g. check out the shambler magic animation in
|
|
|
|
shambler.qc). If its shorter then things will still be
|
|
|
|
smoothed partly, and the jumps will be less noticable
|
|
|
|
because of the shorter time. So, this is probably a good
|
|
|
|
assumption.
|
|
|
|
*/
|
|
|
|
interval = 0.1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gl_lerp_anim->int_val) {
|
|
|
|
trivertx_t *verts1, *verts2;
|
2001-12-21 21:52:03 +00:00
|
|
|
float blend;
|
2002-01-05 16:20:38 +00:00
|
|
|
float v1[3], v2[3];
|
2001-10-23 17:20:56 +00:00
|
|
|
|
|
|
|
e->frame_interval = interval;
|
|
|
|
|
|
|
|
if (e->pose2 != pose) {
|
|
|
|
e->frame_start_time = r_realtime;
|
|
|
|
if (e->pose2 == -1) {
|
|
|
|
e->pose1 = pose;
|
|
|
|
} else {
|
|
|
|
e->pose1 = e->pose2;
|
|
|
|
}
|
|
|
|
e->pose2 = pose;
|
|
|
|
blend = 0;
|
|
|
|
} else {
|
|
|
|
blend = (r_realtime - e->frame_start_time) / e->frame_interval;
|
|
|
|
}
|
|
|
|
|
|
|
|
// wierd things start happening if blend passes 1
|
|
|
|
if (r_paused || blend > 1)
|
|
|
|
blend = 1;
|
|
|
|
|
2002-01-05 19:03:36 +00:00
|
|
|
if (paliashdr->mdl.ident == POLYHEADER16) {
|
2002-01-05 16:20:38 +00:00
|
|
|
verts1 = verts + e->pose1 * count * 2;
|
|
|
|
verts2 = verts + e->pose2 * count * 2;
|
2002-01-05 19:03:36 +00:00
|
|
|
} else {
|
2002-01-05 16:20:38 +00:00
|
|
|
verts1 = verts + e->pose1 * count;
|
|
|
|
verts2 = verts + e->pose2 * count;
|
|
|
|
}
|
2001-10-23 17:20:56 +00:00
|
|
|
|
|
|
|
if (!blend) {
|
|
|
|
verts = verts1;
|
|
|
|
} else if (blend == 1) {
|
|
|
|
verts = verts2;
|
|
|
|
} else {
|
2002-01-05 16:53:43 +00:00
|
|
|
if (paliashdr->mdl.ident == POLYHEADER16) {
|
|
|
|
for (i = 0, vo_v = vo->verts; i < count;
|
|
|
|
i++, vo_v++, verts1++, verts2++) {
|
|
|
|
for (j = 0; j < 3; j++) {
|
2002-01-05 19:03:36 +00:00
|
|
|
v1[j] = verts1->v[j] + (verts1 + count)->v[j] / 256.0;
|
|
|
|
v2[j] = verts2->v[j] + (verts2 + count)->v[j] / 256.0;
|
2002-01-05 16:20:38 +00:00
|
|
|
}
|
|
|
|
VectorBlend (v1, v2, blend, vo_v->vert);
|
2002-01-05 16:53:43 +00:00
|
|
|
vo_v->lightdot =
|
|
|
|
shadedots[verts1->lightnormalindex] * (1 - blend)
|
|
|
|
+ shadedots[verts2->lightnormalindex] * blend;
|
2002-01-05 16:20:38 +00:00
|
|
|
}
|
2002-01-05 19:03:36 +00:00
|
|
|
} else {
|
2002-01-05 16:53:43 +00:00
|
|
|
for (i = 0, vo_v = vo->verts; i < count;
|
|
|
|
i++, vo_v++, verts1++, verts2++) {
|
2002-01-05 16:20:38 +00:00
|
|
|
VectorBlend (verts1->v, verts2->v, blend, vo_v->vert);
|
2002-01-05 16:53:43 +00:00
|
|
|
vo_v->lightdot =
|
|
|
|
shadedots[verts1->lightnormalindex] * (1 - blend)
|
|
|
|
+ shadedots[verts2->lightnormalindex] * blend;
|
|
|
|
}
|
2001-10-23 17:20:56 +00:00
|
|
|
}
|
|
|
|
lastposenum0 = e->pose1;
|
|
|
|
lastposenum = e->pose2;
|
|
|
|
return vo;
|
|
|
|
}
|
2001-10-29 19:38:20 +00:00
|
|
|
} else {
|
2002-01-05 16:20:38 +00:00
|
|
|
if (paliashdr->mdl.ident == POLYHEADER16)
|
|
|
|
verts += pose * count * 2;
|
|
|
|
else
|
|
|
|
verts += pose * count;
|
2001-10-23 17:20:56 +00:00
|
|
|
}
|
2002-01-05 16:53:43 +00:00
|
|
|
if (paliashdr->mdl.ident == POLYHEADER16) {
|
|
|
|
for (i = 0, vo_v = vo->verts; i < count; i++, vo_v++, verts++) {
|
2002-01-05 16:20:38 +00:00
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
vo_v->vert[j] = verts->v[j] + (verts +
|
|
|
|
count)->v[j] / (float)256;
|
|
|
|
}
|
2002-01-05 16:53:43 +00:00
|
|
|
vo_v->lightdot = shadedots[verts->lightnormalindex];
|
2002-01-05 19:03:36 +00:00
|
|
|
} else {
|
2002-01-05 16:53:43 +00:00
|
|
|
for (i = 0, vo_v = vo->verts; i < count; i++, vo_v++, verts++)
|
2002-01-05 16:20:38 +00:00
|
|
|
VectorCopy (verts->v, vo_v->vert);
|
2001-12-18 05:50:57 +00:00
|
|
|
vo_v->lightdot = shadedots[verts->lightnormalindex];
|
2001-10-23 17:20:56 +00:00
|
|
|
}
|
|
|
|
lastposenum = pose;
|
|
|
|
return vo;
|
|
|
|
}
|
|
|
|
|
2001-11-21 08:14:05 +00:00
|
|
|
maliasskindesc_t *
|
|
|
|
R_AliasGetSkindesc (int skinnum, aliashdr_t *ahdr)
|
|
|
|
{
|
|
|
|
maliasskindesc_t *pskindesc;
|
|
|
|
maliasskingroup_t *paliasskingroup;
|
|
|
|
|
|
|
|
if ((skinnum >= ahdr->mdl.numskins) || (skinnum < 0)) {
|
|
|
|
Con_DPrintf ("R_AliasSetupSkin: no such skin # %d\n", skinnum);
|
|
|
|
skinnum = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pskindesc = ((maliasskindesc_t *)
|
|
|
|
((byte *) ahdr + ahdr->skindesc)) + skinnum;
|
|
|
|
|
|
|
|
if (pskindesc->type == ALIAS_SKIN_GROUP) {
|
|
|
|
float fullskininterval;
|
|
|
|
int i;
|
2001-12-04 17:46:42 +00:00
|
|
|
int numskins;
|
2001-11-21 08:14:05 +00:00
|
|
|
float skintargettime, skintime;
|
|
|
|
float *pskinintervals;
|
|
|
|
|
|
|
|
paliasskingroup = (maliasskingroup_t *) ((byte *) ahdr +
|
|
|
|
pskindesc->skin);
|
|
|
|
pskinintervals = (float *)
|
|
|
|
((byte *) ahdr + paliasskingroup->intervals);
|
|
|
|
numskins = paliasskingroup->numskins;
|
|
|
|
fullskininterval = pskinintervals[numskins - 1];
|
|
|
|
|
|
|
|
skintime = r_realtime + currententity->syncbase;
|
|
|
|
|
|
|
|
skintargettime = skintime -
|
|
|
|
((int) (skintime / fullskininterval)) * fullskininterval;
|
|
|
|
for (i = 0; i < (numskins - 1); i++) {
|
|
|
|
if (pskinintervals[i] > skintargettime)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pskindesc = &paliasskingroup->skindescs[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return pskindesc;
|
|
|
|
}
|
|
|
|
|
2001-10-23 17:20:56 +00:00
|
|
|
void
|
|
|
|
R_DrawAliasModel (entity_t *e, qboolean cull)
|
|
|
|
{
|
|
|
|
float add, an;
|
2001-11-21 08:14:05 +00:00
|
|
|
int lnum, texture;
|
2001-10-23 17:20:56 +00:00
|
|
|
int fb_texture = 0;
|
|
|
|
aliashdr_t *paliashdr;
|
|
|
|
model_t *clmodel;
|
|
|
|
vec3_t dist, mins, maxs;
|
|
|
|
vert_order_t *vo;
|
|
|
|
|
2001-11-04 07:40:35 +00:00
|
|
|
clmodel = e->model;
|
2001-10-23 17:20:56 +00:00
|
|
|
|
2001-11-04 07:40:35 +00:00
|
|
|
VectorAdd (e->origin, clmodel->mins, mins);
|
|
|
|
VectorAdd (e->origin, clmodel->maxs, maxs);
|
2001-10-23 17:20:56 +00:00
|
|
|
|
2001-12-19 18:32:26 +00:00
|
|
|
if (cull && R_CullBox (mins, maxs))
|
|
|
|
return;
|
2001-10-23 17:20:56 +00:00
|
|
|
|
2001-11-04 07:40:35 +00:00
|
|
|
VectorCopy (e->origin, r_entorigin);
|
2001-10-23 17:20:56 +00:00
|
|
|
VectorSubtract (r_origin, r_entorigin, modelorg);
|
|
|
|
|
2001-11-20 08:02:35 +00:00
|
|
|
if (clmodel->fullbright) {
|
2001-10-23 17:20:56 +00:00
|
|
|
shadelight = 1.0; // make certain models full brightness always
|
|
|
|
} else {
|
|
|
|
// get lighting information
|
2001-11-04 07:40:35 +00:00
|
|
|
shadelight = R_LightPoint (e->origin);
|
2001-10-23 17:20:56 +00:00
|
|
|
|
|
|
|
// always give the gun some light
|
|
|
|
if (e == r_view_model)
|
|
|
|
shadelight = max (shadelight, 24);
|
|
|
|
|
|
|
|
for (lnum = 0; lnum < r_maxdlights; lnum++) {
|
|
|
|
if (r_dlights[lnum].die >= r_realtime) {
|
2001-11-04 07:40:35 +00:00
|
|
|
VectorSubtract (e->origin, r_dlights[lnum].origin, dist);
|
2001-10-23 17:20:56 +00:00
|
|
|
add = (r_dlights[lnum].radius * r_dlights[lnum].radius * 8) /
|
|
|
|
(DotProduct (dist, dist)); // FIXME Deek
|
|
|
|
|
|
|
|
if (add > 0)
|
|
|
|
shadelight += add;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// clamp lighting so it doesn't overbright as much
|
|
|
|
shadelight = min (shadelight, 100); // was 200
|
|
|
|
|
|
|
|
// never allow players to go totally black
|
2001-11-20 08:02:35 +00:00
|
|
|
shadelight = max (shadelight, clmodel->min_light);
|
|
|
|
|
2001-10-23 17:20:56 +00:00
|
|
|
shadelight *= 0.005;
|
|
|
|
|
|
|
|
shadedots = r_avertexnormal_dots[(int) (e->angles[1] *
|
|
|
|
(SHADEDOT_QUANT / 360.0)) &
|
|
|
|
(SHADEDOT_QUANT - 1)];
|
|
|
|
an = e->angles[1] * (M_PI / 180);
|
|
|
|
shadevector[0] = cos (-an);
|
|
|
|
shadevector[1] = sin (-an);
|
|
|
|
shadevector[2] = 1;
|
|
|
|
VectorNormalize (shadevector);
|
|
|
|
}
|
|
|
|
|
2001-12-21 21:52:03 +00:00
|
|
|
VectorScale (e->colormod, 2.0 * shadelight, shadecolor);
|
2001-12-03 08:46:56 +00:00
|
|
|
modelalpha = e->alpha;
|
|
|
|
|
2001-10-23 17:20:56 +00:00
|
|
|
// locate the proper data
|
2001-11-04 07:40:35 +00:00
|
|
|
paliashdr = Cache_Get (&e->model->cache);
|
2001-10-23 17:20:56 +00:00
|
|
|
c_alias_polys += paliashdr->mdl.numtris;
|
|
|
|
|
|
|
|
// draw all the triangles
|
|
|
|
qfglPushMatrix ();
|
|
|
|
R_RotateForEntity (e);
|
|
|
|
|
2001-11-20 08:02:35 +00:00
|
|
|
qfglTranslatef (paliashdr->mdl.scale_origin[0],
|
|
|
|
paliashdr->mdl.scale_origin[1],
|
|
|
|
paliashdr->mdl.scale_origin[2]);
|
|
|
|
qfglScalef (paliashdr->mdl.scale[0], paliashdr->mdl.scale[1],
|
|
|
|
paliashdr->mdl.scale[2]);
|
2001-10-23 17:20:56 +00:00
|
|
|
|
2002-01-02 19:23:09 +00:00
|
|
|
// if the model has a colorised/external skin, use it, otherwise use
|
|
|
|
// the skin embedded in the model data
|
2001-11-04 07:40:35 +00:00
|
|
|
if (e->skin && !gl_nocolors->int_val) {
|
|
|
|
skin_t *skin = e->skin;
|
2001-10-23 17:20:56 +00:00
|
|
|
|
|
|
|
texture = skin->texture;
|
|
|
|
if (gl_fb_models->int_val) {
|
|
|
|
fb_texture = skin->fb_texture;
|
|
|
|
}
|
2001-11-21 08:14:05 +00:00
|
|
|
} else {
|
|
|
|
maliasskindesc_t *skindesc;
|
|
|
|
|
|
|
|
skindesc = R_AliasGetSkindesc (e->skinnum, paliashdr);
|
|
|
|
texture = skindesc->texnum;
|
|
|
|
if (gl_fb_models->int_val && !clmodel->fullbright)
|
|
|
|
fb_texture = skindesc->fb_texnum;
|
2001-10-23 17:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
qfglBindTexture (GL_TEXTURE_2D, texture);
|
|
|
|
|
2001-11-04 07:40:35 +00:00
|
|
|
vo = GL_GetAliasFrameVerts (e->frame, paliashdr, e);
|
2001-10-23 17:20:56 +00:00
|
|
|
|
2002-01-02 19:23:09 +00:00
|
|
|
if (modelalpha != 1.0)
|
|
|
|
qfglDepthMask (GL_FALSE);
|
|
|
|
|
|
|
|
GL_DrawAliasFrame (vo);
|
2001-10-23 17:20:56 +00:00
|
|
|
|
|
|
|
// This block is GL fullbright support for objects...
|
|
|
|
if (fb_texture) {
|
|
|
|
qfglBindTexture (GL_TEXTURE_2D, fb_texture);
|
2002-01-02 19:23:09 +00:00
|
|
|
GL_DrawAliasFrame_fb (vo);
|
2001-10-23 17:20:56 +00:00
|
|
|
}
|
|
|
|
|
2002-01-02 19:23:09 +00:00
|
|
|
if (modelalpha != 1.0)
|
|
|
|
qfglDepthMask (GL_TRUE);
|
|
|
|
|
2001-10-23 17:20:56 +00:00
|
|
|
qfglPopMatrix ();
|
|
|
|
|
2001-12-19 18:32:26 +00:00
|
|
|
// torches, grenades, and lightning bolts do not have shadows
|
|
|
|
if (r_shadows->int_val && clmodel->shadow_alpha) {
|
2001-10-23 17:20:56 +00:00
|
|
|
qfglPushMatrix ();
|
|
|
|
R_RotateForEntity (e);
|
|
|
|
|
|
|
|
qfglDisable (GL_TEXTURE_2D);
|
2001-11-20 08:02:35 +00:00
|
|
|
color_black[3] = (clmodel->shadow_alpha + 1) / 2;
|
2001-10-23 17:20:56 +00:00
|
|
|
qfglColor4ubv (color_black);
|
|
|
|
|
2001-12-30 04:16:25 +00:00
|
|
|
GL_DrawAliasShadow (paliashdr, vo);
|
2001-10-23 17:20:56 +00:00
|
|
|
|
|
|
|
qfglEnable (GL_TEXTURE_2D);
|
|
|
|
qfglPopMatrix ();
|
|
|
|
}
|
|
|
|
|
2001-11-04 07:40:35 +00:00
|
|
|
Cache_Release (&e->model->cache);
|
2001-10-23 17:20:56 +00:00
|
|
|
}
|