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
This commit is contained in:
terminx 2009-04-24 02:53:50 +00:00
parent 9462a17ae7
commit b7b016383f
12 changed files with 285 additions and 29 deletions

View file

@ -164,7 +164,8 @@ typedef struct BPACK {
int32_t xoff, yoff, zoff; int32_t xoff, yoff, zoff;
uint8_t flags; uint8_t flags;
uint8_t xpanning, ypanning; uint8_t xpanning, ypanning;
uint8_t filler[1]; uint8_t filler;
float alpha;
spritetype *tspr; spritetype *tspr;
} spriteext_t; } spriteext_t;

View file

@ -119,6 +119,10 @@ extern float shadescale;
extern int32_t globalnoeffect; extern int32_t globalnoeffect;
extern int32_t drawingskybox; 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]; extern float fogresult, fogcol[4], fogtable[4*MAXPALOOKUPS];
static inline void fogcalc(const int32_t shade, const int32_t vis, const int32_t pal) static inline void fogcalc(const int32_t shade, const int32_t vis, const int32_t pal)

View file

@ -765,6 +765,7 @@ void editinput(void)
{ {
memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES); memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES+MAXUNIQHUDID)); memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES+MAXUNIQHUDID));
staticlightcount = 0;
mhk=0; mhk=0;
initprintf("Maphacks disabled\n"); initprintf("Maphacks disabled\n");
keystatus[0x44] = 0; keystatus[0x44] = 0;

View file

@ -6731,6 +6731,11 @@ int32_t loadboard(char *filename, char fromwhere, int32_t *daposx, int32_t *dapo
clearbufbyte(&sprite, sizeof(sprite), 0); clearbufbyte(&sprite, sizeof(sprite), 0);
*/ */
#ifdef POLYMER
staticlightcount = 0;
#endif // POLYMER
initspritelists(); initspritelists();
#define MYMAXSECTORS (mapversion==7l?MAXSECTORSV7:MAXSECTORSV8) #define MYMAXSECTORS (mapversion==7l?MAXSECTORSV7:MAXSECTORSV8)
@ -7374,10 +7379,6 @@ int32_t loadmaphack(char *filename)
memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES); memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES+MAXUNIQHUDID)); memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES+MAXUNIQHUDID));
#ifdef POLYMER
staticlightcount = 0;
#endif // POLYMER
while (1) while (1)
{ {
tok = scriptfile_gettoken(script); tok = scriptfile_gettoken(script);

View file

@ -669,6 +669,108 @@ void polymer_loadboard(void)
if (pr_verbosity >= 1) OSD_Printf("PR : Board loaded.\n"); 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<n; i++)
{
ox = px[i]-ghalfx; oy = py[i]-ghoriz; oz = ghalfx;
//Tilt rotation (backwards)
ox2 = ox*gctang + oy*gstang;
oy2 = oy*gctang - ox*gstang;
oz2 = oz;
//Up/down rotation (backwards)
px[i] = ox2;
py[i] = oy2*gchang + oz2*gshang;
pz[i] = oz2*gchang - oy2*gshang;
}
if (searchit == 2)
{
int32_t vx, vy, vz;
int32_t cz, fz;
hitdata_t hitinfo;
vec3_t vect;
ox2 = searchx-ghalfx; oy2 = searchy-ghoriz; oz2 = ghalfx;
//Tilt rotation
ox = ox2*gctang + oy2*gstang;
oy = oy2*gctang - ox2*gstang;
oz = oz2;
//Up/down rotation
ox2 = oz*gchang - oy*gshang;
oy2 = ox;
oz2 = oy*gchang + oz*gshang;
//Standard Left/right rotation
vx = (int32_t)(ox2*((float)cosglobalang) - oy2*((float)singlobalang));
vy = (int32_t)(ox2*((float)singlobalang) + oy2*((float)cosglobalang));
vz = (int32_t)(oz2*16384.0);
vect.x = globalposx;
vect.y = globalposy;
vect.z = globalposz;
hitallsprites = 1;
hitscan((const vec3_t *)&vect,globalcursectnum, //Start position
vx>>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.z<cz) searchstat = 1; else if (hitinfo.pos.z>fz) 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) void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, int16_t daang, int32_t dahoriz, int16_t dacursectnum)
{ {
int16_t cursectnum; 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); horizang = (float)(-getangle(128, dahoriz-100)) / (2048.0f / 360.0f);
tiltang = (gtang * 90.0f); tiltang = (gtang * 90.0f);
if (searchit == 2) polymer_editorselect();
pos[0] = daposy; pos[0] = daposy;
pos[1] = -(float)(daposz) / 16.0f; pos[1] = -(float)(daposz) / 16.0f;
pos[2] = -daposx; pos[2] = -daposx;
@ -894,6 +998,8 @@ void polymer_drawsprite(int32_t snum)
spriteplane.material.diffusemodulation[3] = 0.66f; spriteplane.material.diffusemodulation[3] = 0.66f;
} }
spriteplane.material.diffusemodulation[3] *= (1.0f - spriteext[tspr->owner].alpha);
if (((tspr->cstat>>4) & 3) == 0) if (((tspr->cstat>>4) & 3) == 0)
xratio = (float)(tspr->xrepeat) * 0.20f; // 32 / 160 xratio = (float)(tspr->xrepeat) * 0.20f; // 32 / 160
else else
@ -2923,6 +3029,8 @@ static void polymer_drawmdsprite(spritetype *tspr)
} else } else
color[3] = 1.0; color[3] = 1.0;
color[3] *= (1.0f - spriteext[tspr->owner].alpha);
if (pr_gpusmoothing) if (pr_gpusmoothing)
mdspritematerial.frameprogress = m->interpol; mdspritematerial.frameprogress = m->interpol;

