Added xpanning and ypanning actor members to control the new sprite panning feature.

git-svn-id: https://svn.eduke32.com/eduke32@590 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
plagman 2008-01-03 21:54:58 +00:00
parent a1e00d78ee
commit cfa399998a
5 changed files with 100 additions and 2 deletions

View file

@ -163,7 +163,8 @@ typedef struct BPACK {
short pitch, roll;
int xoff, yoff, zoff;
unsigned char flags;
char filler[3];
unsigned char xpanning, ypanning;
char filler[1];
} spriteexttype;
typedef struct BPACK {

View file

@ -99,6 +99,8 @@ int zbufmem = 0, zbufysiz = 0, zbufbpl = 0, *zbufoff = 0;
#endif
#ifdef USE_OPENGL
static int srepeat = 0, trepeat = 0;
int glredbluemode = 0;
static int lastglredbluemode = 0, redblueclearcnt = 0;
@ -1795,6 +1797,11 @@ void drawpoly(double *dpx, double *dpy, int n, int method)
bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0);
if (srepeat)
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
if (trepeat)
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
// texture scale by parkar request
if (pth && pth->hicr && ((pth->hicr->xscale != 1.0f) || (pth->hicr->yscale != 1.0f)) && !drawingskybox)
{
@ -2131,6 +2138,11 @@ void drawpoly(double *dpx, double *dpy, int n, int method)
bglActiveTextureARB(--texunits);
}
if (srepeat)
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
if (trepeat)
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
if (fullbrightdrawingpass == 1) // tile has fullbright colors ?
{
fullbrightdrawingpass = 2;
@ -4443,6 +4455,12 @@ void polymost_drawsprite(int snum)
{ gvy = (float)tilesizy[globalpicnum]*gdo/(py[3]-py[0]+.002); gvo = -gvy*(py[0]-.001); }
else { gvy = (float)tilesizy[globalpicnum]*gdo/(py[0]-py[3]-.002); gvo = -gvy*(py[3]+.001); }
// sprite panning
guy -= gdy*((float)(spriteext[spritenum].xpanning)/255.f)*tilesizx[globalpicnum];
guo -= gdo*((float)(spriteext[spritenum].xpanning)/255.f)*tilesizx[globalpicnum];
gvy -= gdy*((float)(spriteext[spritenum].ypanning)/255.f)*tilesizy[globalpicnum];
gvo -= gdo*((float)(spriteext[spritenum].ypanning)/255.f)*tilesizy[globalpicnum];
//Clip sprites to ceilings/floors when no parallaxing and not sloped
if (!(sector[tspr->sectnum].ceilingstat&3))
{
@ -4455,7 +4473,22 @@ void polymost_drawsprite(int snum)
if (py[2] > sy0) py[2] = py[3] = sy0;
}
#ifdef USE_OPENGL
if (spriteext[spritenum].xpanning)
srepeat = 1;
if (spriteext[spritenum].ypanning)
trepeat = 1;
#endif
pow2xsplit = 0; drawpoly(px,py,4,method);
#ifdef USE_OPENGL
if (spriteext[spritenum].xpanning)
srepeat = 0;
if (spriteext[spritenum].ypanning)
trepeat = 0;
#endif
break;
case 1: //Wall sprite
@ -4519,6 +4552,10 @@ void polymost_drawsprite(int snum)
//gux*sx0 + guo = t0*tilesizx[globalpicnum]*yp0
//gux*sx1 + guo = t1*tilesizx[globalpicnum]*yp1
if (globalorientation&4) { t0 = 1.f-t0; t1 = 1.f-t1; }
//sprite panning
t0 -= ((float)(spriteext[spritenum].xpanning)/255.f);
t1 -= ((float)(spriteext[spritenum].xpanning)/255.f);
gux = (t0*ryp0 - t1*ryp1)*gxyaspect*(float)tilesizx[globalpicnum] / (sx0-sx1);
guy = 0;
guo = t0*ryp0*gxyaspect*(float)tilesizx[globalpicnum] - gux*sx0;
@ -4540,6 +4577,11 @@ void polymost_drawsprite(int snum)
gvo = -gvx*sx0 - gvy*sf0;
}
// sprite panning
gvx -= gdx*((float)(spriteext[spritenum].ypanning)/255.f)*tilesizy[globalpicnum];
gvy -= gdy*((float)(spriteext[spritenum].ypanning)/255.f)*tilesizy[globalpicnum];
gvo -= gdo*((float)(spriteext[spritenum].ypanning)/255.f)*tilesizy[globalpicnum];
//Clip sprites to ceilings/floors when no parallaxing
if (!(sector[tspr->sectnum].ceilingstat&1))
{
@ -4571,7 +4613,23 @@ void polymost_drawsprite(int snum)
px[1] = sx1; py[1] = sc1;
px[2] = sx1; py[2] = sf1;
px[3] = sx0; py[3] = sf0;
#ifdef USE_OPENGL
if (spriteext[spritenum].xpanning)
srepeat = 1;
if (spriteext[spritenum].ypanning)
trepeat = 1;
#endif
pow2xsplit = 0; drawpoly(px,py,4,method);
#ifdef USE_OPENGL
if (spriteext[spritenum].xpanning)
srepeat = 0;
if (spriteext[spritenum].ypanning)
trepeat = 0;
#endif
break;
case 2: //Floor sprite
@ -4661,7 +4719,28 @@ void polymost_drawsprite(int snum)
guo = ((float)tilesizx[globalpicnum])*gdo - guo;
}
// sprite panning
guy -= gdy*((float)(spriteext[spritenum].xpanning)/255.f)*tilesizx[globalpicnum];
guo -= gdo*((float)(spriteext[spritenum].xpanning)/255.f)*tilesizx[globalpicnum];
gvy -= gdy*((float)(spriteext[spritenum].ypanning)/255.f)*tilesizy[globalpicnum];
gvo -= gdo*((float)(spriteext[spritenum].ypanning)/255.f)*tilesizy[globalpicnum];
#ifdef USE_OPENGL
if (spriteext[spritenum].xpanning)
srepeat = 1;
if (spriteext[spritenum].ypanning)
trepeat = 1;
#endif
pow2xsplit = 0; drawpoly(px,py,npoints,method);
#ifdef USE_OPENGL
if (spriteext[spritenum].xpanning)
srepeat = 0;
if (spriteext[spritenum].ypanning)
trepeat = 0;
#endif
break;
case 3: //Voxel sprite

