2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
gl_rmain.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
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2001-05-09 05:41:34 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/console.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-05-14 06:47:38 +00:00
|
|
|
#include "QF/locs.h"
|
2001-05-14 20:35:32 +00:00
|
|
|
#include "QF/mathlib.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/qargs.h"
|
2001-05-21 00:22:35 +00:00
|
|
|
#include "QF/render.h"
|
2001-05-14 20:35:32 +00:00
|
|
|
#include "QF/skin.h"
|
|
|
|
#include "QF/sound.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/sys.h"
|
2001-05-14 20:35:32 +00:00
|
|
|
#include "QF/vid.h"
|
2001-06-24 09:25:55 +00:00
|
|
|
#include "QF/GL/defines.h"
|
|
|
|
#include "QF/GL/funcs.h"
|
|
|
|
#include "QF/GL/qf_screen.h"
|
|
|
|
#include "QF/GL/qf_vid.h"
|
|
|
|
#include "QF/GL/qf_rsurf.h"
|
|
|
|
#include "QF/GL/qf_rlight.h"
|
|
|
|
|
2001-08-02 02:18:04 +00:00
|
|
|
#include "compat.h"
|
2001-05-13 00:28:50 +00:00
|
|
|
#include "r_cvar.h"
|
|
|
|
#include "r_dynamic.h"
|
2001-05-14 20:35:32 +00:00
|
|
|
#include "r_local.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "view.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-07 21:18:49 +00:00
|
|
|
typedef struct {
|
|
|
|
trivertx_t *verts;
|
|
|
|
int *order;
|
|
|
|
int blended;
|
|
|
|
} vert_order_t;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
entity_t r_worldentity;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
qboolean r_cache_thrash; // compatability
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
vec3_t modelorg, r_entorigin;
|
|
|
|
entity_t *currententity;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
int r_visframecount; // bumped when going to a new PVS
|
|
|
|
int r_framecount; // used for dlight push checking
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
int c_brush_polys, c_alias_polys;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
qboolean envmap; // true during envmap command capture
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
int mirrortexturenum; // quake texturenum, not gltexturenum
|
|
|
|
qboolean mirror;
|
|
|
|
mplane_t *mirror_plane;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// view origin
|
2001-02-26 06:48:02 +00:00
|
|
|
vec3_t vup;
|
|
|
|
vec3_t vpn;
|
|
|
|
vec3_t vright;
|
|
|
|
vec3_t r_origin;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
float r_world_matrix[16];
|
|
|
|
float r_base_world_matrix[16];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// screen size info
|
2001-02-26 06:48:02 +00:00
|
|
|
refdef_t r_refdef;
|
|
|
|
|
|
|
|
mleaf_t *r_viewleaf, *r_oldviewleaf;
|
|
|
|
|
|
|
|
int d_lightstylevalue[256]; // 8.8 fraction of base light value
|
|
|
|
|
2001-05-14 06:47:38 +00:00
|
|
|
vec3_t shadecolor; // Ender (Extend) Colormod
|
|
|
|
float modelalpha; // Ender (Extend) Alpha
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
void R_MarkLeaves (void);
|
|
|
|
|
2001-06-24 09:25:55 +00:00
|
|
|
//qboolean R_CullBlocked (vec3_t mins, vec3_t maxs, vec3_t org);
|
2001-05-13 00:28:50 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// LordHavoc: place for gl_rmain setup code
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-05-14 06:47:38 +00:00
|
|
|
glrmain_init (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-05-14 06:47:38 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-13 00:28:50 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
R_RotateForEntity (entity_t *e)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglTranslatef (e->origin[0], e->origin[1], e->origin[2]);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglRotatef (e->angles[1], 0, 0, 1);
|
|
|
|
qfglRotatef (-e->angles[0], 0, 1, 0);
|
2001-02-26 06:48:02 +00:00
|
|
|
// ZOID: fixed z angle
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglRotatef (e->angles[2], 1, 0, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static mspriteframe_t *
|
|
|
|
R_GetSpriteFrame (entity_t *currententity)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
msprite_t *psprite;
|
|
|
|
mspritegroup_t *pspritegroup;
|
|
|
|
mspriteframe_t *pspriteframe;
|
|
|
|
int i, numframes, frame;
|
|
|
|
float *pintervals, fullinterval, targettime, time;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
psprite = currententity->model->cache.data;
|
|
|
|
frame = currententity->frame;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if ((frame >= psprite->numframes) || (frame < 0)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("R_DrawSprite: no such frame %d\n", frame);
|
|
|
|
frame = 0;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (psprite->frames[frame].type == SPR_SINGLE) {
|
2001-02-19 21:15:25 +00:00
|
|
|
pspriteframe = psprite->frames[frame].frameptr;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
|
|
|
pspritegroup = (mspritegroup_t *) psprite->frames[frame].frameptr;
|
2001-02-19 21:15:25 +00:00
|
|
|
pintervals = pspritegroup->intervals;
|
|
|
|
numframes = pspritegroup->numframes;
|
2001-02-26 06:48:02 +00:00
|
|
|
fullinterval = pintervals[numframes - 1];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-20 03:54:55 +00:00
|
|
|
time = r_realtime + currententity->syncbase;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval
|
|
|
|
// values
|
|
|
|
// are positive, so we don't have to worry about division by 0
|
|
|
|
targettime = time - ((int) (time / fullinterval)) * fullinterval;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < (numframes - 1); i++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (pintervals[i] > targettime)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pspriteframe = pspritegroup->frames[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return pspriteframe;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static void
|
|
|
|
R_DrawSpriteModel (entity_t *e)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
vec3_t point;
|
|
|
|
mspriteframe_t *frame;
|
|
|
|
float *up, *right;
|
|
|
|
vec3_t v_forward, v_right, v_up;
|
|
|
|
msprite_t *psprite;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// don't even bother culling, because it's just a single
|
|
|
|
// polygon without a surface cache
|
|
|
|
frame = R_GetSpriteFrame (e);
|
|
|
|
psprite = currententity->model->cache.data;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (psprite->type == SPR_ORIENTED) { // bullet marks on walls
|
2001-02-19 21:15:25 +00:00
|
|
|
AngleVectors (currententity->angles, v_forward, v_right, v_up);
|
|
|
|
up = v_up;
|
|
|
|
right = v_right;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else { // normal sprite
|
2001-02-19 21:15:25 +00:00
|
|
|
up = vup;
|
|
|
|
right = vright;
|
|
|
|
}
|
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglBindTexture (GL_TEXTURE_2D, frame->gl_texturenum);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglEnable (GL_ALPHA_TEST);
|
|
|
|
qfglBegin (GL_QUADS);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglTexCoord2f (0, 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
VectorMA (e->origin, frame->down, up, point);
|
|
|
|
VectorMA (point, frame->left, right, point);
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglVertex3fv (point);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglTexCoord2f (0, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
VectorMA (e->origin, frame->up, up, point);
|
|
|
|
VectorMA (point, frame->left, right, point);
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglVertex3fv (point);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglTexCoord2f (1, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
VectorMA (e->origin, frame->up, up, point);
|
|
|
|
VectorMA (point, frame->right, right, point);
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglVertex3fv (point);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglTexCoord2f (1, 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
VectorMA (e->origin, frame->down, up, point);
|
|
|
|
VectorMA (point, frame->right, right, point);
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglVertex3fv (point);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglEnd ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDisable (GL_ALPHA_TEST);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-05-14 06:47:38 +00:00
|
|
|
ALIAS MODELS
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define NUMVERTEXNORMALS 162
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
float r_avertexnormals[NUMVERTEXNORMALS][3] = {
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "anorms.h"
|
|
|
|
};
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
vec3_t shadevector;
|
|
|
|
float shadelight;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// precalculated dot products for quantized angles
|
|
|
|
#define SHADEDOT_QUANT 16
|
2001-05-13 00:28:50 +00:00
|
|
|
float r_avertexnormal_dots[SHADEDOT_QUANT][256] =
|
|
|
|
#include "anorm_dots.h"
|
|
|
|
;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
float *shadedots = r_avertexnormal_dots[0];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 06:47:38 +00:00
|
|
|
int lastposenum, lastposenum0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static void
|
2001-08-07 21:18:49 +00:00
|
|
|
GL_DrawAliasFrame (vert_order_t *vo, qboolean fb)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
float l;
|
|
|
|
trivertx_t *verts;
|
|
|
|
int *order;
|
|
|
|
int count;
|
2001-08-07 21:18:49 +00:00
|
|
|
int blended = vo->blended;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-08-07 21:18:49 +00:00
|
|
|
verts = vo->verts;
|
|
|
|
order = vo->order;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-13 00:28:50 +00:00
|
|
|
if (modelalpha != 1.0)
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDepthMask (GL_FALSE);
|
2001-05-13 00:28:50 +00:00
|
|
|
|
|
|
|
if (fb) {
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglColor4f (1, 1, 1, modelalpha);
|
2001-05-13 00:28:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while ((count = *order++)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
// get the vertex count and primitive type
|
2001-02-26 06:48:02 +00:00
|
|
|
if (count < 0) {
|
2001-02-19 21:15:25 +00:00
|
|
|
count = -count;
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglBegin (GL_TRIANGLE_FAN);
|
2001-05-13 00:28:50 +00:00
|
|
|
} else {
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglBegin (GL_TRIANGLE_STRIP);
|
2001-05-13 00:28:50 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
do {
|
2001-02-19 21:15:25 +00:00
|
|
|
// texture coordinates come from the draw list
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglTexCoord2f (((float *) order)[0], ((float *) order)[1]);
|
2001-02-19 21:15:25 +00:00
|
|
|
order += 2;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!fb) {
|
2001-02-19 21:15:25 +00:00
|
|
|
// normals and vertexes come from the frame list
|
2001-08-07 21:18:49 +00:00
|
|
|
if (blended)
|
|
|
|
l = verts->lightnormalindex / 256.0;
|
|
|
|
else
|
|
|
|
l = shadedots[verts->lightnormalindex];
|
|
|
|
l *= shadelight;
|
2001-05-13 00:28:50 +00:00
|
|
|
|
|
|
|
// LordHavoc: cleanup after Endy
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglColor4f (shadecolor[0] * l, shadecolor[1] * l,
|
2001-05-13 00:28:50 +00:00
|
|
|
shadecolor[2] * l, modelalpha);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglVertex3f (verts->v[0], verts->v[1], verts->v[2]);
|
2001-02-19 21:15:25 +00:00
|
|
|
verts++;
|
|
|
|
} while (--count);
|
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglEnd ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-13 00:28:50 +00:00
|
|
|
if (modelalpha != 1.0)
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDepthMask (GL_TRUE);
|
2001-05-13 00:28:50 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglColor3ubv (lighthalf_v);
|
2001-05-13 00:28:50 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
extern vec3_t lightspot;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 06:47:38 +00:00
|
|
|
/*
|
|
|
|
GL_DrawAliasShadow
|
|
|
|
|
|
|
|
Standard shadow drawing
|
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
static void
|
|
|
|
GL_DrawAliasShadow (aliashdr_t *paliashdr, int posenum)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
trivertx_t *verts;
|
|
|
|
int *order;
|
|
|
|
vec3_t point;
|
|
|
|
float height, lheight;
|
|
|
|
int count;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
lheight = currententity->origin[2] - lightspot[2];
|
|
|
|
|
|
|
|
height = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
verts = (trivertx_t *) ((byte *) paliashdr + paliashdr->posedata);
|
2001-02-19 21:15:25 +00:00
|
|
|
verts += posenum * paliashdr->poseverts;
|
2001-02-26 06:48:02 +00:00
|
|
|
order = (int *) ((byte *) paliashdr + paliashdr->commands);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
height = -lheight + 1.0;
|
|
|
|
|
2001-05-13 00:28:50 +00:00
|
|
|
while ((count = *order++)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
// get the vertex count and primitive type
|
2001-05-13 00:28:50 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (count < 0) {
|
2001-02-19 21:15:25 +00:00
|
|
|
count = -count;
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglBegin (GL_TRIANGLE_FAN);
|
2001-02-26 06:48:02 +00:00
|
|
|
} else
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglBegin (GL_TRIANGLE_STRIP);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
do {
|
2001-02-19 21:15:25 +00:00
|
|
|
// texture coordinates come from the draw list
|
2001-06-26 02:26:46 +00:00
|
|
|
// (skipped for shadows) qfglTexCoord2fv ((float *)order);
|
2001-02-19 21:15:25 +00:00
|
|
|
order += 2;
|
|
|
|
|
|
|
|
// normals and vertexes come from the frame list
|
2001-02-26 06:48:02 +00:00
|
|
|
point[0] =
|
|
|
|
verts->v[0] * paliashdr->mdl.scale[0] +
|
|
|
|
paliashdr->mdl.scale_origin[0];
|
|
|
|
point[1] =
|
|
|
|
verts->v[1] * paliashdr->mdl.scale[1] +
|
|
|
|
paliashdr->mdl.scale_origin[1];
|
|
|
|
point[2] =
|
|
|
|
verts->v[2] * paliashdr->mdl.scale[2] +
|
|
|
|
paliashdr->mdl.scale_origin[2];
|
|
|
|
|
|
|
|
point[0] -= shadevector[0] * (point[2] + lheight);
|
|
|
|
point[1] -= shadevector[1] * (point[2] + lheight);
|
2001-02-19 21:15:25 +00:00
|
|
|
point[2] = height;
|
2001-02-26 06:48:02 +00:00
|
|
|
// height -= 0.001;
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglVertex3fv (point);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
verts++;
|
|
|
|
} while (--count);
|
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglEnd ();
|
2001-02-26 06:48:02 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-14 06:47:38 +00:00
|
|
|
/*
|
|
|
|
GL_DrawAliasBlendedShadow
|
|
|
|
|
|
|
|
Interpolated shadow drawing
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
GL_DrawAliasBlendedShadow (aliashdr_t *paliashdr, int pose1, int pose2, entity_t *e)
|
|
|
|
{
|
|
|
|
trivertx_t *verts1, *verts2;
|
|
|
|
float lerp;
|
|
|
|
vec3_t point1, point2;
|
|
|
|
int *order, count;
|
|
|
|
float height, lheight, blend;
|
|
|
|
|
2001-05-20 03:54:55 +00:00
|
|
|
blend = (r_realtime - e->frame_start_time) / e->frame_interval;
|
2001-05-14 06:47:38 +00:00
|
|
|
blend = min (blend, 1);
|
|
|
|
lerp = 1 - blend;
|
|
|
|
|
|
|
|
lheight = e->origin[2] - lightspot[2];
|
|
|
|
height = -lheight + 1.0;
|
|
|
|
|
|
|
|
verts2 = verts1 = (trivertx_t *) ((byte *) paliashdr + paliashdr->posedata);
|
|
|
|
|
|
|
|
verts1 += pose1 * paliashdr->poseverts;
|
|
|
|
verts2 += pose2 * paliashdr->poseverts;
|
|
|
|
|
|
|
|
order = (int *) ((byte *) paliashdr + paliashdr->commands);
|
|
|
|
|
|
|
|
while ((count = *order++)) {
|
|
|
|
// get the vertex count and primitive type
|
|
|
|
|
|
|
|
if (count < 0) {
|
|
|
|
count = -count;
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglBegin (GL_TRIANGLE_FAN);
|
2001-05-14 06:47:38 +00:00
|
|
|
} else {
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglBegin (GL_TRIANGLE_STRIP);
|
2001-05-14 06:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
order += 2;
|
|
|
|
|
|
|
|
point1[0] = verts1->v[0] * paliashdr->mdl.scale[0] + paliashdr->mdl.scale_origin[0];
|
|
|
|
point1[1] = verts1->v[1] * paliashdr->mdl.scale[1] + paliashdr->mdl.scale_origin[1];
|
|
|
|
point1[2] = verts1->v[2] * paliashdr->mdl.scale[2] + paliashdr->mdl.scale_origin[2];
|
|
|
|
|
|
|
|
point1[0] -= shadevector[0] * (point1[2] + lheight);
|
|
|
|
point1[1] -= shadevector[1] * (point1[2] + lheight);
|
|
|
|
|
|
|
|
point2[0] = verts2->v[0] * paliashdr->mdl.scale[0] + paliashdr->mdl.scale_origin[0];
|
|
|
|
point2[1] = verts2->v[1] * paliashdr->mdl.scale[1] + paliashdr->mdl.scale_origin[1];
|
|
|
|
point2[2] = verts2->v[2] * paliashdr->mdl.scale[2] + paliashdr->mdl.scale_origin[2];
|
|
|
|
|
|
|
|
point2[0] -= shadevector[0] * (point2[2] + lheight);
|
|
|
|
point2[1] -= shadevector[1] * (point2[2] + lheight);
|
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglVertex3f ((point1[0] * lerp) + (point2[0] * blend),
|
2001-05-14 06:47:38 +00:00
|
|
|
(point1[1] * lerp) + (point2[1] * blend),
|
|
|
|
height);
|
|
|
|
|
|
|
|
verts1++;
|
|
|
|
verts2++;
|
|
|
|
} while (--count);
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglEnd ();
|
2001-05-14 06:47:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-07 21:18:49 +00:00
|
|
|
vert_order_t *
|
|
|
|
GL_GetAliasFrameVerts (int frame, aliashdr_t *paliashdr, entity_t *e)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-08-07 21:18:49 +00:00
|
|
|
vert_order_t *vo;
|
|
|
|
int *order;
|
|
|
|
int count;
|
|
|
|
int pose;
|
|
|
|
int numposes;
|
|
|
|
trivertx_t *verts;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if ((frame >= paliashdr->mdl.numframes) || (frame < 0)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_DPrintf ("R_AliasSetupFrame: no such frame %d\n", frame);
|
|
|
|
frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pose = paliashdr->frames[frame].firstpose;
|
|
|
|
numposes = paliashdr->frames[frame].numposes;
|
|
|
|
|
2001-08-07 21:18:49 +00:00
|
|
|
verts = (trivertx_t *) ((byte *) paliashdr + paliashdr->posedata);
|
2001-05-14 06:47:38 +00:00
|
|
|
|
2001-08-07 21:18:49 +00:00
|
|
|
if (numposes == 1 || !gl_lerp_anim->int_val) {
|
|
|
|
float interval;
|
2001-05-14 06:47:38 +00:00
|
|
|
|
2001-08-07 21:18:49 +00:00
|
|
|
if (numposes > 1) {
|
|
|
|
interval = paliashdr->frames[frame].interval;
|
|
|
|
pose += (int) (r_realtime / interval) % numposes;
|
|
|
|
}
|
|
|
|
vo = Hunk_TempAlloc (sizeof (*vo));
|
|
|
|
vo->verts = verts + pose * paliashdr->poseverts;
|
|
|
|
vo->order = (int *) ((byte *) paliashdr + paliashdr->commands);
|
|
|
|
vo->blended = 0;
|
|
|
|
lastposenum = pose;
|
2001-05-14 06:47:38 +00:00
|
|
|
} else {
|
2001-08-07 21:18:49 +00:00
|
|
|
trivertx_t *verts1, *verts2;
|
|
|
|
float blend, lerp;
|
|
|
|
int i;
|
2001-05-14 06:47:38 +00:00
|
|
|
|
2001-08-07 21:18:49 +00:00
|
|
|
if (numposes > 1) {
|
|
|
|
e->frame_interval = paliashdr->frames[frame].interval;
|
|
|
|
pose += (int) (r_realtime / e->frame_interval) % numposes;
|
2001-05-14 06:47:38 +00:00
|
|
|
} else {
|
2001-08-07 21:18:49 +00:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
e->frame_interval = 0.1;
|
2001-05-14 06:47:38 +00:00
|
|
|
}
|
|
|
|
|
2001-08-07 21:18:49 +00:00
|
|
|
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;
|
|
|
|
}
|
2001-05-14 06:47:38 +00:00
|
|
|
|
2001-08-07 21:18:49 +00:00
|
|
|
// wierd things start happening if blend passes 1
|
|
|
|
if (r_paused || blend > 1)
|
|
|
|
blend = 1;
|
|
|
|
lerp = 1 - blend;
|
|
|
|
|
|
|
|
order = (int *) ((byte *) paliashdr + paliashdr->commands);
|
|
|
|
|
|
|
|
count = paliashdr->poseverts;
|
|
|
|
vo = Hunk_TempAlloc (sizeof (*vo) + count * sizeof (trivertx_t));
|
|
|
|
vo->order = order;
|
|
|
|
vo->verts = (trivertx_t*)&vo[1];
|
|
|
|
vo->blended = 1;
|
|
|
|
|
|
|
|
verts1 = verts + e->pose1 * count;
|
|
|
|
verts2 = verts + e->pose2 * count;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
vo->verts[i].v[0] = verts1[i].v[0] * lerp
|
|
|
|
+ verts2[i].v[0] * blend;
|
|
|
|
vo->verts[i].v[1] = verts1[i].v[1] * lerp
|
|
|
|
+ verts2[i].v[1] * blend;
|
|
|
|
vo->verts[i].v[2] = verts1[i].v[2] * lerp
|
|
|
|
+ verts2[i].v[2] * blend;
|
|
|
|
vo->verts[i].lightnormalindex =
|
|
|
|
(shadedots[verts[i].lightnormalindex] * lerp
|
|
|
|
+ shadedots[verts2[i].lightnormalindex] * blend) * 256;
|
|
|
|
}
|
|
|
|
lastposenum0 = e->pose1;
|
|
|
|
lastposenum = e->pose2;
|
|
|
|
}
|
|
|
|
return vo;
|
2001-05-14 06:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static void
|
2001-06-24 09:25:55 +00:00
|
|
|
R_DrawAliasModel (entity_t *e, qboolean cull)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int lnum;
|
|
|
|
vec3_t dist;
|
|
|
|
float add;
|
|
|
|
model_t *clmodel;
|
|
|
|
vec3_t mins, maxs;
|
|
|
|
aliashdr_t *paliashdr;
|
|
|
|
float an;
|
|
|
|
int anim;
|
2001-05-14 06:47:38 +00:00
|
|
|
int texture;
|
|
|
|
int fb_texture = 0;
|
|
|
|
int skinnum;
|
|
|
|
qboolean modelIsFullbright = false;
|
2001-08-07 21:18:49 +00:00
|
|
|
vert_order_t *vo;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
clmodel = currententity->model;
|
|
|
|
|
|
|
|
VectorAdd (currententity->origin, clmodel->mins, mins);
|
|
|
|
VectorAdd (currententity->origin, clmodel->maxs, maxs);
|
|
|
|
|
2001-06-24 09:25:55 +00:00
|
|
|
if (cull && R_CullBox (mins, maxs))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (cull && R_CullBlocked(mins, maxs, currententity->origin))
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
2001-06-24 09:25:55 +00:00
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 06:54:14 +00:00
|
|
|
// FIXME: shadecolor is supposed to be the lighting for the model, not
|
|
|
|
// just colormod
|
2001-05-29 21:59:02 +00:00
|
|
|
shadecolor[0] = currententity->colormod[0] * 2.0;
|
|
|
|
shadecolor[1] = currententity->colormod[1] * 2.0;
|
|
|
|
shadecolor[2] = currententity->colormod[2] * 2.0;
|
2001-05-14 06:54:14 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
VectorCopy (currententity->origin, r_entorigin);
|
|
|
|
VectorSubtract (r_origin, r_entorigin, modelorg);
|
|
|
|
|
|
|
|
// get lighting information
|
|
|
|
shadelight = R_LightPoint (currententity->origin);
|
|
|
|
|
2001-02-22 00:15:03 +00:00
|
|
|
// always give the gun some light
|
2001-05-21 00:22:35 +00:00
|
|
|
if (e == r_view_model)
|
2001-05-14 06:47:38 +00:00
|
|
|
shadelight = max (shadelight, 24);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (lnum = 0; lnum < MAX_DLIGHTS; lnum++) {
|
2001-05-20 05:42:52 +00:00
|
|
|
if (r_dlights[lnum].die >= r_realtime) {
|
|
|
|
VectorSubtract (currententity->origin, r_dlights[lnum].origin,
|
2001-02-26 06:48:02 +00:00
|
|
|
dist);
|
2001-05-20 05:42:52 +00:00
|
|
|
add = (r_dlights[lnum].radius * r_dlights[lnum].radius * 8) /
|
2001-05-14 06:47:38 +00:00
|
|
|
(DotProduct (dist, dist)); // FIXME Deek
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (add > 0)
|
|
|
|
shadelight += add;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-14 06:47:38 +00:00
|
|
|
// clamp lighting so it doesn't overbright as much
|
2001-05-19 20:57:29 +00:00
|
|
|
shadelight = min (shadelight, 100); // was 200
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 06:47:38 +00:00
|
|
|
// never allow players to go totally black
|
|
|
|
if (strequal (clmodel->name, "progs/player.mdl")) {
|
|
|
|
shadelight = max (shadelight, 8);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-05-14 06:47:38 +00:00
|
|
|
|
|
|
|
if (strnequal (clmodel->name, "progs/flame", 11)
|
|
|
|
|| strnequal (clmodel->name, "progs/bolt", 10)) {
|
|
|
|
modelIsFullbright = true;
|
2001-05-15 17:38:02 +00:00
|
|
|
shadelight = 255; // make certain models full brightness always
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-14 06:47:38 +00:00
|
|
|
shadedots = r_avertexnormal_dots[((int) (e->angles[1] * (SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)];
|
|
|
|
shadelight /= 200.0;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
an = e->angles[1] / 180 * M_PI;
|
|
|
|
shadevector[0] = cos (-an);
|
|
|
|
shadevector[1] = sin (-an);
|
2001-02-19 21:15:25 +00:00
|
|
|
shadevector[2] = 1;
|
|
|
|
VectorNormalize (shadevector);
|
|
|
|
|
|
|
|
// locate the proper data
|
2001-02-26 06:48:02 +00:00
|
|
|
paliashdr = (aliashdr_t *) Mod_Extradata (currententity->model);
|
2001-02-19 21:15:25 +00:00
|
|
|
c_alias_polys += paliashdr->mdl.numtris;
|
|
|
|
|
|
|
|
// draw all the triangles
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglPushMatrix ();
|
2001-02-19 21:15:25 +00:00
|
|
|
R_RotateForEntity (e);
|
|
|
|
|
2001-05-14 06:47:38 +00:00
|
|
|
if (strequal (clmodel->name, "progs/eyes.mdl")) {
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglTranslatef (paliashdr->mdl.scale_origin[0],
|
2001-02-26 06:48:02 +00:00
|
|
|
paliashdr->mdl.scale_origin[1],
|
|
|
|
paliashdr->mdl.scale_origin[2] - (22 + 8));
|
2001-05-14 06:47:38 +00:00
|
|
|
// double size of eyes, since they are really hard to see in GL
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglScalef (paliashdr->mdl.scale[0] * 2, paliashdr->mdl.scale[1] * 2,
|
2001-02-26 06:48:02 +00:00
|
|
|
paliashdr->mdl.scale[2] * 2);
|
|
|
|
} else {
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglTranslatef (paliashdr->mdl.scale_origin[0],
|
2001-02-26 06:48:02 +00:00
|
|
|
paliashdr->mdl.scale_origin[1],
|
|
|
|
paliashdr->mdl.scale_origin[2]);
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglScalef (paliashdr->mdl.scale[0], paliashdr->mdl.scale[1],
|
2001-02-26 06:48:02 +00:00
|
|
|
paliashdr->mdl.scale[2]);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-20 03:54:55 +00:00
|
|
|
anim = (int) (r_realtime * 10) & 3;
|
2001-05-14 06:47:38 +00:00
|
|
|
|
|
|
|
skinnum = currententity->skinnum;
|
|
|
|
if ((skinnum >= paliashdr->mdl.numskins) || (skinnum < 0)) {
|
|
|
|
Con_DPrintf ("R_AliasSetupSkin: no such skin # %d\n", skinnum);
|
|
|
|
skinnum = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
texture = paliashdr->gl_texturenum[skinnum][anim];
|
|
|
|
if (gl_fb_models->int_val && !modelIsFullbright)
|
|
|
|
fb_texture = paliashdr->gl_fb_texturenum[skinnum][anim];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// we can't dynamically colormap textures, so they are cached
|
|
|
|
// seperately for the players. Heads are just uncolored.
|
2001-05-21 22:25:35 +00:00
|
|
|
if (currententity->skin && !gl_nocolors->int_val) {
|
|
|
|
skin_t *skin = currententity->skin;
|
|
|
|
|
|
|
|
texture = skin->texture;
|
|
|
|
if (gl_fb_models->int_val) {
|
|
|
|
fb_texture = skin->fb_texture;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglBindTexture (GL_TEXTURE_2D, texture);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (gl_affinemodels->int_val)
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-07 21:18:49 +00:00
|
|
|
vo = GL_GetAliasFrameVerts (currententity->frame, paliashdr, currententity);
|
|
|
|
|
|
|
|
GL_DrawAliasFrame (vo, false);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// This block is GL fullbright support for objects...
|
2001-05-14 06:47:38 +00:00
|
|
|
if (fb_texture) {
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglBindTexture (GL_TEXTURE_2D, fb_texture);
|
2001-08-07 21:18:49 +00:00
|
|
|
GL_DrawAliasFrame (vo, true);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gl_affinemodels->int_val)
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglPopMatrix ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (r_shadows->int_val) {
|
2001-05-14 06:47:38 +00:00
|
|
|
// torches, grenades, and lightning bolts do not have shadows
|
|
|
|
if (modelIsFullbright)
|
|
|
|
return;
|
|
|
|
if (strequal (clmodel->name, "progs/grenade.mdl"))
|
|
|
|
return;
|
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglPushMatrix ();
|
2001-02-19 21:15:25 +00:00
|
|
|
R_RotateForEntity (e);
|
2001-05-14 06:47:38 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDisable (GL_TEXTURE_2D);
|
|
|
|
qfglColor4f (0, 0, 0, 0.5);
|
2001-05-14 06:47:38 +00:00
|
|
|
|
|
|
|
if (gl_lerp_anim->int_val) {
|
|
|
|
GL_DrawAliasBlendedShadow (paliashdr, lastposenum0, lastposenum, currententity);
|
|
|
|
} else {
|
|
|
|
GL_DrawAliasShadow (paliashdr, lastposenum);
|
|
|
|
}
|
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglEnable (GL_TEXTURE_2D);
|
|
|
|
qfglColor3ubv (lighthalf_v);
|
|
|
|
qfglPopMatrix ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-05-14 06:47:38 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 06:47:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
R_ShowNearestLoc
|
|
|
|
|
|
|
|
Display the nearest symbolic location (.loc files)
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
R_ShowNearestLoc (void)
|
|
|
|
{
|
|
|
|
location_t *nearloc;
|
|
|
|
vec3_t trueloc;
|
|
|
|
dlight_t *dl;
|
|
|
|
|
|
|
|
if (r_drawentities->int_val)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nearloc = locs_find (r_origin);
|
|
|
|
|
|
|
|
if (nearloc) {
|
2001-05-20 05:42:52 +00:00
|
|
|
dl = R_AllocDlight (4096);
|
2001-05-14 06:47:38 +00:00
|
|
|
VectorCopy (nearloc->loc, dl->origin);
|
|
|
|
dl->radius = 200;
|
2001-05-20 03:54:55 +00:00
|
|
|
dl->die = r_realtime + 0.1;
|
2001-05-14 06:47:38 +00:00
|
|
|
dl->color[0] = 0;
|
|
|
|
dl->color[1] = 1;
|
|
|
|
dl->color[2] = 0;
|
|
|
|
|
|
|
|
VectorCopy (nearloc->loc, trueloc);
|
|
|
|
R_RunSpikeEffect (trueloc, 7);
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-05-14 06:47:38 +00:00
|
|
|
/*
|
|
|
|
R_DrawEntitiesOnList
|
|
|
|
|
|
|
|
Draw all the entities we have information on.
|
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
static void
|
|
|
|
R_DrawEntitiesOnList (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 06:47:38 +00:00
|
|
|
if (!r_drawentities->int_val) {
|
|
|
|
R_ShowNearestLoc();
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
2001-05-14 06:47:38 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// LordHavoc: split into 3 loops to simplify state changes
|
2001-05-20 02:39:56 +00:00
|
|
|
for (i = 0; i < r_numvisedicts; i++) {
|
|
|
|
if (r_visedicts[i]->model->type != mod_brush)
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
2001-05-20 02:39:56 +00:00
|
|
|
currententity = r_visedicts[i];
|
2001-05-18 22:33:35 +00:00
|
|
|
modelalpha = currententity->alpha;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
R_DrawBrushModel (currententity);
|
|
|
|
}
|
|
|
|
|
2001-05-20 02:39:56 +00:00
|
|
|
for (i = 0; i < r_numvisedicts; i++) {
|
|
|
|
if (r_visedicts[i]->model->type != mod_alias)
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
2001-05-20 02:39:56 +00:00
|
|
|
currententity = r_visedicts[i];
|
2001-05-18 22:33:35 +00:00
|
|
|
modelalpha = currententity->alpha;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-21 00:22:35 +00:00
|
|
|
if (currententity == r_player_entity)
|
2001-02-19 21:15:25 +00:00
|
|
|
currententity->angles[PITCH] *= 0.3;
|
|
|
|
|
2001-06-24 09:25:55 +00:00
|
|
|
R_DrawAliasModel (currententity, true);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-20 02:39:56 +00:00
|
|
|
for (i = 0; i < r_numvisedicts; i++) {
|
|
|
|
if (r_visedicts[i]->model->type != mod_sprite)
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
2001-05-20 02:39:56 +00:00
|
|
|
currententity = r_visedicts[i];
|
2001-05-18 22:33:35 +00:00
|
|
|
modelalpha = currententity->alpha;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
R_DrawSpriteModel (currententity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static void
|
|
|
|
R_DrawViewModel (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-05-21 00:22:35 +00:00
|
|
|
currententity = r_view_model;
|
|
|
|
if (r_inhibit_viewmodel
|
|
|
|
|| !r_drawviewmodel->int_val
|
2001-05-15 03:27:55 +00:00
|
|
|
|| envmap
|
|
|
|
|| !r_drawentities->int_val
|
2001-05-21 00:22:35 +00:00
|
|
|
|| !currententity->model)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
2001-05-18 22:33:35 +00:00
|
|
|
// this is a HACK! --KB
|
|
|
|
modelalpha = currententity->alpha;
|
2001-05-14 06:47:38 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// hack the depth range to prevent view model from poking into walls
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDepthRange (gldepthmin, gldepthmin + 0.3 * (gldepthmax - gldepthmin));
|
2001-06-24 09:25:55 +00:00
|
|
|
R_DrawAliasModel (currententity, false);
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDepthRange (gldepthmin, gldepthmax);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static int
|
|
|
|
SignbitsForPlane (mplane_t *out)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int bits, j;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// for fast box on planeside test
|
|
|
|
|
|
|
|
bits = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
for (j = 0; j < 3; j++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (out->normal[j] < 0)
|
2001-02-26 06:48:02 +00:00
|
|
|
bits |= 1 << j;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
return bits;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static void
|
|
|
|
R_SetFrustum (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (r_refdef.fov_x == 90) {
|
2001-02-19 21:15:25 +00:00
|
|
|
// front side is visible
|
|
|
|
|
|
|
|
VectorAdd (vpn, vright, frustum[0].normal);
|
|
|
|
VectorSubtract (vpn, vright, frustum[1].normal);
|
|
|
|
|
|
|
|
VectorAdd (vpn, vup, frustum[2].normal);
|
|
|
|
VectorSubtract (vpn, vup, frustum[3].normal);
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// rotate VPN right by FOV_X/2 degrees
|
2001-02-26 06:48:02 +00:00
|
|
|
RotatePointAroundVector (frustum[0].normal, vup, vpn,
|
|
|
|
-(90 - r_refdef.fov_x / 2));
|
2001-02-19 21:15:25 +00:00
|
|
|
// rotate VPN left by FOV_X/2 degrees
|
2001-02-26 06:48:02 +00:00
|
|
|
RotatePointAroundVector (frustum[1].normal, vup, vpn,
|
|
|
|
90 - r_refdef.fov_x / 2);
|
2001-02-19 21:15:25 +00:00
|
|
|
// rotate VPN up by FOV_X/2 degrees
|
2001-02-26 06:48:02 +00:00
|
|
|
RotatePointAroundVector (frustum[2].normal, vright, vpn,
|
|
|
|
90 - r_refdef.fov_y / 2);
|
2001-02-19 21:15:25 +00:00
|
|
|
// rotate VPN down by FOV_X/2 degrees
|
2001-02-26 06:48:02 +00:00
|
|
|
RotatePointAroundVector (frustum[3].normal, vright, vpn,
|
|
|
|
-(90 - r_refdef.fov_y / 2));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < 4; i++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
frustum[i].type = PLANE_ANYZ;
|
|
|
|
frustum[i].dist = DotProduct (r_origin, frustum[i].normal);
|
|
|
|
frustum[i].signbits = SignbitsForPlane (&frustum[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-10 06:01:11 +00:00
|
|
|
void
|
2001-02-26 06:48:02 +00:00
|
|
|
R_SetupFrame (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
R_AnimateLight ();
|
|
|
|
|
|
|
|
r_framecount++;
|
|
|
|
|
2001-05-14 06:47:38 +00:00
|
|
|
// build the transformation matrix for the given view angles
|
2001-02-19 21:15:25 +00:00
|
|
|
VectorCopy (r_refdef.vieworg, r_origin);
|
|
|
|
|
|
|
|
AngleVectors (r_refdef.viewangles, vpn, vright, vup);
|
|
|
|
|
2001-05-14 06:47:38 +00:00
|
|
|
// current viewleaf
|
2001-02-19 21:15:25 +00:00
|
|
|
r_oldviewleaf = r_viewleaf;
|
2001-05-20 04:25:36 +00:00
|
|
|
r_viewleaf = Mod_PointInLeaf (r_origin, r_worldentity.model);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
V_SetContentsColor (r_viewleaf->contents);
|
2001-08-10 00:28:57 +00:00
|
|
|
// V_CalcBlend ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
r_cache_thrash = false;
|
|
|
|
|
|
|
|
c_brush_polys = 0;
|
|
|
|
c_alias_polys = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static void
|
|
|
|
MYgluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
GLdouble xmin, xmax, ymin, ymax;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
ymax = zNear * tan (fovy * M_PI / 360.0);
|
2001-02-19 21:15:25 +00:00
|
|
|
ymin = -ymax;
|
|
|
|
|
|
|
|
xmin = ymin * aspect;
|
|
|
|
xmax = ymax * aspect;
|
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglFrustum (xmin, xmax, ymin, ymax, zNear, zFar);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static void
|
|
|
|
R_SetupGL (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-05-20 22:02:44 +00:00
|
|
|
float screenaspect;
|
|
|
|
extern int glwidth, glheight;
|
|
|
|
int x, x2, y2, y, w, h;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// set up viewpoint
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglMatrixMode (GL_PROJECTION);
|
|
|
|
qfglLoadIdentity ();
|
2001-02-26 06:48:02 +00:00
|
|
|
x = r_refdef.vrect.x * glwidth / vid.width;
|
|
|
|
x2 = (r_refdef.vrect.x + r_refdef.vrect.width) * glwidth / vid.width;
|
|
|
|
y = (vid.height - r_refdef.vrect.y) * glheight / vid.height;
|
2001-05-20 22:02:44 +00:00
|
|
|
y2 = (vid.height - (r_refdef.vrect.y + r_refdef.vrect.height)) * glheight
|
|
|
|
/ vid.height;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// fudge around because of frac screen scale
|
|
|
|
if (x > 0)
|
|
|
|
x--;
|
|
|
|
if (x2 < glwidth)
|
|
|
|
x2++;
|
|
|
|
if (y2 < 0)
|
|
|
|
y2--;
|
|
|
|
if (y < glheight)
|
|
|
|
y++;
|
|
|
|
|
|
|
|
w = x2 - x;
|
|
|
|
h = y - y2;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (envmap) {
|
2001-02-19 21:15:25 +00:00
|
|
|
x = y2 = 0;
|
|
|
|
w = h = 256;
|
|
|
|
}
|
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglViewport (glx + x, gly + y2, w, h);
|
2001-02-26 06:48:02 +00:00
|
|
|
screenaspect = (float) r_refdef.vrect.width / r_refdef.vrect.height;
|
|
|
|
MYgluPerspective (r_refdef.fov_y, screenaspect, 4, 4096);
|
|
|
|
|
|
|
|
if (mirror) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (mirror_plane->normal[2])
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglScalef (1, -1, 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglScalef (-1, 1, 1);
|
|
|
|
qfglCullFace (GL_BACK);
|
2001-02-26 06:48:02 +00:00
|
|
|
} else
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglCullFace (GL_FRONT);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglMatrixMode (GL_MODELVIEW);
|
|
|
|
qfglLoadIdentity ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglRotatef (-90, 1, 0, 0); // put Z going up
|
|
|
|
qfglRotatef (90, 0, 0, 1); // put Z going up
|
|
|
|
qfglRotatef (-r_refdef.viewangles[2], 1, 0, 0);
|
|
|
|
qfglRotatef (-r_refdef.viewangles[0], 0, 1, 0);
|
|
|
|
qfglRotatef (-r_refdef.viewangles[1], 0, 0, 1);
|
|
|
|
qfglTranslatef (-r_refdef.vieworg[0], -r_refdef.vieworg[1],
|
2001-02-26 06:48:02 +00:00
|
|
|
-r_refdef.vieworg[2]);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglGetFloatv (GL_MODELVIEW_MATRIX, r_world_matrix);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// set drawing parms
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglEnable (GL_CULL_FACE);
|
|
|
|
qfglDisable (GL_ALPHA_TEST);
|
|
|
|
qfglAlphaFunc (GL_GREATER, 0.5);
|
|
|
|
qfglEnable (GL_DEPTH_TEST);
|
2001-05-14 06:47:38 +00:00
|
|
|
if (gl_dlight_smooth->int_val)
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglShadeModel (GL_SMOOTH);
|
2001-05-14 06:47:38 +00:00
|
|
|
else
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglShadeModel (GL_FLAT);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static void
|
|
|
|
R_Clear (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
if (gl_clear->int_val)
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglClear (GL_DEPTH_BUFFER_BIT);
|
2001-02-19 21:15:25 +00:00
|
|
|
gldepthmin = 0;
|
|
|
|
gldepthmax = 1;
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDepthFunc (GL_LEQUAL);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDepthRange (gldepthmin, gldepthmax);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-20 22:02:44 +00:00
|
|
|
|
2001-05-14 20:49:18 +00:00
|
|
|
void
|
|
|
|
R_RenderScene (void)
|
|
|
|
{
|
2001-05-22 06:00:38 +00:00
|
|
|
if (r_timegraph->int_val || r_speeds->int_val || r_dspeeds->int_val)
|
|
|
|
r_time1 = Sys_DoubleTime ();
|
|
|
|
|
2001-05-14 20:49:18 +00:00
|
|
|
R_SetupFrame ();
|
|
|
|
|
|
|
|
R_SetFrustum ();
|
|
|
|
|
|
|
|
R_SetupGL ();
|
|
|
|
|
|
|
|
R_MarkLeaves (); // done here so we know if we're in water
|
|
|
|
|
2001-08-05 04:01:45 +00:00
|
|
|
R_PushDlights (vec3_origin);
|
|
|
|
|
2001-05-14 20:49:18 +00:00
|
|
|
R_DrawWorld (); // adds static entities to the list
|
|
|
|
|
|
|
|
S_ExtraUpdate (); // don't let sound get messed up if going slow
|
|
|
|
|
|
|
|
R_DrawEntitiesOnList ();
|
|
|
|
|
|
|
|
R_RenderDlights ();
|
2001-05-22 06:00:38 +00:00
|
|
|
|
|
|
|
if (r_timegraph->int_val)
|
|
|
|
R_TimeGraph ();
|
|
|
|
|
|
|
|
if (r_zgraph->int_val)
|
|
|
|
R_ZGraph ();
|
2001-05-14 20:49:18 +00:00
|
|
|
}
|
2001-05-13 00:28:50 +00:00
|
|
|
|
2001-05-19 20:57:29 +00:00
|
|
|
|
2001-05-18 22:07:10 +00:00
|
|
|
void R_RenderBrushPoly (msurface_t *fa);
|
2001-05-19 20:57:29 +00:00
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
R_Mirror (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
float d;
|
|
|
|
msurface_t *s;
|
2001-05-15 21:34:54 +00:00
|
|
|
entity_t **ent;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (!mirror)
|
|
|
|
return;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
memcpy (r_base_world_matrix, r_world_matrix, sizeof (r_base_world_matrix));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-19 20:57:29 +00:00
|
|
|
d = DotProduct (r_refdef.vieworg, mirror_plane->normal) -
|
|
|
|
mirror_plane->dist;
|
2001-02-26 06:48:02 +00:00
|
|
|
VectorMA (r_refdef.vieworg, -2 * d, mirror_plane->normal, r_refdef.vieworg);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
d = DotProduct (vpn, mirror_plane->normal);
|
2001-02-26 06:48:02 +00:00
|
|
|
VectorMA (vpn, -2 * d, mirror_plane->normal, vpn);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
r_refdef.viewangles[0] = -asin (vpn[2]) / M_PI * 180;
|
|
|
|
r_refdef.viewangles[1] = atan2 (vpn[1], vpn[0]) / M_PI * 180;
|
2001-02-19 21:15:25 +00:00
|
|
|
r_refdef.viewangles[2] = -r_refdef.viewangles[2];
|
|
|
|
|
2001-05-20 02:39:56 +00:00
|
|
|
ent = R_NewEntity();
|
2001-05-15 21:34:54 +00:00
|
|
|
if (ent)
|
2001-05-21 00:22:35 +00:00
|
|
|
*ent = r_player_entity;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
gldepthmin = 0.5;
|
|
|
|
gldepthmax = 1;
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDepthRange (gldepthmin, gldepthmax);
|
|
|
|
qfglDepthFunc (GL_LEQUAL);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
R_RenderScene ();
|
|
|
|
R_DrawWaterSurfaces ();
|
|
|
|
|
|
|
|
gldepthmin = 0;
|
2001-05-14 20:49:18 +00:00
|
|
|
gldepthmax = 1;//XXX 0.5;
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDepthRange (gldepthmin, gldepthmax);
|
|
|
|
qfglDepthFunc (GL_LEQUAL);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// blend on top
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglMatrixMode (GL_PROJECTION);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (mirror_plane->normal[2])
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglScalef (1, -1, 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglScalef (-1, 1, 1);
|
|
|
|
qfglCullFace (GL_FRONT);
|
|
|
|
qfglMatrixMode (GL_MODELVIEW);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglLoadMatrixf (r_base_world_matrix);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglColor4f (1, 1, 1, r_mirroralpha->value);
|
2001-05-20 04:25:36 +00:00
|
|
|
s = r_worldentity.model->textures[mirrortexturenum]->texturechain;
|
2001-02-26 06:48:02 +00:00
|
|
|
for (; s; s = s->texturechain)
|
2001-02-19 21:15:25 +00:00
|
|
|
R_RenderBrushPoly (s);
|
2001-05-20 04:25:36 +00:00
|
|
|
r_worldentity.model->textures[mirrortexturenum]->texturechain = NULL;
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglColor4f (1, 1, 1, 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-05-13 00:28:50 +00:00
|
|
|
R_RenderView
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-13 00:28:50 +00:00
|
|
|
r_refdef must be set before the first call
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
R_RenderView (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
if (r_norefresh->int_val)
|
|
|
|
return;
|
|
|
|
|
2001-05-20 04:25:36 +00:00
|
|
|
if (!r_worldentity.model)
|
2001-02-19 21:15:25 +00:00
|
|
|
Sys_Error ("R_RenderView: NULL worldmodel");
|
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
// qfglFinish ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
mirror = false;
|
|
|
|
|
|
|
|
R_Clear ();
|
|
|
|
|
|
|
|
// render normal view
|
2001-05-14 20:49:18 +00:00
|
|
|
R_RenderScene ();
|
2001-05-13 00:28:50 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
R_DrawWaterSurfaces ();
|
|
|
|
|
2001-05-13 00:28:50 +00:00
|
|
|
R_UpdateFires ();
|
|
|
|
|
|
|
|
R_DrawParticles ();
|
|
|
|
|
|
|
|
R_DrawViewModel ();
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// render mirror view
|
2001-05-14 20:49:18 +00:00
|
|
|
R_Mirror ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-06-24 09:25:55 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
qboolean R_CullBlocked (vec3_t mins, vec3_t maxs, vec3_t org)
|
|
|
|
{
|
|
|
|
static struct trace_t trace;
|
|
|
|
vec3_t point;
|
|
|
|
float rad;
|
|
|
|
|
|
|
|
if (!gl_occlusion->int_val)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Check the origin first
|
|
|
|
if ( Mod_PointInLeaf(org, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, org, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
rad = sqrt((maxs[0]-org[0])*(maxs[0]-org[0]) +
|
|
|
|
(maxs[1]-org[1])*(maxs[1]-org[1]) +
|
|
|
|
(maxs[2]-org[2])*(maxs[2]-org[2]) );
|
|
|
|
|
|
|
|
// Check a few points on the bounding sphere to catch rotating objects
|
|
|
|
// Raise the origin a bit to catch droptofloor models
|
|
|
|
point[0] = org[0]; point[1] = org[1]+rad; point[2] = org[2]+4;
|
|
|
|
if ( Mod_PointInLeaf(point, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, point, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
point[0] = org[0]+rad; point[1] = org[1]; point[2] = org[2]+4;
|
|
|
|
if ( Mod_PointInLeaf(point, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, point, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
point[0] = org[0]; point[1] = org[1]-rad; point[2] = org[2]+4;
|
|
|
|
if ( Mod_PointInLeaf(point, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, point, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
point[0] = org[0]-rad; point[1] = org[1]; point[2] = org[2]+4;
|
|
|
|
if ( Mod_PointInLeaf(point, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, point, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check the poles of the sphere (can catch ents on ledges that would otherwise be missed)
|
|
|
|
point[0] = org[0]; point[1] = org[1]; point[2] = org[2]+rad;
|
|
|
|
if ( Mod_PointInLeaf(point, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, point, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
point[0] = org[0]; point[1] = org[1]; point[2] = org[2]-rad;
|
|
|
|
if ( Mod_PointInLeaf(point, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, point, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Check the corners...
|
|
|
|
if ( Mod_PointInLeaf(maxs, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, maxs, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
point[0] = mins[0]; point[1] = maxs[1]; point[2] = maxs[2];
|
|
|
|
if ( Mod_PointInLeaf(point, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, point, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
point[0] = mins[0]; point[1] = mins[1]; point[2] = maxs[2];
|
|
|
|
if ( Mod_PointInLeaf(point, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, point, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
point[0] = maxs[0]; point[1] = mins[1]; point[2] = maxs[2];
|
|
|
|
if ( Mod_PointInLeaf(point, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, point, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ( Mod_PointInLeaf(mins, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, mins, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
point[0] = mins[0]; point[1] = maxs[1]; point[2] = mins[2]+4;
|
|
|
|
if ( Mod_PointInLeaf(point, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, point, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
point[0] = maxs[0]; point[1] = mins[1]; point[2] = mins[2]+4;
|
|
|
|
if ( Mod_PointInLeaf(point, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, point, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
point[0] = maxs[0]; point[1] = maxs[1]; point[2] = mins[2]+4;
|
|
|
|
if ( Mod_PointInLeaf(point, cl.worldmodel)->contents != CONTENTS_SOLID)
|
|
|
|
{
|
|
|
|
if (SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, r_refdef.vieworg, point, &trace))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Model is blocked (probably)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|