summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-09-28 11:45:26 +0000
committerrodri <rgl@antares-labs.eu>2024-09-28 11:45:26 +0000
commit545d3c6c2a053007d1a1b032f9e0359d44a9a358 (patch)
treec21f5705c572350efa191b0fe89c09cc1092da3b
parent1af782b52c796fd341621b0c9de2dea3a1c7c660 (diff)
download3dee-545d3c6c2a053007d1a1b032f9e0359d44a9a358.tar.gz
3dee-545d3c6c2a053007d1a1b032f9e0359d44a9a358.tar.bz2
3dee-545d3c6c2a053007d1a1b032f9e0359d44a9a358.zip
obj: add more conversion possibilities.
this brings back the < in.obj obj >out.mdl mechanic that's so handy for simpler models where there are no textures.
-rw-r--r--obj.c21
-rw-r--r--readme5
2 files changed, 20 insertions, 6 deletions
diff --git a/obj.c b/obj.c
index a2e5936..7095e58 100644
--- a/obj.c
+++ b/obj.c
@@ -325,7 +325,7 @@ readobjmodel(char *path)
static void
usage(void)
{
- fprint(2, "usage: %s objfile dstdir\n", argv0);
+ fprint(2, "usage: %s [objfile [dstdir]]\n", argv0);
exits("usage");
}
@@ -333,17 +333,28 @@ void
threadmain(int argc, char *argv[])
{
Model *m;
+ char *infile, *dstdir;
ARGBEGIN{
default: usage();
}ARGEND;
- if(argc != 2)
+ if(argc > 2)
usage();
- m = readobjmodel(argv[0]);
+ infile = argc > 0? argv[0]: "/fd/0";
+ dstdir = argc == 2? argv[1]: nil;
+
+ m = readobjmodel(infile);
if(m == nil)
sysfatal("readobjmodel: %r");
- if(exportmodel(argv[1], m) < 0)
- sysfatal("exportmodel: %r");
+
+ if(dstdir == nil){
+ if(writemodel(1, m) == 0)
+ sysfatal("writemodel: %r");
+ }else{
+ if(exportmodel(dstdir, m) < 0)
+ sysfatal("exportmodel: %r");
+ }
+
exits(nil);
}
diff --git a/readme b/readme
index a888d60..37d91ac 100644
--- a/readme
+++ b/readme
@@ -94,12 +94,15 @@ USAGE
positions.
- obj objfile dir
+ obj [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.
+ 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.
+
CUBEMAPS
The skyboxes for vis and solar are stored in the cubemap/ folder. To use