HAVE YOU EVER FELT

git-svn-id: https://svn.eduke32.com/eduke32@697 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
plagman 2008-04-06 23:35:48 +00:00
parent 369d848650
commit dff876f1d0
9 changed files with 256 additions and 88 deletions

View file

@ -281,6 +281,7 @@ extern int usevoxels, voxscale[MAXVOXELS];
#endif #endif
#ifdef POLYMOST #ifdef POLYMOST
extern int usemodels, usehightile; extern int usemodels, usehightile;
extern int rendmode;
#endif #endif
EXTERN int h_xsize[MAXTILES], h_ysize[MAXTILES]; EXTERN int h_xsize[MAXTILES], h_ysize[MAXTILES];
EXTERN signed char h_xoffs[MAXTILES], h_yoffs[MAXTILES]; EXTERN signed char h_xoffs[MAXTILES], h_yoffs[MAXTILES];
@ -479,6 +480,10 @@ _equation equation(int x1, int y1, int x2, int y2);
int sameside(_equation* eq, _point2d* p1, _point2d* p2); int sameside(_equation* eq, _point2d* p1, _point2d* p2);
int wallvisible(short wallnum); int wallvisible(short wallnum);
// polymer stuff for the game to provide it with the animatessprites ptr
typedef void (*animatespritesptr)(int, int, int, int);
EXTERN void polymer_setanimatesprites(animatespritesptr, int, int, int, int);
#define STATUS2DSIZ 144 #define STATUS2DSIZ 144
void qsetmode640350(void); void qsetmode640350(void);
void qsetmode640480(void); void qsetmode640480(void);

View file

@ -68,6 +68,7 @@ extern void (APIENTRY * bglHint)( GLenum target, GLenum mode );
extern void (APIENTRY * bglDrawBuffer)(GLenum mode); extern void (APIENTRY * bglDrawBuffer)(GLenum mode);
extern void (APIENTRY * bglReadBuffer)(GLenum mode); extern void (APIENTRY * bglReadBuffer)(GLenum mode);
extern void (APIENTRY * bglScissor)(GLint x, GLint y, GLsizei width, GLsizei height); extern void (APIENTRY * bglScissor)(GLint x, GLint y, GLsizei width, GLsizei height);
extern void (APIENTRY * bglClipPlane)(GLenum plane, const GLdouble *equation);
// Depth // Depth
extern void (APIENTRY * bglDepthFunc)( GLenum func ); extern void (APIENTRY * bglDepthFunc)( GLenum func );

View file

@ -56,6 +56,7 @@ typedef struct s_prsector {
GLdouble* verts; GLdouble* verts;
GLfloat* floorbuffer; GLfloat* floorbuffer;
GLfloat* ceilbuffer; GLfloat* ceilbuffer;
GLdouble floorplane[4], ceilplane[4];
// attributes // attributes
GLfloat floorcolor[4], ceilcolor[4]; GLfloat floorcolor[4], ceilcolor[4];
GLuint floorglpic, ceilglpic, floorfbglpic, ceilfbglpic; GLuint floorglpic, ceilglpic, floorfbglpic, ceilfbglpic;
@ -104,10 +105,10 @@ typedef struct s_prwall {
char controlstate; char controlstate;
} _prwall; } _prwall;
typedef struct s_cliplane { typedef struct s_pranimatespritesinfo {
_equation left, right, clip; animatespritesptr animatesprites;
_point2d ref; int x, y, a, smoothratio;
} _cliplane; } _pranimatespritesinfo;
extern _prsector* prsectors[MAXSECTORS]; extern _prsector* prsectors[MAXSECTORS];
extern _prwall* prwalls[MAXWALLS]; extern _prwall* prwalls[MAXWALLS];
@ -127,9 +128,12 @@ void polymer_drawsprite(int snum);
# ifdef POLYMER_C # ifdef POLYMER_C
extern int globalposx, globalposy, globalposz, globalhoriz;
// CORE // CORE
static void polymer_displayrooms(short sectnum); static void polymer_displayrooms(short sectnum);
static void polymer_inb4mirror(short sectnum); static void polymer_inb4mirror(short sectnum);
static void polymer_animatesprites(void);
// SECTORS // SECTORS
static int polymer_initsector(short sectnum); static int polymer_initsector(short sectnum);
static int polymer_updatesector(short sectnum); static int polymer_updatesector(short sectnum);
@ -143,10 +147,12 @@ static int polymer_initwall(short wallnum);
static void polymer_updatewall(short wallnum); static void polymer_updatewall(short wallnum);
static void polymer_drawwall(short wallnum); static void polymer_drawwall(short wallnum);
// HSR // HSR
static void polymer_buffertoplane(GLfloat* buffer, GLushort* indices, GLdouble* plane);
static void polymer_crossproduct(GLfloat* in_a, GLfloat* in_b, GLdouble* out);
static void polymer_pokesector(short sectnum); static void polymer_pokesector(short sectnum);
static void polymer_extractfrustum(GLdouble* modelview, GLdouble* projection, float* frustum); static void polymer_extractfrustum(GLdouble* modelview, GLdouble* projection, float* frustum);
static int polymer_portalinfrustum(short wallnum, float* frustum); static int polymer_portalinfrustum(short wallnum, float* frustum);
static void polymer_scansprites(short sectnum); static void polymer_scansprites(short sectnum, spritetype* tsprite, int* spritesortcnt);
// SKIES // SKIES
static void polymer_initskybox(void); static void polymer_initskybox(void);
static void polymer_getsky(void); static void polymer_getsky(void);

