Polymost-style HUD model support for Polymer. It properly displays all HRP HUD models as far as I can tell.

git-svn-id: https://svn.eduke32.com/eduke32@1699 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
plagman 2010-08-21 07:39:12 +00:00
parent 7ae2a1071d
commit 99415a625f
6 changed files with 213 additions and 147 deletions

View file

@ -189,7 +189,7 @@ EXTERN walltype *wall;
EXTERN int16_t maskwall[MAXWALLSB], maskwallcnt; EXTERN int16_t maskwall[MAXWALLSB], maskwallcnt;
EXTERN int16_t thewall[MAXWALLSB]; EXTERN int16_t thewall[MAXWALLSB];
EXTERN spritetype *sprite; EXTERN spritetype *sprite;
EXTERN spritetype *tspriteptr[MAXSPRITESONSCREEN]; EXTERN spritetype *tspriteptr[MAXSPRITESONSCREEN + 1];
EXTERN int32_t spritesortcnt; EXTERN int32_t spritesortcnt;
EXTERN spritetype *tsprite; EXTERN spritetype *tsprite;

View file

@ -436,7 +436,7 @@ int16_t maskwall[MAXWALLSB], maskwallcnt;
static int32_t spritesx[MAXSPRITESONSCREEN]; static int32_t spritesx[MAXSPRITESONSCREEN];
static int32_t spritesy[MAXSPRITESONSCREEN+1]; static int32_t spritesy[MAXSPRITESONSCREEN+1];
static int32_t spritesz[MAXSPRITESONSCREEN]; static int32_t spritesz[MAXSPRITESONSCREEN];
spritetype *tspriteptr[MAXSPRITESONSCREEN]; spritetype *tspriteptr[MAXSPRITESONSCREEN + 1];
int16_t umost[MAXXDIM], dmost[MAXXDIM]; int16_t umost[MAXXDIM], dmost[MAXXDIM];
static int16_t bakumost[MAXXDIM], bakdmost[MAXXDIM]; static int16_t bakumost[MAXXDIM], bakdmost[MAXXDIM];

View file

@ -14,7 +14,7 @@ extern int32_t pow2int[32];
extern int16_t thesector[MAXWALLSB], thewall[MAXWALLSB]; extern int16_t thesector[MAXWALLSB], thewall[MAXWALLSB];
extern int16_t bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB]; extern int16_t bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB];
extern int16_t maskwall[MAXWALLSB], maskwallcnt; extern int16_t maskwall[MAXWALLSB], maskwallcnt;
extern spritetype *tspriteptr[MAXSPRITESONSCREEN]; extern spritetype *tspriteptr[MAXSPRITESONSCREEN + 1];
extern int32_t xdimen, xdimenrecip, halfxdimen, xdimenscale, xdimscale, ydimen; extern int32_t xdimen, xdimenrecip, halfxdimen, xdimenscale, xdimscale, ydimen;
extern intptr_t frameoffset; extern intptr_t frameoffset;
extern int32_t globalposx, globalposy, globalposz, globalhoriz; extern int32_t globalposx, globalposy, globalposz, globalhoriz;

View file

