From: lordhavoc Date: Sun, 17 Mar 2002 16:32:02 +0000 (+0000) Subject: added EF_STARDUST effect (showering golden sparks, and the entity glows) X-Git-Tag: RELEASE_0_2_0_RC1~566 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=17c635ed3aab74ad2931d6267253ad79df98bbdd;p=xonotic%2Fdarkplaces.git added EF_STARDUST effect (showering golden sparks, and the entity glows) reduced rocket glow a little made blood stains brighter again (so you can at least see the floor) EF_STARDUST and EF_FLAME now create a fixed size effect rather than attempting to use the model bounding box (which is too big usually) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@1661 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_main.c b/cl_main.c index 30b27560..851f591a 100644 --- a/cl_main.c +++ b/cl_main.c @@ -526,21 +526,29 @@ static void CL_RelinkNetworkEntities() { vec3_t mins, maxs; int temp; + /* if (ent->render.angles[0] || ent->render.angles[2]) { - VectorAdd(neworg, ent->render.model->rotatedmins, mins); - VectorAdd(neworg, ent->render.model->rotatedmaxs, maxs); + VectorMA(neworg, 0.25f, ent->render.model->rotatedmins, mins); + VectorMA(neworg, 0.25f, ent->render.model->rotatedmaxs, maxs); } else if (ent->render.angles[1]) { - VectorAdd(neworg, ent->render.model->yawmins, mins); - VectorAdd(neworg, ent->render.model->yawmaxs, maxs); + VectorMA(neworg, 0.25f, ent->render.model->yawmins, mins); + VectorMA(neworg, 0.25f, ent->render.model->yawmaxs, maxs); } else { - VectorAdd(neworg, ent->render.model->normalmins, mins); - VectorAdd(neworg, ent->render.model->normalmaxs, maxs); + VectorMA(neworg, 0.25f, ent->render.model->normalmins, mins); + VectorMA(neworg, 0.25f, ent->render.model->normalmaxs, maxs); } + */ + mins[0] = neworg[0] - 16.0f; + mins[1] = neworg[1] - 16.0f; + mins[2] = neworg[2] - 16.0f; + maxs[0] = neworg[0] + 16.0f; + maxs[1] = neworg[1] + 16.0f; + maxs[2] = neworg[2] + 16.0f; // how many flames to make temp = (int) (cl.time * 300) - (int) (cl.oldtime * 300); CL_FlameCube(mins, maxs, temp); @@ -550,6 +558,44 @@ static void CL_RelinkNetworkEntities() dlightcolor[1] += d * 0.7f; dlightcolor[2] += d * 0.3f; } + if (effects & EF_STARDUST) + { + if (ent->render.model) + { + vec3_t mins, maxs; + int temp; + /* + if (ent->render.angles[0] || ent->render.angles[2]) + { + VectorMA(neworg, 0.25f, ent->render.model->rotatedmins, mins); + VectorMA(neworg, 0.25f, ent->render.model->rotatedmaxs, maxs); + } + else if (ent->render.angles[1]) + { + VectorMA(neworg, 0.25f, ent->render.model->yawmins, mins); + VectorMA(neworg, 0.25f, ent->render.model->yawmaxs, maxs); + } + else + { + VectorMA(neworg, 0.25f, ent->render.model->normalmins, mins); + VectorMA(neworg, 0.25f, ent->render.model->normalmaxs, maxs); + } + */ + mins[0] = neworg[0] - 16.0f; + mins[1] = neworg[1] - 16.0f; + mins[2] = neworg[2] - 16.0f; + maxs[0] = neworg[0] + 16.0f; + maxs[1] = neworg[1] + 16.0f; + maxs[2] = neworg[2] + 16.0f; + // how many particles to make + temp = (int) (cl.time * 200) - (int) (cl.oldtime * 200); + CL_Stardust(mins, maxs, temp); + } + d = 100; + dlightcolor[0] += d * 1.0f; + dlightcolor[1] += d * 0.7f; + dlightcolor[2] += d * 0.3f; + } } // LordHavoc: if the model has no flags, don't check each @@ -574,10 +620,9 @@ static void CL_RelinkNetworkEntities() else if (ent->render.model->flags & EF_ROCKET) { CL_RocketTrail (oldorg, ent->render.origin, 0, ent); - // LordHavoc: changed from 200, 160, 80 to 250, 200, 100 - dlightcolor[0] += 250.0f; - dlightcolor[1] += 200.0f; - dlightcolor[2] += 100.0f; + dlightcolor[0] += 200.0f; + dlightcolor[1] += 160.0f; + dlightcolor[2] += 80.0f; } else if (ent->render.model->flags & EF_GRENADE) { @@ -591,14 +636,15 @@ static void CL_RelinkNetworkEntities() } } // LordHavoc: customizable glow - glowsize = ent->state_current.glowsize * 4.0f; // FIXME: interpolate? + glowsize = ent->state_current.glowsize; // FIXME: interpolate? glowcolor = ent->state_current.glowcolor; if (glowsize) { qbyte *tempcolor = (qbyte *)&d_8to24table[glowcolor]; - dlightcolor[0] += glowsize * tempcolor[0] * (1.0f / 255.0f); - dlightcolor[1] += glowsize * tempcolor[1] * (1.0f / 255.0f); - dlightcolor[2] += glowsize * tempcolor[2] * (1.0f / 255.0f); + // * 4 for the expansion from 0-255 to 0-1023 range, + // / 255 to scale down byte colors + glowsize *= (4.0f / 255.0f); + VectorMA(dlightcolor, glowsize, tempcolor, dlightcolor); } // LordHavoc: customizable trail if (ent->render.flags & RENDER_GLOWTRAIL) @@ -607,13 +653,11 @@ static void CL_RelinkNetworkEntities() if (dlightcolor[0] || dlightcolor[1] || dlightcolor[2]) { vec3_t vec; - dlightradius = VectorLength(dlightcolor); - d = 1.0f / dlightradius; VectorCopy(neworg, vec); // hack to make glowing player light shine on their gun if (i == cl.viewentity && !chase_active.integer) vec[2] += 30; - CL_AllocDlight (/*&ent->render*/ NULL, vec, dlightradius, dlightcolor[0] * d, dlightcolor[1] * d, dlightcolor[2] * d, 0, 0); + CL_AllocDlight (/*&ent->render*/ NULL, vec, 1, dlightcolor[0], dlightcolor[1], dlightcolor[2], 0, 0); } if (chase_active.integer) diff --git a/cl_particles.c b/cl_particles.c index c33c4b1b..09d12c7c 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. typedef enum { - pt_static, pt_grav, pt_blob, pt_blob2, pt_bulletsmoke, pt_smoke, pt_snow, pt_rain, pt_spark, pt_bubble, pt_fade, pt_steam, pt_splash, pt_splashpuff, pt_flame, pt_blood, pt_oneframe, pt_lavasplash, pt_raindropsplash, pt_underwaterspark, pt_explosionsplash + pt_static, pt_grav, pt_blob, pt_blob2, pt_bulletsmoke, pt_smoke, pt_snow, pt_rain, pt_spark, pt_bubble, pt_fade, pt_steam, pt_splash, pt_splashpuff, pt_flame, pt_blood, pt_oneframe, pt_lavasplash, pt_raindropsplash, pt_underwaterspark, pt_explosionsplash, pt_stardust } ptype_t; @@ -40,12 +40,9 @@ ptype_t; typedef struct particle_s { ptype_t type; - unsigned int flags; - //int orientation; // typically PARTICLE_BILLBOARD + unsigned int flags; // dynamically lit, orientation, additive blending, texnum vec3_t org; vec3_t vel; - //int additive; - //int tex; float die; float scalex; float scaley; @@ -56,7 +53,6 @@ typedef struct particle_s vec3_t vel2; // used for snow fluttering (base velocity, wind for instance) float friction; // how much air friction affects this object (objects with a low mass/size ratio tend to get more air friction) float pressure; // if non-zero, apply pressure to other particles - //int dynlight; // if set the particle will be dynamically lit (if cl_dynamicparticles is on), used for smoke and blood qbyte color[4]; } particle_t; @@ -673,6 +669,36 @@ void CL_ParticleRain (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int color } } +void CL_Stardust (vec3_t mins, vec3_t maxs, int count) +{ + int k; + float t; + vec3_t o, v, center; + //Con_Printf("CL_Stardust ('%f %f %f', '%f %f %f', %d);\n", mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2], count); + if (!cl_particles.integer) return; + + if (maxs[0] <= mins[0]) {t = mins[0];mins[0] = maxs[0];maxs[0] = t;} + if (maxs[1] <= mins[1]) {t = mins[1];mins[1] = maxs[1];maxs[1] = t;} + if (maxs[2] <= mins[2]) {t = mins[2];mins[2] = maxs[2];maxs[2] = t;} + + center[0] = (mins[0] + maxs[0]) * 0.5f; + center[1] = (mins[1] + maxs[1]) * 0.5f; + center[2] = (mins[2] + maxs[2]) * 0.5f; + + while (count--) + { + k = particlepalette[224 + (rand()&15)]; + o[0] = lhrandom(mins[0], maxs[0]); + o[1] = lhrandom(mins[1], maxs[1]); + o[2] = lhrandom(mins[2], maxs[2]); + VectorSubtract(o, center, v); + VectorNormalizeFast(v); + VectorScale(v, 100, v); + v[2] += sv_gravity.value * 0.15f; + particle(pt_stardust, PARTICLE_BILLBOARD, 0x903010, 0xFFD030, tex_particle, false, true, 1.5, 1.5, lhrandom(64, 128), 9999, 0, o[0], o[1], o[2], v[0], v[1], v[2], 0, 0, 0, 0, 0, 0); + } +} + void CL_FlameCube (vec3_t mins, vec3_t maxs, int count) { int k; @@ -685,7 +711,7 @@ void CL_FlameCube (vec3_t mins, vec3_t maxs, int count) while (count--) { k = particlepalette[224 + (rand()&15)]; - particle(pt_flame, PARTICLE_BILLBOARD, k, k, tex_particle, false, true, 8, 8, 255, 9999, 1.1, lhrandom(mins[0], maxs[0]), lhrandom(mins[1], maxs[1]), lhrandom(mins[2], maxs[2]), lhrandom(-32, 32), lhrandom(-32, 32), lhrandom(-32, 64), 0, 0, 0, 0, 1, 0); + particle(pt_flame, PARTICLE_BILLBOARD, k, k, tex_particle, false, true, 4, 4, lhrandom(64, 128), 9999, 0, lhrandom(mins[0], maxs[0]), lhrandom(mins[1], maxs[1]), lhrandom(mins[2], maxs[2]), lhrandom(-32, 32), lhrandom(-32, 32), lhrandom(0, 64), 0, 0, 0, 0, 1, 0); } } @@ -697,7 +723,7 @@ void CL_Flames (vec3_t org, vec3_t vel, int count) while (count--) { k = particlepalette[224 + (rand()&15)]; - particle(pt_flame, PARTICLE_BILLBOARD, k, k, tex_particle, false, true, 8, 8, 255, 9999, 1.1, org[0], org[1], org[2], vel[0] + lhrandom(-128, 128), vel[1] + lhrandom(-128, 128), vel[2] + lhrandom(-128, 128), 0, 0, 0, 0, 1, 0); + particle(pt_flame, PARTICLE_BILLBOARD, k, k, tex_particle, false, true, 4, 4, lhrandom(64, 128), 9999, 1.1, org[0], org[1], org[2], vel[0] + lhrandom(-128, 128), vel[1] + lhrandom(-128, 128), vel[2] + lhrandom(-128, 128), 0, 0, 0, 0, 1, 0); } } @@ -954,7 +980,7 @@ void CL_MoveParticles (void) if (p->bounce < 0) { // assume it's blood (lame, but...) - R_Stain(v, 64, 32, 16, 16, p->alpha * p->scalex * (1.0f / 100.0f), 128, 48, 48, p->alpha * p->scalex * (1.0f / 100.0f)); + R_Stain(v, 64, 32, 16, 16, p->alpha * p->scalex * (1.0f / 100.0f), 192, 48, 48, p->alpha * p->scalex * (1.0f / 100.0f)); p->die = -1; freeparticles[j++] = p; continue; @@ -1235,7 +1261,7 @@ void CL_MoveParticles (void) break; */ case pt_flame: - p->alpha -= frametime * 512; + p->alpha -= frametime * 384; p->vel[2] += gravity; if (p->alpha < 16) p->die = -1; @@ -1245,6 +1271,12 @@ void CL_MoveParticles (void) p->die = -1; p->time2 = 1; break; + case pt_stardust: + p->alpha -= frametime * 128; + p->vel[2] -= gravity; + if (p->alpha < 16) + p->die = -1; + break; default: printf("unknown particle type %i\n", p->type); p->die = -1; diff --git a/client.h b/client.h index 64e9bec6..9430e3a4 100644 --- a/client.h +++ b/client.h @@ -461,6 +461,7 @@ void CL_RocketTrail2 (vec3_t start, vec3_t end, int color, entity_t *ent); void CL_SparkShower (vec3_t org, vec3_t dir, int count); void CL_PlasmaBurn (vec3_t org); void CL_BloodPuff (vec3_t org, vec3_t vel, int count); +void CL_Stardust (vec3_t mins, vec3_t maxs, int count); void CL_FlameCube (vec3_t mins, vec3_t maxs, int count); void CL_Flames (vec3_t org, vec3_t vel, int count); void CL_BloodShower (vec3_t mins, vec3_t maxs, float velspeed, int count); diff --git a/protocol.h b/protocol.h index d30dfd39..220ef14c 100644 --- a/protocol.h +++ b/protocol.h @@ -49,6 +49,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define EF_REFLECTIVE 256 // LordHavoc: shiny metal objects :) (not currently supported) #define EF_FULLBRIGHT 512 // LordHavoc: fullbright #define EF_FLAME 1024 // LordHavoc: on fire +#define EF_STARDUST 2048 // LordHavoc: showering sparks #define EF_STEP 0x80000000 // internal client use only - present on MOVETYPE_STEP entities, not QC accessible (too many bits)