mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-29 07:02:12 +00:00
Fix up our iqmtool to not fail on md5mesh inputs.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6035 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
7791405627
commit
eea586dd13
2 changed files with 48 additions and 18 deletions
|
@ -7574,18 +7574,29 @@ qbyte *ReadRawImageFile(qbyte *buf, int len, int *width, int *height, uploadfmt_
|
||||||
int i;
|
int i;
|
||||||
if (w >= 3 && h >= 4 && w*h+sizeof(int)*2 == len)
|
if (w >= 3 && h >= 4 && w*h+sizeof(int)*2 == len)
|
||||||
{ //quake lmp
|
{ //quake lmp
|
||||||
qboolean foundalpha = false;
|
if (force_rgba8)
|
||||||
qbyte *in = buf+sizeof(int)*2;
|
|
||||||
data = BZ_Malloc(w * h * sizeof(int));
|
|
||||||
for (i = 0; i < w * h; i++)
|
|
||||||
{
|
{
|
||||||
if (in[i] == 255)
|
qboolean foundalpha = false;
|
||||||
foundalpha = true;
|
qbyte *in = buf+sizeof(int)*2;
|
||||||
((unsigned int*)data)[i] = d_8to24rgbtable[in[i]];
|
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;
|
return data;
|
||||||
}
|
}
|
||||||
else if (w >= 3 && h >= 4 && w*h+sizeof(int)*2+768+2 == len)
|
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_RGBA32F, PTI_RGB32F, Image_Tr_DropBytes, (16<<16)|12, true},
|
||||||
|
|
||||||
{PTI_RG8, PTI_RGBX8, Image_Tr_RG8ToRGXX8},
|
{PTI_RG8, PTI_RGBX8, Image_Tr_RG8ToRGXX8},
|
||||||
{PTI_RGBX8, PTI_P8, Image_Tr_RGBX8toPaletted, 0},
|
{PTI_RGBX8, PTI_P8, Image_Tr_RGBX8toPaletted, 0|(256<<16)},
|
||||||
{PTI_RGBX8, TF_H2_TRANS8_0, Image_Tr_RGBX8toPaletted, 1|(255<<16)},
|
{PTI_RGBX8, TF_H2_TRANS8_0, Image_Tr_RGBX8toPaletted, 1|(256<<16)},
|
||||||
{PTI_RGBX8, TF_TRANS8, Image_Tr_RGBX8toPaletted, 0|(254<<16)},
|
{PTI_RGBX8, TF_TRANS8, Image_Tr_RGBX8toPaletted, 0|(255<<16)},
|
||||||
{PTI_P8, PTI_RGBX8, Image_Tr_PalettedtoRGBX8, -1},
|
{PTI_P8, PTI_RGBX8, Image_Tr_PalettedtoRGBX8, -1},
|
||||||
{TF_SOLID8, PTI_RGBX8, Image_Tr_PalettedtoRGBX8, -1},
|
{TF_SOLID8, PTI_RGBX8, Image_Tr_PalettedtoRGBX8, -1},
|
||||||
{TF_H2_TRANS8_0,PTI_RGBA8, Image_Tr_PalettedtoRGBX8, 0},
|
{TF_H2_TRANS8_0,PTI_RGBA8, Image_Tr_PalettedtoRGBX8, 0},
|
||||||
|
|
29
iqm/iqm.cpp
29
iqm/iqm.cpp
|
@ -140,6 +140,7 @@ struct filespec
|
||||||
int endframe;
|
int endframe;
|
||||||
meshprop meshprops;
|
meshprop meshprops;
|
||||||
const char *materialprefix;
|
const char *materialprefix;
|
||||||
|
const char *materialsuffix;
|
||||||
bool ignoresurfname;
|
bool ignoresurfname;
|
||||||
Quat rotate;
|
Quat rotate;
|
||||||
float scale;
|
float scale;
|
||||||
|
@ -160,6 +161,7 @@ struct filespec
|
||||||
endframe = -1;
|
endframe = -1;
|
||||||
meshprops = meshprop();
|
meshprops = meshprop();
|
||||||
materialprefix = NULL;
|
materialprefix = NULL;
|
||||||
|
materialsuffix = NULL;
|
||||||
ignoresurfname = false;
|
ignoresurfname = false;
|
||||||
rotate = Quat(0, 0, 0, 1);
|
rotate = Quat(0, 0, 0, 1);
|
||||||
scale = 1;
|
scale = 1;
|
||||||
|
@ -1195,7 +1197,7 @@ void makemeshes(const filespec &spec)
|
||||||
{
|
{
|
||||||
emesh &em = emeshes[j];
|
emesh &em = emeshes[j];
|
||||||
if(em.used) continue;
|
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();
|
int lasttri = emeshes.inrange(j+1) ? emeshes[j+1].firsttri : etriangles.length();
|
||||||
for(int k = em.firsttri; k < lasttri; k++)
|
for(int k = em.firsttri; k < lasttri; k++)
|
||||||
{
|
{
|
||||||
|
@ -1213,10 +1215,10 @@ void makemeshes(const filespec &spec)
|
||||||
if(tinfo.empty()) continue;
|
if(tinfo.empty()) continue;
|
||||||
|
|
||||||
mesh &m = meshes.add();
|
mesh &m = meshes.add();
|
||||||
if (spec.materialprefix)
|
if (spec.materialprefix || spec.materialsuffix)
|
||||||
{
|
{
|
||||||
char material[512];
|
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);
|
m.material = sharestring(material);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2135,10 +2137,10 @@ bool loadmd5mesh(const char *filename, const filespec &spec)
|
||||||
delete f;
|
delete f;
|
||||||
|
|
||||||
buildmd5verts();
|
buildmd5verts();
|
||||||
|
makerelativebasepose();
|
||||||
makeanims(spec);
|
makeanims(spec);
|
||||||
smoothverts();
|
smoothverts();
|
||||||
makemeshes(spec);
|
makemeshes(spec);
|
||||||
makerelativebasepose();
|
|
||||||
|
|
||||||
return true;
|
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.fbx anim1.fbx ... animN.fbx\n"
|
||||||
"./iqmtool [options] output.iqm mesh.obj\n"
|
"./iqmtool [options] output.iqm mesh.obj\n"
|
||||||
"./iqmtool [options] output.iqm source.gltf\n"
|
"./iqmtool [options] output.iqm source.gltf\n"
|
||||||
|
"./iqmtool [options] output.iqm --kex sources.md5\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Basic commandline options:\n"
|
"Basic commandline options:\n"
|
||||||
" --help Show full help.\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"
|
" --meshtrans X,Y,Z Translates a mesh by X,Y,Z (floats).\n"
|
||||||
" This does not affect the skeleton.\n"
|
" This does not affect the skeleton.\n"
|
||||||
" -j\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"
|
" 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"
|
"\n"
|
||||||
"Legacy commandline options that affect the following animation file:\n"
|
"Legacy commandline options that affect the following animation file:\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -5449,6 +5454,7 @@ static void help(bool exitstatus, bool fullhelp)
|
||||||
" nomesh 1 Skips importing of meshes, getting animations only.\n"
|
" nomesh 1 Skips importing of meshes, getting animations only.\n"
|
||||||
" noanim 1 Skips importing of animations, for mesh import only.\n"
|
" noanim 1 Skips importing of animations, for mesh import only.\n"
|
||||||
" materialprefix PRE Prefixes material names with the specified string.\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"
|
" ignoresurfname 1 Ignores source surface names.\n"
|
||||||
" start FRAME The Imported animation starts on this frame...\n"
|
" start FRAME The Imported animation starts on this frame...\n"
|
||||||
" end FRAME ... and ends on this one.\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);
|
spec.noanim = !!strtoul(mystrtok(line), NULL, 0);
|
||||||
else if (!strcasecmp(tok, "materialprefix"))
|
else if (!strcasecmp(tok, "materialprefix"))
|
||||||
spec.materialprefix = newstring(mystrtok(line));
|
spec.materialprefix = newstring(mystrtok(line));
|
||||||
|
else if (!strcasecmp(tok, "materialsuffix"))
|
||||||
|
spec.materialsuffix = newstring(mystrtok(line));
|
||||||
else if (!strcasecmp(tok, "ignoresurfname"))
|
else if (!strcasecmp(tok, "ignoresurfname"))
|
||||||
spec.ignoresurfname = atoi(mystrtok(line));
|
spec.ignoresurfname = atoi(mystrtok(line));
|
||||||
else if(!strcasecmp(tok, "start"))
|
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], "ignoresurfname")) inspec.ignoresurfname = true;
|
||||||
else if(!strcasecmp(&argv[i][2], "help")) help(EXIT_SUCCESS,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], "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"))
|
else if(!strcasecmp(&argv[i][2], "meshtrans"))
|
||||||
{
|
{
|
||||||
if(i + 1 < argc) switch(sscanf(argv[++i], "%lf , %lf , %lf", &gmeshtrans.x, &gmeshtrans.y, &gmeshtrans.z))
|
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);
|
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"))
|
else if(!strcasecmp(type, ".iqe"))
|
||||||
{
|
{
|
||||||
if(!loadiqe(infile, inspec)) fatal("failed reading: %s", infile);
|
if(!loadiqe(infile, inspec)) fatal("failed reading: %s", infile);
|
||||||
|
|
Loading…
Reference in a new issue