From f676eb873f3e161fdd8aed7ffed95bb7aa1cf2b0 Mon Sep 17 00:00:00 2001 From: driAn Date: Fri, 21 Oct 2005 23:15:01 +0000 Subject: [PATCH] shotlines git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@52 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/renderextras.cpp | 37 +++++++++++++++++++++++++++++-------- source/src/rendergl.cpp | 10 ++++------ source/src/rendermd2.cpp | 2 +- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/source/src/renderextras.cpp b/source/src/renderextras.cpp index 1f9e82e1..fde6514d 100644 --- a/source/src/renderextras.cpp +++ b/source/src/renderextras.cpp @@ -403,36 +403,57 @@ void shotlinereset() { loopi(MAXSHOTLINES) shotlines[i].inuse = false; }; void addshotline(vec &from, vec &to) { + if(rnd(3) != 0) return; loopi(MAXSHOTLINES) { shotline *s = &shotlines[i]; if(s->inuse) continue; + vdist(dist, unitv, from, to); + vdiv(unitv, dist); s->inuse = true; - s->from = from; - s->to = to; + s->from = unitv; + vmul(s->from, dist/6*4); + vadd(s->from, from); + s->to = unitv; + vmul(s->to, dist/6*-1); + vadd(s->to, to); s->millis = lastmillis; return; }; }; +VAR(shotline_duration, 0, 50, 10000); + void rendershotlines() { - return; loopi(MAXSHOTLINES) { shotline *s = &shotlines[i]; if(!s->inuse) continue; - //if(lastmillis-s->millis > 1000) { s->inuse = false; continue; } + if(lastmillis-s->millis > shotline_duration) { s->inuse = false; continue; } glPushMatrix(); + glDisable(GL_TEXTURE_2D); + + glDepthMask(GL_FALSE); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA); + glDisable(GL_FOG); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glDisable(GL_BLEND); glBegin(GL_LINES); - glVertex3f(s->to.x, s->to.y, s->to.z); - glVertex3f(s->from.x, s->from.y, s->from.z); + glColor4f(1.0f, 1.0f, 0.7f, 0.5f); + glVertex3f(s->from.x, s->from.z, s->from.y); + glVertex3f(s->to.x, s->to.z, s->to.y); glEnd(); - glEnable(GL_BLEND); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + + glEnable(GL_FOG); + glDisable(GL_BLEND); + glDepthMask(GL_TRUE); + + glEnable(GL_TEXTURE_2D); glPopMatrix(); + }; }; diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index f6fd82aa..71fee7dd 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -340,8 +340,7 @@ void gl_drawframe(int w, int h, float changelod, float curfps) renderstripssky(); - glLoadIdentity(); - + glLoadIdentity(); glRotated(player1->pitch, -1.0, 0.0, 0.0); glRotated(player1->yaw, 0.0, 1.0, 0.0); glRotated(90.0, 1.0, 0.0, 0.0); @@ -365,9 +364,7 @@ void gl_drawframe(int w, int h, float changelod, float curfps) renderentities(); renderspheres(curtime); - renderents(); - - rendershotlines(); + renderents(); glDisable(GL_CULL_FACE); @@ -377,7 +374,8 @@ void gl_drawframe(int w, int h, float changelod, float curfps) int nquads = renderwater(hf); overbright(2); - render_particles(curtime); + render_particles(curtime); + rendershotlines(); overbright(1); glDisable(GL_FOG); diff --git a/source/src/rendermd2.cpp b/source/src/rendermd2.cpp index a868847e..80a70d03 100644 --- a/source/src/rendermd2.cpp +++ b/source/src/rendermd2.cpp @@ -186,7 +186,7 @@ void md2::render(vec &light, int frame, int range, float x, float y, float z, fl glEndList(); displaylistverts = xtraverts-displaylistverts; }; - }; + }; glPopMatrix(); }