Added xscale and yscale DEF tokens to texture blocks to control the size ratio with the ART.

git-svn-id: https://svn.eduke32.com/eduke32@504 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
Plagman 2007-02-17 02:23:50 +00:00
parent 8c462256c0
commit 6440b48ec8
6 changed files with 43 additions and 24 deletions

View file

@ -504,7 +504,7 @@ void hicinit(void);
// effect bitset: 1 = greyscale, 2 = invert // effect bitset: 1 = greyscale, 2 = invert
void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect); void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect);
// flags bitset: 1 = don't compress // flags bitset: 1 = don't compress
int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, char flags); int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, float xscale, float yscale, char flags);
int hicsetskybox(long picnum, long palnum, char *faces[6]); int hicsetskybox(long picnum, long palnum, char *faces[6]);
int hicclearsubst(long picnum, long palnum); int hicclearsubst(long picnum, long palnum);

View file

@ -12,7 +12,7 @@ typedef struct hicreplc_t {
struct hicreplc_t *next; struct hicreplc_t *next;
char palnum, ignore, flags, filler; char palnum, ignore, flags, filler;
char *filename; char *filename;
float alphacut; float alphacut, xscale, yscale;
struct hicskybox_t *skybox; struct hicskybox_t *skybox;
} hicreplctyp; } hicreplctyp;

View file

@ -58,7 +58,7 @@ enum {
T_SKYBOX, T_SKYBOX,
T_FRONT,T_RIGHT,T_BACK,T_LEFT,T_TOP,T_BOTTOM, T_FRONT,T_RIGHT,T_BACK,T_LEFT,T_TOP,T_BOTTOM,
T_TINT,T_RED,T_GREEN,T_BLUE, T_TINT,T_RED,T_GREEN,T_BLUE,
T_TEXTURE,T_ALPHACUT,T_NOCOMPRESS, T_TEXTURE,T_ALPHACUT,T_XSCALE,T_YSCALE,T_NOCOMPRESS,
T_UNDEFMODEL,T_UNDEFMODELRANGE,T_UNDEFMODELOF,T_UNDEFTEXTURE,T_UNDEFTEXTURERANGE, T_UNDEFMODEL,T_UNDEFMODELRANGE,T_UNDEFMODELOF,T_UNDEFTEXTURE,T_UNDEFTEXTURERANGE,
T_ALPHAHACK,T_ALPHAHACKRANGE, T_ALPHAHACK,T_ALPHAHACKRANGE,
T_SPRITECOL,T_2DCOL, T_SPRITECOL,T_2DCOL,
@ -197,9 +197,11 @@ static tokenlist texturetokens[] = {
{ "glow", T_GLOW }, { "glow", T_GLOW },
}; };
static tokenlist texturetokens_pal[] = { static tokenlist texturetokens_pal[] = {
{ "file", T_FILE },{ "name", T_FILE }, { "file", T_FILE },{ "name", T_FILE },
{ "alphacut", T_ALPHACUT }, { "detailscale", T_ALPHACUT }, { "scale", T_ALPHACUT }, { "intensity", T_ALPHACUT }, { "alphacut", T_ALPHACUT },
{ "nocompress",T_NOCOMPRESS }, { "detailscale", T_XSCALE }, { "scale", T_XSCALE }, { "xscale", T_XSCALE }, { "intensity", T_XSCALE },
{ "yscale", T_YSCALE },
{ "nocompress", T_NOCOMPRESS },
}; };
static int getatoken(scriptfile *sf, tokenlist *tl, int ntokens) static int getatoken(scriptfile *sf, tokenlist *tl, int ntokens)
@ -296,7 +298,7 @@ static int defsparser(scriptfile *script)
break; break;
} else kclose(i); } else kclose(i);
hicsetsubsttex(tile,pal,fn,-1.0,0); hicsetsubsttex(tile,pal,fn,-1.0,1.0,1.0,0);
} }
break; break;
case T_DEFINESKYBOX: case T_DEFINESKYBOX:
@ -1110,7 +1112,7 @@ static int defsparser(scriptfile *script)
char *paltokptr = script->ltextptr, *palend; char *paltokptr = script->ltextptr, *palend;
int pal=-1, i; int pal=-1, i;
char *fn = NULL; char *fn = NULL;
double alphacut = -1.0; double alphacut = -1.0, xscale = 1.0, yscale = 1.0;
char flags = 0; char flags = 0;
if (scriptfile_getsymbol(script,&pal)) break; if (scriptfile_getsymbol(script,&pal)) break;
@ -1121,6 +1123,10 @@ static int defsparser(scriptfile *script)
scriptfile_getstring(script,&fn); break; scriptfile_getstring(script,&fn); break;
case T_ALPHACUT: case T_ALPHACUT:
scriptfile_getdouble(script,&alphacut); break; scriptfile_getdouble(script,&alphacut); break;
case T_XSCALE:
scriptfile_getdouble(script,&xscale); break;
case T_YSCALE:
scriptfile_getdouble(script,&yscale); break;
case T_NOCOMPRESS: case T_NOCOMPRESS:
flags |= 1; break; flags |= 1; break;
default: default:
@ -1144,7 +1150,10 @@ static int defsparser(scriptfile *script)
break; break;
} else kclose(i); } else kclose(i);
hicsetsubsttex(tile,pal,fn,alphacut,flags); xscale = 1.0f / xscale;
yscale = 1.0f / yscale;
hicsetsubsttex(tile,pal,fn,alphacut,xscale,yscale,flags);
} break; } break;
case T_DETAIL: case T_GLOW: { case T_DETAIL: case T_GLOW: {
char *detailtokptr = script->ltextptr, *detailend; char *detailtokptr = script->ltextptr, *detailend;
@ -1158,7 +1167,7 @@ static int defsparser(scriptfile *script)
switch (getatoken(script,texturetokens_pal,sizeof(texturetokens_pal)/sizeof(tokenlist))) { switch (getatoken(script,texturetokens_pal,sizeof(texturetokens_pal)/sizeof(tokenlist))) {
case T_FILE: case T_FILE:
scriptfile_getstring(script,&fn); break; scriptfile_getstring(script,&fn); break;
case T_ALPHACUT: case T_XSCALE:
scriptfile_getdouble(script,&param); break; scriptfile_getdouble(script,&param); break;
case T_NOCOMPRESS: case T_NOCOMPRESS:
flags |= 1; break; flags |= 1; break;
@ -1186,7 +1195,7 @@ static int defsparser(scriptfile *script)
else if (token == T_GLOW) else if (token == T_GLOW)
pal = GLOWPAL; pal = GLOWPAL;
hicsetsubsttex(tile,pal,fn,param,flags); hicsetsubsttex(tile,pal,fn,-1.0,param,1.0,flags);
} break; } break;
default: default:
break; break;

View file

@ -690,7 +690,7 @@ static void scansector(short sectnum);
#include "polymost.c" #include "polymost.c"
#else #else
void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect) { } void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect) { }
int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, char flags) { return 0; } int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, float xscale, float yscale, char flags) { return 0; }
int hicsetskybox(long picnum, long palnum, char *faces[6]) { return 0; } int hicsetskybox(long picnum, long palnum, char *faces[6]) { return 0; }
int hicclearsubst(long picnum, long palnum) { return 0; } int hicclearsubst(long picnum, long palnum) { return 0; }
long polymost_drawtilescreen (long tilex, long tiley, long wallnum, long dimen) { return -1; } long polymost_drawtilescreen (long tilex, long tiley, long wallnum, long dimen) { return -1; }

