Add the 'yoffset' token to model definitions to allow models to compensate for ART tiles with large yoffsets, such as #603. Under normal circumstances the existing 'zadd' parameter should be used instead. Special thanks to Supertanker.

git-svn-id: https://svn.eduke32.com/eduke32@2264 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2012-01-17 04:31:59 +00:00
parent ff94311f13
commit 426ef1494e
5 changed files with 18 additions and 8 deletions

View file

@ -767,7 +767,7 @@ int32_t hicclearsubst(int32_t picnum, int32_t palnum);
int32_t Ptile2tile(int32_t tile, int32_t pallet);
int32_t md_loadmodel(const char *fn);
int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, int32_t flags);
int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, float yoffset, int32_t flags);
// int32_t md_tilehasmodel(int32_t tilenume, int32_t pal);
extern char defsfilename[BMAX_PATH];

View file

@ -9,7 +9,7 @@ typedef struct
{
int32_t mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure!
int32_t shadeoff;
float scale, bscale, zadd;
float scale, bscale, zadd, yoffset;
GLuint *texid; // skins
int32_t flags;
} mdmodel_t;
@ -68,7 +68,7 @@ typedef struct
//WARNING: This top block is a union between md2model&md3model: Make sure it matches!
int32_t mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure!
int32_t shadeoff;
float scale, bscale, zadd;
float scale, bscale, zadd, yoffset;
GLuint *texid; // texture ids for base skin if no mappings defined
int32_t flags;
@ -154,7 +154,7 @@ typedef struct
//WARNING: This top block is a union between md2model&md3model: Make sure it matches!
int32_t mdnum; //VOX=1, MD2=2, MD3=3. NOTE: must be first in structure!
int32_t shadeoff;
float scale, bscale, zadd;
float scale, bscale, zadd, yoffset;
uint32_t *texid; // texture ids for base skin if no mappings defined
int32_t flags;

View file

@ -728,7 +728,7 @@ static int32_t defsparser(scriptfile *script)
initprintf("Warning: Failed loading MD2/MD3 model \"%s\"\n", modelfn);
break;
}
md_setmisc(lastmodelid,(float)scale, shadeoffs,0.0,0);
md_setmisc(lastmodelid,(float)scale, shadeoffs,0.0,0.0,0);
if (glrendmode==4)
md3postload_polymer((md3model_t *)models[lastmodelid]);
#endif
@ -933,7 +933,7 @@ static int32_t defsparser(scriptfile *script)
case T_MODEL:
{
char *modelend, *modelfn;
double scale=1.0, mzadd=0.0;
double scale=1.0, mzadd=0.0, myoffset=0.0;
int32_t shadeoffs=0, pal=0, flags=0;
uint8_t usedframebitmap[1024>>3];
@ -944,6 +944,7 @@ static int32_t defsparser(scriptfile *script)
{ "scale", T_SCALE },
{ "shade", T_SHADE },
{ "zadd", T_ZADD },
{ "yoffset", T_YOFFSET },
{ "frame", T_FRAME },
{ "anim", T_ANIM },
{ "skin", T_SKIN },
@ -983,6 +984,8 @@ static int32_t defsparser(scriptfile *script)
scriptfile_getnumber(script,&shadeoffs); break;
case T_ZADD:
scriptfile_getdouble(script,&mzadd); break;
case T_YOFFSET:
scriptfile_getdouble(script,&myoffset); break;
case T_FLAGS:
scriptfile_getnumber(script,&flags); break;
case T_FRAME:
@ -1344,7 +1347,7 @@ static int32_t defsparser(scriptfile *script)
}
#ifdef USE_OPENGL
md_setmisc(lastmodelid,(float)scale,shadeoffs,(float)mzadd,flags);
md_setmisc(lastmodelid,(float)scale,shadeoffs,(float)mzadd,(float)myoffset,flags);
// thin out the loaded model by throwing away unused frames
// FIXME: CURRENTLY DISABLED: interpolation may access frames we consider 'unused'?

View file

@ -210,7 +210,7 @@ int32_t md_loadmodel(const char *fn)
return(nextmodelid-1);
}
int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, int32_t flags)
int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, float yoffset, int32_t flags)
{
mdmodel_t *m;
@ -221,6 +221,7 @@ int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, i
m->bscale = scale;
m->shadeoff = shadeoff;
m->zadd = zadd;
m->yoffset = yoffset;
m->flags = flags;
return 0;
@ -1948,6 +1949,9 @@ static int32_t md3draw(md3model_t *m, const spritetype *tspr)
}
if (globalorientation&4) { m0.y = -m0.y; m1.y = -m1.y; a0.y = -a0.y; } //x-flipping
// yoffset differs from zadd in that it does not follow cstat&8 y-flipping
a0.z += m->yoffset*m->scale;
f = ((float)tspr->xrepeat)/64*m->bscale;
m0.x *= f; m1.x *= f; a0.x *= f; f = -f; // 20040610: backwards models aren't cool
m0.y *= f; m1.y *= f; a0.y *= f;

View file

@ -3989,6 +3989,9 @@ static void polymer_drawmdsprite(spritetype *tspr)
if ((tspr->cstat & 128) && (((tspr->cstat>>4) & 3) != 2))
bglTranslatef(0.0f, 0.0, -(float)(tilesizy[tspr->picnum] * tspr->yrepeat) / 8.0f);
// yoffset differs from zadd in that it does not follow cstat&8 y-flipping
bglTranslatef(0.0f, 0.0, m->yoffset * 64 * scale * tspr->yrepeat);
if (tspr->cstat & 8)
{
bglTranslatef(0.0f, 0.0, (float)(tilesizy[tspr->picnum] * tspr->yrepeat) / 4.0f);