From 0da3edba5840a1c71d1b295e29a2b68de3dddb9a Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 31 Jul 2009 14:00:52 +0000 Subject: [PATCH] model handling for new m32 aim; adapted gradients in astub.c git-svn-id: https://svn.eduke32.com/eduke32@1482 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/polymer.c | 220 +++++++++++++++++++++------- polymer/eduke32/source/astub.c | 22 +-- 2 files changed, 182 insertions(+), 60 deletions(-) diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index bc43fbdcf..e29b02e98 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -580,6 +580,7 @@ static struct GLfloat verts[4*3]; GLfloat plane[4]; int16_t owner; + int8_t type; // 0: planar sprite, 1: model sprite } m32_drawnsprites[MAXSPRITESONSCREEN]; // EXTERNAL FUNCTIONS @@ -1095,6 +1096,7 @@ void polymer_drawsprite(int32_t snum) Bmemcpy(&m32_drawnsprites[m32_numdrawnsprites].verts[9], &spriteplane.buffer[15], 3*sizeof(GLfloat)); Bmemcpy(&m32_drawnsprites[m32_numdrawnsprites].plane, spriteplane.plane, 4*sizeof(GLfloat)); m32_drawnsprites[m32_numdrawnsprites].owner = (tspr->owner&(MAXSPRITES-1)); + m32_drawnsprites[m32_numdrawnsprites].type = 0; m32_numdrawnsprites++; } } @@ -2227,63 +2229,159 @@ nextsector: for (i=0; i bestdist+1.01) + t = dot3f(pl,scrv); + if (t==0 || ((sprite[sn].cstat&64) && -t<0)) continue; - { - GLfloat *v = m32_drawnsprites[i].verts; - GLfloat v12_r[3], v23_r[3], v34_r[3], v41_r[3]; - GLfloat v1p[3], v2p[3], v3p[3], v4p[3]; - GLfloat tp[3]; + svcoeff = -(dot3f(pl,scr)+pl[3])/t; + if (svcoeff < 0) + continue; - tp[0] = scrx + svcoeff*scrv[0]; - tp[1] = scry + svcoeff*scrv[1]; - tp[2] = scrz + svcoeff*scrv[2]; + dist = svcoeff * sqrt(dot3f(scrv,scrv)); + if (dist > bestdist+1.01) + continue; - relvec3f(&v[3*3],&v[0*3], v12_r); - relvec3f(&v[0*3],&v[1*3], v23_r); - relvec3f(&v[1*3],&v[2*3], v34_r); - relvec3f(&v[2*3],&v[3*3], v41_r); - relvec3f(&v[0*3],tp, v1p); - relvec3f(&v[1*3],tp, v2p); - relvec3f(&v[2*3],tp, v3p); - relvec3f(&v[3*3],tp, v4p); - if (dot3f(v1p,v12_r)<=0 && dot3f(v2p,v23_r)<=0 - && dot3f(v3p,v34_r)<=0 && dot3f(v4p,v41_r)<=0) { - bestwhat = 3; - bestdist = dist; - bestwall = m32_drawnsprites[i].owner; + GLfloat *v = m32_drawnsprites[i].verts; + GLfloat v12_r[3], v23_r[3], v34_r[3], v41_r[3]; + GLfloat v1p[3], v2p[3], v3p[3], v4p[3]; + GLfloat tp[3]; + + tp[0] = scrx + svcoeff*scrv[0]; + tp[1] = scry + svcoeff*scrv[1]; + tp[2] = scrz + svcoeff*scrv[2]; + + relvec3f(&v[3*3],&v[0*3], v12_r); + relvec3f(&v[0*3],&v[1*3], v23_r); + relvec3f(&v[1*3],&v[2*3], v34_r); + relvec3f(&v[2*3],&v[3*3], v41_r); + relvec3f(&v[0*3],tp, v1p); + relvec3f(&v[1*3],tp, v2p); + relvec3f(&v[2*3],tp, v3p); + relvec3f(&v[3*3],tp, v4p); + if (dot3f(v1p,v12_r)<=0 && dot3f(v2p,v23_r)<=0 + && dot3f(v3p,v34_r)<=0 && dot3f(v4p,v41_r)<=0) + { + bestwhat = 3; + bestdist = dist; + bestwall = m32_drawnsprites[i].owner; #ifdef M32_SHOWDEBUG - if (m32_numdebuglines<64) - { - Bsprintf(m32_debugstr[m32_numdebuglines++], "what=spr %d, dist=%.02f", - bestwall, bestdist); - } - if (qvertcount 0) + pl[3] = -dot3f(pl, &verts[3*j]); + else + pl[3] = -dot3f(pl, &verts[0]); + + svcoeff = -(dot3f(pl,scr)+pl[3])/t; + if (svcoeff < 0) + continue; + + dist = svcoeff * sqrt(dot3f(scrv,scrv)); + if (dist > bestdist) + continue; + + { + GLfloat vrel[3*2]; + GLfloat v[3*4]; + GLfloat v1p[3], v2p[3], v3p[3], v4p[3]; + GLfloat tp[3]; + int k, l=0; + + for (k=1; k<=3; k++) + { + if (k==j) + continue; + relvec3f(&verts[0], &verts[3*k], &vrel[3*l]); + l++; + } + + if (-t > 0) + Bmemcpy(&v[0], &verts[3*j], 3*sizeof(GLfloat)); + else + Bmemcpy(&v[0], &verts[0], 3*sizeof(GLfloat)); + + addvec3f(&v[3*0], &vrel[3*0], &v[3*1]); + addvec3f(&v[3*1], &vrel[3*1], &v[3*2]); + relvec3f(&vrel[0], &v[3*2], &v[3*3]); + + tp[0] = scrx + svcoeff*scrv[0]; + tp[1] = scry + svcoeff*scrv[1]; + tp[2] = scrz + svcoeff*scrv[2]; + + relvec3f(&v[0*3],tp, v1p); + relvec3f(&v[1*3],tp, v2p); + relvec3f(&v[2*3],tp, v3p); + relvec3f(&v[3*3],tp, v4p); + + if (dot3f(&vrel[3*1], v1p)>0 && dot3f(&vrel[3*1], v3p)<0 + && dot3f(&vrel[0], v2p)<0 && dot3f(&vrel[0], v4p)>0) + { + bestwhat = 3; + bestdist = dist; + bestwall = m32_drawnsprites[i].owner; +#ifdef M32_SHOWDEBUG + if (m32_numdebuglines<64) + { + Bsprintf(m32_debugstr[m32_numdebuglines++], "what=spr %d (model), dist=%.02f", + bestwall, bestdist); + } + if (qvertcounthead.frames[m->cframe].min; + point3d *ma = &m->head.frames[m->cframe].max; + float fverts[3*4] = {mi->x,mi->y,mi->z, ma->x,mi->y,mi->z, + mi->x,ma->y,mi->z, mi->x,mi->y,ma->z}; + float tfverts[3*4]; + GLfloat gtfverts[3*4]; + int i; + + for (i=0; i<4; i++) + polymer_transformpoint(&fverts[i*3], &tfverts[i*3], spritemodelview); + for (i=0; i<12; i++) + gtfverts[i] = tfverts[i]; + + Bmemcpy(m32_drawnsprites[m32_numdrawnsprites].verts, gtfverts, 12*sizeof(GLfloat)); + m32_drawnsprites[m32_numdrawnsprites].type = 1; + m32_drawnsprites[m32_numdrawnsprites].owner = (tspr->owner&(MAXSPRITES-1)); + m32_numdrawnsprites++; + } + } + polymer_getscratchmaterial(&mdspritematerial); color = mdspritematerial.diffusemodulation; diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index c37c8b6a3..b84078514 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -1035,7 +1035,7 @@ void ExtShowSectorData(int16_t sectnum) //F5 clearmidstatbar16(); //Clear middle of status bar ydim -= 8; - color = whitecol-16; + color = whitecol-21; begindrawing(); for (i=ydim-STATUS2DSIZ+16; i