diff options
Diffstat (limited to 'src/renderergl1/tr_model.c')
-rw-r--r-- | src/renderergl1/tr_model.c | 182 |
1 files changed, 4 insertions, 178 deletions
diff --git a/src/renderergl1/tr_model.c b/src/renderergl1/tr_model.c index 2a677be7..bbc8e437 100644 --- a/src/renderergl1/tr_model.c +++ b/src/renderergl1/tr_model.c @@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define LL(x) x=LittleLong(x) static qboolean R_LoadMD3(model_t *mod, int lod, void *buffer, const char *name ); -static qboolean R_LoadMD4(model_t *mod, void *buffer, const char *name ); static qboolean R_LoadMDR(model_t *mod, void *buffer, int filesize, const char *name ); /* @@ -73,15 +72,10 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) continue; ident = LittleLong(* (unsigned *) buf.u); - if (ident == MD4_IDENT) - loaded = R_LoadMD4(mod, buf.u, name); + if (ident == MD3_IDENT) + loaded = R_LoadMD3(mod, lod, buf.u, name); else - { - if (ident == MD3_IDENT) - loaded = R_LoadMD3(mod, lod, buf.u, name); - else - ri.Printf(PRINT_WARNING,"R_RegisterMD3: unknown fileid for %s\n", name); - } + ri.Printf(PRINT_WARNING,"R_RegisterMD3: unknown fileid for %s\n", name); ri.FS_FreeFile(buf.v); @@ -201,7 +195,6 @@ static modelExtToLoaderMap_t modelLoaders[ ] = { { "iqm", R_RegisterIQM }, { "mdr", R_RegisterMDR }, - { "md4", R_RegisterMD3 }, { "md3", R_RegisterMD3 } }; @@ -577,7 +570,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char LL(pinmodel->ofsFrames); // This is a model that uses some type of compressed Bones. We don't want to uncompress every bone for each rendered frame - // over and over again, we'll uncompress it in this function already, so we must adjust the size of the target md4. + // over and over again, we'll uncompress it in this function already, so we must adjust the size of the target mdr. if(pinmodel->ofsFrames < 0) { // mdrFrame_t is larger than mdrCompFrame_t: @@ -874,162 +867,6 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char return qtrue; } -/* -================= -R_LoadMD4 -================= -*/ - -static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) { - int i, j, k, lodindex; - md4Header_t *pinmodel, *md4; - md4Frame_t *frame; - md4LOD_t *lod; - md4Surface_t *surf; - md4Triangle_t *tri; - md4Vertex_t *v; - int version; - int size; - shader_t *sh; - int frameSize; - - pinmodel = (md4Header_t *)buffer; - - version = LittleLong (pinmodel->version); - if (version != MD4_VERSION) { - ri.Printf( PRINT_WARNING, "R_LoadMD4: %s has wrong version (%i should be %i)\n", - mod_name, version, MD4_VERSION); - return qfalse; - } - - mod->type = MOD_MD4; - size = LittleLong(pinmodel->ofsEnd); - mod->dataSize += size; - mod->modelData = md4 = ri.Hunk_Alloc( size, h_low ); - - Com_Memcpy(md4, buffer, size); - - LL(md4->ident); - LL(md4->version); - LL(md4->numFrames); - LL(md4->numBones); - LL(md4->numLODs); - LL(md4->ofsFrames); - LL(md4->ofsLODs); - md4->ofsEnd = size; - - if ( md4->numFrames < 1 ) { - ri.Printf( PRINT_WARNING, "R_LoadMD4: %s has no frames\n", mod_name ); - return qfalse; - } - - // we don't need to swap tags in the renderer, they aren't used - - // swap all the frames - frameSize = (size_t)( &((md4Frame_t *)0)->bones[ md4->numBones ] ); - for ( i = 0 ; i < md4->numFrames ; i++) { - frame = (md4Frame_t *) ( (byte *)md4 + md4->ofsFrames + i * frameSize ); - frame->radius = LittleFloat( frame->radius ); - for ( j = 0 ; j < 3 ; j++ ) { - frame->bounds[0][j] = LittleFloat( frame->bounds[0][j] ); - frame->bounds[1][j] = LittleFloat( frame->bounds[1][j] ); - frame->localOrigin[j] = LittleFloat( frame->localOrigin[j] ); - } - for ( j = 0 ; j < md4->numBones * sizeof( md4Bone_t ) / 4 ; j++ ) { - ((float *)frame->bones)[j] = LittleFloat( ((float *)frame->bones)[j] ); - } - } - - // swap all the LOD's - lod = (md4LOD_t *) ( (byte *)md4 + md4->ofsLODs ); - for ( lodindex = 0 ; lodindex < md4->numLODs ; lodindex++ ) { - - // swap all the surfaces - surf = (md4Surface_t *) ( (byte *)lod + lod->ofsSurfaces ); - for ( i = 0 ; i < lod->numSurfaces ; i++) { - LL(surf->ident); - LL(surf->numTriangles); - LL(surf->ofsTriangles); - LL(surf->numVerts); - LL(surf->ofsVerts); - LL(surf->ofsEnd); - - if ( surf->numVerts >= SHADER_MAX_VERTEXES ) { - ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i verts on %s (%i).\n", - mod_name, SHADER_MAX_VERTEXES - 1, surf->name[0] ? surf->name : "a surface", - surf->numVerts ); - return qfalse; - } - if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES ) { - ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i triangles on %s (%i).\n", - mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, surf->name[0] ? surf->name : "a surface", - surf->numTriangles ); - return qfalse; - } - - // change to surface identifier - surf->ident = SF_MD4; - - // lowercase the surface name so skin compares are faster - Q_strlwr( surf->name ); - - // register the shaders - sh = R_FindShader( surf->shader, LIGHTMAP_NONE, qtrue ); - if ( sh->defaultShader ) { - surf->shaderIndex = 0; - } else { - surf->shaderIndex = sh->index; - } - - // swap all the triangles - tri = (md4Triangle_t *) ( (byte *)surf + surf->ofsTriangles ); - for ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) { - LL(tri->indexes[0]); - LL(tri->indexes[1]); - LL(tri->indexes[2]); - } - - // swap all the vertexes - // FIXME - // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left - // in for reference. - //v = (md4Vertex_t *) ( (byte *)surf + surf->ofsVerts + 12); - v = (md4Vertex_t *) ( (byte *)surf + surf->ofsVerts); - for ( j = 0 ; j < surf->numVerts ; j++ ) { - v->normal[0] = LittleFloat( v->normal[0] ); - v->normal[1] = LittleFloat( v->normal[1] ); - v->normal[2] = LittleFloat( v->normal[2] ); - - v->texCoords[0] = LittleFloat( v->texCoords[0] ); - v->texCoords[1] = LittleFloat( v->texCoords[1] ); - - v->numWeights = LittleLong( v->numWeights ); - - for ( k = 0 ; k < v->numWeights ; k++ ) { - v->weights[k].boneIndex = LittleLong( v->weights[k].boneIndex ); - v->weights[k].boneWeight = LittleFloat( v->weights[k].boneWeight ); - v->weights[k].offset[0] = LittleFloat( v->weights[k].offset[0] ); - v->weights[k].offset[1] = LittleFloat( v->weights[k].offset[1] ); - v->weights[k].offset[2] = LittleFloat( v->weights[k].offset[2] ); - } - // FIXME - // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left - // in for reference. - //v = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights] + 12 ); - v = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights]); - } - - // find the next surface - surf = (md4Surface_t *)( (byte *)surf + surf->ofsEnd ); - } - - // find the next LOD - lod = (md4LOD_t *)( (byte *)lod + lod->ofsEnd ); - } - - return qtrue; -} - //============================================================================= @@ -1267,17 +1104,6 @@ void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) { VectorCopy( frame->bounds[1], maxs ); return; - } else if (model->type == MOD_MD4) { - md4Header_t *header; - md4Frame_t *frame; - - header = (md4Header_t *)model->modelData; - frame = (md4Frame_t *) ((byte *)header + header->ofsFrames); - - VectorCopy( frame->bounds[0], mins ); - VectorCopy( frame->bounds[1], maxs ); - - return; } else if (model->type == MOD_MDR) { mdrHeader_t *header; mdrFrame_t *frame; |