Make R_DarkFieldParticles & R_EntityParticles work in all renderers.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2003-10-22 06:00:36 +00:00
parent 0205a8a999
commit 5686ff51e5
5 changed files with 319 additions and 124 deletions

View file

@ -44,14 +44,14 @@ typedef enum {
struct entity_s;
extern void (*R_RocketTrail) (struct entity_s *ent);
extern void (*R_GrenadeTrail) (struct entity_s *ent);
extern void (*R_BloodTrail) (struct entity_s *ent);
extern void (*R_SlightBloodTrail) (struct entity_s *ent);
extern void (*R_WizTrail) (struct entity_s *ent);
extern void (*R_FlameTrail) (struct entity_s *ent);
extern void (*R_VoorTrail) (struct entity_s *ent);
extern void (*R_GlowTrail) (struct entity_s *ent, int glow_color);
extern void (*R_RocketTrail) (const struct entity_s *ent);
extern void (*R_GrenadeTrail) (const struct entity_s *ent);
extern void (*R_BloodTrail) (const struct entity_s *ent);
extern void (*R_SlightBloodTrail) (const struct entity_s *ent);
extern void (*R_WizTrail) (const struct entity_s *ent);
extern void (*R_FlameTrail) (const struct entity_s *ent);
extern void (*R_VoorTrail) (const struct entity_s *ent);
extern void (*R_GlowTrail) (const struct entity_s *ent, int glow_color);
extern void (*R_RunParticleEffect) (const vec3_t org, const vec3_t dir,
int color, int count);
@ -69,9 +69,8 @@ extern void (*R_ParticleExplosion2) (const vec3_t org, int colorStart,
int colorLength);
extern void (*R_LavaSplash) (const vec3_t org);
extern void (*R_TeleportSplash) (const vec3_t org);
void R_DarkFieldParticles (struct entity_s *ent);
void R_EntityParticles (struct entity_s *ent);
extern void (*R_DarkFieldParticles) (const struct entity_s *ent);
extern void (*R_EntityParticles) (const struct entity_s *ent);
void R_PushDlights (const vec3_t entorigin);
struct cvar_s;

View file

@ -255,8 +255,7 @@ R_ParticleExplosion_QF (const vec3_t org)
static void
R_ParticleExplosion2_QF (const vec3_t org, int colorStart, int colorLength)
{
unsigned int i;
unsigned int colorMod = 0, j = 512;
unsigned int i, j = 512;
if (numparticles >= r_maxparticles)
return;
@ -266,8 +265,7 @@ R_ParticleExplosion2_QF (const vec3_t org, int colorStart, int colorLength)
for (i = 0; i < j; i++) {
particle_new_random (pt_blob, part_tex_dot, org, 16, 2, 256,
r_realtime + 0.3,
colorStart + (colorMod % colorLength), 1.0, 0.0);
colorMod++;
colorStart + (i % colorLength), 1.0, 0.0);
}
}
@ -1118,6 +1116,93 @@ R_TeleportSplash_ID (const vec3_t org)
}
}
static void
R_DarkFieldParticles_ID (entity_t *ent)
{
int i, j, k, l;
unsigned int rnd;
float vel;
vec3_t dir, org, porg, pvel;
if (numparticles + l >= r_maxparticles) {
return;
} // else if (numparticles + l >= r_maxparticles) {
// l = r_maxparticles - numparticles;
// }
VectorCopy (ent->origin, org);
for (i = -16; i < 16; i += 8) {
dir [1] = i * 8;
for (j = -16; j < 16; j += 8) {
dir [0] = j * 8;
for (k = 0; k < 32; k += 8) {
dir [2] = k * 8;
rnd = rand ();
porg[0] = org[0] + i + ((rnd >> 3) & 3);
porg[1] = org[1] + j + ((rnd >> 5) & 3);
porg[2] = org[2] + k + ((rnd >> 7) & 3);
VectorNormalize (dir);
vel = 50 + ((rnd >> 9) & 63);
VectorScale (dir, vel, pvel);
particle_new (pt_slowgrav, part_tex_dot, porg, 1.5, pvel,
(r_realtime + 0.2 + (rnd & 7) * 0.02),
(150 + rand () % 6), 1.0, 0.0);
}
}
}
}
static vec3_t avelocities[NUMVERTEXNORMALS];
static void
R_EntityParticles_ID (entity_t *ent)
{
int i, j;
float angle, sp, sy, cp, cy; // cr, sr
float beamlength = 16.0, dist = 64.0;
vec3_t forward, porg;
if (numparticles + j >= r_maxparticles) {
return;
} else if (numparticles + j >= r_maxparticles) {
j = r_maxparticles - numparticles;
}
if (!avelocities[0][0]) {
for (i = 0; i < NUMVERTEXNORMALS * 3; i++)
avelocities[0][i] = (rand () & 255) * 0.01;
}
for (i = 0; i < j; i++) {
angle = r_realtime * avelocities[i][0];
cy = cos (angle);
sy = sin (angle);
angle = r_realtime * avelocities[i][1];
cp = cos (angle);
sp = sin (angle);
// Next 3 lines results aren't currently used, may be in future. --Despair
// angle = r_realtime * avelocities[i][2];
// sr = sin (angle);
// cr = cos (angle);
forward[0] = cp * cy;
forward[1] = cp * sy;
forward[2] = -sp;
porg[0] = ent->origin[0] + r_avertexnormals[i][0] * dist +
forward[0] * beamlength;
porg[1] = ent->origin[1] + r_avertexnormals[i][1] * dist +
forward[1] * beamlength;
porg[2] = ent->origin[2] + r_avertexnormals[i][2] * dist +
forward[2] * beamlength;
particle_new (pt_explode, part_tex_dot, porg, 1.0, vec3_origin,
r_realtime + 0.01, 0x6f, 1.0, 0);
}
}
static void
R_RocketTrail_ID (entity_t *ent)
{
@ -1642,6 +1727,8 @@ r_particles_style_f (cvar_t *var)
R_VoorTrail = R_VoorTrail_ID;
}
}
R_DarkFieldParticles = R_DarkFieldParticles_ID;
R_EntityParticles = R_EntityParticles_ID;
R_ParticleExplosion2 = R_ParticleExplosion2_QF;
R_GlowTrail = R_GlowTrail_QF;
// Handle R_GrenadeTrail, R_RocketTrail, R_ParticleExplosion,

