high precision model loading

This commit is contained in:
Seth Galbraith 2001-12-30 02:30:26 +00:00
parent 94b1683862
commit d570f0905f
7 changed files with 67 additions and 20 deletions

View file

@ -462,12 +462,12 @@ int Mod_CalcFullbright (byte *in, byte *out, int pixels);
int Mod_Fullbright (byte * skin, int width, int height, char *name);
void *Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame);
void *Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame);
void *Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame, int extra);
void *Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame, int extra);
void *Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
qboolean group, maliasskindesc_t *skindesc);
void Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
int _s);
int _s, int extra);
void Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr);
void Mod_SpriteLoadTexture (mspriteframe_t *pspriteframe, int framenum);

View file

@ -126,4 +126,8 @@ typedef struct {
#define IDPOLYHEADER (('O'<<24)+('P'<<16)+('D'<<8)+'I')
// little-endian "IDPO"
// special header indicating 16 bit vertices - little-endian "MD16"
#define POLYHEADER16 (('6'<<24)+('1'<<16)+('D'<<8)+'M')
#endif // _MODELGEN_H

View file

@ -342,7 +342,7 @@ BuildTris (void)
}
void
Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s)
Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s, int extra)
{
int i, j;
int *cmds;
@ -489,11 +489,21 @@ Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s)
paliashdr->commands = (byte *) cmds - (byte *) paliashdr;
memcpy (cmds, commands, numcommands * sizeof (int));
verts = Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts
if (extra)
verts = Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts
* sizeof (trivertx_t) * 2);
else
verts = Hunk_Alloc (paliashdr->numposes * paliashdr->poseverts
* sizeof (trivertx_t));
paliashdr->posedata = (byte *) verts - (byte *) paliashdr;
for (i = 0; i < paliashdr->numposes; i++)
{
for (j = 0; j < numorder; j++)
*verts++ = poseverts[i][vertexorder[j]];
*verts++ = poseverts[i][vertexorder[j]];
if (extra)
for (j = 0; j < numorder; j++)
*verts++ = poseverts[i][vertexorder[j] + hdr->mdl.numverts];
}
}

View file

@ -182,7 +182,7 @@ Mod_LoadSkin (byte * skin, int skinsize, int snum, int gnum, qboolean group,
}
void *
Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame)
Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame, int extra)
{
trivertx_t *pinframe;
int i;
@ -205,13 +205,16 @@ Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame)
poseverts[(*posenum)] = pinframe;
(*posenum)++;
pinframe += pheader->mdl.numverts;
if (extra)
pinframe += pheader->mdl.numverts * 2;
else
pinframe += pheader->mdl.numverts;
return (void *) pinframe;
}
void *
Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame)
Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame, int extra)
{
daliasgroup_t *pingroup;
int i, numframes;
@ -242,7 +245,12 @@ Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame)
for (i = 0; i < numframes; i++) {
poseverts[(*posenum)] = (trivertx_t *) ((daliasframe_t *) ptemp + 1);
(*posenum)++;
ptemp = (trivertx_t *) ((daliasframe_t *) ptemp + 1) + pheader->mdl.numverts;
if (extra)
ptemp = (trivertx_t *) ((daliasframe_t *) ptemp + 1)
+ pheader->mdl.numverts * 2;
else
ptemp = (trivertx_t *) ((daliasframe_t *) ptemp + 1)
+ pheader->mdl.numverts;
}
return ptemp;
}

View file

@ -151,6 +151,11 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
unsigned short crc;
void *mem;
int extra = 0; // extra precision bytes
if (LittleLong (*(unsigned int *) buffer) == POLYHEADER16)
extra = 1; // extra precision bytes
CRC_Init (&crc);
for (len = com_filesize, p = buffer; len; len--, p++)
CRC_ProcessByte (&crc, *p);
@ -253,11 +258,11 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
if (frametype == ALIAS_SINGLE) {
pframetype = (daliasframetype_t *)
Mod_LoadAliasFrame (pframetype + 1, &posenum,
&pheader->frames[i]);
&pheader->frames[i], extra);
} else {
pframetype = (daliasframetype_t *)
Mod_LoadAliasGroup (pframetype + 1, &posenum,
&pheader->frames[i]);
&pheader->frames[i], extra);
}
}
@ -270,7 +275,7 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
mod->maxs[0] = mod->maxs[1] = mod->maxs[2] = 16;
// build the draw lists
Mod_MakeAliasModelDisplayLists (mod, pheader, buffer, com_filesize);
Mod_MakeAliasModelDisplayLists (mod, pheader, buffer, com_filesize, extra);
Mod_FinalizeAliasModel (mod, pheader);

View file

@ -73,7 +73,7 @@ Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
}
void
Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s)
Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s, int extra)
{
int i, j;
stvert_t *pstverts;
@ -104,7 +104,7 @@ Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s)
}
void *
Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame)
Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame, int extra)
{
trivertx_t *pframe, *pinframe;
int i, j;
@ -121,7 +121,12 @@ Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame)
}
pinframe = (trivertx_t *) (pdaliasframe + 1);
pframe = Hunk_AllocName (pheader->mdl.numverts * sizeof (*pframe),
if (extra)
pframe = Hunk_AllocName (pheader->mdl.numverts * sizeof (*pframe) * 2,
loadname);
else
pframe = Hunk_AllocName (pheader->mdl.numverts * sizeof (*pframe),
loadname);
frame->frame = (byte *) pframe - (byte *) pheader;
@ -137,13 +142,27 @@ Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame)
}
}
pinframe += pheader->mdl.numverts;
if (extra)
{
for (j = pheader->mdl.numverts; j < pheader->mdl.numverts * 2; j++)
{
int k;
for (k = 0; k < 3; k++)
pframe[j].v[k] = pinframe[j].v[k];
}
}
if (extra)
pinframe += pheader->mdl.numverts * 2;
else
pinframe += pheader->mdl.numverts;
return (void *) pinframe;
}
void *
Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame)
Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame, int extra)
{
daliasgroup_t *pingroup;
maliasgroup_t *paliasgroup;
@ -187,7 +206,7 @@ Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame)
for (i = 0; i < numframes; i++) {
maliasframedesc_t temp_frame;
ptemp = Mod_LoadAliasFrame (ptemp, &i, &temp_frame);
ptemp = Mod_LoadAliasFrame (ptemp, &i, &temp_frame, extra);
memcpy (&paliasgroup->frames[i], &temp_frame,
sizeof(paliasgroup->frames[i]));
}

View file

@ -215,6 +215,7 @@ Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator)
switch (LittleLong (*(unsigned int *) buf)) {
case IDPOLYHEADER:
case POLYHEADER16:
Mod_LoadAliasModel (mod, buf, allocator);
break;