View file

@ -37,6 +37,7 @@ void (APIENTRY * bglHint)(GLenum target, GLenum mode);
void (APIENTRY * bglDrawBuffer)(GLenum mode); void (APIENTRY * bglDrawBuffer)(GLenum mode);
void (APIENTRY * bglReadBuffer)(GLenum mode); void (APIENTRY * bglReadBuffer)(GLenum mode);
void (APIENTRY * bglScissor)(GLint x, GLint y, GLsizei width, GLsizei height); void (APIENTRY * bglScissor)(GLint x, GLint y, GLsizei width, GLsizei height);
void (APIENTRY * bglClipPlane)(GLenum plane, const GLdouble *equation);
// Depth // Depth
void (APIENTRY * bglDepthFunc)(GLenum func); void (APIENTRY * bglDepthFunc)(GLenum func);
@ -283,6 +284,7 @@ int loadgldriver(const char *driver)
bglDrawBuffer = GETPROC("glDrawBuffer"); bglDrawBuffer = GETPROC("glDrawBuffer");
bglReadBuffer = GETPROC("glDrawBuffer"); bglReadBuffer = GETPROC("glDrawBuffer");
bglScissor = GETPROC("glScissor"); bglScissor = GETPROC("glScissor");
bglClipPlane = GETPROC("glClipPlane");
// Depth // Depth
bglDepthFunc = GETPROC("glDepthFunc"); bglDepthFunc = GETPROC("glDepthFunc");
@ -458,6 +460,7 @@ int unloadgldriver(void)
bglDrawBuffer = NULL; bglDrawBuffer = NULL;
bglReadBuffer = NULL; bglReadBuffer = NULL;
bglScissor = NULL; bglScissor = NULL;
bglClipPlane = NULL;
// Depth // Depth
bglDepthFunc = NULL; bglDepthFunc = NULL;

View file

