diff --git a/engine/client/modelgen.h b/engine/client/modelgen.h index 0f3603825..f15d7adb7 100644 --- a/engine/client/modelgen.h +++ b/engine/client/modelgen.h @@ -43,6 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #define ALIAS_VERSION 6 +#define QTESTALIAS_VERSION 3 #define ALIAS_ONSEAM 0x0020 @@ -132,6 +133,12 @@ typedef struct { char name[16]; // frame name from grabbing } 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 { int numframes; dtrivertx_t bboxmin; // lightnormal isn't used diff --git a/engine/gl/gl_alias.c b/engine/gl/gl_alias.c index 6cc7d10b7..2d31b82a2 100644 --- a/engine/gl/gl_alias.c +++ b/engine/gl/gl_alias.c @@ -2965,6 +2965,68 @@ static galiasinfo_t *galias; static dmdl_t *pq1inmodel; #define NUMVERTEXNORMALS 162 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) { galiaspose_t *pose; @@ -3329,6 +3391,7 @@ qboolean GL_LoadQ1Model (model_t *mod, void *buffer) dtriangle_t *pintriangles; int *seamremap; index_t *indexes; + qboolean qtest = false; int size; @@ -3340,18 +3403,26 @@ qboolean GL_LoadQ1Model (model_t *mod, void *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; - 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", mod->name, version, ALIAS_VERSION); 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 || pq1inmodel->numskins < 1 || pq1inmodel->numtris < 1 || @@ -3363,7 +3434,10 @@ qboolean GL_LoadQ1Model (model_t *mod, void *buffer) 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) #ifndef SERVERONLY @@ -3379,7 +3453,9 @@ qboolean GL_LoadQ1Model (model_t *mod, void *buffer) galias->nextsurf = 0; //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); else if( mod->flags & EF_TRANSPARENT ) pinstverts = (dstvert_t *)Q1_LoadSkins((daliasskintype_t *)(pq1inmodel+1), 2); @@ -3444,11 +3520,23 @@ qboolean GL_LoadQ1Model (model_t *mod, void *buffer) } //frames - if (Q1_LoadFrameGroup((daliasframetype_t *)&pintriangles[pq1inmodel->numtris], seamremap) == NULL) + if (qtest) { - BZ_Free(seamremap); - Hunk_FreeToLowMark (hunkstart); - return false; + if (QTest_LoadFrameGroup((daliasframetype_t *)&pintriangles[pq1inmodel->numtris], seamremap) == NULL) + { + 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); diff --git a/engine/sw/d_trans.c b/engine/sw/d_trans.c index f0702dae5..21884bfcd 100644 --- a/engine/sw/d_trans.c +++ b/engine/sw/d_trans.c @@ -415,7 +415,6 @@ palremap_t *D_GetPaletteRemap(int red, int green, int blue, qboolean desaturate, palremap_t *RebuildMenuTint(void) { - char *t; vec3_t rgb; if (r_menutint.string[0]) diff --git a/engine/sw/sw_model.c b/engine/sw/sw_model.c index 8a3f0cb1f..d60cdabc2 100644 --- a/engine/sw/sw_model.c +++ b/engine/sw/sw_model.c @@ -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 ; jengineflags & MDLF_DOCRC) { @@ -2412,7 +2455,9 @@ qboolean SWMod_LoadAliasModel (model_t *mod, void *buffer) pinmodel = (dmdl_t *)buffer; 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", mod->name, version, ALIAS_VERSION); @@ -2435,7 +2480,10 @@ qboolean SWMod_LoadAliasModel (model_t *mod, void *buffer) sizeof (pheader->frames[0])); // 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 @@ -2480,7 +2528,10 @@ qboolean SWMod_LoadAliasModel (model_t *mod, void *buffer) } 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->numframes = pmodel->numframes; @@ -2515,7 +2566,10 @@ qboolean SWMod_LoadAliasModel (model_t *mod, void *buffer) 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), 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, pheader->frames[i].scale); - - if (frametype == ALIAS_SINGLE) + if (qtest) + { + 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 *) SWMod_LoadAliasFrame (pframetype + 1,