2001-05-09 05:41:34 +00:00
|
|
|
/*
|
|
|
|
gl_dyn_part.c
|
|
|
|
|
|
|
|
OpenGL particle system.
|
|
|
|
|
|
|
|
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-05-09 05:41:34 +00:00
|
|
|
|
|
|
|
#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 <stdlib.h>
|
|
|
|
|
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/console.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/qargs.h"
|
2001-05-29 19:43:15 +00:00
|
|
|
#include "QF/render.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/sys.h"
|
2001-05-30 04:34:06 +00:00
|
|
|
#include "QF/vfs.h"
|
2001-06-24 09:25:55 +00:00
|
|
|
#include "QF/GL/defines.h"
|
|
|
|
#include "QF/GL/funcs.h"
|
2001-10-09 20:35:17 +00:00
|
|
|
#include "QF/GL/qf_explosions.h"
|
2001-10-28 04:23:37 +00:00
|
|
|
#include "QF/GL/qf_textures.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-06-29 02:43:04 +00:00
|
|
|
#include "compat.h"
|
|
|
|
#include "r_cvar.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "r_dynamic.h"
|
2001-05-29 19:43:15 +00:00
|
|
|
#include "r_shared.h"
|
2001-06-29 02:43:04 +00:00
|
|
|
#include "varrays.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-09-16 20:07:28 +00:00
|
|
|
int ramp[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 };
|
2001-05-09 05:41:34 +00:00
|
|
|
|
|
|
|
|
2001-11-06 21:02:18 +00:00
|
|
|
inline static void
|
2001-05-09 05:41:34 +00:00
|
|
|
particle_new (ptype_t type, int texnum, vec3_t org, float scale, vec3_t vel,
|
2001-09-05 00:08:54 +00:00
|
|
|
float die, byte color, byte alpha)
|
2001-05-09 05:41:34 +00:00
|
|
|
{
|
|
|
|
particle_t *part;
|
|
|
|
|
2001-09-18 23:22:57 +00:00
|
|
|
/*
|
2001-09-19 18:07:09 +00:00
|
|
|
if (numparticles >= r_maxparticles) {
|
2001-10-28 00:47:21 +00:00
|
|
|
Sys_Error ("FAILED PARTICLE ALLOC!\n");
|
2001-05-09 05:41:34 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-09-18 23:22:57 +00:00
|
|
|
*/
|
2001-05-09 05:41:34 +00:00
|
|
|
|
|
|
|
part = &particles[numparticles++];
|
|
|
|
|
|
|
|
part->type = type;
|
|
|
|
VectorCopy (org, part->org);
|
|
|
|
VectorCopy (vel, part->vel);
|
|
|
|
part->die = die;
|
|
|
|
part->color = color;
|
|
|
|
part->alpha = alpha;
|
|
|
|
part->tex = texnum;
|
|
|
|
part->scale = scale;
|
|
|
|
}
|
|
|
|
|
2001-11-06 21:02:18 +00:00
|
|
|
inline static void
|
2001-05-09 05:41:34 +00:00
|
|
|
particle_new_random (ptype_t type, int texnum, vec3_t org, int org_fuzz,
|
|
|
|
float scale, int vel_fuzz, float die, byte color,
|
|
|
|
byte alpha)
|
|
|
|
{
|
|
|
|
int j;
|
2001-09-01 08:57:04 +00:00
|
|
|
vec3_t porg, pvel;
|
2001-05-09 05:41:34 +00:00
|
|
|
|
|
|
|
for (j = 0; j < 3; j++) {
|
|
|
|
if (org_fuzz)
|
2001-09-09 19:37:07 +00:00
|
|
|
porg[j] = qfrandom (org_fuzz * 2) - org_fuzz + org[j];
|
2001-05-09 05:41:34 +00:00
|
|
|
if (vel_fuzz)
|
2001-09-09 19:37:07 +00:00
|
|
|
pvel[j] = qfrandom (vel_fuzz * 2) - vel_fuzz;
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
2001-11-06 21:02:18 +00:00
|
|
|
particle_new (type, texnum, porg, scale, pvel, die, color, alpha);
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
R_Particles_Init_Cvars (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-09-04 10:32:51 +00:00
|
|
|
inline void
|
2001-05-09 05:41:34 +00:00
|
|
|
R_ClearParticles (void)
|
|
|
|
{
|
|
|
|
numparticles = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
R_ReadPointFile_f (void)
|
|
|
|
{
|
|
|
|
char name[MAX_OSPATH], *mapname, *t1;
|
2001-09-01 08:57:04 +00:00
|
|
|
int c, r;
|
|
|
|
vec3_t org;
|
|
|
|
VFile *f;
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-05-20 03:54:55 +00:00
|
|
|
mapname = strdup (r_worldentity.model->name);
|
2001-05-09 05:41:34 +00:00
|
|
|
if (!mapname)
|
|
|
|
Sys_Error ("Can't duplicate mapname!");
|
|
|
|
t1 = strrchr (mapname, '.');
|
|
|
|
if (!t1)
|
|
|
|
Sys_Error ("Can't find .!");
|
|
|
|
t1[0] = '\0';
|
|
|
|
|
|
|
|
snprintf (name, sizeof (name), "%s.pts", mapname);
|
|
|
|
free (mapname);
|
|
|
|
|
|
|
|
COM_FOpenFile (name, &f);
|
|
|
|
if (!f) {
|
|
|
|
Con_Printf ("couldn't open %s\n", name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Con_Printf ("Reading %s...\n", name);
|
|
|
|
c = 0;
|
|
|
|
for (;;) {
|
|
|
|
char buf[64];
|
|
|
|
|
|
|
|
Qgets (f, buf, sizeof (buf));
|
|
|
|
r = sscanf (buf, "%f %f %f\n", &org[0], &org[1], &org[2]);
|
|
|
|
if (r != 3)
|
|
|
|
break;
|
|
|
|
c++;
|
|
|
|
|
2001-10-28 00:47:21 +00:00
|
|
|
if (numparticles >= r_maxparticles) {
|
2001-05-09 05:41:34 +00:00
|
|
|
Con_Printf ("Not enough free particles\n");
|
|
|
|
break;
|
2001-10-28 00:47:21 +00:00
|
|
|
} else {
|
|
|
|
particle_new (pt_static, part_tex_dot, org, 1.5, vec3_origin,
|
|
|
|
99999, (-c) & 15, 255);
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Qclose (f);
|
|
|
|
Con_Printf ("%i points read\n", c);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
R_ParticleExplosion (vec3_t org)
|
|
|
|
{
|
2001-09-19 18:07:09 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-09-18 23:22:57 +00:00
|
|
|
return;
|
2001-10-09 20:35:17 +00:00
|
|
|
/*
|
|
|
|
R_NewExplosion (org);
|
|
|
|
*/
|
2001-11-15 23:36:14 +00:00
|
|
|
particle_new_random (pt_smokecloud, part_tex_smoke, org, 4,
|
2001-11-15 20:53:23 +00:00
|
|
|
30, 8, r_realtime + 5,
|
|
|
|
(rand () & 7) + 8,
|
|
|
|
128 + (rand () & 63));
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
void
|
|
|
|
R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength)
|
|
|
|
{
|
|
|
|
int i;
|
2001-09-18 23:22:57 +00:00
|
|
|
int colorMod = 0, j = 512;
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-09-19 18:07:09 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-09-18 23:22:57 +00:00
|
|
|
return;
|
2001-09-19 18:07:09 +00:00
|
|
|
else if (numparticles + j >= r_maxparticles)
|
|
|
|
j = r_maxparticles - numparticles;
|
2001-09-18 23:22:57 +00:00
|
|
|
|
|
|
|
for (i = 0; i < j; i++) {
|
2001-07-21 23:18:59 +00:00
|
|
|
particle_new_random (pt_blob, part_tex_dot, org, 16, 2, 256,
|
2001-11-15 20:53:23 +00:00
|
|
|
(r_realtime + 0.3),
|
|
|
|
(colorStart + (colorMod % colorLength)),
|
|
|
|
255);
|
2001-05-09 05:41:34 +00:00
|
|
|
colorMod++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
R_BlobExplosion (vec3_t org)
|
|
|
|
{
|
|
|
|
int i;
|
2001-09-18 23:22:57 +00:00
|
|
|
int j = 1024;
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-09-19 18:07:09 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-09-18 23:22:57 +00:00
|
|
|
return;
|
2001-09-19 18:07:09 +00:00
|
|
|
else if (numparticles + j >= r_maxparticles)
|
|
|
|
j = r_maxparticles - numparticles;
|
2001-09-18 23:22:57 +00:00
|
|
|
|
|
|
|
for (i = 0; i < j / 2; i++) {
|
2001-05-09 05:41:34 +00:00
|
|
|
particle_new_random (pt_blob, part_tex_dot, org, 12, 2, 256,
|
2001-09-16 20:07:28 +00:00
|
|
|
(r_realtime + 1 + (rand () & 7) * 0.05),
|
2001-05-09 05:41:34 +00:00
|
|
|
(66 + rand () % 6), 255);
|
|
|
|
}
|
2001-09-18 23:22:57 +00:00
|
|
|
for (i = 0; i < j / 2; i++) {
|
2001-05-09 05:41:34 +00:00
|
|
|
particle_new_random (pt_blob2, part_tex_dot, org, 12, 2, 256,
|
2001-09-16 20:07:28 +00:00
|
|
|
(r_realtime + 1 + (rand () & 7) * 0.05),
|
2001-05-09 05:41:34 +00:00
|
|
|
(150 + rand () % 6), 255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
R_RunSparkEffect (vec3_t org, int count, int ofuzz)
|
|
|
|
{
|
2001-09-18 23:22:57 +00:00
|
|
|
int j = count + 1;
|
|
|
|
|
2001-09-19 18:07:09 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-09-18 23:22:57 +00:00
|
|
|
return;
|
2001-09-19 18:07:09 +00:00
|
|
|
else if (numparticles + j >= r_maxparticles)
|
|
|
|
j = r_maxparticles - numparticles;
|
2001-09-18 23:22:57 +00:00
|
|
|
count = j - 1;
|
|
|
|
|
2001-09-24 17:52:13 +00:00
|
|
|
particle_new (pt_smokecloud, part_tex_smoke, org,
|
2001-09-16 20:07:28 +00:00
|
|
|
ofuzz * 0.08, vec3_origin, r_realtime + 9,
|
|
|
|
12 + (rand () & 3), 64 + (rand () & 31));
|
2001-05-09 05:41:34 +00:00
|
|
|
while (count--)
|
2001-11-07 06:57:34 +00:00
|
|
|
particle_new_random (pt_fallfadespark, part_tex_dot, org,
|
|
|
|
ofuzz * 0.75, 0.7, 96, r_realtime + 5,
|
2001-09-16 20:07:28 +00:00
|
|
|
ramp[rand () & 7], 255);
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
|
2001-09-04 10:32:51 +00:00
|
|
|
inline static void
|
2001-05-09 05:41:34 +00:00
|
|
|
R_BloodPuff (vec3_t org, int count)
|
|
|
|
{
|
2001-09-19 18:07:09 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-09-18 23:22:57 +00:00
|
|
|
return;
|
|
|
|
|
2001-09-27 06:52:38 +00:00
|
|
|
particle_new (pt_bloodcloud, part_tex_smoke, org, count / 5,
|
|
|
|
vec3_origin, r_realtime + 99, 70 + (rand () & 3), 128);
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
2001-05-09 06:00:19 +00:00
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
void
|
2001-05-29 19:43:15 +00:00
|
|
|
R_RunPuffEffect (vec3_t org, particle_effect_t type, byte count)
|
2001-05-09 05:41:34 +00:00
|
|
|
{
|
2001-09-22 02:37:45 +00:00
|
|
|
// FIXME: Is this test worthwhile?
|
|
|
|
if (numparticles >= r_maxparticles)
|
2001-05-09 05:41:34 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
switch (type) {
|
2001-05-29 19:43:15 +00:00
|
|
|
case PE_GUNSHOT:
|
2001-09-17 01:48:52 +00:00
|
|
|
{
|
|
|
|
int scale = 16;
|
|
|
|
|
2001-09-27 03:09:24 +00:00
|
|
|
if (count > 120)
|
2001-09-17 01:48:52 +00:00
|
|
|
scale = 24;
|
|
|
|
R_RunSparkEffect (org, count / 2, scale);
|
|
|
|
}
|
2001-05-09 05:41:34 +00:00
|
|
|
break;
|
2001-05-29 19:43:15 +00:00
|
|
|
case PE_BLOOD:
|
2001-05-18 19:58:49 +00:00
|
|
|
R_BloodPuff (org, count);
|
|
|
|
break;
|
2001-05-29 19:43:15 +00:00
|
|
|
case PE_LIGHTNINGBLOOD:
|
2001-09-27 03:09:24 +00:00
|
|
|
R_BloodPuff (org, 50);
|
2001-09-18 23:22:57 +00:00
|
|
|
|
2001-09-19 18:07:09 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-10-27 08:32:52 +00:00
|
|
|
break;
|
2001-09-24 17:52:13 +00:00
|
|
|
particle_new (pt_smokecloud, part_tex_smoke, org,
|
2001-09-17 01:48:52 +00:00
|
|
|
3, vec3_origin, r_realtime + 9,
|
|
|
|
12 + (rand () & 3), 64 + (rand () & 31));
|
2001-10-02 09:11:20 +00:00
|
|
|
count = 7;
|
|
|
|
if (numparticles + count >= r_maxparticles)
|
|
|
|
count = r_maxparticles - numparticles;
|
2001-09-17 01:48:52 +00:00
|
|
|
while (count--)
|
|
|
|
particle_new_random (pt_fallfadespark, part_tex_spark, org,
|
2001-09-18 23:22:57 +00:00
|
|
|
12, 2, 128, r_realtime + 5,
|
2001-09-17 01:48:52 +00:00
|
|
|
244 + (rand () % 3), 255);
|
2001-05-18 19:58:49 +00:00
|
|
|
break;
|
2001-05-29 19:43:15 +00:00
|
|
|
default:
|
|
|
|
break;
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-27 00:43:46 +00:00
|
|
|
R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count)
|
2001-05-09 05:41:34 +00:00
|
|
|
{
|
2001-09-27 03:09:24 +00:00
|
|
|
int i, j;
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-09-19 18:07:09 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-09-18 23:22:57 +00:00
|
|
|
return;
|
|
|
|
|
2001-09-27 00:43:46 +00:00
|
|
|
if (numparticles + count >= r_maxparticles)
|
|
|
|
count = r_maxparticles - numparticles;
|
2001-09-18 23:22:57 +00:00
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
for (j = 0; j < 3; j++) {
|
2001-09-27 03:09:24 +00:00
|
|
|
org[j] += ((rand () & 15) - 8);
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
2001-09-27 00:43:46 +00:00
|
|
|
particle_new (pt_slowgrav, part_tex_dot, org, 1.5, dir,
|
2001-05-20 03:54:55 +00:00
|
|
|
(r_realtime + 0.1 * (rand () % 5)),
|
2001-09-05 00:08:54 +00:00
|
|
|
(color & ~7) + (rand () & 7), 255);
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-05-29 19:43:15 +00:00
|
|
|
R_RunSpikeEffect (vec3_t org, particle_effect_t type)
|
2001-05-09 05:41:34 +00:00
|
|
|
{
|
|
|
|
switch (type) {
|
2001-05-29 19:43:15 +00:00
|
|
|
case PE_SPIKE:
|
2001-05-09 05:41:34 +00:00
|
|
|
R_RunSparkEffect (org, 5, 8);
|
|
|
|
break;
|
2001-05-29 19:43:15 +00:00
|
|
|
case PE_SUPERSPIKE:
|
2001-05-09 05:41:34 +00:00
|
|
|
R_RunSparkEffect (org, 10, 8);
|
|
|
|
break;
|
2001-05-29 19:43:15 +00:00
|
|
|
case PE_KNIGHTSPIKE:
|
2001-05-09 05:41:34 +00:00
|
|
|
R_RunSparkEffect (org, 10, 8);
|
|
|
|
break;
|
2001-05-29 19:43:15 +00:00
|
|
|
case PE_WIZSPIKE:
|
2001-05-09 05:41:34 +00:00
|
|
|
R_RunSparkEffect (org, 15, 16);
|
|
|
|
break;
|
2001-05-29 19:43:15 +00:00
|
|
|
default:
|
|
|
|
break;
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
R_LavaSplash (vec3_t org)
|
|
|
|
{
|
|
|
|
float vel;
|
2001-11-06 21:02:18 +00:00
|
|
|
int rnd, i, j;
|
2001-09-18 23:22:57 +00:00
|
|
|
int k = 256;
|
2001-05-09 05:41:34 +00:00
|
|
|
vec3_t dir, porg, pvel;
|
|
|
|
|
2001-09-19 18:07:09 +00:00
|
|
|
if (numparticles + k >= r_maxparticles) {
|
2001-09-18 23:22:57 +00:00
|
|
|
return;
|
2001-09-19 18:07:09 +00:00
|
|
|
} // else if (numparticles + k >= r_maxparticles) {
|
|
|
|
// k = r_maxparticles - numparticles;
|
2001-09-18 23:22:57 +00:00
|
|
|
// }
|
|
|
|
|
2001-10-02 09:11:20 +00:00
|
|
|
dir[2] = 256;
|
2001-09-18 23:22:57 +00:00
|
|
|
for (i = -128; i < 128; i += 16) {
|
|
|
|
for (j = -128; j < 128; j += 16) {
|
2001-11-06 21:02:18 +00:00
|
|
|
rnd = rand ();
|
|
|
|
dir[0] = j + (rnd & 7);
|
|
|
|
dir[1] = i + ((rnd >> 6) & 7);
|
2001-05-09 05:41:34 +00:00
|
|
|
|
|
|
|
porg[0] = org[0] + dir[0];
|
|
|
|
porg[1] = org[1] + dir[1];
|
2001-11-06 21:02:18 +00:00
|
|
|
porg[2] = org[2] + ((rnd >> 9) & 63);
|
2001-05-09 05:41:34 +00:00
|
|
|
|
|
|
|
VectorNormalize (dir);
|
2001-11-06 21:02:18 +00:00
|
|
|
rnd = rand ();
|
|
|
|
vel = 50 + (rnd & 63);
|
2001-05-09 05:41:34 +00:00
|
|
|
VectorScale (dir, vel, pvel);
|
|
|
|
particle_new (pt_grav, part_tex_dot, porg, 3, pvel,
|
2001-11-06 21:02:18 +00:00
|
|
|
(r_realtime + 2 + ((rnd >> 7) & 31) * 0.02),
|
|
|
|
(224 + ((rnd >> 12) & 7)), 193);
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
R_TeleportSplash (vec3_t org)
|
|
|
|
{
|
|
|
|
float vel;
|
2001-11-06 21:02:18 +00:00
|
|
|
int rnd, i, j, k;
|
2001-09-18 23:22:57 +00:00
|
|
|
int l = 896;
|
2001-05-09 05:41:34 +00:00
|
|
|
vec3_t dir, porg, pvel;
|
|
|
|
|
2001-09-19 18:07:09 +00:00
|
|
|
if (numparticles + l >= r_maxparticles) {
|
2001-09-18 23:22:57 +00:00
|
|
|
return;
|
2001-09-19 18:07:09 +00:00
|
|
|
} // else if (numparticles + l >= r_maxparticles) {
|
|
|
|
// l = r_maxparticles - numparticles;
|
2001-09-18 23:22:57 +00:00
|
|
|
// }
|
|
|
|
|
2001-10-02 09:11:20 +00:00
|
|
|
for (i = -16; i < 16; i += 4) {
|
|
|
|
dir[1] = i * 8;
|
|
|
|
for (j = -16; j < 16; j += 4) {
|
|
|
|
dir[0] = j * 8;
|
2001-05-09 05:41:34 +00:00
|
|
|
for (k = -24; k < 32; k += 4) {
|
|
|
|
dir[2] = k * 8;
|
2001-11-06 21:02:18 +00:00
|
|
|
|
|
|
|
rnd = rand ();
|
|
|
|
porg[0] = org[0] + i + (rnd & 3);
|
|
|
|
porg[1] = org[1] + j + ((rnd >> 2) & 3);
|
|
|
|
porg[2] = org[2] + k + ((rnd >> 4) & 3);
|
2001-05-09 05:41:34 +00:00
|
|
|
|
|
|
|
VectorNormalize (dir);
|
2001-11-06 21:02:18 +00:00
|
|
|
vel = 50 + ((rnd >> 6) & 63);
|
2001-05-09 05:41:34 +00:00
|
|
|
VectorScale (dir, vel, pvel);
|
|
|
|
particle_new (pt_grav, part_tex_spark, porg, 0.6, pvel,
|
2001-10-02 09:11:20 +00:00
|
|
|
(r_realtime + 0.2 + (rand () & 15) * 0.01),
|
2001-11-06 21:02:18 +00:00
|
|
|
(7 + ((rnd >> 12) & 7)), 255);
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
2001-10-02 09:11:20 +00:00
|
|
|
}
|
|
|
|
}
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-07 05:37:11 +00:00
|
|
|
R_RocketTrail (entity_t *ent)
|
2001-05-09 05:41:34 +00:00
|
|
|
{
|
2001-11-09 12:09:46 +00:00
|
|
|
float dist, maxlen, origlen, percent, pscale, pscalenext;
|
|
|
|
float len = 0;
|
2001-09-06 04:26:53 +00:00
|
|
|
vec3_t subtract, vec;
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-09-22 02:37:45 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-09-07 05:37:11 +00:00
|
|
|
return;
|
|
|
|
|
2001-09-06 04:26:53 +00:00
|
|
|
R_AddFire (ent->old_origin, ent->origin, ent);
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-09-06 04:26:53 +00:00
|
|
|
VectorSubtract (ent->origin, ent->old_origin, vec);
|
2001-11-09 12:09:46 +00:00
|
|
|
maxlen = VectorNormalize (vec);
|
|
|
|
origlen = r_frametime / maxlen;
|
2001-11-02 20:47:47 +00:00
|
|
|
|
2001-09-06 04:26:53 +00:00
|
|
|
pscale = 1.5 + qfrandom (1.5);
|
|
|
|
|
2001-11-09 12:09:46 +00:00
|
|
|
while (len < maxlen) {
|
2001-09-06 04:26:53 +00:00
|
|
|
pscalenext = 1.5 + qfrandom (1.5);
|
2001-09-09 19:37:07 +00:00
|
|
|
dist = (pscale + pscalenext) * 3.0;
|
2001-09-06 04:26:53 +00:00
|
|
|
|
|
|
|
VectorScale (vec, min(dist, len), subtract);
|
|
|
|
VectorAdd (ent->old_origin, subtract, ent->old_origin);
|
2001-11-02 20:47:47 +00:00
|
|
|
percent = len * origlen;
|
2001-09-06 04:26:53 +00:00
|
|
|
|
2001-11-15 01:37:57 +00:00
|
|
|
particle_new (pt_smoke, part_tex_smoke, ent->old_origin,
|
|
|
|
pscale + percent * 4.0, vec3_origin,
|
2001-11-15 23:36:14 +00:00
|
|
|
r_realtime + 2.0 - percent * 2.0,
|
|
|
|
12 + (rand () & 3),
|
2001-11-15 01:37:57 +00:00
|
|
|
128 + (rand () & 31) - percent * 100.0);
|
2001-11-09 12:09:46 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2001-09-06 04:26:53 +00:00
|
|
|
pscale = pscalenext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-07 05:37:11 +00:00
|
|
|
R_GrenadeTrail (entity_t *ent)
|
2001-09-06 04:26:53 +00:00
|
|
|
{
|
2001-11-09 12:09:46 +00:00
|
|
|
float dist, maxlen, origlen, percent, pscale, pscalenext;
|
|
|
|
float len = 0;
|
2001-09-06 04:26:53 +00:00
|
|
|
vec3_t subtract, vec;
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-09-22 02:37:45 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-09-07 05:37:11 +00:00
|
|
|
return;
|
|
|
|
|
2001-05-18 19:58:49 +00:00
|
|
|
VectorSubtract (ent->origin, ent->old_origin, vec);
|
2001-11-09 12:09:46 +00:00
|
|
|
maxlen = VectorNormalize (vec);
|
|
|
|
origlen = r_frametime / maxlen;
|
2001-09-06 04:26:53 +00:00
|
|
|
pscale = 6.0 + qfrandom (7.0);
|
|
|
|
|
2001-11-09 12:09:46 +00:00
|
|
|
while (len < maxlen) {
|
2001-09-06 04:26:53 +00:00
|
|
|
pscalenext = 6.0 + qfrandom (7.0);
|
2001-09-07 05:37:11 +00:00
|
|
|
dist = (pscale + pscalenext) * 2.0;
|
2001-09-06 04:26:53 +00:00
|
|
|
|
|
|
|
VectorScale (vec, min(dist, len), subtract);
|
|
|
|
VectorAdd (ent->old_origin, subtract, ent->old_origin);
|
2001-11-02 20:47:47 +00:00
|
|
|
percent = len * origlen;
|
2001-09-06 04:26:53 +00:00
|
|
|
|
2001-11-15 01:37:57 +00:00
|
|
|
particle_new (pt_smoke, part_tex_smoke, ent->old_origin,
|
|
|
|
pscale + percent * 4.0, vec3_origin,
|
2001-11-15 23:36:14 +00:00
|
|
|
r_realtime + 2.0 - percent * 2.0,
|
|
|
|
(rand () & 3),
|
2001-11-15 01:37:57 +00:00
|
|
|
160 + (rand () & 31) - percent * 100.0);
|
2001-11-09 12:09:46 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2001-09-06 04:26:53 +00:00
|
|
|
pscale = pscalenext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-07 05:37:11 +00:00
|
|
|
R_BloodTrail (entity_t *ent)
|
2001-09-06 04:26:53 +00:00
|
|
|
{
|
2001-11-09 12:09:46 +00:00
|
|
|
float dist, maxlen, origlen, percent, pscale, pscalenext;
|
|
|
|
float len = 0;
|
2001-09-06 04:26:53 +00:00
|
|
|
int j;
|
|
|
|
vec3_t subtract, vec, porg, pvel;
|
|
|
|
|
2001-09-22 02:37:45 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-09-07 05:37:11 +00:00
|
|
|
return;
|
|
|
|
|
2001-09-06 04:26:53 +00:00
|
|
|
VectorSubtract (ent->origin, ent->old_origin, vec);
|
2001-11-09 12:09:46 +00:00
|
|
|
maxlen = VectorNormalize (vec);
|
|
|
|
origlen = r_frametime / maxlen;
|
2001-09-06 04:26:53 +00:00
|
|
|
pscale = 5.0 + qfrandom (10.0);
|
|
|
|
|
2001-11-09 12:09:46 +00:00
|
|
|
while (len < maxlen) {
|
2001-09-06 04:26:53 +00:00
|
|
|
VectorCopy (vec3_origin, pvel);
|
|
|
|
VectorCopy (ent->old_origin, porg);
|
|
|
|
|
|
|
|
pscalenext = 5.0 + qfrandom (10.0);
|
2001-09-07 05:37:11 +00:00
|
|
|
dist = (pscale + pscalenext) * 1.5;
|
2001-09-06 04:26:53 +00:00
|
|
|
|
|
|
|
for (j = 0; j < 3; j++) {
|
2001-11-06 21:02:18 +00:00
|
|
|
pvel[j] = qfrandom (24.0) - 12.0;
|
2001-09-06 04:26:53 +00:00
|
|
|
porg[j] = ent->old_origin[j] + qfrandom (3.0) - 1.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
VectorScale (vec, min(dist, len), subtract);
|
|
|
|
VectorAdd (ent->old_origin, subtract, ent->old_origin);
|
2001-11-02 20:47:47 +00:00
|
|
|
percent = len * origlen;
|
|
|
|
pvel[2] -= percent * 40;
|
2001-09-06 04:26:53 +00:00
|
|
|
|
2001-09-24 17:52:13 +00:00
|
|
|
particle_new (pt_grav, part_tex_smoke, porg, pscale, pvel,
|
2001-11-09 12:09:46 +00:00
|
|
|
r_realtime + 2.0 - percent * 2.0, 68 + (rand () & 3),
|
|
|
|
255);
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2001-09-06 04:26:53 +00:00
|
|
|
pscale = pscalenext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-07 05:37:11 +00:00
|
|
|
R_SlightBloodTrail (entity_t *ent)
|
2001-09-06 04:26:53 +00:00
|
|
|
{
|
2001-11-09 12:09:46 +00:00
|
|
|
float dist, maxlen, origlen, percent, pscale, pscalenext;
|
|
|
|
float len = 0;
|
2001-09-06 04:26:53 +00:00
|
|
|
int j;
|
|
|
|
vec3_t subtract, vec, porg, pvel;
|
|
|
|
|
2001-09-22 02:37:45 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-09-07 05:37:11 +00:00
|
|
|
return;
|
|
|
|
|
2001-09-06 04:26:53 +00:00
|
|
|
VectorSubtract (ent->origin, ent->old_origin, vec);
|
2001-11-09 12:09:46 +00:00
|
|
|
maxlen = VectorNormalize (vec);
|
|
|
|
origlen = r_frametime / maxlen;
|
2001-09-06 04:26:53 +00:00
|
|
|
pscale = 1.5 + qfrandom (7.5);
|
|
|
|
|
2001-11-09 12:09:46 +00:00
|
|
|
while (len < maxlen) {
|
2001-09-06 04:26:53 +00:00
|
|
|
VectorCopy (vec3_origin, pvel);
|
|
|
|
VectorCopy (ent->old_origin, porg);
|
|
|
|
|
|
|
|
pscalenext = 1.5 + qfrandom (7.5);
|
|
|
|
dist = (pscale + pscalenext) * 1.5;
|
|
|
|
|
|
|
|
for (j = 0; j < 3; j++) {
|
2001-09-07 05:37:11 +00:00
|
|
|
pvel[j] = (qfrandom (12.0) - 6.0);
|
2001-09-06 04:26:53 +00:00
|
|
|
porg[j] = ent->old_origin[j] + qfrandom (3.0) - 1.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
VectorScale (vec, min(dist, len), subtract);
|
|
|
|
VectorAdd (ent->old_origin, subtract, ent->old_origin);
|
2001-11-02 20:47:47 +00:00
|
|
|
percent = len * origlen;
|
|
|
|
pvel[2] -= percent * 40;
|
2001-09-06 04:26:53 +00:00
|
|
|
|
2001-09-24 17:52:13 +00:00
|
|
|
particle_new (pt_grav, part_tex_smoke, porg, pscale, pvel,
|
2001-11-09 12:09:46 +00:00
|
|
|
r_realtime + 1.5 - percent * 1.5, 68 + (rand () & 3),
|
|
|
|
192);
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2001-09-06 04:26:53 +00:00
|
|
|
pscale = pscalenext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-07 05:37:11 +00:00
|
|
|
R_GreenTrail (entity_t *ent)
|
2001-09-06 04:26:53 +00:00
|
|
|
{
|
2001-11-09 12:09:46 +00:00
|
|
|
float dist, maxlen, origlen, percent;
|
|
|
|
float len = 0;
|
2001-09-06 04:26:53 +00:00
|
|
|
static int tracercount;
|
|
|
|
vec3_t subtract, vec, pvel;
|
|
|
|
|
2001-09-22 02:37:45 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-09-07 05:37:11 +00:00
|
|
|
return;
|
|
|
|
|
2001-09-06 04:26:53 +00:00
|
|
|
VectorSubtract (ent->origin, ent->old_origin, vec);
|
2001-11-09 12:09:46 +00:00
|
|
|
maxlen = VectorNormalize (vec);
|
|
|
|
origlen = r_frametime / maxlen;
|
2001-09-06 04:26:53 +00:00
|
|
|
dist = 3.0;
|
|
|
|
|
2001-11-09 12:09:46 +00:00
|
|
|
while (len < maxlen) {
|
2001-09-06 04:26:53 +00:00
|
|
|
VectorCopy (vec3_origin, pvel);
|
|
|
|
tracercount++;
|
|
|
|
if (tracercount & 1) {
|
|
|
|
pvel[0] = 30 * vec[1];
|
|
|
|
pvel[1] = 30 * -vec[0];
|
|
|
|
} else {
|
|
|
|
pvel[0] = 30 * -vec[1];
|
|
|
|
pvel[1] = 30 * vec[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
VectorScale (vec, min(dist, len), subtract);
|
|
|
|
VectorAdd (ent->old_origin, subtract, ent->old_origin);
|
2001-11-02 20:47:47 +00:00
|
|
|
percent = len * origlen;
|
2001-09-06 04:26:53 +00:00
|
|
|
|
2001-09-24 17:52:13 +00:00
|
|
|
particle_new (pt_fire, part_tex_smoke, ent->old_origin,
|
2001-11-09 12:09:46 +00:00
|
|
|
2.0 + qfrandom (1.0) - percent * 2.0, pvel,
|
|
|
|
r_realtime + 0.5 - percent * 0.5, 52 + (rand () & 4),
|
|
|
|
255 - percent * 32.0);
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2001-09-06 04:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-07 05:37:11 +00:00
|
|
|
R_FlameTrail (entity_t *ent)
|
2001-09-06 04:26:53 +00:00
|
|
|
{
|
2001-11-09 12:09:46 +00:00
|
|
|
float dist, maxlen, origlen, percent;
|
|
|
|
float len = 0;
|
2001-09-06 04:26:53 +00:00
|
|
|
static int tracercount;
|
|
|
|
vec3_t subtract, vec, pvel;
|
|
|
|
|
2001-09-22 02:37:45 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-09-07 05:37:11 +00:00
|
|
|
return;
|
|
|
|
|
2001-09-06 04:26:53 +00:00
|
|
|
VectorSubtract (ent->origin, ent->old_origin, vec);
|
2001-11-09 12:09:46 +00:00
|
|
|
maxlen = VectorNormalize (vec);
|
|
|
|
origlen = r_frametime / maxlen;
|
2001-09-06 04:26:53 +00:00
|
|
|
dist = 3.0;
|
|
|
|
|
2001-11-09 12:09:46 +00:00
|
|
|
while (len < maxlen) {
|
2001-09-06 04:26:53 +00:00
|
|
|
VectorCopy (vec3_origin, pvel);
|
|
|
|
tracercount++;
|
|
|
|
if (tracercount & 1) {
|
|
|
|
pvel[0] = 30 * vec[1];
|
|
|
|
pvel[1] = 30 * -vec[0];
|
|
|
|
} else {
|
|
|
|
pvel[0] = 30 * -vec[1];
|
|
|
|
pvel[1] = 30 * vec[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
VectorScale (vec, min(dist, len), subtract);
|
|
|
|
VectorAdd (ent->old_origin, subtract, ent->old_origin);
|
2001-11-02 20:47:47 +00:00
|
|
|
percent = len * origlen;
|
2001-09-06 04:26:53 +00:00
|
|
|
|
2001-09-24 17:52:13 +00:00
|
|
|
particle_new (pt_fire, part_tex_smoke, ent->old_origin,
|
2001-11-09 12:09:46 +00:00
|
|
|
2.0 + qfrandom (1.0) - percent * 2.0, pvel,
|
|
|
|
r_realtime + 0.5 - percent * 0.5, 234,
|
|
|
|
255 - percent * 32.0);
|
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2001-09-06 04:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-07 05:37:11 +00:00
|
|
|
R_VoorTrail (entity_t *ent)
|
2001-09-06 04:26:53 +00:00
|
|
|
{
|
2001-11-09 12:09:46 +00:00
|
|
|
float dist, maxlen, origlen, percent;
|
|
|
|
float len = 0;
|
2001-09-06 04:26:53 +00:00
|
|
|
int j;
|
|
|
|
vec3_t subtract, vec, porg;
|
|
|
|
|
2001-09-22 02:37:45 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
2001-09-07 05:37:11 +00:00
|
|
|
return;
|
|
|
|
|
2001-09-06 04:26:53 +00:00
|
|
|
VectorSubtract (ent->origin, ent->old_origin, vec);
|
2001-11-09 12:09:46 +00:00
|
|
|
maxlen = VectorNormalize (vec);
|
|
|
|
origlen = r_frametime / maxlen;
|
2001-09-06 04:26:53 +00:00
|
|
|
dist = 3.0;
|
|
|
|
|
2001-11-09 12:09:46 +00:00
|
|
|
while (len < maxlen) {
|
2001-09-06 04:26:53 +00:00
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
porg[j] = ent->old_origin[j] + qfrandom (16.0) - 8.0;
|
|
|
|
|
|
|
|
VectorScale (vec, min(dist, len), subtract);
|
|
|
|
VectorAdd (ent->old_origin, subtract, ent->old_origin);
|
2001-11-02 20:47:47 +00:00
|
|
|
percent = len * origlen;
|
2001-09-06 04:26:53 +00:00
|
|
|
|
|
|
|
particle_new (pt_static, part_tex_dot, porg, 1.0 + qfrandom (1.0),
|
2001-11-09 12:09:46 +00:00
|
|
|
vec3_origin, r_realtime + 0.3 - percent * 0.3,
|
2001-09-06 04:26:53 +00:00
|
|
|
9 * 16 + 8 + (rand () & 3), 255);
|
2001-11-09 12:09:46 +00:00
|
|
|
if (numparticles >= r_maxparticles)
|
|
|
|
break;
|
|
|
|
len += dist;
|
2001-09-06 04:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
void
|
|
|
|
R_DrawParticles (void)
|
|
|
|
{
|
2001-11-06 21:02:18 +00:00
|
|
|
// byte i;
|
2001-09-14 12:11:54 +00:00
|
|
|
unsigned char *at;
|
2001-11-02 21:12:09 +00:00
|
|
|
float dvel, grav, fast_grav, minparticledist, scale,
|
|
|
|
bloodcloud_alpha, bloodcloud_scale, fallfadespark_alpha,
|
|
|
|
fire_alpha, fire_scale, smoke_alpha, smoke_scale,
|
|
|
|
smokecloud_alpha, smokecloud_org, smokecloud_scale;
|
|
|
|
|
2001-09-14 12:11:54 +00:00
|
|
|
int activeparticles, maxparticle, j, k;
|
|
|
|
particle_t *part;
|
|
|
|
vec3_t up_scale, right_scale, up_right_scale, down_right_scale;
|
2001-09-22 02:37:45 +00:00
|
|
|
|
2001-09-05 02:04:02 +00:00
|
|
|
if (!r_particles->int_val)
|
|
|
|
return;
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
// LordHavoc: particles should not affect zbuffer
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDepthMask (GL_FALSE);
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-11-06 21:02:18 +00:00
|
|
|
varray[0].texcoord[0] = 0;
|
|
|
|
varray[0].texcoord[1] = 1;
|
|
|
|
varray[1].texcoord[0] = 0;
|
|
|
|
varray[1].texcoord[1] = 0;
|
|
|
|
varray[2].texcoord[0] = 1;
|
|
|
|
varray[2].texcoord[1] = 0;
|
|
|
|
varray[3].texcoord[0] = 1;
|
|
|
|
varray[3].texcoord[1] = 1;
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-05-29 19:43:15 +00:00
|
|
|
grav = (fast_grav = r_frametime * 800) * 0.05;
|
2001-11-02 21:12:09 +00:00
|
|
|
dvel = bloodcloud_scale = smoke_scale = r_frametime * 4;
|
|
|
|
smoke_alpha = r_frametime * 100;
|
|
|
|
smokecloud_alpha = r_frametime * 140;
|
|
|
|
smokecloud_scale = r_frametime * 50;
|
|
|
|
smokecloud_org = r_frametime * 30;
|
|
|
|
bloodcloud_alpha = r_frametime * 65;
|
|
|
|
fallfadespark_alpha = r_frametime * 256;
|
|
|
|
fire_alpha = r_frametime * 32;
|
|
|
|
fire_scale = r_frametime * 2;
|
2001-05-09 05:41:34 +00:00
|
|
|
|
|
|
|
minparticledist = DotProduct (r_refdef.vieworg, vpn) + 32.0f;
|
|
|
|
|
|
|
|
activeparticles = 0;
|
|
|
|
maxparticle = -1;
|
|
|
|
j = 0;
|
|
|
|
|
|
|
|
for (k = 0, part = particles; k < numparticles; k++, part++) {
|
|
|
|
// Don't render particles too close to us.
|
|
|
|
// Note, we must still do physics and such on them.
|
2001-09-05 00:08:54 +00:00
|
|
|
if (!(DotProduct (part->org, vpn) < minparticledist)) {
|
2001-05-09 05:41:34 +00:00
|
|
|
at = (byte *) & d_8to24table[(byte) part->color];
|
|
|
|
|
2001-09-14 12:11:54 +00:00
|
|
|
varray[0].color[0] = at[0];
|
|
|
|
varray[0].color[1] = at[1];
|
|
|
|
varray[0].color[2] = at[2];
|
|
|
|
varray[0].color[3] = part->alpha;
|
2001-05-09 05:41:34 +00:00
|
|
|
|
|
|
|
memcpy(varray[1].color, varray[0].color, sizeof(varray[0].color));
|
|
|
|
memcpy(varray[2].color, varray[0].color, sizeof(varray[0].color));
|
|
|
|
memcpy(varray[3].color, varray[0].color, sizeof(varray[0].color));
|
|
|
|
|
|
|
|
scale = part->scale;
|
|
|
|
|
2001-09-05 09:06:48 +00:00
|
|
|
VectorScale (vup, scale, up_scale);
|
|
|
|
VectorScale (vright, scale, right_scale);
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-08-29 20:19:54 +00:00
|
|
|
VectorAdd (right_scale, up_scale, up_right_scale);
|
|
|
|
VectorSubtract (right_scale, up_scale, down_right_scale);
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-08-29 20:19:54 +00:00
|
|
|
VectorAdd (part->org, up_right_scale, varray[0].vertex);
|
|
|
|
VectorAdd (part->org, down_right_scale, varray[1].vertex);
|
|
|
|
VectorSubtract (part->org, up_right_scale, varray[2].vertex);
|
|
|
|
VectorSubtract (part->org, down_right_scale, varray[3].vertex);
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglBindTexture (GL_TEXTURE_2D, part->tex);
|
|
|
|
qfglDrawArrays (GL_QUADS, 0, 4);
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
|
2001-11-06 21:02:18 +00:00
|
|
|
VectorMA (part->org, r_frametime, part->vel, part->org);
|
2001-05-09 05:41:34 +00:00
|
|
|
|
|
|
|
switch (part->type) {
|
|
|
|
case pt_static:
|
|
|
|
break;
|
|
|
|
case pt_blob:
|
2001-11-06 21:02:18 +00:00
|
|
|
VectorMA (part->vel, dvel, part->vel, part->vel);
|
2001-05-09 05:41:34 +00:00
|
|
|
part->vel[2] -= grav;
|
|
|
|
break;
|
|
|
|
case pt_blob2:
|
2001-11-06 21:02:18 +00:00
|
|
|
VectorMA (part->vel, dvel, part->vel, part->vel);
|
2001-05-09 05:41:34 +00:00
|
|
|
part->vel[2] -= grav;
|
|
|
|
break;
|
|
|
|
case pt_grav:
|
|
|
|
part->vel[2] -= grav;
|
|
|
|
break;
|
|
|
|
case pt_smoke:
|
2001-11-02 21:12:09 +00:00
|
|
|
if ((part->alpha -= smoke_alpha) < 1)
|
2001-05-09 05:41:34 +00:00
|
|
|
part->die = -1;
|
2001-11-02 21:12:09 +00:00
|
|
|
part->scale += smoke_scale;
|
|
|
|
// part->org[2] += smokecloud_org - grav;
|
2001-05-09 05:41:34 +00:00
|
|
|
break;
|
2001-10-02 09:11:20 +00:00
|
|
|
case pt_smokecloud:
|
2001-11-02 21:12:09 +00:00
|
|
|
if ((part->alpha -= smokecloud_alpha) < 1)
|
2001-05-09 05:41:34 +00:00
|
|
|
{
|
|
|
|
part->die = -1;
|
|
|
|
break;
|
|
|
|
}
|
2001-11-02 21:12:09 +00:00
|
|
|
part->scale += smokecloud_scale;
|
|
|
|
part->org[2] += smokecloud_org;
|
2001-05-09 05:41:34 +00:00
|
|
|
break;
|
|
|
|
case pt_bloodcloud:
|
2001-11-02 21:12:09 +00:00
|
|
|
if ((part->alpha -= bloodcloud_alpha) < 1)
|
2001-05-09 05:41:34 +00:00
|
|
|
{
|
|
|
|
part->die = -1;
|
|
|
|
break;
|
|
|
|
}
|
2001-11-02 21:12:09 +00:00
|
|
|
part->scale += bloodcloud_scale;
|
2001-05-09 05:41:34 +00:00
|
|
|
part->vel[2] -= grav;
|
|
|
|
break;
|
|
|
|
case pt_fallfadespark:
|
2001-11-02 21:12:09 +00:00
|
|
|
if ((part->alpha -= fallfadespark_alpha) < 1)
|
2001-05-09 05:41:34 +00:00
|
|
|
part->die = -1;
|
|
|
|
part->vel[2] -= fast_grav;
|
|
|
|
break;
|
2001-07-21 20:32:45 +00:00
|
|
|
case pt_fire:
|
2001-11-02 21:12:09 +00:00
|
|
|
if ((part->alpha -= fire_alpha) < 1)
|
2001-07-21 20:32:45 +00:00
|
|
|
part->die = -1;
|
2001-11-02 21:12:09 +00:00
|
|
|
part->scale -= fire_scale;
|
2001-07-21 20:32:45 +00:00
|
|
|
break;
|
2001-05-10 06:01:11 +00:00
|
|
|
default:
|
|
|
|
Con_DPrintf ("unhandled particle type %d\n", part->type);
|
|
|
|
break;
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
2001-11-09 12:09:46 +00:00
|
|
|
// LordHavoc: immediate removal of unnecessary particles (must be done
|
|
|
|
// to ensure compactor below operates properly in all cases)
|
|
|
|
if (part->die < r_realtime)
|
|
|
|
freeparticles[j++] = part;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maxparticle = k;
|
|
|
|
activeparticles++;
|
|
|
|
}
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|
|
|
|
k = 0;
|
|
|
|
while (maxparticle >= activeparticles) {
|
|
|
|
*freeparticles[k++] = particles[maxparticle--];
|
|
|
|
while (maxparticle >= activeparticles &&
|
2001-05-20 03:54:55 +00:00
|
|
|
particles[maxparticle].die <= r_realtime)
|
2001-05-09 05:41:34 +00:00
|
|
|
maxparticle--;
|
|
|
|
}
|
|
|
|
numparticles = activeparticles;
|
|
|
|
|
2001-08-30 18:24:19 +00:00
|
|
|
qfglColor3ubv (color_white);
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDepthMask (GL_TRUE);
|
2001-05-09 05:41:34 +00:00
|
|
|
}
|