View file

@ -41,6 +41,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "sounds_mapster32.h" #include "sounds_mapster32.h"
#include "fx_man.h" #include "fx_man.h"
#include "macros.h"
#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
@ -616,6 +618,12 @@ const char *SectorEffectorTagText(int32_t lotag)
case 36: case 36:
Bsprintf(tempbuf,"%d: SKRINK RAY SHOOTER",lotag); Bsprintf(tempbuf,"%d: SKRINK RAY SHOOTER",lotag);
break; break;
case 49:
Bsprintf(tempbuf,"%d: POINT LIGHT",lotag);
break;
case 50:
Bsprintf(tempbuf,"%d: SPOTLIGHT",lotag);
break;
default: default:
Bsprintf(tempbuf,"%d: (UNKNOWN)",lotag); Bsprintf(tempbuf,"%d: (UNKNOWN)",lotag);
break; break;
@ -1967,6 +1975,7 @@ extern int32_t NumVoices;
extern int32_t g_numEnvSoundsPlaying; extern int32_t g_numEnvSoundsPlaying;
int32_t AmbienceToggle = 1; //SoundToggle; int32_t AmbienceToggle = 1; //SoundToggle;
int32_t ParentalLock = 0; int32_t ParentalLock = 0;
#undef T1
#define T1 (s->filler) #define T1 (s->filler)
// adapted from actors.c // adapted from actors.c
@ -4514,8 +4523,9 @@ static void Keys3d(void)
sector[searchsector].extra = getnumber256(buffer,(int32_t)sector[searchsector].extra,65536L,1); sector[searchsector].extra = getnumber256(buffer,(int32_t)sector[searchsector].extra,65536L,1);
break; break;
case 3: case 3:
strcpy(buffer,"Sprite extra: "); // strcpy(buffer,"Sprite extra: ");
sprite[searchwall].extra = getnumber256(buffer,(int32_t)sprite[searchwall].extra,65536L,1); // 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; break;
} }
asksave = 1; asksave = 1;
@ -4639,7 +4649,8 @@ static void Keys3d(void)
break; break;
case 3: case 3:
strcpy(buffer,"Sprite hitag: "); 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; break;
} }
} }
@ -9520,6 +9531,7 @@ void ExtPreCheckKeys(void) // just before drawrooms
if (qsetmode == 200) //In 3D mode if (qsetmode == 200) //In 3D mode
{ {
if (shadepreview) if (shadepreview)
{ {
int32_t i = 0; int32_t i = 0;
@ -9730,6 +9742,63 @@ void ExtAnalyzeSprites(void)
spritetype *tspr; spritetype *tspr;
int32_t frames=0, l; 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]; i<spritesortcnt; i++,tspr++) for (i=0,tspr=&tsprite[0]; i<spritesortcnt; i++,tspr++)
{ {
frames=0; frames=0;

View file

@ -4452,12 +4452,13 @@ void G_DrawRooms(int32_t snum,int32_t smoothratio)
ud.camerasect = sprite[p->newowner].sectnum; ud.camerasect = sprite[p->newowner].sectnum;
smoothratio = 65536L; smoothratio = 65536L;
} }
else if (p->over_shoulder_on == 0) else if (ud.viewbob) // if (p->over_shoulder_on == 0)
{ {
if (ud.viewbob) if (p->over_shoulder_on)
ud.cameraz += p->opyoff+mulscale16((int32_t)(p->pyoff-p->opyoff),smoothratio); 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; ud.cameraz -= 3072;
G_DoThirdPerson(p,(vec3_t *)&ud,&ud.camerasect,ud.cameraang,ud.camerahoriz); 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; 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); 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) if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum, t->pal) >= 0)
t->cstat |= 2;
else if (usemodels && md_tilehasmodel(t->picnum, t->pal) >= 0)
{ {
static int32_t targetang = 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); targetang = clamp(targetang, -128, 128);
t->ang += targetang; t->ang += targetang;
} }
else t->cstat |= 2;
} }
if (ud.multimode > 1 && (display_mirror || screenpeek != p || s->owner == -1)) if (ud.multimode > 1 && (display_mirror || screenpeek != p || s->owner == -1))

