From b7b016383f86fc6a286031a84f3c936ebf1ce645 Mon Sep 17 00:00:00 2001 From: terminx Date: Fri, 24 Apr 2009 02:53:50 +0000 Subject: [PATCH] Sector effector based light sources, basic Mapster32 light support, additional sprite/model alpha control, sprite selection in Mapster32 3D mode with Polymer git-svn-id: https://svn.eduke32.com/eduke32@1341 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 3 +- polymer/eduke32/build/include/polymost.h | 4 + polymer/eduke32/build/src/build.c | 1 + polymer/eduke32/build/src/engine.c | 9 +- polymer/eduke32/build/src/polymer.c | 108 +++++++++++++++++++++++ polymer/eduke32/source/astub.c | 97 +++++++++++++++++--- polymer/eduke32/source/game.c | 15 ++-- polymer/eduke32/source/gamedef.c | 2 + polymer/eduke32/source/gamedef.h | 1 + polymer/eduke32/source/gamestructures.c | 10 +++ polymer/eduke32/source/osdcmds.c | 6 +- polymer/eduke32/source/premap.c | 58 ++++++++++++ 12 files changed, 285 insertions(+), 29 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 64bd7c300..8e864e98f 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -164,7 +164,8 @@ typedef struct BPACK { int32_t xoff, yoff, zoff; uint8_t flags; uint8_t xpanning, ypanning; - uint8_t filler[1]; + uint8_t filler; + float alpha; spritetype *tspr; } spriteext_t; diff --git a/polymer/eduke32/build/include/polymost.h b/polymer/eduke32/build/include/polymost.h index eedca8973..fac7eb92d 100644 --- a/polymer/eduke32/build/include/polymost.h +++ b/polymer/eduke32/build/include/polymost.h @@ -119,6 +119,10 @@ extern float shadescale; extern int32_t globalnoeffect; extern int32_t drawingskybox; +extern double gyxscale, gxyaspect, gviewxrange, ghalfx, grhalfxdown10, grhalfxdown10x, ghoriz; +extern double gcosang, gsinang, gcosang2, gsinang2; +extern double gchang, gshang, gctang, gstang, gvisibility; + extern float fogresult, fogcol[4], fogtable[4*MAXPALOOKUPS]; static inline void fogcalc(const int32_t shade, const int32_t vis, const int32_t pal) diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 1668f1420..20d3be6e2 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -765,6 +765,7 @@ void editinput(void) { memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES); memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES+MAXUNIQHUDID)); + staticlightcount = 0; mhk=0; initprintf("Maphacks disabled\n"); keystatus[0x44] = 0; diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 47ce04554..de432eba2 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -6731,6 +6731,11 @@ int32_t loadboard(char *filename, char fromwhere, int32_t *daposx, int32_t *dapo clearbufbyte(&sprite, sizeof(sprite), 0); */ +#ifdef POLYMER + staticlightcount = 0; +#endif // POLYMER + + initspritelists(); #define MYMAXSECTORS (mapversion==7l?MAXSECTORSV7:MAXSECTORSV8) @@ -7374,10 +7379,6 @@ int32_t loadmaphack(char *filename) memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES); memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES+MAXUNIQHUDID)); -#ifdef POLYMER - staticlightcount = 0; -#endif // POLYMER - while (1) { tok = scriptfile_gettoken(script); diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index ec5d7b11d..6548375ce 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -669,6 +669,108 @@ void polymer_loadboard(void) if (pr_verbosity >= 1) OSD_Printf("PR : Board loaded.\n"); } +void polymer_editorselect(void) +{ + + int32_t i, n; + double ox, oy, oz, ox2, oy2, oz2, px[6], py[6], pz[6]; + + //Polymost supports true look up/down :) Here, we convert horizon to angle. + //gchang&gshang are cos&sin of this angle (respectively) + ghalfx = (double)halfxdimen; grhalfxdown10 = 1.0/(((double)ghalfx)*1024); + ghoriz = (double)globalhoriz; + + gvisibility = ((float)globalvisibility)*FOGSCALE; + + ghoriz = (double)(ydimen>>1); + + //global cos/sin tilt angle + gctang = cos(gtang); + gstang = sin(gtang); + if (fabs(gstang) < .001) //This hack avoids nasty precision bugs in domost() + { gstang = 0; if (gctang > 0) gctang = 1.0; else gctang = -1.0; } + + //Generate viewport trapezoid (for handling screen up/down) + px[0] = px[3] = 0-1; px[1] = px[2] = windowx2+1-windowx1+2; + py[0] = py[1] = 0-1; py[2] = py[3] = windowy2+1-windowy1+2; n = 4; + for (i=0; i>12,vy>>12,vz>>8,&hitinfo,0xffff0030); + getzsofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz); + hitallsprites = 0; + + searchsector = hitinfo.hitsect; + if (hitinfo.pos.zfz) searchstat = 2; else if (hitinfo.hitwall >= 0) + { + searchwall = hitinfo.hitwall; searchstat = 0; + if (wall[hitinfo.hitwall].nextwall >= 0) + { + int32_t cz, fz; + getzsofslope(wall[hitinfo.hitwall].nextsector,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz); + if (hitinfo.pos.z > fz) + { + if (wall[hitinfo.hitwall].cstat&2) //'2' bottoms of walls + searchwall = wall[hitinfo.hitwall].nextwall; + } + else if ((hitinfo.pos.z > cz) && (wall[hitinfo.hitwall].cstat&(16+32))) //masking or 1-way + searchstat = 4; + } + } + else if (hitinfo.hitsprite >= 0) { searchwall = hitinfo.hitsprite; searchstat = 3; } + else + { + int32_t cz, fz; + getzsofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz); + if ((hitinfo.pos.z<<1) < cz+fz) searchstat = 1; else searchstat = 2; + //if (vz < 0) searchstat = 1; else searchstat = 2; //Won't work for slopes :/ + } + searchit = 0; + } +} + void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, int16_t daang, int32_t dahoriz, int16_t dacursectnum) { int16_t cursectnum; @@ -692,6 +794,8 @@ void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t da horizang = (float)(-getangle(128, dahoriz-100)) / (2048.0f / 360.0f); tiltang = (gtang * 90.0f); + if (searchit == 2) polymer_editorselect(); + pos[0] = daposy; pos[1] = -(float)(daposz) / 16.0f; pos[2] = -daposx; @@ -894,6 +998,8 @@ void polymer_drawsprite(int32_t snum) spriteplane.material.diffusemodulation[3] = 0.66f; } + spriteplane.material.diffusemodulation[3] *= (1.0f - spriteext[tspr->owner].alpha); + if (((tspr->cstat>>4) & 3) == 0) xratio = (float)(tspr->xrepeat) * 0.20f; // 32 / 160 else @@ -2923,6 +3029,8 @@ static void polymer_drawmdsprite(spritetype *tspr) } else color[3] = 1.0; + color[3] *= (1.0f - spriteext[tspr->owner].alpha); + if (pr_gpusmoothing) mdspritematerial.frameprogress = m->interpol; diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index c8ebe64ed..63c3f01cb 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -41,6 +41,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sounds_mapster32.h" #include "fx_man.h" +#include "macros.h" + #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include @@ -616,6 +618,12 @@ const char *SectorEffectorTagText(int32_t lotag) case 36: Bsprintf(tempbuf,"%d: SKRINK RAY SHOOTER",lotag); break; + case 49: + Bsprintf(tempbuf,"%d: POINT LIGHT",lotag); + break; + case 50: + Bsprintf(tempbuf,"%d: SPOTLIGHT",lotag); + break; default: Bsprintf(tempbuf,"%d: (UNKNOWN)",lotag); break; @@ -1967,6 +1975,7 @@ extern int32_t NumVoices; extern int32_t g_numEnvSoundsPlaying; int32_t AmbienceToggle = 1; //SoundToggle; int32_t ParentalLock = 0; +#undef T1 #define T1 (s->filler) // adapted from actors.c @@ -4514,8 +4523,9 @@ static void Keys3d(void) sector[searchsector].extra = getnumber256(buffer,(int32_t)sector[searchsector].extra,65536L,1); break; case 3: - strcpy(buffer,"Sprite extra: "); - sprite[searchwall].extra = getnumber256(buffer,(int32_t)sprite[searchwall].extra,65536L,1); +// strcpy(buffer,"Sprite extra: "); +// sprite[searchwall].extra = getnumber256(buffer,(int32_t)sprite[searchwall].extra,65536L,1); + getnumberptr256("Sprite extra: ",&sprite[searchwall].extra,sizeof(sprite[searchwall].extra),1024,1,NULL); break; } asksave = 1; @@ -4639,7 +4649,8 @@ static void Keys3d(void) break; case 3: strcpy(buffer,"Sprite hitag: "); - sprite[searchwall].hitag = getnumber256(buffer,(int32_t)sprite[searchwall].hitag,65536L,0); + // sprite[searchwall].hitag = getnumber256(buffer,(int32_t)sprite[searchwall].hitag,65536L,0); + getnumberptr256(buffer,&sprite[searchwall].hitag,sizeof(sprite[searchwall].hitag),INT16_MAX,1,NULL); break; } } @@ -9520,6 +9531,7 @@ void ExtPreCheckKeys(void) // just before drawrooms if (qsetmode == 200) //In 3D mode { + if (shadepreview) { int32_t i = 0; @@ -9541,16 +9553,16 @@ void ExtPreCheckKeys(void) // just before drawrooms wallflag[w] = 1; } /* if (wall[w].nextwall >= 0) - { - if (!wallflag[wall[w].nextwall]) - { - wallshades[wall[w].nextwall] = wall[wall[w].nextwall].shade; - wall[wall[w].nextwall].shade = sprite[i].shade; - wallpals[wall[w].nextwall] = wall[wall[w].nextwall].pal; - wall[wall[w].nextwall].pal = sprite[i].pal; - wallflag[wall[w].nextwall] = 1; - } - } */ + { + if (!wallflag[wall[w].nextwall]) + { + wallshades[wall[w].nextwall] = wall[wall[w].nextwall].shade; + wall[wall[w].nextwall].shade = sprite[i].shade; + wallpals[wall[w].nextwall] = wall[wall[w].nextwall].pal; + wall[wall[w].nextwall].pal = sprite[i].pal; + wallflag[wall[w].nextwall] = 1; + } + } */ } sectorshades[sprite[i].sectnum][0] = sector[sprite[i].sectnum].floorshade; sectorshades[sprite[i].sectnum][1] = sector[sprite[i].sectnum].ceilingshade; @@ -9571,7 +9583,7 @@ void ExtPreCheckKeys(void) // just before drawrooms w = nextspritesect[w]; } } - } + } if (floor_over_floor) SE40Code(pos.x,pos.y,pos.z,ang,horiz); if (purpleon) clearview(255); if (sidemode != 0) @@ -9730,6 +9742,63 @@ void ExtAnalyzeSprites(void) spritetype *tspr; int32_t frames=0, l; + gamelightcount = 0; + + for (i=numsprites-1; i>=0; i--) + { + if (sprite[i].picnum == SECTOREFFECTOR && sprite[i].lotag == 49) + { + gamelights[gamelightcount].sector = SECT; + gamelights[gamelightcount].x = SX; + gamelights[gamelightcount].y = SY; + gamelights[gamelightcount].z = SZ; + gamelights[gamelightcount].range = SHT; + if ((sprite[i].xvel | sprite[i].yvel | sprite[i].zvel) != 0) + { + gamelights[gamelightcount].color[0] = sprite[i].xvel; + gamelights[gamelightcount].color[1] = sprite[i].yvel; + gamelights[gamelightcount].color[2] = sprite[i].zvel; + } + else + { + gamelights[gamelightcount].color[0] = hictinting[PL].r; + gamelights[gamelightcount].color[1] = hictinting[PL].g; + gamelights[gamelightcount].color[2] = hictinting[PL].b; + } + gamelights[gamelightcount].radius = 0; + gamelights[gamelightcount].angle = SA; + gamelights[gamelightcount].horiz = SH; + gamelights[gamelightcount].priority = SS; + gamelightcount++; + } + if (sprite[i].picnum == SECTOREFFECTOR && sprite[i].lotag == 50) + { + gamelights[gamelightcount].sector = SECT; + gamelights[gamelightcount].x = SX; + gamelights[gamelightcount].y = SY; + gamelights[gamelightcount].z = SZ; + gamelights[gamelightcount].range = SHT; + if ((sprite[i].xvel | sprite[i].yvel | sprite[i].zvel) != 0) + { + gamelights[gamelightcount].color[0] = sprite[i].xvel; + gamelights[gamelightcount].color[1] = sprite[i].yvel; + gamelights[gamelightcount].color[2] = sprite[i].zvel; + } + else + { + gamelights[gamelightcount].color[0] = hictinting[PL].r; + gamelights[gamelightcount].color[1] = hictinting[PL].g; + gamelights[gamelightcount].color[2] = hictinting[PL].b; + } + gamelights[gamelightcount].radius = 256; + gamelights[gamelightcount].faderadius = 200; + gamelights[gamelightcount].angle = SA; + gamelights[gamelightcount].horiz = SH; + gamelights[gamelightcount].priority = SS; + gamelightcount++; + } + } + for (i=0,tspr=&tsprite[0]; inewowner].sectnum; smoothratio = 65536L; } - else if (p->over_shoulder_on == 0) + else if (ud.viewbob) // if (p->over_shoulder_on == 0) { - if (ud.viewbob) - ud.cameraz += p->opyoff+mulscale16((int32_t)(p->pyoff-p->opyoff),smoothratio); + if (p->over_shoulder_on) + ud.cameraz += (p->opyoff+mulscale16((int32_t)(p->pyoff-p->opyoff),smoothratio))>>3; + else ud.cameraz += p->opyoff+mulscale16((int32_t)(p->pyoff-p->opyoff),smoothratio); } - else + if (p->over_shoulder_on) { ud.cameraz -= 3072; G_DoThirdPerson(p,(vec3_t *)&ud,&ud.camerasect,ud.cameraang,ud.camerahoriz); @@ -7031,9 +7032,7 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio) t->sectnum = mycursectnum; } else t->ang = g_player[p].ps->ang+mulscale16((int32_t)(((g_player[p].ps->ang+1024- g_player[p].ps->oang)&2047)-1024),smoothratio); - if (bpp == 8) - t->cstat |= 2; - else if (usemodels && md_tilehasmodel(t->picnum, t->pal) >= 0) + if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum, t->pal) >= 0) { static int32_t targetang = 0; @@ -7055,7 +7054,7 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio) targetang = clamp(targetang, -128, 128); t->ang += targetang; } - + else t->cstat |= 2; } if (ud.multimode > 1 && (display_mirror || screenpeek != p || s->owner == -1)) diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 2b512a0b7..978b5c767 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -604,6 +604,8 @@ const memberlabel_t ActorLabels[]= { "htflags", ACTOR_HTFLAGS, 0, 0 }, + { "alpha", ACTOR_ALPHA, 0, 0 }, + { "", -1, 0, 0 } // END OF LIST }; diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index 4e42ea4fc..0dd49e29c 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -506,6 +506,7 @@ enum ActorLabel_t ACTOR_XPANNING, ACTOR_YPANNING, ACTOR_HTFLAGS, + ACTOR_ALPHA, ACTOR_END }; diff --git a/polymer/eduke32/source/gamestructures.c b/polymer/eduke32/source/gamestructures.c index 4428065eb..eea6101c4 100644 --- a/polymer/eduke32/source/gamestructures.c +++ b/polymer/eduke32/source/gamestructures.c @@ -3530,6 +3530,15 @@ static inline void X_AccessSprite(int32_t iSet, int32_t lVar1, int32_t lLabelID, Gv_SetVar(lVar2,ActorExtra[iActor].flags, vm.g_i, vm.g_p); return; + case ACTOR_ALPHA: + if (iSet) + { + spriteext[iActor].alpha=(float) (lValue/255.0f); + return; + } + Gv_SetVar(lVar2, (uint8_t)(spriteext[iActor].alpha * 255.0f), vm.g_i, vm.g_p); + return; + default: return; } @@ -4110,6 +4119,7 @@ static int32_t X_AccessSpriteX(int32_t iActor, int32_t lLabelID, int32_t lParm2) case ACTOR_XPANNING: return spriteext[iActor].xpanning; case ACTOR_YPANNING: return spriteext[iActor].ypanning; case ACTOR_HTFLAGS: return ActorExtra[iActor].flags; + case ACTOR_ALPHA: return (uint8_t)(ActorExtra[iActor].alpha*255.0f); default: return -1; } } diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 3d7e4e457..dff35a1a6 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -1171,8 +1171,10 @@ static int32_t osdcmd_bind(const osdfuncparm_t *parm) if (parm->numparms==1&&!Bstrcasecmp(parm->parms[0],"showkeys")) { - for (i=0; ConsoleKeys[i].name; i++)OSD_Printf("%s\n",ConsoleKeys[i].name); - for (i=0; i