@ -7,7 +7,7 @@
// CVARS // CVARS
int pr_occlusionculling = 1; int pr_occlusionculling = 1;
int pr_fov = 426; // appears to be the classic setting. int pr_fov = 426; // appears to be the classic setting.
int pr_billboardingmode = 0; int pr_billboardingmode = 1;
int pr_verbosity = 1; // 0: silent, 1: errors and one-times, 2: multiple-times, 3: flood int pr_verbosity = 1; // 0: silent, 1: errors and one-times, 2: multiple-times, 3: flood
int pr_wireframe = 0; int pr_wireframe = 0;
int pr_mirrordepth = 1; int pr_mirrordepth = 1;
@ -32,13 +32,13 @@ GLfloat vertsprite[4 * 5] = {
}; };
GLfloat horizsprite[4 * 5] = { GLfloat horizsprite[4 * 5] = {
-0.5f, 0.0f, -0.03125f, -0.5f, 0.0f, -0.5f,
0.0f, 1.0f, 0.0f, 1.0f,
0.5f, 0.0f, -0.03125f, 0.5f, 0.0f, -0.5f,
1.0f, 1.0f, 1.0f, 1.0f,
0.5f, 0.0f, 0.03125f, 0.5f, 0.0f, 0.5f,
1.0f, 0.0f, 1.0f, 0.0f,
-0.5f, 0.0f, 0.03125f, -0.5f, 0.0f, 0.5f,
0.0f, 0.0f, 0.0f, 0.0f,
}; };
@ -59,6 +59,8 @@ short viewangle;
int rootsectnum; int rootsectnum;
_pranimatespritesinfo asi;
// EXTERNAL FUNCTIONS // EXTERNAL FUNCTIONS
int polymer_init(void) int polymer_init(void)
{ {
@ -203,7 +205,7 @@ void polymer_drawrooms(int daposx, int daposy, int daposz, short
tiltang = (gtang * 90.0f); tiltang = (gtang * 90.0f);
pos[0] = daposy; pos[0] = daposy;
pos[1] = -daposz; pos[1] = -(float)(daposz) / 16.0f;
pos[2] = -daposx; pos[2] = -daposx;
bglMatrixMode(GL_MODELVIEW); bglMatrixMode(GL_MODELVIEW);
@ -218,7 +220,7 @@ void polymer_drawrooms(int daposx, int daposy, int daposz, short
polymer_drawartsky(cursky); polymer_drawartsky(cursky);
bglEnable(GL_DEPTH_TEST); bglEnable(GL_DEPTH_TEST);
bglScalef(1.0f / 1000.0f, 1.0f / 16000.0f, 1.0f / 1000.0f); bglScalef(1.0f / 1000.0f, 1.0f / 1000.0f, 1.0f / 1000.0f);
bglTranslatef(-pos[0], -pos[1], -pos[2]); bglTranslatef(-pos[0], -pos[1], -pos[2]);
bglGetDoublev(GL_MODELVIEW_MATRIX, rootmodelviewmatrix); bglGetDoublev(GL_MODELVIEW_MATRIX, rootmodelviewmatrix);
@ -237,7 +239,7 @@ void polymer_drawrooms(int daposx, int daposy, int daposz, short
{ {
polymer_updatesector(i); polymer_updatesector(i);
polymer_drawsector(i); polymer_drawsector(i);
polymer_scansprites(i); polymer_scansprites(i, tsprite, &spritesortcnt);
i++; i++;
} }
@ -377,10 +379,10 @@ void polymer_drawsprite(int snum)
else else
xsize = tspr->xrepeat * tilesizx[curpicnum] / 4; xsize = tspr->xrepeat * tilesizx[curpicnum] / 4;
ysize = tspr->yrepeat * tilesizy[curpicnum] * 4; ysize = tspr->yrepeat * tilesizy[curpicnum] / 4;
spos[0] = tspr->y; spos[0] = tspr->y;
spos[1] = -tspr->z; spos[1] = -(float)(tspr->z) / 16.0f;
spos[2] = -tspr->x; spos[2] = -tspr->x;
curspritedata = vertsprite; curspritedata = vertsprite;
@ -413,7 +415,7 @@ void polymer_drawsprite(int snum)
bglLoadMatrixd(spritemodelview); bglLoadMatrixd(spritemodelview);
bglRotatef((gtang * 90.0f), 0.0f, 0.0f, -1.0f); bglRotatef((gtang * 90.0f), 0.0f, 0.0f, -1.0f);
bglScalef((float)(xsize) / 1000.0f, (float)(ysize) / 16000.0f, 1.0f / 1000.0f); bglScalef((float)(xsize) / 1000.0f, (float)(ysize) / 1000.0f, 1.0f / 1000.0f);
bglPolygonOffset(0.0f, 0.0f); bglPolygonOffset(0.0f, 0.0f);
break; break;
@ -461,14 +463,14 @@ void polymer_drawsprite(int snum)
bglBindTexture(GL_TEXTURE_2D, glpic); bglBindTexture(GL_TEXTURE_2D, glpic);
bglColor4f(color[0], color[1], color[2], color[3]); bglColor4f(color[0], color[1], color[2], color[3]);
if (tspr->cstat & 64) if ((tspr->cstat & 64) && (((tspr->cstat>>4) & 3) == 1))
bglEnable(GL_CULL_FACE); bglEnable(GL_CULL_FACE);
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), curspritedata); bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), curspritedata);
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &curspritedata[3]); bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &curspritedata[3]);
bglDrawArrays(GL_QUADS, 0, 4); bglDrawArrays(GL_QUADS, 0, 4);
if (tspr->cstat & 64) if ((tspr->cstat & 64) && (((tspr->cstat>>4) & 3) == 1))
bglDisable(GL_CULL_FACE); bglDisable(GL_CULL_FACE);
bglLoadIdentity(); bglLoadIdentity();
@ -476,6 +478,15 @@ void polymer_drawsprite(int snum)
bglPopMatrix(); bglPopMatrix();
} }
void polymer_setanimatesprites(animatespritesptr animatesprites, int x, int y, int a, int smoothratio)
{
asi.animatesprites = animatesprites;
asi.x = x;
asi.y = y;
asi.a = a;
asi.smoothratio = smoothratio;
}
// CORE // CORE
static void polymer_displayrooms(short dacursectnum) static void polymer_displayrooms(short dacursectnum)
{ {
@ -492,6 +503,9 @@ static void polymer_displayrooms(short dacursectnum)
short drawingstate[MAXSECTORS]; short drawingstate[MAXSECTORS];
GLdouble localmodelviewmatrix[16]; GLdouble localmodelviewmatrix[16];
float frustum[5 * 4]; float frustum[5 * 4];
int localspritesortcnt;
spritetype localtsprite[MAXSPRITESONSCREEN];
short localmaskwall[MAXWALLSB], localmaskwallcnt;
if (depth) if (depth)
{ {
@ -509,10 +523,14 @@ static void polymer_displayrooms(short dacursectnum)
front = 0; front = 0;
back = 0; back = 0;
localspritesortcnt = localmaskwallcnt = 0;
polymer_pokesector(dacursectnum); polymer_pokesector(dacursectnum);
polymer_drawsector(dacursectnum); if (!depth)
polymer_scansprites(dacursectnum); polymer_drawsector(dacursectnum);
else
polymer_drawsector(dacursectnum | 8192);
polymer_scansprites(dacursectnum, localtsprite, &localspritesortcnt);
drawingstate[dacursectnum] = 1; drawingstate[dacursectnum] = 1;
sec = &sector[dacursectnum]; sec = &sector[dacursectnum];
@ -521,12 +539,12 @@ static void polymer_displayrooms(short dacursectnum)
i = 0; i = 0;
while (i < sec->wallnum) while (i < sec->wallnum)
{ {
if ((wallvisible(sec->wallptr + i)) && if (((wallvisible(sec->wallptr + i))) &&
(polymer_portalinfrustum(sec->wallptr + i, frustum))) (polymer_portalinfrustum(sec->wallptr + i, frustum)))
{ {
polymer_drawwall(sec->wallptr + i); polymer_drawwall(sec->wallptr + i);
// mask // mask
if ((wal->cstat&48) == 16) maskwall[maskwallcnt++] = sec->wallptr + i; if ((wal->cstat&48) == 16) localmaskwall[localmaskwallcnt++] = sec->wallptr + i;
if ((wal->nextsector != -1) && if ((wal->nextsector != -1) &&
(drawingstate[wal->nextsector] == 0)) (drawingstate[wal->nextsector] == 0))
@ -562,7 +580,7 @@ static void polymer_displayrooms(short dacursectnum)
polymer_pokesector(sectorqueue[front]); polymer_pokesector(sectorqueue[front]);
polymer_drawsector(sectorqueue[front]); polymer_drawsector(sectorqueue[front]);
polymer_scansprites(sectorqueue[front]); polymer_scansprites(sectorqueue[front], localtsprite, &localspritesortcnt);
// scan sectors // scan sectors
sec = &sector[sectorqueue[front]]; sec = &sector[sectorqueue[front]];
@ -572,11 +590,11 @@ static void polymer_displayrooms(short dacursectnum)
while (i < sec->wallnum) while (i < sec->wallnum)
{ {
if ((wallvisible(sec->wallptr + i)) && if ((wallvisible(sec->wallptr + i)) &&
(polymer_portalinfrustum(sec->wallptr + i, frustum))) (polymer_portalinfrustum(sec->wallptr + i, frustum)))
{ {
polymer_drawwall(sec->wallptr + i); polymer_drawwall(sec->wallptr + i);
// mask // mask
if ((wal->cstat&48) == 16) maskwall[maskwallcnt++] = sec->wallptr + i; if ((wal->cstat&48) == 16) localmaskwall[localmaskwallcnt++] = sec->wallptr + i;
if ((wal->nextsector != -1) && if ((wal->nextsector != -1) &&
(drawingstate[wal->nextsector] == 0)) (drawingstate[wal->nextsector] == 0))
@ -629,25 +647,33 @@ static void polymer_displayrooms(short dacursectnum)
front++; front++;
} }
spritesortcnt = localspritesortcnt;
memcpy(tsprite, localtsprite, sizeof(spritetype) * MAXSPRITESONSCREEN);
maskwallcnt = localmaskwallcnt;
memcpy(maskwall, localmaskwall, sizeof(short) * MAXWALLSB);
if (depth) if (depth)
{ {
polymer_animatesprites();
bglDisable(GL_CULL_FACE);
drawmasks(); drawmasks();
bglEnable(GL_CULL_FACE);
bglEnable(GL_BLEND);
} }
} }
static void polymer_inb4mirror(short sectnum) static void polymer_inb4mirror(short sectnum)
{ {
float pv; float pv;
float normal[3]; GLdouble *normal;
float reflectionmatrix[16]; float reflectionmatrix[16];
normal[0] = 0.0f;
normal[1] = -1.0f; normal = prsectors[sectnum]->floorplane;
normal[2] = 0.0f;
pv = prsectors[sectnum]->floorbuffer[0] * normal[0] + pv = prsectors[sectnum]->floorbuffer[0] * normal[0] +
prsectors[sectnum]->floorbuffer[1] * normal[1] + prsectors[sectnum]->floorbuffer[1] * normal[1] +
prsectors[sectnum]->floorbuffer[2] * normal[2]; prsectors[sectnum]->floorbuffer[2] * normal[2];
reflectionmatrix[0] = 1 - (2 * normal[0] * normal[0]); reflectionmatrix[0] = 1 - (2 * normal[0] * normal[0]);
reflectionmatrix[1] = -2 * normal[0] * normal[1]; reflectionmatrix[1] = -2 * normal[0] * normal[1];
@ -672,6 +698,11 @@ static void polymer_inb4mirror(short sectnum)
bglMultMatrixf(reflectionmatrix); bglMultMatrixf(reflectionmatrix);
} }
static void polymer_animatesprites(void)
{
asi.animatesprites(asi.x, asi.y, asi.a, asi.smoothratio);
}
// SECTORS // SECTORS
static int polymer_initsector(short sectnum) static int polymer_initsector(short sectnum)
{ {
@ -768,8 +799,8 @@ static int polymer_updatesector(short sectnum)
while (i < sec->wallnum) while (i < sec->wallnum)
{ {
getzsofslope(sectnum, wal->x, wal->y, &ceilz, &florz); getzsofslope(sectnum, wal->x, wal->y, &ceilz, &florz);
s->floorbuffer[(i*5)+1] = -florz; s->floorbuffer[(i*5)+1] = -(float)(florz) / 16.0f;
s->ceilbuffer[(i*5)+1] = -ceilz; s->ceilbuffer[(i*5)+1] = -(float)(ceilz) / 16.0f;
i++; i++;
wal = &wall[sec->wallptr + i]; wal = &wall[sec->wallptr + i];
@ -930,7 +961,11 @@ finish:
polymer_buildfloor(sectnum); polymer_buildfloor(sectnum);
if (wallinvalidate) if (wallinvalidate)
{
s->invalidid++; s->invalidid++;
polymer_buffertoplane(s->floorbuffer, s->floorindices, s->floorplane);
polymer_buffertoplane(s->ceilbuffer, s->ceilindices, s->ceilplane);
}
s->controlstate = 1; s->controlstate = 1;
@ -1034,9 +1069,19 @@ static void polymer_drawsector(short sectnum)
sectortype *sec; sectortype *sec;
walltype *wal; walltype *wal;
_prsector* s; _prsector* s;
int skipfloor, gx, gy, gz, px, py, pz;
float coeff;
if (pr_verbosity >= 3) OSD_Printf("PR : Drawing sector %i...\n", sectnum); if (pr_verbosity >= 3) OSD_Printf("PR : Drawing sector %i...\n", sectnum);
if (sectnum & 8192)
{
skipfloor = 1;
sectnum ^= 8192;
}
else
skipfloor = 0;
sec = &sector[sectnum]; sec = &sector[sectnum];
wal = &wall[sec->wallptr]; wal = &wall[sec->wallptr];
s = prsectors[sectnum]; s = prsectors[sectnum];
@ -1047,46 +1092,112 @@ static void polymer_drawsector(short sectnum)
polymer_updatesector(sectnum); polymer_updatesector(sectnum);
} }
// if (depth < 1) if (skipfloor)
// { goto ceiling;
// //bglDisable(GL_DEPTH_TEST);
// bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); if ((depth < 1))
// {
// bglEnable(GL_STENCIL_TEST); //bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
// bglStencilOp(GL_KEEP, GL_KEEP, GL_INCR); // set the stencil to 1 and clear the area to black where the sector floor is
// bglStencilFunc(GL_EQUAL, 0, 0xffffffff); bglDisable(GL_TEXTURE_2D);
// bglDisable(GL_FOG);
// bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), s->floorbuffer); bglColor4f(0.0f, 1.0f, 0.0f, 1.0f);
// bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &s->floorbuffer[3]); bglDepthMask(0);
// bglDrawElements(GL_TRIANGLES, s->indicescount, GL_UNSIGNED_SHORT, s->floorindices);
// bglEnable(GL_STENCIL_TEST);
// bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); bglStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
// //bglEnable(GL_DEPTH_TEST); bglStencilFunc(GL_EQUAL, 0, 0xffffffff);
//
// bglStencilFunc(GL_EQUAL, 1, 0xffffffff); /* draw if stencil ==1 */ bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), s->floorbuffer);
// bglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &s->floorbuffer[3]);
// bglDrawElements(GL_TRIANGLES, s->indicescount, GL_UNSIGNED_SHORT, s->floorindices);
// bglMatrixMode(GL_MODELVIEW); //bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
// bglPushMatrix(); bglDepthMask(1);
// polymer_inb4mirror(sectnum);
// bglCullFace(GL_FRONT); // set the depth to 1 where we put the stencil by drawing a screen aligned quad
// depth++; bglStencilFunc(GL_EQUAL, 1, 0xffffffff);
// bglDepthFunc(GL_GREATER); bglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
// polymer_displayrooms(rootsectnum); bglDepthFunc(GL_ALWAYS);
// bglDepthFunc(GL_LEQUAL); bglMatrixMode(GL_PROJECTION);
// depth--; bglPushMatrix();
// bglCullFace(GL_BACK); bglLoadIdentity();
// bglMatrixMode(GL_MODELVIEW); bglMatrixMode(GL_MODELVIEW);
// bglPopMatrix(); bglPushMatrix();
// //bglDisable(GL_DEPTH_TEST); bglLoadIdentity();
// }
bglColor4f(0.0f, 0.0f, 0.0f, 1.0f);
bglBegin(GL_QUADS);
bglVertex3f(-1.0f, -1.0f, 1.0f);
bglVertex3f(1.0f, -1.0f, 1.0f);
bglVertex3f(1.0f, 1.0f, 1.0f);
bglVertex3f(-1.0f, 1.0f, 1.0f);
bglEnd();
bglMatrixMode(GL_PROJECTION);
bglPopMatrix();
bglMatrixMode(GL_MODELVIEW);
bglPopMatrix();
bglDepthFunc(GL_LEQUAL);
bglEnable(GL_TEXTURE_2D);
bglEnable(GL_FOG);
// finally draw the shit
bglPushMatrix();
bglClipPlane(GL_CLIP_PLANE0, s->floorplane);
polymer_inb4mirror(sectnum);
//bglDisable(GL_CULL_FACE);
bglCullFace(GL_FRONT);
bglEnable(GL_CLIP_PLANE0);
gx = globalposx;
gy = globalposy;
gz = globalposz;
// map the player pos from build to polymer
px = globalposy;
py = -globalposz / 16;
pz = -globalposx;
// calculate new player position on the other side of the mirror
// this way the basic build visibility shit can be used (wallvisible)
coeff = -s->floorplane[0] * px +
-s->floorplane[1] * py +
-s->floorplane[2] * pz +
-s->floorplane[3];
coeff /= (float)(s->floorplane[0] * s->floorplane[0] +
s->floorplane[1] * s->floorplane[1] +
s->floorplane[2] * s->floorplane[2]);
px = coeff*s->floorplane[0]*2 + px;
py = coeff*s->floorplane[1]*2 + py;
pz = coeff*s->floorplane[2]*2 + pz;
// map back from polymer to build
globalposx = -pz;
globalposy = px;
globalposz = -py * 16;
depth++;
polymer_displayrooms(sectnum);
depth--;
globalposx = gx;
globalposy = gy;
globalposz = gz;
bglDisable(GL_CLIP_PLANE0);
bglCullFace(GL_BACK);
//bglEnable(GL_CULL_FACE);
bglMatrixMode(GL_MODELVIEW);
bglPopMatrix();
}
// floor // floor
if (sec->floorstat & 1) if (sec->floorstat & 1)
bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
bglBindTexture(GL_TEXTURE_2D, s->floorglpic); bglBindTexture(GL_TEXTURE_2D, s->floorglpic);
bglColor4f(s->floorcolor[0], s->floorcolor[1], s->floorcolor[2], s->floorcolor[3]); bglColor4f(s->floorcolor[0], s->floorcolor[1], s->floorcolor[2], (!depth) ? 0.5f : s->floorcolor[3]);
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), s->floorbuffer); bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), s->floorbuffer);
bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &s->floorbuffer[3]); bglTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &s->floorbuffer[3]);
bglDrawElements(GL_TRIANGLES, s->indicescount, GL_UNSIGNED_SHORT, s->floorindices); bglDrawElements(GL_TRIANGLES, s->indicescount, GL_UNSIGNED_SHORT, s->floorindices);
@ -1100,13 +1211,14 @@ static void polymer_drawsector(short sectnum)
if (sec->floorstat & 1) if (sec->floorstat & 1)
bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
// if (!depth) if ((depth < 1))
// { {
// //bglEnable(GL_DEPTH_TEST); //bglEnable(GL_DEPTH_TEST);
// bglDisable(GL_STENCIL_TEST); bglDisable(GL_STENCIL_TEST);
// bglClear(GL_STENCIL_BUFFER_BIT); bglClear(GL_STENCIL_BUFFER_BIT);
// } }
ceiling:
// ceiling // ceiling
if (sec->ceilingstat & 1) if (sec->ceilingstat & 1)
bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
@ -1317,7 +1429,7 @@ static void polymer_updatewall(short wallnum)
dist = (xref == 0); dist = (xref == 0);
w->wallbuffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesizx[curpicnum]); w->wallbuffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesizx[curpicnum]);
w->wallbuffer[(i * 5) + 4] = (-(float)(yref + w->wallbuffer[(i * 5) + 1]) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef; w->wallbuffer[(i * 5) + 4] = (-(float)(yref + (w->wallbuffer[(i * 5) + 1] * 16)) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
if (wal->cstat & 256) w->wallbuffer[(i * 5) + 4] = -w->wallbuffer[(i * 5) + 4]; if (wal->cstat & 256) w->wallbuffer[(i * 5) + 4] = -w->wallbuffer[(i * 5) + 4];
@ -1398,7 +1510,7 @@ static void polymer_updatewall(short wallnum)
dist = (xref == 0); dist = (xref == 0);
w->wallbuffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + curxpanning) / (float)(tilesizx[curpicnum]); w->wallbuffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + curxpanning) / (float)(tilesizx[curpicnum]);
w->wallbuffer[(i * 5) + 4] = (-(float)(yref + w->wallbuffer[(i * 5) + 1]) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef; w->wallbuffer[(i * 5) + 4] = (-(float)(yref + (w->wallbuffer[(i * 5) + 1] * 16)) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
if (wal->cstat & 256) w->wallbuffer[(i * 5) + 4] = -w->wallbuffer[(i * 5) + 4]; if (wal->cstat & 256) w->wallbuffer[(i * 5) + 4] = -w->wallbuffer[(i * 5) + 4];
@ -1513,7 +1625,7 @@ static void polymer_updatewall(short wallnum)
dist = (xref == 0); dist = (xref == 0);
w->overbuffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesizx[curpicnum]); w->overbuffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesizx[curpicnum]);
w->overbuffer[(i * 5) + 4] = (-(float)(yref + w->overbuffer[(i * 5) + 1]) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef; w->overbuffer[(i * 5) + 4] = (-(float)(yref + (w->overbuffer[(i * 5) + 1] * 16)) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
if (wal->cstat & 256) w->overbuffer[(i * 5) + 4] = -w->overbuffer[(i * 5) + 4]; if (wal->cstat & 256) w->overbuffer[(i * 5) + 4] = -w->overbuffer[(i * 5) + 4];
@ -1558,7 +1670,7 @@ static void polymer_updatewall(short wallnum)
dist = (xref == 0); dist = (xref == 0);
w->portal[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesizx[curpicnum]); w->portal[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesizx[curpicnum]);
w->portal[(i * 5) + 4] = (-(float)(yref + w->portal[(i * 5) + 1]) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef; w->portal[(i * 5) + 4] = (-(float)(yref + (w->portal[(i * 5) + 1] * 16)) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef;
if (wal->cstat & 256) w->portal[(i * 5) + 4] = -w->portal[(i * 5) + 4]; if (wal->cstat & 256) w->portal[(i * 5) + 4] = -w->portal[(i * 5) + 4];
@ -1642,6 +1754,43 @@ static void polymer_drawwall(short wallnum)
} }
// HSR // HSR
static void polymer_buffertoplane(GLfloat* buffer, GLushort* indices, GLdouble* plane)
{
GLfloat vec1[3], vec2[3];
int i;
i = 0;
do {
vec1[0] = buffer[(indices[i+1]*5) + 0] - buffer[(indices[i+0]*5) + 0];
vec1[1] = buffer[(indices[i+1]*5) + 1] - buffer[(indices[i+0]*5) + 1];
vec1[2] = buffer[(indices[i+1]*5) + 2] - buffer[(indices[i+0]*5) + 2];
vec2[0] = buffer[(indices[i+2]*5) + 0] - buffer[(indices[i+1]*5) + 0];
vec2[1] = buffer[(indices[i+2]*5) + 1] - buffer[(indices[i+1]*5) + 1];
vec2[2] = buffer[(indices[i+2]*5) + 2] - buffer[(indices[i+1]*5) + 2];
polymer_crossproduct(vec2, vec1, plane);
// normalize
vec1[0] = plane[0] * plane[0] + plane[1] * plane[1] + plane[2] * plane[2];
i+= 3;
}
while (vec1[0] == 0);
vec1[0] = sqrt(vec1[0]);
plane[0] /= vec1[0];
plane[1] /= vec1[0];
plane[2] /= vec1[0];
plane[3] = -(plane[0] * buffer[0] + plane[1] * buffer[1] + plane[2] * buffer[2]);
}
static void polymer_crossproduct(GLfloat* in_a, GLfloat* in_b, GLdouble* out)
{
out[0] = in_a[1] * in_b[2] - in_a[2] * in_b[1];
out[1] = in_a[2] * in_b[0] - in_a[0] * in_b[2];
out[2] = in_a[0] * in_b[1] - in_a[1] * in_b[0];
}
static void polymer_pokesector(short sectnum) static void polymer_pokesector(short sectnum)
{ {
sectortype *sec; sectortype *sec;
@ -1726,7 +1875,7 @@ static int polymer_portalinfrustum(short wallnum, float* frustum)
return (1); return (1);
} }
static void polymer_scansprites(short sectnum) static void polymer_scansprites(short sectnum, spritetype* localtsprite, int* localspritesortcnt)
{ {
int i; int i;
spritetype *spr; spritetype *spr;
@ -1736,10 +1885,10 @@ static void polymer_scansprites(short sectnum)
spr = &sprite[i]; spr = &sprite[i];
if ((((spr->cstat&0x8000) == 0) || (showinvisibility)) && if ((((spr->cstat&0x8000) == 0) || (showinvisibility)) &&
(spr->xrepeat > 0) && (spr->yrepeat > 0) && (spr->xrepeat > 0) && (spr->yrepeat > 0) &&
(spritesortcnt < MAXSPRITESONSCREEN)) (*localspritesortcnt < MAXSPRITESONSCREEN))
{ {
copybufbyte(spr,&tsprite[spritesortcnt],sizeof(spritetype)); copybufbyte(spr,&localtsprite[*localspritesortcnt],sizeof(spritetype));
tsprite[spritesortcnt++].owner = i; localtsprite[(*localspritesortcnt)++].owner = i;
} }
} }
} }

View file

@ -66,7 +66,7 @@ Low priority:
**************************************************************************************************/ **************************************************************************************************/
int animateoffs(short tilenum, short fakevar); int animateoffs(short tilenum, short fakevar);
int rendmode = 0; int rendmode=0;
int usemodels=1, usehightile=1; int usemodels=1, usehightile=1;
#include <math.h> //<-important! #include <math.h> //<-important!

View file

@ -939,6 +939,7 @@ int setvideomode(int x, int y, int c, int fs)
{ SDL_GL_DOUBLEBUFFER, 1 }, { SDL_GL_DOUBLEBUFFER, 1 },
{ SDL_GL_MULTISAMPLEBUFFERS, glmultisample > 0 }, { SDL_GL_MULTISAMPLEBUFFERS, glmultisample > 0 },
{ SDL_GL_MULTISAMPLESAMPLES, glmultisample }, { SDL_GL_MULTISAMPLESAMPLES, glmultisample },
{ SDL_GL_STENCIL_SIZE, 1 },
}; };
if (nogl) return -1; if (nogl) return -1;