View file

@ -604,6 +604,8 @@ const memberlabel_t ActorLabels[]=
{ "htflags", ACTOR_HTFLAGS, 0, 0 }, { "htflags", ACTOR_HTFLAGS, 0, 0 },
{ "alpha", ACTOR_ALPHA, 0, 0 },
{ "", -1, 0, 0 } // END OF LIST { "", -1, 0, 0 } // END OF LIST
}; };

View file

@ -506,6 +506,7 @@ enum ActorLabel_t
ACTOR_XPANNING, ACTOR_XPANNING,
ACTOR_YPANNING, ACTOR_YPANNING,
ACTOR_HTFLAGS, ACTOR_HTFLAGS,
ACTOR_ALPHA,
ACTOR_END ACTOR_END
}; };

View file

@ -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); Gv_SetVar(lVar2,ActorExtra[iActor].flags, vm.g_i, vm.g_p);
return; 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: default:
return; 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_XPANNING: return spriteext[iActor].xpanning;
case ACTOR_YPANNING: return spriteext[iActor].ypanning; case ACTOR_YPANNING: return spriteext[iActor].ypanning;
case ACTOR_HTFLAGS: return ActorExtra[iActor].flags; case ACTOR_HTFLAGS: return ActorExtra[iActor].flags;
case ACTOR_ALPHA: return (uint8_t)(ActorExtra[iActor].alpha*255.0f);
default: return -1; default: return -1;
} }
} }

View file

@ -1171,8 +1171,10 @@ static int32_t osdcmd_bind(const osdfuncparm_t *parm)
if (parm->numparms==1&&!Bstrcasecmp(parm->parms[0],"showkeys")) 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; ConsoleKeys[i].name; i++)
for (i=0; i<MAXMOUSEBUTTONS; i++)OSD_Printf("%s\n",ConsoleButtons[i]); OSD_Printf("%s\n",ConsoleKeys[i].name);
for (i=0; i<MAXMOUSEBUTTONS; i++)
OSD_Printf("%s\n",ConsoleButtons[i]);
return OSDCMD_OK; return OSDCMD_OK;
} }

View file

@ -987,6 +987,64 @@ static inline void prelevel(char g)
{ {
if (PN == SECTOREFFECTOR && SLT == 14) if (PN == SECTOREFFECTOR && SLT == 14)
continue; continue;
#if 1 // POLYMER
if (PN == SECTOREFFECTOR && SLT == 49)
{
staticlights[staticlightcount].sector = SECT;
staticlights[staticlightcount].x = SX;
staticlights[staticlightcount].y = SY;
staticlights[staticlightcount].z = SZ;
staticlights[staticlightcount].range = SHT;
if ((sprite[i].xvel | sprite[i].yvel | sprite[i].zvel) != 0)
{
staticlights[staticlightcount].color[0] = sprite[i].xvel;
staticlights[staticlightcount].color[1] = sprite[i].yvel;
staticlights[staticlightcount].color[2] = sprite[i].zvel;
}
else
{
staticlights[staticlightcount].color[0] = hictinting[PL].r;
staticlights[staticlightcount].color[1] = hictinting[PL].g;
staticlights[staticlightcount].color[2] = hictinting[PL].b;
}
staticlights[staticlightcount].radius = 0;
staticlights[staticlightcount].angle = SA;
staticlights[staticlightcount].horiz = SH;
staticlights[staticlightcount].priority = SS;
staticlightcount++;
deletesprite(i);
continue;
}
if (PN == SECTOREFFECTOR && SLT == 50)
{
staticlights[staticlightcount].sector = SECT;
staticlights[staticlightcount].x = SX;
staticlights[staticlightcount].y = SY;
staticlights[staticlightcount].z = SZ;
staticlights[staticlightcount].range = SHT;
if ((sprite[i].xvel | sprite[i].yvel | sprite[i].zvel) != 0)
{
staticlights[staticlightcount].color[0] = sprite[i].xvel;
staticlights[staticlightcount].color[1] = sprite[i].yvel;
staticlights[staticlightcount].color[2] = sprite[i].zvel;
}
else
{
staticlights[staticlightcount].color[0] = hictinting[PL].r;
staticlights[staticlightcount].color[1] = hictinting[PL].g;
staticlights[staticlightcount].color[2] = hictinting[PL].b;
}
staticlights[staticlightcount].radius = 256;
staticlights[staticlightcount].faderadius = 200;
staticlights[staticlightcount].angle = SA;
staticlights[staticlightcount].horiz = SH;
staticlights[staticlightcount].priority = SS;
staticlightcount++;
deletesprite(i);
continue;
}
#endif // POLYMER
A_Spawn(-1,i); A_Spawn(-1,i);
} }
} }