ref: ad91b9f49cd7e1655d6578657eabbbeddc3a1301
parent: c51a1e272599dff06b591ef3c17544acd2faab52
author: rodri <rgl@antares-labs.eu>
date: Sun Feb 23 16:14:41 EST 2025
adjust to new (write|export)model interface (optional dedup).
--- a/med.c
+++ b/med.c
@@ -573,7 +573,7 @@
usrlog->send(usrlog, "create: %r");
break;
}
- writemodel(fd, model);
+ writemodel(fd, model, 1);
close(fd);
break;
case QUIT:
--- a/obj.c
+++ b/obj.c
@@ -330,7 +330,7 @@
static void
usage(void)
{
- fprint(2, "usage: %s [objfile [dstdir]]\n", argv0);
+ fprint(2, "usage: %s [-d] [objfile [dstdir]]\n", argv0);
exits("usage");
}
@@ -339,8 +339,11 @@
{
Model *m;
char *infile, *dstdir;
+ int dedup;
+ dedup = 1;
ARGBEGIN{
+ case 'd': dedup--; break;
default: usage();
}ARGEND;
if(argc > 2)
@@ -354,10 +357,10 @@
sysfatal("readobjmodel: %r");
if(dstdir == nil){
- if(writemodel(1, m) == 0)
+ if(writemodel(1, m, dedup) == 0)
sysfatal("writemodel: %r");
}else{
- if(exportmodel(dstdir, m) < 0)
+ if(exportmodel(dstdir, m, dedup) < 0)
sysfatal("exportmodel: %r");
}
--- a/readme
+++ b/readme
@@ -94,11 +94,14 @@
positions.
- obj [objfile [dir]]
+ obj [-d] [objfile [dir]]
This tool will take a Wavefront OBJ file objfile, with all its materials,
and convert it into a model(6) file (see libgraphics/model.6.txt) that's
written, along with its assets, inside the directory dir.
+
+ By default it will try to compress the resulting model by deduplicating
+ entries, to disable this feature use -d.
If no dir is specified, it writes the model(6) to stdout. And if no
arguments are given, it reads the OBJ file from stdin.