View file

@ -549,6 +549,8 @@ LABELS actorlabels[]=
{ "mdyoff", ACTOR_MDYOFF, 0, 0 },
{ "mdzoff", ACTOR_MDZOFF, 0, 0 },
{ "mdflags", ACTOR_MDFLAGS, 0, 0 },
{ "xpanning", ACTOR_XPANNING, 0, 0 },
{ "ypanning", ACTOR_YPANNING, 0, 0 },
{ "", -1, 0, 0 } // END OF LIST
};

View file

@ -434,7 +434,9 @@ enum actorlabels
ACTOR_MDXOFF,
ACTOR_MDYOFF,
ACTOR_MDZOFF,
ACTOR_MDFLAGS
ACTOR_MDFLAGS,
ACTOR_XPANNING,
ACTOR_YPANNING
};
enum inputlabels

View file

@ -2732,6 +2732,20 @@ static void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2)
SetGameVarID(lVar2,spriteext[iActor].flags, g_i, g_p);
break;
case ACTOR_XPANNING:
if (iSet)
spriteext[iActor].xpanning=lValue;
else
SetGameVarID(lVar2, spriteext[iActor].xpanning,g_i,g_p);
break;
case ACTOR_YPANNING:
if (iSet)
spriteext[iActor].ypanning=lValue;
else
SetGameVarID(lVar2, spriteext[iActor].ypanning,g_i,g_p);
break;
default:
break;
}