From 89abd8be7d10c8b932f1810ae1d01fe3a7b3756b Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Sat, 18 Oct 2008 23:33:43 +0000 Subject: [PATCH] let blob shadows fade out when models sink through ground git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@3151 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/model.h | 2 +- source/src/rendermodel.cpp | 33 ++++++++++++++++++++++++--------- source/src/weapon.cpp | 5 ++++- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/source/src/model.h b/source/src/model.h index 84a0bfc0..5060e67c 100644 --- a/source/src/model.h +++ b/source/src/model.h @@ -1,4 +1,4 @@ -enum { ANIM_IDLE = 0, ANIM_RUN, ANIM_ATTACK, ANIM_PAIN, ANIM_JUMP, ANIM_LAND, ANIM_FLIPOFF, ANIM_SALUTE, ANIM_TAUNT, ANIM_WAVE, ANIM_POINT, ANIM_CROUCH_IDLE, ANIM_CROUCH_WALK, ANIM_CROUCH_ATTACK, ANIM_CROUCH_PAIN, ANIM_CROUCH_DEATH, ANIM_DEATH, ANIM_LYING_DEAD, ANIM_FLAG, ANIM_GUN_IDLE, ANIM_GUN_SHOOT, ANIM_GUN_RELOAD, ANIM_GUN_THROW, ANIM_MAPMODEL, ANIM_TRIGGER, ANIM_ALL, NUMANIMS }; +enum { ANIM_IDLE = 0, ANIM_RUN, ANIM_ATTACK, ANIM_PAIN, ANIM_JUMP, ANIM_LAND, ANIM_FLIPOFF, ANIM_SALUTE, ANIM_TAUNT, ANIM_WAVE, ANIM_POINT, ANIM_CROUCH_IDLE, ANIM_CROUCH_WALK, ANIM_CROUCH_ATTACK, ANIM_CROUCH_PAIN, ANIM_CROUCH_DEATH, ANIM_DEATH, ANIM_LYING_DEAD, ANIM_FLAG, ANIM_GUN_IDLE, ANIM_GUN_SHOOT, ANIM_GUN_RELOAD, ANIM_GUN_THROW, ANIM_MAPMODEL, ANIM_TRIGGER, ANIM_DECAY, ANIM_ALL, NUMANIMS }; #define ANIM_INDEX 0xFF #define ANIM_LOOP (1<<8) diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 4e4c952c..16507333 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -144,6 +144,7 @@ void cleanupmodels() } VARP(dynshadow, 0, 40, 100); +VARP(dynshadowdecay, 0, 1000, 3000); struct batchedmodel { @@ -244,6 +245,15 @@ void renderbatchedmodelshadow(model *m, batchedmodel &b) center.z += 0.1f; modelattach *a = NULL; if(b.attached>=0) a = &modelattached[b.attached]; + float intensity = dynshadow/100.0f; + if(dynshadowdecay) switch(b.anim&ANIM_INDEX) + { + case ANIM_DECAY: + case ANIM_LYING_DEAD: + intensity *= max(1.0f - float(lastmillis - b.basetime)/dynshadowdecay, 0.0f); + break; + } + glColor4f(0, 0, 0, intensity); m->rendershadow(b.anim, b.varseed, b.speed, b.basetime, dynshadowquad ? center : b.o, b.yaw, a); } @@ -297,7 +307,6 @@ void endmodelbatches(bool flush) } if(dynshadow && b.m->hasshadows() && (!reflecting || refracting) && (!stencilshadow || !hasstencil || stencilbits < 8)) { - glColor4f(0, 0, 0, dynshadow/100.0f); loopvj(b.batched) { batchedmodel &bm = b.batched[j]; @@ -399,7 +408,15 @@ void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, fl if(!dynshadowquad || center.z-0.1f<=o.z) { center.z += 0.1f; - glColor4f(0, 0, 0, dynshadow/100.0f); + float intensity = dynshadow/100.0f; + if(dynshadowdecay) switch(anim&ANIM_INDEX) + { + case ANIM_DECAY: + case ANIM_LYING_DEAD: + intensity *= max(1.0f - float(lastmillis - basetime)/dynshadowdecay, 0.0f); + break; + } + glColor4f(0, 0, 0, intensity); m->rendershadow(anim, varseed, speed, basetime, dynshadowquad ? center : o, yaw, a); } } @@ -437,7 +454,7 @@ void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, fl int findanim(const char *name) { - const char *names[] = { "idle", "run", "attack", "pain", "jump", "land", "flipoff", "salute", "taunt", "wave", "point", "crouch idle", "crouch walk", "crouch attack", "crouch pain", "crouch death", "death", "lying dead", "flag", "gun idle", "gun shoot", "gun reload", "gun throw", "mapmodel", "trigger", "all" }; + const char *names[] = { "idle", "run", "attack", "pain", "jump", "land", "flipoff", "salute", "taunt", "wave", "point", "crouch idle", "crouch walk", "crouch attack", "crouch pain", "crouch death", "death", "lying dead", "flag", "gun idle", "gun shoot", "gun reload", "gun throw", "mapmodel", "trigger", "decay", "all" }; loopi(sizeof(names)/sizeof(names[0])) if(!strcmp(name, names[i])) return i; return -1; } @@ -581,14 +598,12 @@ void renderclient(playerent *d, const char *mdlname, const char *vwepname, int t basetime = d->lastpain; int t = lastmillis-d->lastpain; if(t<0 || t>20000) return; - if(t>1000) + if(t>2000) { anim = ANIM_LYING_DEAD|ANIM_NOINTERP|ANIM_LOOP; - if(t>1600) - { - t -= 1600; - o.z -= t*t/10000000000.0f*t; - } + basetime += 2000; + t -= 2000; + o.z -= t*t/10000000000.0f*t; } } else if(d->state==CS_EDITING) { anim = ANIM_JUMP|ANIM_END; } diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 5caf107a..d7b222a6 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -404,6 +404,7 @@ void renderbounceents() string model; vec o(p->o); + int anim = ANIM_MAPMODEL, basetime = 0; switch(p->bouncetype) { case BT_NADE: @@ -417,6 +418,8 @@ void renderbounceents() int t = lastmillis-p->millis; if(t>p->timetolive-2000) { + anim = ANIM_DECAY; + basetime = p->millis+p->timetolive-2000; t -= p->timetolive-2000; o.z -= t*t/4000000000.0f*t; } @@ -424,7 +427,7 @@ void renderbounceents() } } path(model); - rendermodel(model, ANIM_MAPMODEL|ANIM_LOOP|ANIM_DYNALLOC, 0, 1.1f, o, p->yaw+90, p->pitch); + rendermodel(model, anim|ANIM_LOOP|ANIM_DYNALLOC, 0, 1.1f, o, p->yaw+90, p->pitch, 0, basetime); } }