mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Remove md2draw() and friends
git-svn-id: https://svn.eduke32.com/eduke32@295 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
fe40a9ce85
commit
c1f5d7fd0d
1 changed files with 0 additions and 238 deletions
|
@ -858,32 +858,6 @@ else { if (i >= j) { i -= j; if (i >= j) i %= j; } }
|
|||
}
|
||||
|
||||
//--------------------------------------- MD2 LIBRARY BEGINS ---------------------------------------
|
||||
static void md2free (md2model *m)
|
||||
{
|
||||
mdanim_t *anim, *nanim = NULL;
|
||||
mdskinmap_t *sk, *nsk = NULL;
|
||||
|
||||
if (!m) return;
|
||||
|
||||
for(anim=m->animations; anim; anim=nanim)
|
||||
{
|
||||
nanim = anim->next;
|
||||
free(anim);
|
||||
}
|
||||
for(sk=m->skinmap; sk; sk=nsk)
|
||||
{
|
||||
nsk = sk->next;
|
||||
free(sk->fn);
|
||||
free(sk);
|
||||
}
|
||||
|
||||
if (m->frames) free(m->frames);
|
||||
if (m->glcmds) free(m->glcmds);
|
||||
if (m->basepath) free(m->basepath);
|
||||
if (m->skinfn) free(m->skinfn);
|
||||
|
||||
if (m->texid) free(m->texid);
|
||||
}
|
||||
static long long memoryusage = 0;
|
||||
|
||||
static md2model *md2load (int fil, const char *filnam)
|
||||
|
@ -1092,216 +1066,6 @@ m->basepath = (char *)malloc(i+1); if (!m->basepath) { free(m->uv); free(m->tris
|
|||
|
||||
return((md2model *)m3);
|
||||
}
|
||||
|
||||
static int md2draw (md2model *m, spritetype *tspr)
|
||||
{
|
||||
point3d fp, fp1, fp2, m0, m1, a0, a1;
|
||||
md2frame_t *f0, *f1;
|
||||
unsigned char *c0, *c1;
|
||||
long i, *lptr;
|
||||
float f, g, k0, k1, k2, k3, k4, k5, k6, k7, mat[16], pc[4];
|
||||
|
||||
// if ((tspr->cstat&48) == 32) return 0;
|
||||
|
||||
updateanimation(m,tspr);
|
||||
|
||||
// -------- Unnecessarily clean (lol) code to generate translation/rotation matrix for MD2 ---------
|
||||
|
||||
//create current&next frame's vertex list from whole list
|
||||
f0 = (md2frame_t *)&m->frames[m->cframe*m->framebytes];
|
||||
f1 = (md2frame_t *)&m->frames[m->nframe*m->framebytes];
|
||||
f = m->interpol; g = 1-f;
|
||||
m0.x = f0->mul.x*m->scale*g; m1.x = f1->mul.x*m->scale*f;
|
||||
m0.y = f0->mul.y*m->scale*g; m1.y = f1->mul.y*m->scale*f;
|
||||
m0.z = f0->mul.z*m->scale*g; m1.z = f1->mul.z*m->scale*f;
|
||||
a0.x = f0->add.x*m->scale; a0.x = (f1->add.x*m->scale-a0.x)*f+a0.x;
|
||||
a0.y = f0->add.y*m->scale; a0.y = (f1->add.y*m->scale-a0.y)*f+a0.y;
|
||||
a0.z = f0->add.z*m->scale; a0.z = (f1->add.z*m->scale-a0.z)*f+a0.z + m->zadd*m->scale;
|
||||
c0 = &f0->verts[0].v[0]; c1 = &f1->verts[0].v[0];
|
||||
|
||||
// Parkar: Moved up to be able to use k0 for the y-flipping code
|
||||
k0 = tspr->z;
|
||||
if ((globalorientation&128) && !((globalorientation&48)==32)) k0 += (float)((tilesizy[tspr->picnum]*tspr->yrepeat)<<1);
|
||||
|
||||
// Parkar: Changed to use the same method as centeroriented sprites
|
||||
if (globalorientation&8) //y-flipping
|
||||
{
|
||||
m0.z = -m0.z; m1.z = -m1.z; a0.z = -a0.z;
|
||||
k0 -= (float)((tilesizy[tspr->picnum]*tspr->yrepeat)<<2);
|
||||
}
|
||||
if (globalorientation&4) { m0.y = -m0.y; m1.y = -m1.y; a0.y = -a0.y; } //x-flipping
|
||||
|
||||
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;
|
||||
f = ((float)tspr->yrepeat)/64*m->bscale;
|
||||
m0.z *= f; m1.z *= f; a0.z *= f;
|
||||
|
||||
// floor aligned
|
||||
k1 = tspr->y;
|
||||
if((globalorientation&48)==32)
|
||||
{
|
||||
m0.z = -m0.z; m1.z = -m1.z; a0.z = -a0.z;
|
||||
m0.y = -m0.y; m1.y = -m1.y; a0.y = -a0.y;
|
||||
f = a0.x; a0.x = a0.z; a0.z = f;
|
||||
k1 += (float)((tilesizy[tspr->picnum]*tspr->yrepeat)>>3);
|
||||
}
|
||||
|
||||
f = (65536.0*512.0)/((float)xdimen*viewingrange);
|
||||
g = 32.0/((float)xdimen*gxyaspect);
|
||||
m0.y *= f; m1.y *= f; a0.y = (((float)(tspr->x-globalposx))/ 1024.0 + a0.y)*f;
|
||||
m0.x *=-f; m1.x *=-f; a0.x = (((float)(k1 -globalposy))/ -1024.0 + a0.x)*-f;
|
||||
m0.z *= g; m1.z *= g; a0.z = (((float)(k0 -globalposz))/-16384.0 + a0.z)*g;
|
||||
|
||||
k0 = ((float)(tspr->x-globalposx))*f/1024.0;
|
||||
k1 = ((float)(tspr->y-globalposy))*f/1024.0;
|
||||
f = gcosang2*gshang;
|
||||
g = gsinang2*gshang;
|
||||
k4 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+1024)&2047] / 16384.0;
|
||||
k5 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+ 512)&2047] / 16384.0;
|
||||
k2 = k0*(1-k4)+k1*k5;
|
||||
k3 = k1*(1-k4)-k0*k5;
|
||||
k6 = f*gstang - gsinang*gctang; k7 = g*gstang + gcosang*gctang;
|
||||
mat[0] = k4*k6 + k5*k7; mat[4] = gchang*gstang; mat[ 8] = k4*k7 - k5*k6; mat[12] = k2*k6 + k3*k7;
|
||||
k6 = f*gctang + gsinang*gstang; k7 = g*gctang - gcosang*gstang;
|
||||
mat[1] = k4*k6 + k5*k7; mat[5] = gchang*gctang; mat[ 9] = k4*k7 - k5*k6; mat[13] = k2*k6 + k3*k7;
|
||||
k6 = gcosang2*gchang; k7 = gsinang2*gchang;
|
||||
mat[2] = k4*k6 + k5*k7; mat[6] =-gshang; mat[10] = k4*k7 - k5*k6; mat[14] = k2*k6 + k3*k7;
|
||||
|
||||
mat[12] += a0.y*mat[0] + a0.z*mat[4] + a0.x*mat[ 8];
|
||||
mat[13] += a0.y*mat[1] + a0.z*mat[5] + a0.x*mat[ 9];
|
||||
mat[14] += a0.y*mat[2] + a0.z*mat[6] + a0.x*mat[10];
|
||||
|
||||
// floor aligned
|
||||
if((globalorientation&48)==32)
|
||||
{
|
||||
f = mat[4]; mat[4] = mat[8]*16.0; mat[8] = -f*(1.0/16.0);
|
||||
f = mat[5]; mat[5] = mat[9]*16.0; mat[9] = -f*(1.0/16.0);
|
||||
f = mat[6]; mat[6] = mat[10]*16.0; mat[10] = -f*(1.0/16.0);
|
||||
}
|
||||
|
||||
//Mirrors
|
||||
if (grhalfxdown10x < 0) { mat[0] = -mat[0]; mat[4] = -mat[4]; mat[8] = -mat[8]; mat[12] = -mat[12]; }
|
||||
|
||||
// ------ Unnecessarily clean (lol) code to generate translation/rotation matrix for MD2 ends ------
|
||||
|
||||
// PLAG: Cleaner model rotation code
|
||||
if (spriteext[tspr->owner].pitch || spriteext[tspr->owner].roll)
|
||||
{
|
||||
if (spriteext[tspr->owner].xoff)
|
||||
a0.x = (int)(spriteext[tspr->owner].xoff / (2048 * (m0.x+m1.x)));
|
||||
else
|
||||
a0.x = 0;
|
||||
if (spriteext[tspr->owner].yoff)
|
||||
a0.y = (int)(spriteext[tspr->owner].yoff / (2048 * (m0.y+m1.y)));
|
||||
else
|
||||
a0.y = 0;
|
||||
if ((spriteext[tspr->owner].zoff) && !(tspr->cstat&1024))
|
||||
a0.z = (int)(spriteext[tspr->owner].zoff / (524288 * (m0.z+m1.z)));
|
||||
else
|
||||
a0.z = 0;
|
||||
k0 = (float)sintable[(spriteext[tspr->owner].pitch+512)&2047] / 16384.0;
|
||||
k1 = (float)sintable[spriteext[tspr->owner].pitch&2047] / 16384.0;
|
||||
k2 = (float)sintable[(spriteext[tspr->owner].roll+512)&2047] / 16384.0;
|
||||
k3 = (float)sintable[spriteext[tspr->owner].roll&2047] / 16384.0;
|
||||
}
|
||||
for(i=m->numverts-1;i>=0;i--)
|
||||
{
|
||||
if (spriteext[tspr->owner].pitch || spriteext[tspr->owner].roll)
|
||||
{
|
||||
fp.z = c0[(i<<2)+0] + a0.x;
|
||||
fp.x = c0[(i<<2)+1] + a0.y;
|
||||
fp.y = c0[(i<<2)+2] + a0.z;
|
||||
fp1.x = fp.x*k2 + fp.y*k3;
|
||||
fp1.y = fp.x*k0*(-k3) + fp.y*k0*k2 + fp.z*(-k1);
|
||||
fp1.z = fp.x*k1*(-k3) + fp.y*k1*k2 + fp.z*k0;
|
||||
fp.z = c1[(i<<2)+0] + a0.x;
|
||||
fp.x = c1[(i<<2)+1] + a0.y;
|
||||
fp2.y = c1[(i<<2)+2] + a0.z;
|
||||
fp2.x = fp.x*k2 + fp.y*k3;
|
||||
fp2.y = fp.x*k0*(-k3) + fp.y*k0*k2 + fp.z*(-k1);
|
||||
fp2.z = fp.x*k1*(-k3) + fp.y*k1*k2 + fp.z*k0;
|
||||
fp.z = (fp1.z - a0.x)*m0.x + (fp2.z - a0.x)*m1.x;
|
||||
fp.x = (fp1.x - a0.y)*m0.y + (fp2.x - a0.y)*m1.y;
|
||||
fp.y = (fp1.y - a0.z)*m0.z + (fp2.y - a0.z)*m1.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
fp.z = c0[(i<<2)+0]*m0.x + c1[(i<<2)+0]*m1.x;
|
||||
fp.y = c0[(i<<2)+2]*m0.z + c1[(i<<2)+2]*m1.z;
|
||||
fp.x = c0[(i<<2)+1]*m0.y + c1[(i<<2)+1]*m1.y;
|
||||
}
|
||||
vertlist[i].x = fp.x;
|
||||
vertlist[i].y = fp.y;
|
||||
vertlist[i].z = fp.z;
|
||||
}
|
||||
bglMatrixMode(GL_MODELVIEW); //Let OpenGL (and perhaps hardware :) handle the matrix rotation
|
||||
mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f; bglLoadMatrixf(mat);
|
||||
// PLAG: End
|
||||
|
||||
i = mdloadskin(m,tile2model[tspr->picnum].skinnum,globalpal,0); if (!i) return 0;
|
||||
|
||||
//bit 10 is an ugly hack in game.c\animatesprites telling MD2SPRITE
|
||||
//to use Z-buffer hacks to hide overdraw problems with the shadows
|
||||
if (tspr->cstat&1024)
|
||||
{
|
||||
bglDepthFunc(GL_LESS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
|
||||
bglDepthRange(0.0,0.9999);
|
||||
}
|
||||
bglPushAttrib(GL_POLYGON_BIT);
|
||||
if ((grhalfxdown10x >= 0) ^ ((globalorientation&8) != 0) ^ ((globalorientation&4) != 0)) bglFrontFace(GL_CW); else bglFrontFace(GL_CCW);
|
||||
bglEnable(GL_CULL_FACE);
|
||||
bglCullFace(GL_BACK);
|
||||
|
||||
bglEnable(GL_TEXTURE_2D);
|
||||
bglBindTexture(GL_TEXTURE_2D, i);
|
||||
|
||||
pc[0] = pc[1] = pc[2] = ((float)(numpalookups-min(max(globalshade+m->shadeoff,0),numpalookups)))/((float)numpalookups);
|
||||
pc[0] *= (float)hictinting[globalpal].r / 255.0;
|
||||
pc[1] *= (float)hictinting[globalpal].g / 255.0;
|
||||
pc[2] *= (float)hictinting[globalpal].b / 255.0;
|
||||
if (tspr->cstat&2) { if (!(tspr->cstat&512)) pc[3] = 0.66; else pc[3] = 0.33; } else pc[3] = 1.0;
|
||||
if (m->usesalpha) //Sprites with alpha in texture
|
||||
{
|
||||
// bglEnable(GL_BLEND);// bglBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||
// bglEnable(GL_ALPHA_TEST); bglAlphaFunc(GL_GREATER,0.32);
|
||||
float al = 0.32;
|
||||
if (alphahackarray[globalpicnum] != 0)
|
||||
al=alphahackarray[globalpicnum];
|
||||
bglEnable(GL_BLEND);
|
||||
bglEnable(GL_ALPHA_TEST);
|
||||
bglAlphaFunc(GL_GREATER,al);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tspr->cstat&2) bglEnable(GL_BLEND); else bglDisable(GL_BLEND);
|
||||
}
|
||||
bglColor4f(pc[0],pc[1],pc[2],pc[3]);
|
||||
|
||||
for(lptr=m->glcmds;(i=*lptr++);)
|
||||
{
|
||||
if (i < 0) { bglBegin(GL_TRIANGLE_FAN); i = -i; }
|
||||
else { bglBegin(GL_TRIANGLE_STRIP); }
|
||||
for(;i>0;i--,lptr+=3)
|
||||
{
|
||||
bglTexCoord2f(((float *)lptr)[0],((float *)lptr)[1]);
|
||||
bglVertex3fv((float *)&vertlist[lptr[2]]);
|
||||
}
|
||||
bglEnd();
|
||||
}
|
||||
|
||||
if (m->usesalpha) bglDisable(GL_ALPHA_TEST);
|
||||
bglDisable(GL_CULL_FACE);
|
||||
bglPopAttrib();
|
||||
if (tspr->cstat&1024)
|
||||
{
|
||||
bglDepthFunc(GL_LEQUAL); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
|
||||
bglDepthRange(0.0,0.99999);
|
||||
}
|
||||
bglLoadIdentity();
|
||||
|
||||
return 1;
|
||||
}
|
||||
//---------------------------------------- MD2 LIBRARY ENDS ----------------------------------------
|
||||
|
||||
// DICHOTOMIC RECURSIVE SORTING - USED BY MD3DRAW - MAY PUT IT IN ITS OWN SOURCE FILE LATER
|
||||
|
@ -2708,7 +2472,6 @@ int mddraw (spritetype *tspr)
|
|||
|
||||
vm = models[tile2model[tspr->picnum].modelid];
|
||||
if (vm->mdnum == 1) { return voxdraw((voxmodel *)vm,tspr); }
|
||||
if (vm->mdnum == 2) { return md2draw((md2model *)vm,tspr); }
|
||||
if (vm->mdnum == 3) { return md3draw((md3model *)vm,tspr); }
|
||||
return 0;
|
||||
}
|
||||
|
@ -2716,7 +2479,6 @@ int mddraw (spritetype *tspr)
|
|||
void mdfree (mdmodel *vm)
|
||||
{
|
||||
if (vm->mdnum == 1) { voxfree((voxmodel *)vm); return; }
|
||||
if (vm->mdnum == 2) { md2free((md2model *)vm); return; }
|
||||
if (vm->mdnum == 3) { md3free((md3model *)vm); return; }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue