diff --git a/engine/client/image.c b/engine/client/image.c index 255c5d16e..916143c71 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -7574,18 +7574,29 @@ qbyte *ReadRawImageFile(qbyte *buf, int len, int *width, int *height, uploadfmt_ int i; if (w >= 3 && h >= 4 && w*h+sizeof(int)*2 == len) { //quake lmp - qboolean foundalpha = false; - qbyte *in = buf+sizeof(int)*2; - data = BZ_Malloc(w * h * sizeof(int)); - for (i = 0; i < w * h; i++) + if (force_rgba8) { - if (in[i] == 255) - foundalpha = true; - ((unsigned int*)data)[i] = d_8to24rgbtable[in[i]]; + qboolean foundalpha = false; + qbyte *in = buf+sizeof(int)*2; + data = BZ_Malloc(w * h * sizeof(int)); + for (i = 0; i < w * h; i++) + { + if (in[i] == 255) + foundalpha = true; + ((unsigned int*)data)[i] = d_8to24rgbtable[in[i]]; + } + *width = w; + *height = h; + *format = foundalpha?PTI_RGBA8:PTI_RGBX8; + } + else + { + data = BZ_Malloc(w * h); + memcpy(data, buf+8, w*h); + *width = w; + *height = h; + *format = TF_TRANS8; } - *width = w; - *height = h; - *format = foundalpha?PTI_RGBA8:PTI_RGBX8; return data; } else if (w >= 3 && h >= 4 && w*h+sizeof(int)*2+768+2 == len) @@ -12224,9 +12235,9 @@ static struct {PTI_RGBA32F, PTI_RGB32F, Image_Tr_DropBytes, (16<<16)|12, true}, {PTI_RG8, PTI_RGBX8, Image_Tr_RG8ToRGXX8}, - {PTI_RGBX8, PTI_P8, Image_Tr_RGBX8toPaletted, 0}, - {PTI_RGBX8, TF_H2_TRANS8_0, Image_Tr_RGBX8toPaletted, 1|(255<<16)}, - {PTI_RGBX8, TF_TRANS8, Image_Tr_RGBX8toPaletted, 0|(254<<16)}, + {PTI_RGBX8, PTI_P8, Image_Tr_RGBX8toPaletted, 0|(256<<16)}, + {PTI_RGBX8, TF_H2_TRANS8_0, Image_Tr_RGBX8toPaletted, 1|(256<<16)}, + {PTI_RGBX8, TF_TRANS8, Image_Tr_RGBX8toPaletted, 0|(255<<16)}, {PTI_P8, PTI_RGBX8, Image_Tr_PalettedtoRGBX8, -1}, {TF_SOLID8, PTI_RGBX8, Image_Tr_PalettedtoRGBX8, -1}, {TF_H2_TRANS8_0,PTI_RGBA8, Image_Tr_PalettedtoRGBX8, 0}, diff --git a/iqm/iqm.cpp b/iqm/iqm.cpp index ad78b81c2..4ae56ec73 100644 --- a/iqm/iqm.cpp +++ b/iqm/iqm.cpp @@ -140,6 +140,7 @@ struct filespec int endframe; meshprop meshprops; const char *materialprefix; + const char *materialsuffix; bool ignoresurfname; Quat rotate; float scale; @@ -160,6 +161,7 @@ struct filespec endframe = -1; meshprops = meshprop(); materialprefix = NULL; + materialsuffix = NULL; ignoresurfname = false; rotate = Quat(0, 0, 0, 1); scale = 1; @@ -1195,7 +1197,7 @@ void makemeshes(const filespec &spec) { emesh &em = emeshes[j]; if(em.used) continue; - if(strcmp(em.name, em1.name) || strcmp(em.material, em1.material) || memcmp(&em.explicits, &em1.explicits, sizeof(em.explicits))) continue; + if(strcmp(em.name?em.name:"", em1.name?em1.name:"") || strcmp(em.material, em1.material) || memcmp(&em.explicits, &em1.explicits, sizeof(em.explicits))) continue; int lasttri = emeshes.inrange(j+1) ? emeshes[j+1].firsttri : etriangles.length(); for(int k = em.firsttri; k < lasttri; k++) { @@ -1213,10 +1215,10 @@ void makemeshes(const filespec &spec) if(tinfo.empty()) continue; mesh &m = meshes.add(); - if (spec.materialprefix) + if (spec.materialprefix || spec.materialsuffix) { char material[512]; - formatstring(material, "%s%s", spec.materialprefix, em1.material); + formatstring(material, "%s%s%s", spec.materialprefix?spec.materialprefix:"", em1.material, spec.materialsuffix?spec.materialsuffix:""); m.material = sharestring(material); } else @@ -2135,10 +2137,10 @@ bool loadmd5mesh(const char *filename, const filespec &spec) delete f; buildmd5verts(); + makerelativebasepose(); makeanims(spec); smoothverts(); makemeshes(spec); - makerelativebasepose(); return true; } @@ -5364,6 +5366,7 @@ static void help(bool exitstatus, bool fullhelp) "./iqmtool [options] output.iqm mesh.fbx anim1.fbx ... animN.fbx\n" "./iqmtool [options] output.iqm mesh.obj\n" "./iqmtool [options] output.iqm source.gltf\n" +"./iqmtool [options] output.iqm --kex sources.md5\n" "\n" "Basic commandline options:\n" " --help Show full help.\n" @@ -5387,8 +5390,10 @@ static void help(bool exitstatus, bool fullhelp) " --meshtrans X,Y,Z Translates a mesh by X,Y,Z (floats).\n" " This does not affect the skeleton.\n" " -j\n" -" --forcejoints Forces the exporting of joint information in animation" +" --forcejoints Forces the exporting of joint information in animation\n" " files without meshes.\n" +" --kex Applies a set of fixups to work around the quirks in\n" +" the quake rerelease's md5 files.\n" "\n" "Legacy commandline options that affect the following animation file:\n" "\n" @@ -5449,6 +5454,7 @@ static void help(bool exitstatus, bool fullhelp) " nomesh 1 Skips importing of meshes, getting animations only.\n" " noanim 1 Skips importing of animations, for mesh import only.\n" " materialprefix PRE Prefixes material names with the specified string.\n" +" materialsuffix EXT Forces the material's extension as specified.\n" " ignoresurfname 1 Ignores source surface names.\n" " start FRAME The Imported animation starts on this frame...\n" " end FRAME ... and ends on this one.\n" @@ -5635,6 +5641,8 @@ bool parseanimfield(const char *tok, char **line, filespec &spec, bool defaults) spec.noanim = !!strtoul(mystrtok(line), NULL, 0); else if (!strcasecmp(tok, "materialprefix")) spec.materialprefix = newstring(mystrtok(line)); + else if (!strcasecmp(tok, "materialsuffix")) + spec.materialsuffix = newstring(mystrtok(line)); else if (!strcasecmp(tok, "ignoresurfname")) spec.ignoresurfname = atoi(mystrtok(line)); else if(!strcasecmp(tok, "start")) @@ -5895,6 +5903,9 @@ int main(int argc, char **argv) else if(!strcasecmp(&argv[i][2], "ignoresurfname")) inspec.ignoresurfname = true; else if(!strcasecmp(&argv[i][2], "help")) help(EXIT_SUCCESS,true); else if(!strcasecmp(&argv[i][2], "forcejoints")) forcejoints = true; + else if(!strcasecmp(&argv[i][2], "materialprefix")) { if(i + 1 < argc) inspec.materialprefix = argv[++i]; } + else if(!strcasecmp(&argv[i][2], "materialsuffix")) { if(i + 1 < argc) inspec.materialsuffix = argv[++i]; } + else if(!strcasecmp(&argv[i][2], "kex")) inspec.materialprefix = "progs/", inspec.materialsuffix = "_00_00.lmp", inspec.flags |= IQM_UNPACK; else if(!strcasecmp(&argv[i][2], "meshtrans")) { if(i + 1 < argc) switch(sscanf(argv[++i], "%lf , %lf , %lf", &gmeshtrans.x, &gmeshtrans.y, &gmeshtrans.z)) @@ -5985,6 +5996,14 @@ int main(int argc, char **argv) { if(!loadmd5anim(infile, inspec)) fatal("failed reading: %s", infile); } + else if(!strcasecmp(type, ".md5")) + { + char tmp[MAXSTRLEN]; + formatstring(tmp, "%smesh", infile); + if(!loadmd5mesh(tmp, inspec)) fatal("failed reading: %s", tmp); + formatstring(tmp, "%sanim", infile); + if(!loadmd5anim(tmp, inspec)) fatal("failed reading: %s", tmp); + } else if(!strcasecmp(type, ".iqe")) { if(!loadiqe(infile, inspec)) fatal("failed reading: %s", infile);