From 614cb686bcc071e38f1a9146e57ea6acad0d29a9 Mon Sep 17 00:00:00 2001 From: Harry Young Date: Tue, 27 Dec 2011 14:50:34 +0100 Subject: [PATCH] fx_plasma This should do bit it doesn't, lol Signed-off-by: Harry Young --- cgame/cg_env.c | 23 +++++++-------- cgame/cg_event.c | 2 +- cgame/cg_local.h | 3 +- cgame/cg_main.c | 1 + cgame/fx_lib.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++- cgame/fx_local.h | 28 ++++++++++++++++++ game/g_fx.c | 4 ++- 7 files changed, 121 insertions(+), 17 deletions(-) diff --git a/cgame/cg_env.c b/cgame/cg_env.c index f3a935e..8abb726 100644 --- a/cgame/cg_env.c +++ b/cgame/cg_env.c @@ -1685,17 +1685,14 @@ Create directed and scaled plasma jet =========================== */ -/*void CG_Plasma( vec3_t start, vec3_t end, vec4_t startRGBA, vec4_t endRGBA ) +void CG_Plasma( vec3_t start, vec3_t end, vec3_t sRGB, vec3_t eRGB, int startalpha, int endalpha ) { - vec3_t v, sp, sRGB, eRGB; - float detail, len, salpha, ealpha; + vec3_t v, sp; + float detail, len, salpha = (startalpha / 255) , ealpha = (endalpha / 255); - detail = FX_DetailLevel( start, 16, 1200 ); - if ( detail == 0 ) - return; - - salpha = Vector4to3( startRGBA, sRGB ); - ealpha = Vector4to3( endRGBA, eRGB ); + //detail = FX_DetailLevel( start, 16, 1200 ); + //if ( detail == 0 ) + // return; // Orient the plasma VectorSubtract( end, start, v ); @@ -1703,7 +1700,7 @@ Create directed and scaled plasma jet VectorMA( start, 0.5f, v, sp ); // Stash a quad at the base to make the effect look a bit more solid - FX_AddQuad( sp, v, NULL, NULL, len * 0.36f, 0.0f, salpha, salpha, sRGB, sRGB, 0.0f, 45.0f, 0.0f, 200, cgs.media.prifleImpactShader ); + //FX_AddQuad( sp, v, NULL, NULL, len * 0.36f, 0.0f, salpha, salpha, sRGB, sRGB, 0.0f, 45.0f, 0.0f, 200, cgs.media.prifleImpactShader ); // Add a subtle, random flutter to the cone direction v[0] += crandom() * 0.04; @@ -1711,11 +1708,11 @@ Create directed and scaled plasma jet v[2] += crandom() * 0.04; // Wanted the effect to be scalable based on the length of the jet. - FX_AddCylinder( start, v, len * 0.05, len * 2.0f, len * 0.16f, len * 0.32f, len * 0.40f, len * 0.64f, + FX_AddCylinder2( start, v, len * 0.05, len * 2.0f, len * 0.16f, len * 0.32f, len * 0.40f, len * 0.64f, salpha, ealpha, sRGB, eRGB, 200, cgs.media.plasmaShader, 0.3f ); - FX_AddCylinder( start, v, len * 0.05, len * 4.0f, len * 0.16f, len * 0.32f, len * 0.28f, len * 0.64f, + FX_AddCylinder2( start, v, len * 0.05, len * 4.0f, len * 0.16f, len * 0.32f, len * 0.28f, len * 0.64f, salpha, ealpha, sRGB, eRGB, 200, cgs.media.plasmaShader, 0.2f ); - FX_AddCylinder( start, v, len * 0.25, len * 8.0f, len * 0.20f, len * 0.32f, len * 0.02f, len * 0.32f, + FX_AddCylinder2( start, v, len * 0.25, len * 8.0f, len * 0.20f, len * 0.32f, len * 0.02f, len * 0.32f, salpha, ealpha, sRGB, eRGB, 200, cgs.media.plasmaShader, 0.1f ); } diff --git a/cgame/cg_event.c b/cgame/cg_event.c index 5409279..a32f745 100644 --- a/cgame/cg_event.c +++ b/cgame/cg_event.c @@ -1802,7 +1802,7 @@ case EV_SHAKE_SOUND: case EV_FX_PLASMA: DEBUGNAME("EV_FX_PLASMA"); - //CG_Plasma( cent->currentState.origin, cent->currentState.origin2, cent->currentState.angles, cent->currentState.angles2 ); // RGBA's + CG_Plasma( cent->currentState.origin, cent->currentState.origin2, cent->currentState.angles, cent->currentState.angles2, cent->currentState.weapon, cent->currentState.powerups ); break; case EV_FX_STREAM: diff --git a/cgame/cg_local.h b/cgame/cg_local.h index 23f764a..e5b5281 100644 --- a/cgame/cg_local.h +++ b/cgame/cg_local.h @@ -1178,6 +1178,7 @@ typedef struct { qhandle_t redRingShader; qhandle_t redRing2Shader; qhandle_t bigShockShader; + qhandle_t plasmaShader; qhandle_t bolt2Shader; qhandle_t quantumRingShader; @@ -2064,7 +2065,7 @@ void CG_CookingSteam( vec3_t origin, float radius ); void CG_ElectricFire( vec3_t origin, vec3_t normal ); void ForgeBoltFireback( vec3_t start, vec3_t end, vec3_t velocity, vec3_t user ); void CG_ForgeBolt( centity_t *cent ); -void CG_Plasma( vec3_t start, vec3_t end, vec4_t startRGBA, vec4_t endRGBA ); +void CG_Plasma( vec3_t start, vec3_t end, vec3_t sRGB, vec3_t eRGB, int startalpha, int endalpha ); void CG_ParticleStream( centity_t *cent ); void CG_TransporterStream( centity_t *cent ); void CG_ExplosionTrail( centity_t *cent ); diff --git a/cgame/cg_main.c b/cgame/cg_main.c index f18f32d..944a5d2 100644 --- a/cgame/cg_main.c +++ b/cgame/cg_main.c @@ -1374,6 +1374,7 @@ static void CG_RegisterGraphics( void ) { cgs.media.nukeModel = trap_R_RegisterModel ( "models/weaphits/nuke.md3" ); cgs.media.bigShockShader = trap_R_RegisterShader( "gfx/misc/bigshock" ); //cgs.media.IMODMarkShader = trap_R_RegisterShader( "gfx/damage/burnmark2" ); + cgs.media.plasmaShader = trap_R_RegisterShader( "gfx/misc/plasmanew" ); cgs.media.bolt2Shader = trap_R_RegisterShader( "gfx/effects/electrica" ); //cgs.media.holoOuchShader = trap_R_RegisterShader( "powerups/holoOuch" ); cgs.media.painBlobShader = trap_R_RegisterShader( "gfx/misc/painblob" ); diff --git a/cgame/fx_lib.c b/cgame/fx_lib.c index 261eec5..d2d5a41 100644 --- a/cgame/fx_lib.c +++ b/cgame/fx_lib.c @@ -801,7 +801,6 @@ localEntity_t *FX_AddQuad2( vec3_t origin, vec3_t normal, float scale, float dsc FX_AddCylinder Adds a cylinder to the FX wrapper render list -Overloaded for RGB =============== */ @@ -870,6 +869,82 @@ localEntity_t *FX_AddCylinder( vec3_t start, return(le); } +/* +=============== +FX_AddCylinder2 + +Adds a cylinder to the FX wrapper render list +Overloaded for RGB +=============== +*/ + +//NOTENOTE: The reigning king of parameters! +#define DEFAULT_ST_SCALE 1.0f + +localEntity_t *FX_AddCylinder2( vec3_t start, + vec3_t normal, + float height, + float dheight, + float scale, + float dscale, + float scale2, + float dscale2, + float startalpha, + float endalpha, + vec3_t startRGB, + vec3_t endRGB, + float killTime, + qhandle_t shader, + float bias ) +{ + localEntity_t *le = CG_AllocLocalEntity(); + +#ifdef _DEBUG + if (!shader) + { + Com_Printf("FX_AddCylinder: NULL shader\n"); + } +#endif + + le->leType = LE_CYLINDER; + le->refEntity.data.cylinder.height = height; + le->refEntity.data.cylinder.width = scale; + le->refEntity.data.cylinder.width2 = scale2; + + le->startTime = cg.time; + le->endTime = le->startTime + killTime; + + le->data.cylinder.height = height; + le->data.cylinder.dheight = dheight; + le->data.cylinder.width = scale; + le->data.cylinder.dwidth = dscale; + le->data.cylinder.width2 = scale2; + le->data.cylinder.dwidth2 = dscale2; + + le->alpha = startalpha; + le->dalpha = endalpha - startalpha; + + le->refEntity.customShader = shader; + + le->refEntity.data.cylinder.bias = bias; + le->refEntity.data.cylinder.stscale = 1.0; + le->refEntity.data.cylinder.wrap = qtrue; + + // set origin + VectorCopy ( start, le->refEntity.origin); + VectorCopy ( start, le->refEntity.oldorigin ); + + VectorCopy( normal, le->refEntity.axis[0] ); + RotateAroundDirection( le->refEntity.axis, 0); + + le->color[0] = startRGB[0]; + le->color[1] = startRGB[1]; + le->color[2] = startRGB[2]; + le->color[3] = startalpha; + le->lifeRate = 1.0 / ( le->endTime - le->startTime ); + + return(le); +} diff --git a/cgame/fx_local.h b/cgame/fx_local.h index 26083ea..75ba83d 100644 --- a/cgame/fx_local.h +++ b/cgame/fx_local.h @@ -49,6 +49,34 @@ localEntity_t *FX_AddCylinder( vec3_t start, float killTime, qhandle_t shader, float bias ); +localEntity_t *FX_AddCylinder2( vec3_t start, + vec3_t normal, + float height, + float dheight, + float scale, + float dscale, + float scale2, + float dscale2, + float startalpha, + float endalpha, + vec3_t startRGB, + vec3_t endRGB, + float killTime, + qhandle_t shader, + float bias ); +localEntity_t *FX_AddCylinder( vec3_t start, + vec3_t normal, + float height, + float dheight, + float scale, + float dscale, + float scale2, + float dscale2, + float startalpha, + float endalpha, + float killTime, + qhandle_t shader, + float bias ); localEntity_t *FX_AddElectricity( vec3_t origin, vec3_t origin2, float stScale, float scale, float dscale, float startalpha, float endalpha, float killTime, qhandle_t shader, float deviation ); localEntity_t *FX_AddParticle( vec3_t origin, vec3_t velocity, qboolean gravity, float scale, float dscale, diff --git a/game/g_fx.c b/game/g_fx.c index 39fd5ae..dbd42a4 100644 --- a/game/g_fx.c +++ b/game/g_fx.c @@ -1541,11 +1541,13 @@ void SP_fx_plasma( gentity_t *ent ) // Convert from range of 0-255 to 0-1 int t; - for (t=0; t < 4; t++) + for (t=0; t < 3; t++) { ent->startRGBA[t] = ent->startRGBA[t] / 255; ent->finalRGBA[t] = ent->finalRGBA[t] / 255; } + ent->startRGBA[3] = ent->s.weapon; + ent->finalRGBA[3] = ent->s.powerups; VectorCopy( ent->s.origin, ent->s.pos.trBase );