View file

@ -1,7 +1,7 @@
/*
r_part.c
@description@
Interface for particles
Copyright (C) 1996-1997 Id Software, Inc.
@ -44,14 +44,14 @@ unsigned int r_maxparticles, numparticles;
particle_t *active_particles, *free_particles, *particles, **freeparticles;
vec3_t r_pright, r_pup, r_ppn;
void (*R_RocketTrail) (struct entity_s *ent);
void (*R_GrenadeTrail) (struct entity_s *ent);
void (*R_BloodTrail) (struct entity_s *ent);
void (*R_SlightBloodTrail) (struct entity_s *ent);
void (*R_WizTrail) (struct entity_s *ent);
void (*R_FlameTrail) (struct entity_s *ent);
void (*R_VoorTrail) (struct entity_s *ent);
void (*R_GlowTrail) (struct entity_s *ent, int glow_color);
void (*R_RocketTrail) (const struct entity_s *ent);
void (*R_GrenadeTrail) (const struct entity_s *ent);
void (*R_BloodTrail) (const struct entity_s *ent);
void (*R_SlightBloodTrail) (const struct entity_s *ent);
void (*R_WizTrail) (const struct entity_s *ent);
void (*R_FlameTrail) (const struct entity_s *ent);
void (*R_VoorTrail) (const struct entity_s *ent);
void (*R_GlowTrail) (const struct entity_s *ent, int glow_color);
void (*R_RunParticleEffect) (const vec3_t org, const vec3_t dir, int color, int count);
void (*R_BloodPuffEffect) (const vec3_t org, int count);
void (*R_GunshotEffect) (const vec3_t org, int count);
@ -65,6 +65,8 @@ void (*R_ParticleExplosion) (const vec3_t org);
void (*R_ParticleExplosion2) (const vec3_t org, int colorStart, int colorLength);
void (*R_LavaSplash) (const vec3_t org);
void (*R_TeleportSplash) (const vec3_t org);
void (*R_DarkFieldParticles) (const struct entity_s *ent);
void (*R_EntityParticles) (const struct entity_s *ent);
/*
@ -112,99 +114,3 @@ R_MaxParticlesCheck (cvar_t *r_particles, cvar_t *r_particles_max)
if (r_init)
R_InitParticles ();
}
void
R_DarkFieldParticles (entity_t *ent)
{
int i, j, k;
unsigned int rnd;
float vel;
particle_t *p;
vec3_t dir, org;
org[0] = ent->origin[0];
org[1] = ent->origin[1];
org[2] = ent->origin[2];
for (i = -16; i < 16; i += 8) {
for (j = -16; j < 16; j += 8) {
for (k = 0; k < 32; k += 8) {
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
rnd = rand ();
p->die = r_realtime + 0.2 + (rnd & 7) * 0.02;
p->color = 150 + rand () % 6;
p->type = pt_slowgrav;
dir[0] = j * 8;
dir[1] = i * 8;
dir[2] = k * 8;
p->org[0] = org[0] + i + ((rnd >> 3) & 3);
p->org[1] = org[1] + j + ((rnd >> 5) & 3);
p->org[2] = org[2] + k + ((rnd >> 7) & 3);
VectorNormalize (dir);
vel = 50 + ((rnd >> 9) & 63);
VectorScale (dir, vel, p->vel);
}
}
}
}
static vec3_t avelocities[NUMVERTEXNORMALS];
void
R_EntityParticles (entity_t *ent)
{
int i;
float angle, sp, sy, cp, cy; // cr, sr
float beamlength = 16.0, dist = 64.0;
particle_t *p;
vec3_t forward;
if (!avelocities[0][0]) {
for (i = 0; i < NUMVERTEXNORMALS * 3; i++)
avelocities[0][i] = (rand () & 255) * 0.01;
}
for (i = 0; i < NUMVERTEXNORMALS; i++) {
angle = r_realtime * avelocities[i][0];
cy = cos (angle);
sy = sin (angle);
angle = r_realtime * avelocities[i][1];
cp = cos (angle);
sp = sin (angle);
// Next 3 lines results aren't currently used, may be in future. --Despair
// angle = r_realtime * avelocities[i][2];
// sr = sin (angle);
// cr = cos (angle);
forward[0] = cp * cy;
forward[1] = cp * sy;
forward[2] = -sp;
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = r_realtime + 0.01;
p->color = 0x6f;
p->type = pt_explode;
p->org[0] = ent->origin[0] + r_avertexnormals[i][0] * dist +
forward[0] * beamlength;
p->org[1] = ent->origin[1] + r_avertexnormals[i][1] * dist +
forward[1] * beamlength;
p->org[2] = ent->origin[2] + r_avertexnormals[i][2] * dist +
forward[2] * beamlength;
}
}

View file

@ -1,7 +1,7 @@
/*
sw_rpart.c
(description)
Software renderer particle effects code.
Copyright (C) 1996-1997 Id Software, Inc.
@ -355,6 +355,107 @@ R_TeleportSplash_QF (const vec3_t org)
}
}
void
R_DarkFieldParticles_ID (entity_t *ent)
{
int i, j, k;
unsigned int rnd;
float vel;
particle_t *p;
vec3_t dir, org;
if (!r_particles->int_val)
return;
org[0] = ent->origin[0];
org[1] = ent->origin[1];
org[2] = ent->origin[2];
for (i = -16; i < 16; i += 8) {
for (j = -16; j < 16; j += 8) {
for (k = 0; k < 32; k += 8) {
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
rnd = rand ();
p->die = r_realtime + 0.2 + (rnd & 7) * 0.02;
p->color = 150 + rand () % 6;
p->type = pt_slowgrav;
dir[0] = j * 8;
dir[1] = i * 8;
dir[2] = k * 8;
p->org[0] = org[0] + i + ((rnd >> 3) & 3);
p->org[1] = org[1] + j + ((rnd >> 5) & 3);
p->org[2] = org[2] + k + ((rnd >> 7) & 3);
VectorNormalize (dir);
vel = 50 + ((rnd >> 9) & 63);
VectorScale (dir, vel, p->vel);
}
}
}
}
static vec3_t avelocities[NUMVERTEXNORMALS];
static void
R_EntityParticles_ID (entity_t *ent)
{
int i;
float angle, sp, sy, cp, cy; // cr, sr
float beamlength = 16.0, dist = 64.0;
particle_t *p;
vec3_t forward;
if (!r_particles->int_val)
return;
if (!avelocities[0][0]) {
for (i = 0; i < NUMVERTEXNORMALS * 3; i++)
avelocities[0][i] = (rand () & 255) * 0.01;
}
for (i = 0; i < NUMVERTEXNORMALS; i++) {
angle = r_realtime * avelocities[i][0];
cy = cos (angle);
sy = sin (angle);
angle = r_realtime * avelocities[i][1];
cp = cos (angle);
sp = sin (angle);
// Next 3 lines results aren't currently used, may be in future. --Despair
// angle = r_realtime * avelocities[i][2];
// sr = sin (angle);
// cr = cos (angle);
forward[0] = cp * cy;
forward[1] = cp * sy;
forward[2] = -sp;
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = r_realtime + 0.01;
p->color = 0x6f;
p->type = pt_explode;
p->org[0] = ent->origin[0] + r_avertexnormals[i][0] * dist +
forward[0] * beamlength;
p->org[1] = ent->origin[1] + r_avertexnormals[i][1] * dist +
forward[1] * beamlength;
p->org[2] = ent->origin[2] + r_avertexnormals[i][2] * dist +
forward[2] * beamlength;
}
}
static void
R_RocketTrail_QF (entity_t *ent)
{
@ -736,6 +837,8 @@ R_ParticleFunctionInit (void)
R_ParticleExplosion2 = R_ParticleExplosion2_QF;
R_LavaSplash = R_LavaSplash_QF;
R_TeleportSplash = R_TeleportSplash_QF;
R_DarkFieldParticles = R_DarkFieldParticles_ID;
R_EntityParticles = R_EntityParticles_ID;
R_BloodPuffEffect = R_BloodPuffEffect_QF;
R_GunshotEffect = R_GunshotEffect_QF;

View file

@ -1,7 +1,7 @@
/*
sw32_rpart.c
(description)
24 bit color software renderer particle effects.
Copyright (C) 1996-1997 Id Software, Inc.
@ -269,8 +269,8 @@ R_TeleportSplash_QF (const vec3_t org)
if (!r_particles->int_val)
return;
for (i = -16; i < 16; i += 4)
for (j = -16; j < 16; j += 4)
for (i = -16; i < 16; i += 4) {
for (j = -16; j < 16; j += 4) {
for (k = -24; k < 32; k += 4) {
if (!free_particles)
return;
@ -295,6 +295,104 @@ R_TeleportSplash_QF (const vec3_t org)
vel = 50 + (rand () & 63);
VectorScale (dir, vel, p->vel);
}
}
}
}
static void
R_DarkFieldParticles_ID (entity_t *ent)
{
int i, j, k;
unsigned int rnd;
float vel;
particle_t *p;
vec3_t dir, org;
org[0] = ent->origin[0];
org[1] = ent->origin[1];
org[2] = ent->origin[2];
for (i = -16; i < 16; i += 8) {
for (j = -16; j < 16; j += 8) {
for (k = 0; k < 32; k += 8) {
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
rnd = rand ();
p->die = r_realtime + 0.2 + (rnd & 7) * 0.02;
p->color = 150 + rand () % 6;
p->type = pt_slowgrav;
dir[0] = j * 8;
dir[1] = i * 8;
dir[2] = k * 8;
p->org[0] = org[0] + i + ((rnd >> 3) & 3);
p->org[1] = org[1] + j + ((rnd >> 5) & 3);
p->org[2] = org[2] + k + ((rnd >> 7) & 3);
VectorNormalize (dir);
vel = 50 + ((rnd >> 9) & 63);
VectorScale (dir, vel, p->vel);
}
}
}
}
static vec3_t avelocities[NUMVERTEXNORMALS];
static void
R_EntityParticles_ID (entity_t *ent)
{
int i;
float angle, sp, sy, cp, cy; // cr, sr
float beamlength = 16.0, dist = 64.0;
particle_t *p;
vec3_t forward;
if (!avelocities[0][0]) {
for (i = 0; i < NUMVERTEXNORMALS * 3; i++)
avelocities[0][i] = (rand () & 255) * 0.01;
}
for (i = 0; i < NUMVERTEXNORMALS; i++) {
angle = r_realtime * avelocities[i][0];
cy = cos (angle);
sy = sin (angle);
angle = r_realtime * avelocities[i][1];
cp = cos (angle);
sp = sin (angle);
// Next 3 lines results aren't currently used, may be in future. --Despair
// angle = r_realtime * avelocities[i][2];
// sr = sin (angle);
// cr = cos (angle);
forward[0] = cp * cy;
forward[1] = cp * sy;
forward[2] = -sp;
if (!free_particles)
return;
p = free_particles;
free_particles = p->next;
p->next = active_particles;
active_particles = p;
p->die = r_realtime + 0.01;
p->color = 0x6f;
p->type = pt_explode;
p->org[0] = ent->origin[0] + r_avertexnormals[i][0] * dist +
forward[0] * beamlength;
p->org[1] = ent->origin[1] + r_avertexnormals[i][1] * dist +
forward[1] * beamlength;
p->org[2] = ent->origin[2] + r_avertexnormals[i][2] * dist +
forward[2] * beamlength;
}
}
static void
@ -753,6 +851,8 @@ R_ParticleFunctionInit (void)
R_ParticleExplosion2 = R_ParticleExplosion2_QF;
R_LavaSplash = R_LavaSplash_QF;
R_TeleportSplash = R_TeleportSplash_QF;
R_DarkFieldParticles = R_DarkFieldParticles_ID;
R_EntityParticles = R_EntityParticles_ID;
R_BloodPuffEffect = R_BloodPuffEffect_QF;
R_GunshotEffect = R_GunshotEffect_QF;