View file

@ -4000,9 +4000,6 @@ void displayrooms(int snum,int smoothratio)
player_struct *p = g_player[snum].ps; player_struct *p = g_player[snum].ps;
short tang; short tang;
int tiltcx,tiltcy,tiltcs=0; // JBF 20030807 int tiltcx,tiltcy,tiltcs=0; // JBF 20030807
#ifdef POLYMOST
extern int rendmode;
#endif
if (pub > 0 || getrendermode() >= 3) // JBF 20040101: redraw background always if (pub > 0 || getrendermode() >= 3) // JBF 20040101: redraw background always
{ {
@ -4045,6 +4042,8 @@ void displayrooms(int snum,int smoothratio)
#ifdef SE40 #ifdef SE40
se40code(s->x,s->y,s->z,ud.cameraang,s->yvel,smoothratio); se40code(s->x,s->y,s->z,ud.cameraang,s->yvel,smoothratio);
#endif #endif
if (rendmode == 4)
polymer_setanimatesprites(animatesprites, s->x, s->y, ud.cameraang, smoothratio);
drawrooms(s->x,s->y,s->z-(4<<8),ud.cameraang,s->yvel,s->sectnum); drawrooms(s->x,s->y,s->z-(4<<8),ud.cameraang,s->yvel,s->sectnum);
animatesprites(s->x,s->y,ud.cameraang,smoothratio); animatesprites(s->x,s->y,ud.cameraang,smoothratio);
drawmasks(); drawmasks();
@ -4186,7 +4185,7 @@ void displayrooms(int snum,int smoothratio)
#ifdef SE40 #ifdef SE40
se40code(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,smoothratio); se40code(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,smoothratio);
#endif #endif
if ((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0) if (((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0) && (rendmode != 4))
{ {
dst = 0x7fffffff; dst = 0x7fffffff;
i = 0; i = 0;
@ -4217,6 +4216,8 @@ void displayrooms(int snum,int smoothratio)
gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7)); gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7));
} }
if (rendmode == 4)
polymer_setanimatesprites(animatesprites, ud.camerax,ud.cameray,ud.cameraang,smoothratio);
drawrooms(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,ud.camerasect); drawrooms(ud.camerax,ud.cameray,ud.cameraz,ud.cameraang,ud.camerahoriz,ud.camerasect);
animatesprites(ud.camerax,ud.cameray,ud.cameraang,smoothratio); animatesprites(ud.camerax,ud.cameray,ud.cameraang,smoothratio);
drawmasks(); drawmasks();

View file

@ -5561,7 +5561,7 @@ static int parse(void)
se40code(x,y,z,a,horiz,smoothratio); se40code(x,y,z,a,horiz,smoothratio);
#endif #endif
if ((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0) if (((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0) && (rendmode != 4))
{ {
int j, i = 0, k, dst = 0x7fffffff; int j, i = 0, k, dst = 0x7fffffff;
@ -5595,6 +5595,8 @@ static int parse(void)
gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7)); gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7));
} }
if (rendmode == 4)
polymer_setanimatesprites(animatesprites, x,y,a,smoothratio);
drawrooms(x,y,z,a,horiz,sect); drawrooms(x,y,z,a,horiz,sect);
display_mirror = 2; display_mirror = 2;
animatesprites(x,y,a,smoothratio); animatesprites(x,y,a,smoothratio);