2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
gl_warp.c
|
|
|
|
|
2001-05-11 01:01:27 +00:00
|
|
|
water polygons
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
*/
|
2001-09-28 06:26:31 +00:00
|
|
|
static const char rcsid[] =
|
|
|
|
"$Id$";
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-11 01:01:27 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/sys.h"
|
2001-04-15 21:11:41 +00:00
|
|
|
|
2001-06-24 09:25:55 +00:00
|
|
|
#include "r_cvar.h"
|
2001-09-01 08:57:04 +00:00
|
|
|
#include "r_shared.h"
|
2001-06-24 09:25:55 +00:00
|
|
|
|
|
|
|
#include "QF/GL/defines.h"
|
|
|
|
#include "QF/GL/funcs.h"
|
2003-01-06 18:28:13 +00:00
|
|
|
#include "QF/GL/qf_rsurf.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// speed up sin calculations - Ed
|
2001-02-26 06:48:02 +00:00
|
|
|
float turbsin[] = {
|
2001-05-09 18:45:38 +00:00
|
|
|
# include "gl_warp_sin.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
};
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-05-11 01:01:27 +00:00
|
|
|
#define TURBSCALE (256.0 / (2 * M_PI))
|
2002-07-25 14:01:36 +00:00
|
|
|
#define TURBFRAC (32.0 / (2 * M_PI)) // an 8th of TURBSCALE
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-05-11 01:01:27 +00:00
|
|
|
EmitWaterPolys
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-11 01:01:27 +00:00
|
|
|
Does a water warp on the pre-fragmented glpoly_t chain
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
EmitWaterPolys (msurface_t *fa)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-07-25 14:01:36 +00:00
|
|
|
float os, ot, s, t, timetemp;
|
2001-02-26 06:48:02 +00:00
|
|
|
float *v;
|
|
|
|
int i;
|
2001-09-01 08:57:04 +00:00
|
|
|
glpoly_t *p;
|
2002-07-25 14:01:36 +00:00
|
|
|
|
|
|
|
timetemp = r_realtime * TURBSCALE;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
for (p = fa->polys; p; p = p->next) {
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglBegin (GL_POLYGON);
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0, v = p->verts[0]; i < p->numverts; i++, v += VERTEXSIZE) {
|
2002-07-25 14:01:36 +00:00
|
|
|
os = turbsin[(int) (v[3] * TURBFRAC + timetemp) & 255];
|
|
|
|
ot = turbsin[(int) (v[4] * TURBFRAC + timetemp) & 255];
|
2001-12-18 03:59:37 +00:00
|
|
|
s = (v[3] + ot) * (1.0 / 64.0);
|
|
|
|
t = (v[4] + os) * (1.0 / 64.0);
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglTexCoord2f (s, t);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-07-25 14:01:36 +00:00
|
|
|
if (r_waterripple->value != 0) {
|
|
|
|
vec3_t nv;
|
|
|
|
|
|
|
|
VectorCopy (v, nv);
|
|
|
|
nv[2] += r_waterripple->value * os * ot * (1.0 / 64.0);
|
|
|
|
qfglVertex3fv (nv);
|
|
|
|
} else
|
|
|
|
qfglVertex3fv (v);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglEnd ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|