From 778af4276e0c4002d78ff5c21de1ac4dfa2a4daa Mon Sep 17 00:00:00 2001 From: Seth Galbraith Date: Wed, 16 Jan 2002 20:32:39 +0000 Subject: [PATCH] external tga skin loading, doesn't work for players (teamcolor stuff) --- include/QF/model.h | 1 + libs/models/alias/gl_model_alias.c | 50 ++++++++++++++++++++++++++++++ libs/models/alias/sw_model_alias.c | 6 ++++ libs/models/model.c | 1 + nq/source/sv_model.c | 5 +++ qw/source/sv_model.c | 5 +++ 6 files changed, 68 insertions(+) diff --git a/include/QF/model.h b/include/QF/model.h index dd4778db0..2b6a43597 100644 --- a/include/QF/model.h +++ b/include/QF/model.h @@ -455,6 +455,7 @@ mleaf_t *Mod_PointInLeaf (const vec3_t p, model_t *model); byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model); model_t *Mod_FindName (const char *name); void Mod_ProcessTexture(miptex_t *mt, texture_t *tx); +void Mod_LoadExternalSkins (model_t * mod); void Mod_LoadExternalTextures (model_t * mod); void Mod_LoadLighting (lump_t *l); int Mod_CalcFullbright (byte *in, byte *out, int pixels); diff --git a/libs/models/alias/gl_model_alias.c b/libs/models/alias/gl_model_alias.c index af44ec22e..22837f39d 100644 --- a/libs/models/alias/gl_model_alias.c +++ b/libs/models/alias/gl_model_alias.c @@ -45,6 +45,9 @@ static const char rcsid[] = #include "QF/qendian.h" #include "QF/skin.h" #include "QF/sys.h" +#include "QF/texture.h" +#include "QF/tga.h" +#include "QF/vfs.h" #include "QF/vid.h" #include "QF/GL/qf_textures.h" @@ -263,3 +266,50 @@ Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr) VectorScale (hdr->mdl.scale, 2, hdr->mdl.scale); } } + +void +Mod_LoadExternalSkin (maliasskindesc_t *pskindesc, char *filename) +{ + VFile *f; + tex_t *targa; + + COM_FOpenFile (filename, &f); + if (f) + { + targa = LoadTGA (f); + Qclose (f); + if (targa->format < 4) + pskindesc->texnum = GL_LoadTexture ("", targa->width, + targa->height, targa->data, true, false, 3); + else + pskindesc->texnum = GL_LoadTexture ("", targa->width, + targa->height, targa->data, true, true, 4); + } +} + +void +Mod_LoadExternalSkins (model_t *mod) +{ + char filename[MAX_QPATH + 4]; + aliashdr_t *paliashdr; + maliasskindesc_t *pskindesc; + maliasskingroup_t *pskingroup; + int i, j; + + paliashdr = Cache_Get (&mod->cache); + for (i = 0; i < paliashdr->mdl.numskins; i++) { + pskindesc = ((maliasskindesc_t *) + ((byte *) paliashdr + paliashdr->skindesc)) + i; + if (pskindesc->type == ALIAS_SKIN_SINGLE) { + snprintf (filename, sizeof (filename), "%s_%i.tga", mod->name, i); + Mod_LoadExternalSkin (pskindesc, filename); + } else { + pskingroup = (maliasskingroup_t *) + ((byte *) paliashdr + pskindesc->skin); + for (j = 0; j < pskingroup->numskins; j++) { + snprintf (filename, sizeof (filename), "%s_%i_%i.tga", mod->name, i, j); + Mod_LoadExternalSkin (pskingroup->skindescs + j, filename); + } + } + } +} diff --git a/libs/models/alias/sw_model_alias.c b/libs/models/alias/sw_model_alias.c index fa193d0d4..e1062a648 100644 --- a/libs/models/alias/sw_model_alias.c +++ b/libs/models/alias/sw_model_alias.c @@ -218,3 +218,9 @@ void Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr) { } + +void +Mod_LoadExternalSkins (model_t *mod) +{ +} + diff --git a/libs/models/model.c b/libs/models/model.c index 627a121ab..9f2e45753 100644 --- a/libs/models/model.c +++ b/libs/models/model.c @@ -217,6 +217,7 @@ Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator) case IDPOLYHEADER: case POLYHEADER16: Mod_LoadAliasModel (mod, buf, allocator); + Mod_LoadExternalSkins (mod); break; case IDSPRITEHEADER: diff --git a/nq/source/sv_model.c b/nq/source/sv_model.c index 13807b646..6f49ca62a 100644 --- a/nq/source/sv_model.c +++ b/nq/source/sv_model.c @@ -67,6 +67,11 @@ Mod_ProcessTexture (miptex_t *mx, texture_t *tx) { } +void +Mod_LoadExternalSkins (model_t *mod) +{ +} + void Mod_LoadExternalTextures (model_t *mod) { diff --git a/qw/source/sv_model.c b/qw/source/sv_model.c index de9ca5ce5..a658e52e6 100644 --- a/qw/source/sv_model.c +++ b/qw/source/sv_model.c @@ -67,6 +67,11 @@ Mod_ProcessTexture (miptex_t *mx, texture_t *tx) { } +void +Mod_LoadExternalSkins (model_t *mod) +{ +} + void Mod_LoadExternalTextures (model_t *mod) {