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;
uint8_t flags;
uint8_t xpanning, ypanning;
uint8_t filler[1];
uint8_t filler;
float alpha;
spritetype *tspr;
} spriteext_t;

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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<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)
{
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;

View File

@ -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 <windows.h>
@ -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]; i<spritesortcnt; i++,tspr++)
{
frames=0;

View File

@ -4452,12 +4452,13 @@ void G_DrawRooms(int32_t snum,int32_t smoothratio)
ud.camerasect = sprite[p->newowner].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))

View File

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

View File

@ -506,6 +506,7 @@ enum ActorLabel_t
ACTOR_XPANNING,
ACTOR_YPANNING,
ACTOR_HTFLAGS,
ACTOR_ALPHA,
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);
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;
}
}

View File

@ -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<MAXMOUSEBUTTONS; i++)OSD_Printf("%s\n",ConsoleButtons[i]);
for (i=0; ConsoleKeys[i].name; i++)
OSD_Printf("%s\n",ConsoleKeys[i].name);
for (i=0; i<MAXMOUSEBUTTONS; i++)
OSD_Printf("%s\n",ConsoleButtons[i]);
return OSDCMD_OK;
}

View File

@ -987,6 +987,64 @@ static inline void prelevel(char g)
{
if (PN == SECTOREFFECTOR && SLT == 14)
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);
}
}