View file

@ -115,7 +115,7 @@ void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned c
// hicsetsubsttex(picnum,pal,filen,alphacut) // hicsetsubsttex(picnum,pal,filen,alphacut)
// Specifies a replacement graphic file for an ART tile. // Specifies a replacement graphic file for an ART tile.
// //
int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, char flags) int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, float xscale, float yscale, char flags)
{ {
hicreplctyp *hr, *hrn; hicreplctyp *hr, *hrn;
@ -145,10 +145,9 @@ int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, char f
return -1; return -1;
} }
hrn->ignore = 0; hrn->ignore = 0;
if (palnum < (MAXPALOOKUPS - RESERVEDPALS)) hrn->alphacut = min(alphacut,1.0);
hrn->alphacut = min(alphacut,1.0); hrn->xscale = xscale;
else hrn->yscale = yscale;
hrn->alphacut = alphacut;
hrn->flags = flags; hrn->flags = flags;
if (hr == NULL) { if (hr == NULL) {
hrn->next = hicreplc[picnum]; hrn->next = hicreplc[picnum];

View file

@ -1649,6 +1649,16 @@ void drawpoly (double *dpx, double *dpy, long n, long method)
bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0); bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0);
// texture scale by parkar request
if (pth && pth->hicr && ((pth->hicr->xscale != 1.0f) || (pth->hicr->yscale != 1.0f)))
{
bglMatrixMode(GL_TEXTURE);
bglLoadIdentity();
bglScalef(pth->hicr->xscale, pth->hicr->yscale, 1.0f);
bglMatrixMode(GL_MODELVIEW);
}
// detail texture
detailpth = NULL; detailpth = NULL;
if (r_detailmapping && usehightile && !r_depthpeeling && !drawingskybox && if (r_detailmapping && usehightile && !r_depthpeeling && !drawingskybox &&
hicfindsubst(globalpicnum, DETAILPAL, 0)) hicfindsubst(globalpicnum, DETAILPAL, 0))
@ -1680,7 +1690,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method)
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
f = detailpth ? detailpth->hicr->alphacut : 1.0; f = detailpth ? detailpth->hicr->xscale : 1.0;
bglMatrixMode(GL_TEXTURE); bglMatrixMode(GL_TEXTURE);
bglLoadIdentity(); bglLoadIdentity();
@ -1690,6 +1700,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method)
else else
detailpth = NULL; detailpth = NULL;
// glow texture
glowpth = NULL; glowpth = NULL;
if (r_glowmapping && usehightile && !r_depthpeeling && !drawingskybox && if (r_glowmapping && usehightile && !r_depthpeeling && !drawingskybox &&
hicfindsubst(globalpicnum, GLOWPAL, 0)) hicfindsubst(globalpicnum, GLOWPAL, 0))
@ -1952,17 +1963,17 @@ void drawpoly (double *dpx, double *dpy, long n, long method)
bglEnd(); bglEnd();
} }
if (texunits > GL_TEXTURE0_ARB) while (texunits >= GL_TEXTURE0_ARB)
{ {
while (texunits > GL_TEXTURE0_ARB) bglMatrixMode(GL_TEXTURE);
bglLoadIdentity();
bglMatrixMode(GL_MODELVIEW);
if (texunits > GL_TEXTURE0_ARB)
{ {
bglMatrixMode(GL_TEXTURE);
bglLoadIdentity();
bglMatrixMode(GL_MODELVIEW);
bglTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0f); bglTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0f);
bglDisable(GL_TEXTURE_2D); bglDisable(GL_TEXTURE_2D);
bglActiveTextureARB(--texunits);
} }
bglActiveTextureARB(--texunits);
} }
if (fullbrightdrawingpass == 1) // tile has fullbright colors ? if (fullbrightdrawingpass == 1) // tile has fullbright colors ?