@ -3469,7 +3469,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
float *v0, *v1; float *v0, *v1;
md3surf_t *s; md3surf_t *s;
char lpal; char lpal;
float spos[3], tspos[3], lpos[3], tlpos[3], vec[3], mat[4][4]; float spos2[3], spos[3], tspos[3], lpos[3], tlpos[3], vec[3], mat[4][4];
float ang; float ang;
float scale; float scale;
double det; double det;
@ -3489,9 +3489,28 @@ static void polymer_drawmdsprite(spritetype *tspr)
if ((pr_vbos > 1) && (m->indices == NULL)) if ((pr_vbos > 1) && (m->indices == NULL))
polymer_loadmodelvbos(m); polymer_loadmodelvbos(m);
// Hackish, but that means it's a model drawn by rotatesprite.
if (tspriteptr[MAXSPRITESONSCREEN] == tspr) {
float x, y, z;
spos[0] = (float)globalposy;
spos[1] = -(float)(globalposz) / 16.0f;
spos[2] = -(float)globalposx;
// The coordinates are actually floats disguised as int in this case
memcpy(&x, &tspr->x, sizeof(float));
memcpy(&y, &tspr->y, sizeof(float));
memcpy(&z, &tspr->z, sizeof(float));
spos2[0] = (float)y - globalposy;
spos2[1] = -(float)(z - globalposz) / 16.0f;
spos2[2] = -(float)(x - globalposx);
} else {
spos[0] = (float)tspr->y; spos[0] = (float)tspr->y;
spos[1] = -(float)(tspr->z) / 16.0f; spos[1] = -(float)(tspr->z) / 16.0f;
spos[2] = -(float)tspr->x; spos[2] = -(float)tspr->x;
}
ang = (float)((tspr->ang+spriteext[tspr->owner].angoff) & 2047) / (2048.0f / 360.0f); ang = (float)((tspr->ang+spriteext[tspr->owner].angoff) & 2047) / (2048.0f / 360.0f);
ang -= 90.0f; ang -= 90.0f;
if (((tspr->cstat>>4) & 3) == 2) if (((tspr->cstat>>4) & 3) == 2)
@ -3504,8 +3523,22 @@ static void polymer_drawmdsprite(spritetype *tspr)
scale *= m->scale; scale *= m->scale;
scale *= m->bscale; scale *= m->bscale;
if (tspriteptr[MAXSPRITESONSCREEN] == tspr) {
float radplayerang, cosminusradplayerang, sinminusradplayerang;
radplayerang = (globalang & 2047) * 2.0f * PI / 2048.0f;
cosminusradplayerang = cos(-radplayerang);
sinminusradplayerang = sin(-radplayerang);
bglTranslatef(spos[0], spos[1], spos[2]);
bglRotatef(horizang, -cosminusradplayerang, 0.0f, sinminusradplayerang);
bglRotatef(spriteext[tspr->owner].roll / (2048.0f / 360.0f), sinminusradplayerang, 0.0f, cosminusradplayerang);
bglTranslatef(spos2[0], spos2[1], spos2[2]);
bglRotatef(-ang, 0.0f, 1.0f, 0.0f);
} else {
bglTranslatef(spos[0], spos[1], spos[2]); bglTranslatef(spos[0], spos[1], spos[2]);
bglRotatef(-ang, 0.0f, 1.0f, 0.0f); bglRotatef(-ang, 0.0f, 1.0f, 0.0f);
}
if (((tspr->cstat>>4) & 3) == 2) if (((tspr->cstat>>4) & 3) == 2)
{ {
bglTranslatef(0.0f, 0.0, -(float)(tilesizy[tspr->picnum] * tspr->yrepeat) / 8.0f); bglTranslatef(0.0f, 0.0, -(float)(tilesizy[tspr->picnum] * tspr->yrepeat) / 8.0f);
@ -3530,7 +3563,8 @@ static void polymer_drawmdsprite(spritetype *tspr)
bglTranslatef(0.0f, 0.0, m->zadd * 64); bglTranslatef(0.0f, 0.0, m->zadd * 64);
// scripted model rotation // scripted model rotation
if (spriteext[tspr->owner].pitch || spriteext[tspr->owner].roll) if (tspr->owner < MAXSPRITES &&
(spriteext[tspr->owner].pitch || spriteext[tspr->owner].roll))
{ {
float pitchang, rollang, offsets[3]; float pitchang, rollang, offsets[3];

View file

@ -5260,17 +5260,35 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
} }
} }
tspr.ang = hudmem[(dastat&4)>>2][picnum].angadd+globalang; tspr.ang = hudmem[(dastat&4)>>2][picnum].angadd+globalang;
tspr.xrepeat = tspr.yrepeat = 32;
if (dastat&4) { x1 = -x1; y1 = -y1; } if (dastat&4) { x1 = -x1; y1 = -y1; }
// In Polymost, we don't care if the model is very big
if (rendmode < 4) {
tspr.xrepeat = tspr.yrepeat = 32;
tspr.x = (int32_t)(((double)gcosang*z1 - (double)gsinang*x1)*16384.0 + globalposx); tspr.x = (int32_t)(((double)gcosang*z1 - (double)gsinang*x1)*16384.0 + globalposx);
tspr.y = (int32_t)(((double)gsinang*z1 + (double)gcosang*x1)*16384.0 + globalposy); tspr.y = (int32_t)(((double)gsinang*z1 + (double)gcosang*x1)*16384.0 + globalposy);
tspr.z = (int32_t)(globalposz + y1*16384.0*0.8); tspr.z = (int32_t)(globalposz + y1*16384.0*0.8);
} else {
float x, y, z;
tspr.xrepeat = tspr.yrepeat = 5;
x = (float)(((double)gcosang*z1 - (double)gsinang*x1)*2560.0 + globalposx);
y = (float)(((double)gsinang*z1 + (double)gcosang*x1)*2560.0 + globalposy);
z = (float)(globalposz + y1*2560.0*0.8);
memcpy(&tspr.x, &x, sizeof(float));
memcpy(&tspr.y, &y, sizeof(float));
memcpy(&tspr.z, &z, sizeof(float));
}
tspr.picnum = picnum; tspr.picnum = picnum;
tspr.shade = dashade; tspr.shade = dashade;
tspr.pal = dapalnum; tspr.pal = dapalnum;
tspr.owner = uniqid+MAXSPRITES; tspr.owner = uniqid+MAXSPRITES;
globalorientation = (dastat&1)+((dastat&32)<<4)+((dastat&4)<<1); globalorientation = (dastat&1)+((dastat&32)<<4)+((dastat&4)<<1);
tspr.cstat = globalorientation;
if ((dastat&10) == 2) if ((dastat&10) == 2)
bglViewport(windowx1,yres-(windowy2+1),windowx2-windowx1+1,windowy2-windowy1+1); bglViewport(windowx1,yres-(windowy2+1),windowx2-windowx1+1,windowy2-windowy1+1);
@ -5280,6 +5298,8 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
glox1 = -1; //Force fullscreen (glox1=-1 forces it to restore) glox1 = -1; //Force fullscreen (glox1=-1 forces it to restore)
} }
if (rendmode < 4)
{
bglMatrixMode(GL_PROJECTION); bglMatrixMode(GL_PROJECTION);
memset(m,0,sizeof(m)); memset(m,0,sizeof(m));
if ((dastat&10) == 2) if ((dastat&10) == 2)
@ -5294,6 +5314,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
bglLoadMatrixf(&m[0][0]); bglLoadMatrixf(&m[0][0]);
bglMatrixMode(GL_MODELVIEW); bglMatrixMode(GL_MODELVIEW);
bglLoadIdentity(); bglLoadIdentity();
}
if (hudmem[(dastat&4)>>2][picnum].flags&8) //NODEPTH flag if (hudmem[(dastat&4)>>2][picnum].flags&8) //NODEPTH flag
bglDisable(GL_DEPTH_TEST); bglDisable(GL_DEPTH_TEST);
@ -5307,22 +5328,31 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
} }
} }
#if 0
if (!nofog)
{
i = klabs(tspr.shade);
bglFogf(GL_FOG_DENSITY,fogcalc(tspr.shade,sector[tspr.sectnum].visibility);
}
mddraw(&tspr);
#else
#ifdef USE_OPENGL #ifdef USE_OPENGL
if (!nofog) bglDisable(GL_FOG); if (!nofog) bglDisable(GL_FOG);
if (rendmode < 4)
mddraw(&tspr); mddraw(&tspr);
else {
tspriteptr[MAXSPRITESONSCREEN] = &tspr;
bglEnable(GL_ALPHA_TEST);
bglEnable(GL_BLEND);
spriteext[tspr.owner].roll = a;
polymer_drawsprite(MAXSPRITESONSCREEN);
spriteext[tspr.owner].roll = 0;
bglDisable(GL_BLEND);
bglDisable(GL_ALPHA_TEST);
}
if (!nofog) bglEnable(GL_FOG); if (!nofog) bglEnable(GL_FOG);
#else #else
mddraw(&tspr); mddraw(&tspr);
#endif #endif
#endif
viewingrange = oldviewingrange; viewingrange = oldviewingrange;
gxyaspect = ogxyaspect; gxyaspect = ogxyaspect;
globalshade = ogshade; globalshade = ogshade;
@ -5360,6 +5390,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
m[0][0] = m[2][3] = 1.0f; m[1][1] = ((float)xdim)/((float)ydim); m[2][2] = 1.0001f; m[3][2] = 1-m[2][2]; m[0][0] = m[2][3] = 1.0f; m[1][1] = ((float)xdim)/((float)ydim); m[2][2] = 1.0001f; m[3][2] = 1-m[2][2];
bglPushMatrix(); bglLoadMatrixf(&m[0][0]); bglPushMatrix(); bglLoadMatrixf(&m[0][0]);
bglMatrixMode(GL_MODELVIEW); bglMatrixMode(GL_MODELVIEW);
bglPushMatrix();
bglLoadIdentity(); bglLoadIdentity();
bglDisable(GL_DEPTH_TEST); bglDisable(GL_DEPTH_TEST);
@ -5519,6 +5550,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
if (rendmode >= 3) if (rendmode >= 3)
{ {
bglMatrixMode(GL_PROJECTION); bglPopMatrix(); bglMatrixMode(GL_PROJECTION); bglPopMatrix();
bglMatrixMode(GL_MODELVIEW); bglPopMatrix();
} }
#endif #endif