add CLI args

main
_ 2022-02-21 23:36:14 +00:00
parent ce29ce6ad1
commit 7d70c8af21
2 changed files with 26 additions and 2 deletions

4
.gitignore vendored
View File

@ -1 +1,5 @@
/target /target
*.blend
*.glb
*.iqm

View File

@ -9,7 +9,27 @@ use glam::{
}; };
fn main () { fn main () {
let (document, buffers, _images) = gltf::import ("input.glb").unwrap (); // The `clap` crate is very popular but also very slow to compile,
// so I'll do my own CLI parsing
let mut args = std::env::args ();
let _exe_name = args.next ().unwrap ();
let mut input_path = None;
let mut output_path = None;
while let Some (arg) = args.next () {
if arg == "--input" || arg == "-i" {
input_path = args.next ();
}
else if arg == "--output" || arg == "-o" {
output_path = args.next ();
}
}
let input_path = input_path.unwrap ();
let output_path = output_path.unwrap ();
let (document, buffers, _images) = gltf::import (input_path).unwrap ();
let buffer = buffers.get (0).unwrap (); let buffer = buffers.get (0).unwrap ();
let mut vertexes = Vec::default (); let mut vertexes = Vec::default ();
@ -121,7 +141,7 @@ fn main () {
let filesize = ofs_text + num_text; let filesize = ofs_text + num_text;
let mut f = File::create ("output.iqm").unwrap (); let mut f = File::create (output_path).unwrap ();
f.write_all (b"INTERQUAKEMODEL\0").unwrap (); f.write_all (b"INTERQUAKEMODEL\0").unwrap ();