mdl version 3 support, misc fixes
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2104 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
d5f4940c7c
commit
baad7f5422
4 changed files with 175 additions and 18 deletions
|
@ -43,6 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ALIAS_VERSION 6
|
#define ALIAS_VERSION 6
|
||||||
|
#define QTESTALIAS_VERSION 3
|
||||||
|
|
||||||
#define ALIAS_ONSEAM 0x0020
|
#define ALIAS_ONSEAM 0x0020
|
||||||
|
|
||||||
|
@ -132,6 +133,12 @@ typedef struct {
|
||||||
char name[16]; // frame name from grabbing
|
char name[16]; // frame name from grabbing
|
||||||
} daliasframe_t;
|
} daliasframe_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
dtrivertx_t bboxmin; // lightnormal isn't used
|
||||||
|
dtrivertx_t bboxmax; // lightnormal isn't used
|
||||||
|
// no name[16]!
|
||||||
|
} qtestaliasframe_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int numframes;
|
int numframes;
|
||||||
dtrivertx_t bboxmin; // lightnormal isn't used
|
dtrivertx_t bboxmin; // lightnormal isn't used
|
||||||
|
|
|
@ -2965,6 +2965,68 @@ static galiasinfo_t *galias;
|
||||||
static dmdl_t *pq1inmodel;
|
static dmdl_t *pq1inmodel;
|
||||||
#define NUMVERTEXNORMALS 162
|
#define NUMVERTEXNORMALS 162
|
||||||
extern float r_avertexnormals[NUMVERTEXNORMALS][3];
|
extern float r_avertexnormals[NUMVERTEXNORMALS][3];
|
||||||
|
static void *QTest_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps)
|
||||||
|
{
|
||||||
|
galiaspose_t *pose;
|
||||||
|
galiasgroup_t *frame;
|
||||||
|
dtrivertx_t *pinframe;
|
||||||
|
qtestaliasframe_t *frameinfo;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
vec3_t *normals;
|
||||||
|
vec3_t *verts;
|
||||||
|
|
||||||
|
frame = (galiasgroup_t*)((char *)galias + galias->groupofs);
|
||||||
|
|
||||||
|
for (i = 0; i < pq1inmodel->numframes; i++)
|
||||||
|
{
|
||||||
|
switch(LittleLong(pframetype->type))
|
||||||
|
{
|
||||||
|
case ALIAS_SINGLE:
|
||||||
|
frameinfo = (qtestaliasframe_t*)((char *)(pframetype+1));
|
||||||
|
pinframe = (dtrivertx_t*)((char*)frameinfo+sizeof(qtestaliasframe_t));
|
||||||
|
pose = (galiaspose_t *)Hunk_Alloc(sizeof(galiaspose_t) + sizeof(vec3_t)*2*galias->numverts);
|
||||||
|
frame->poseofs = (char *)pose - (char *)frame;
|
||||||
|
frame->numposes = 1;
|
||||||
|
galias->groups++;
|
||||||
|
|
||||||
|
frame->name[0] = '\0';
|
||||||
|
|
||||||
|
verts = (vec3_t *)(pose+1);
|
||||||
|
normals = &verts[galias->numverts];
|
||||||
|
pose->ofsverts = (char *)verts - (char *)pose;
|
||||||
|
#ifndef SERVERONLY
|
||||||
|
pose->ofsnormals = (char *)normals - (char *)pose;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (j = 0; j < pq1inmodel->numverts; j++)
|
||||||
|
{
|
||||||
|
verts[j][0] = pinframe[j].v[0]*pq1inmodel->scale[0]+pq1inmodel->scale_origin[0];
|
||||||
|
verts[j][1] = pinframe[j].v[1]*pq1inmodel->scale[1]+pq1inmodel->scale_origin[1];
|
||||||
|
verts[j][2] = pinframe[j].v[2]*pq1inmodel->scale[2]+pq1inmodel->scale_origin[2];
|
||||||
|
#ifndef SERVERONLY
|
||||||
|
VectorCopy(r_avertexnormals[pinframe[j].lightnormalindex], normals[j]);
|
||||||
|
#endif
|
||||||
|
if (seamremaps[j] != j)
|
||||||
|
{
|
||||||
|
VectorCopy(verts[j], verts[seamremaps[j]]);
|
||||||
|
VectorCopy(normals[j], normals[seamremaps[j]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GL_GenerateNormals((float*)verts, (float*)normals, (int *)((char *)galias + galias->ofs_indexes), galias->numindexes/3, galias->numverts);
|
||||||
|
|
||||||
|
pframetype = (daliasframetype_t *)&pinframe[pq1inmodel->numverts];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Con_Printf(S_ERROR "Bad frame type for QTest model in %s\n", loadmodel->name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
frame++;
|
||||||
|
}
|
||||||
|
return pframetype;
|
||||||
|
}
|
||||||
|
|
||||||
static void *Q1_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps)
|
static void *Q1_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps)
|
||||||
{
|
{
|
||||||
galiaspose_t *pose;
|
galiaspose_t *pose;
|
||||||
|
@ -3329,6 +3391,7 @@ qboolean GL_LoadQ1Model (model_t *mod, void *buffer)
|
||||||
dtriangle_t *pintriangles;
|
dtriangle_t *pintriangles;
|
||||||
int *seamremap;
|
int *seamremap;
|
||||||
index_t *indexes;
|
index_t *indexes;
|
||||||
|
qboolean qtest = false;
|
||||||
|
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
|
@ -3340,18 +3403,26 @@ qboolean GL_LoadQ1Model (model_t *mod, void *buffer)
|
||||||
|
|
||||||
pq1inmodel = (dmdl_t *)buffer;
|
pq1inmodel = (dmdl_t *)buffer;
|
||||||
|
|
||||||
seamremap = (int*)pq1inmodel; //I like overloading locals.
|
|
||||||
for (i = 0; i < sizeof(dmdl_t)/4; i++)
|
|
||||||
seamremap[i] = LittleLong(seamremap[i]);
|
|
||||||
|
|
||||||
version = pq1inmodel->version;
|
version = pq1inmodel->version;
|
||||||
if (version != ALIAS_VERSION)
|
if (version == QTESTALIAS_VERSION)
|
||||||
|
qtest = true;
|
||||||
|
else if (version != ALIAS_VERSION)
|
||||||
{
|
{
|
||||||
Con_Printf (S_ERROR "%s has wrong version number (%i should be %i)\n",
|
Con_Printf (S_ERROR "%s has wrong version number (%i should be %i)\n",
|
||||||
mod->name, version, ALIAS_VERSION);
|
mod->name, version, ALIAS_VERSION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
seamremap = (int*)pq1inmodel; //I like overloading locals.
|
||||||
|
|
||||||
|
if (qtest)
|
||||||
|
i = sizeof(dmdl_t)/4 - sizeof(int)*2 - 1;
|
||||||
|
else
|
||||||
|
i = sizeof(dmdl_t)/4 - 1;
|
||||||
|
|
||||||
|
for (; i >= 0; i--)
|
||||||
|
seamremap[i] = LittleLong(seamremap[i]);
|
||||||
|
|
||||||
if (pq1inmodel->numframes < 1 ||
|
if (pq1inmodel->numframes < 1 ||
|
||||||
pq1inmodel->numskins < 1 ||
|
pq1inmodel->numskins < 1 ||
|
||||||
pq1inmodel->numtris < 1 ||
|
pq1inmodel->numtris < 1 ||
|
||||||
|
@ -3363,7 +3434,10 @@ qboolean GL_LoadQ1Model (model_t *mod, void *buffer)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mod->flags = pq1inmodel->flags;
|
if (qtest)
|
||||||
|
mod->flags = 0; // Qtest has no flags in header
|
||||||
|
else
|
||||||
|
mod->flags = pq1inmodel->flags;
|
||||||
|
|
||||||
size = sizeof(galiasinfo_t)
|
size = sizeof(galiasinfo_t)
|
||||||
#ifndef SERVERONLY
|
#ifndef SERVERONLY
|
||||||
|
@ -3379,7 +3453,9 @@ qboolean GL_LoadQ1Model (model_t *mod, void *buffer)
|
||||||
galias->nextsurf = 0;
|
galias->nextsurf = 0;
|
||||||
|
|
||||||
//skins
|
//skins
|
||||||
if( mod->flags & EF_HOLEY )
|
if (qtest)
|
||||||
|
pinstverts = (dstvert_t *)Q1_LoadSkins((daliasskintype_t *)((char *)buffer + sizeof(dmdl_t) - sizeof(int)*2), 0);
|
||||||
|
else if( mod->flags & EF_HOLEY )
|
||||||
pinstverts = (dstvert_t *)Q1_LoadSkins((daliasskintype_t *)(pq1inmodel+1), 3);
|
pinstverts = (dstvert_t *)Q1_LoadSkins((daliasskintype_t *)(pq1inmodel+1), 3);
|
||||||
else if( mod->flags & EF_TRANSPARENT )
|
else if( mod->flags & EF_TRANSPARENT )
|
||||||
pinstverts = (dstvert_t *)Q1_LoadSkins((daliasskintype_t *)(pq1inmodel+1), 2);
|
pinstverts = (dstvert_t *)Q1_LoadSkins((daliasskintype_t *)(pq1inmodel+1), 2);
|
||||||
|
@ -3444,11 +3520,23 @@ qboolean GL_LoadQ1Model (model_t *mod, void *buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
//frames
|
//frames
|
||||||
if (Q1_LoadFrameGroup((daliasframetype_t *)&pintriangles[pq1inmodel->numtris], seamremap) == NULL)
|
if (qtest)
|
||||||
{
|
{
|
||||||
BZ_Free(seamremap);
|
if (QTest_LoadFrameGroup((daliasframetype_t *)&pintriangles[pq1inmodel->numtris], seamremap) == NULL)
|
||||||
Hunk_FreeToLowMark (hunkstart);
|
{
|
||||||
return false;
|
BZ_Free(seamremap);
|
||||||
|
Hunk_FreeToLowMark (hunkstart);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Q1_LoadFrameGroup((daliasframetype_t *)&pintriangles[pq1inmodel->numtris], seamremap) == NULL)
|
||||||
|
{
|
||||||
|
BZ_Free(seamremap);
|
||||||
|
Hunk_FreeToLowMark (hunkstart);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
BZ_Free(seamremap);
|
BZ_Free(seamremap);
|
||||||
|
|
||||||
|
|
|
@ -415,7 +415,6 @@ palremap_t *D_GetPaletteRemap(int red, int green, int blue, qboolean desaturate,
|
||||||
|
|
||||||
palremap_t *RebuildMenuTint(void)
|
palremap_t *RebuildMenuTint(void)
|
||||||
{
|
{
|
||||||
char *t;
|
|
||||||
vec3_t rgb;
|
vec3_t rgb;
|
||||||
|
|
||||||
if (r_menutint.string[0])
|
if (r_menutint.string[0])
|
||||||
|
|
|
@ -2144,6 +2144,48 @@ ALIAS MODELS
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void * SWMod_LoadAliasQTestFrame (void * pin, int *pframeindex, int numv,
|
||||||
|
dtrivertx_t *pbboxmin, dtrivertx_t *pbboxmax, aliashdr_t *pheader, char *name)
|
||||||
|
{
|
||||||
|
dtrivertx_t *pframe, *pinframe;
|
||||||
|
int i, j;
|
||||||
|
qtestaliasframe_t *pdaliasframe;
|
||||||
|
|
||||||
|
pdaliasframe = (qtestaliasframe_t *)pin;
|
||||||
|
|
||||||
|
name[0] = '\0';
|
||||||
|
|
||||||
|
for (i=0 ; i<3 ; i++)
|
||||||
|
{
|
||||||
|
// these are byte values, so we don't have to worry about
|
||||||
|
// endianness
|
||||||
|
pbboxmin->v[i] = pdaliasframe->bboxmin.v[i];
|
||||||
|
pbboxmax->v[i] = pdaliasframe->bboxmax.v[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
pinframe = (dtrivertx_t *)(pdaliasframe + 1);
|
||||||
|
pframe = Hunk_AllocName (numv * sizeof(*pframe), loadname);
|
||||||
|
|
||||||
|
*pframeindex = (qbyte *)pframe - (qbyte *)pheader;
|
||||||
|
|
||||||
|
for (j=0 ; j<numv ; j++)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
|
||||||
|
// these are all byte values, so no need to deal with endianness
|
||||||
|
pframe[j].lightnormalindex = pinframe[j].lightnormalindex;
|
||||||
|
|
||||||
|
for (k=0 ; k<3 ; k++)
|
||||||
|
{
|
||||||
|
pframe[j].v[k] = pinframe[j].v[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pinframe += numv;
|
||||||
|
|
||||||
|
return (void *)pinframe;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
Mod_LoadAliasFrame
|
Mod_LoadAliasFrame
|
||||||
|
@ -2382,6 +2424,7 @@ qboolean SWMod_LoadAliasModel (model_t *mod, void *buffer)
|
||||||
maliasskindesc_t *pskindesc;
|
maliasskindesc_t *pskindesc;
|
||||||
int skinsize;
|
int skinsize;
|
||||||
int start, end, total;
|
int start, end, total;
|
||||||
|
qboolean qtest = false;
|
||||||
|
|
||||||
if (loadmodel->engineflags & MDLF_DOCRC)
|
if (loadmodel->engineflags & MDLF_DOCRC)
|
||||||
{
|
{
|
||||||
|
@ -2412,7 +2455,9 @@ qboolean SWMod_LoadAliasModel (model_t *mod, void *buffer)
|
||||||
pinmodel = (dmdl_t *)buffer;
|
pinmodel = (dmdl_t *)buffer;
|
||||||
|
|
||||||
version = LittleLong (pinmodel->version);
|
version = LittleLong (pinmodel->version);
|
||||||
if (version != ALIAS_VERSION)
|
if (version == QTESTALIAS_VERSION)
|
||||||
|
qtest = true;
|
||||||
|
else if (version != ALIAS_VERSION)
|
||||||
{
|
{
|
||||||
Con_Printf (S_ERROR "%s has wrong version number (%i should be %i)\n",
|
Con_Printf (S_ERROR "%s has wrong version number (%i should be %i)\n",
|
||||||
mod->name, version, ALIAS_VERSION);
|
mod->name, version, ALIAS_VERSION);
|
||||||
|
@ -2435,7 +2480,10 @@ qboolean SWMod_LoadAliasModel (model_t *mod, void *buffer)
|
||||||
sizeof (pheader->frames[0]));
|
sizeof (pheader->frames[0]));
|
||||||
|
|
||||||
// mod->cache.data = pheader;
|
// mod->cache.data = pheader;
|
||||||
mod->flags = LittleLong (pinmodel->flags);
|
if (qtest)
|
||||||
|
mod->flags = 0;
|
||||||
|
else
|
||||||
|
mod->flags = LittleLong (pinmodel->flags);
|
||||||
|
|
||||||
//
|
//
|
||||||
// endian-adjust and copy the data, starting with the alias model header
|
// endian-adjust and copy the data, starting with the alias model header
|
||||||
|
@ -2480,7 +2528,10 @@ qboolean SWMod_LoadAliasModel (model_t *mod, void *buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
pmodel->numframes = LittleLong (pinmodel->numframes);
|
pmodel->numframes = LittleLong (pinmodel->numframes);
|
||||||
pmodel->size = LittleFloat (pinmodel->size) * ALIAS_BASE_SIZE_RATIO;
|
if (qtest)
|
||||||
|
pmodel->size = 1.0 * ALIAS_BASE_SIZE_RATIO;
|
||||||
|
else
|
||||||
|
pmodel->size = LittleFloat (pinmodel->size) * ALIAS_BASE_SIZE_RATIO;
|
||||||
mod->synctype = LittleLong (pinmodel->synctype);
|
mod->synctype = LittleLong (pinmodel->synctype);
|
||||||
mod->numframes = pmodel->numframes;
|
mod->numframes = pmodel->numframes;
|
||||||
|
|
||||||
|
@ -2515,7 +2566,10 @@ qboolean SWMod_LoadAliasModel (model_t *mod, void *buffer)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pskintype = (daliasskintype_t *)&pinmodel[1];
|
if (qtest)
|
||||||
|
pskintype = (daliasskintype_t *)((char *)&pinmodel[1] - sizeof(int)*2);
|
||||||
|
else
|
||||||
|
pskintype = (daliasskintype_t *)&pinmodel[1];
|
||||||
|
|
||||||
pskindesc = Hunk_AllocName (numskins * sizeof (maliasskindesc_t),
|
pskindesc = Hunk_AllocName (numskins * sizeof (maliasskindesc_t),
|
||||||
loadname);
|
loadname);
|
||||||
|
@ -2612,8 +2666,17 @@ qboolean SWMod_LoadAliasModel (model_t *mod, void *buffer)
|
||||||
VectorCopy(pmodel->scale_origin, pheader->frames[i].scale_origin);
|
VectorCopy(pmodel->scale_origin, pheader->frames[i].scale_origin);
|
||||||
VectorCopy(pmodel->scale, pheader->frames[i].scale);
|
VectorCopy(pmodel->scale, pheader->frames[i].scale);
|
||||||
|
|
||||||
|
if (qtest)
|
||||||
if (frametype == ALIAS_SINGLE)
|
{
|
||||||
|
pframetype = (daliasframetype_t *)
|
||||||
|
SWMod_LoadAliasQTestFrame (pframetype + 1,
|
||||||
|
&pheader->frames[i].frame,
|
||||||
|
pmodel->numverts,
|
||||||
|
&pheader->frames[i].bboxmin,
|
||||||
|
&pheader->frames[i].bboxmax,
|
||||||
|
pheader, pheader->frames[i].name);
|
||||||
|
}
|
||||||
|
else if (frametype == ALIAS_SINGLE)
|
||||||
{
|
{
|
||||||
pframetype = (daliasframetype_t *)
|
pframetype = (daliasframetype_t *)
|
||||||
SWMod_LoadAliasFrame (pframetype + 1,
|
SWMod_LoadAliasFrame (pframetype + 1,
|
||||||
|
|
Loading…
Reference in a new issue