mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-11 03:29:03 +08:00
Start working on a gltf utility program
Signed-off-by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
This commit is contained in:
parent
f1cdd1c4cb
commit
ea2b1c5e5d
11
examples/gltfutil/CMakeLists.txt
Normal file
11
examples/gltfutil/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
cmake_minimum_required (VERSION 3.6)
|
||||
project (gltfutil)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
include_directories(
|
||||
../../
|
||||
)
|
||||
|
||||
file(GLOB gltfutil_sources *.cc *.h)
|
||||
add_executable(gltfutil ${gltfutil_sources})
|
18
examples/gltfutil/gltfuilconfig.h
Normal file
18
examples/gltfutil/gltfuilconfig.h
Normal file
@ -0,0 +1,18 @@
|
||||
#include <string>
|
||||
|
||||
namespace gltfutil {
|
||||
enum class ui_mode { cli, interactive };
|
||||
|
||||
enum class cli_action { not_set, help, dump };
|
||||
|
||||
struct configuration {
|
||||
std::string input_path, output_dir;
|
||||
ui_mode mode;
|
||||
cli_action action = cli_action::not_set;
|
||||
bool has_output_dir;
|
||||
bool is_valid() {
|
||||
// TODO impl check
|
||||
return false;
|
||||
}
|
||||
};
|
||||
} // namespace gltfutil
|
70
examples/gltfutil/main.cc
Normal file
70
examples/gltfutil/main.cc
Normal file
@ -0,0 +1,70 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "gltfuilconfig.h"
|
||||
|
||||
namespace gltfutil {
|
||||
int usage() {
|
||||
using std::cout;
|
||||
cout << "gltfutil: tool for manipulating gltf files\n"
|
||||
<< " usage information:\n\n"
|
||||
<< "\t gltfutil (-i|-d|-h) [path to .gltf/glb] (-o [path to output "
|
||||
"directory])\n\n"
|
||||
<< "\t\t -i: start in interactive mode\n"
|
||||
<< "\t\t -d: dump enclosed content (image assets)\n"
|
||||
<< "\t\t -h: print this help\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
int arg_error() {
|
||||
(void)usage();
|
||||
return -1;
|
||||
}
|
||||
|
||||
int parse_args(int argc, char** argv) {
|
||||
gltfutil::configuration config;
|
||||
|
||||
for (size_t i = 1; i < size_t(argc); ++i) {
|
||||
char* arg = argv[i];
|
||||
if (arg[0] == '-') switch (arg[1]) {
|
||||
case 'h':
|
||||
config.mode = ui_mode::cli;
|
||||
config.action = cli_action::help;
|
||||
case 'd':
|
||||
// TODO impl
|
||||
break;
|
||||
case 'i':
|
||||
config.mode = ui_mode::interactive;
|
||||
break;
|
||||
// TODO impl
|
||||
default:
|
||||
return arg_error();
|
||||
}
|
||||
}
|
||||
|
||||
if (config.is_valid()) {
|
||||
if (config.mode == ui_mode::interactive) {
|
||||
// interactive usage now;
|
||||
// TODO impl
|
||||
} else {
|
||||
switch (config.action) {
|
||||
case cli_action::help:
|
||||
return usage();
|
||||
case cli_action::dump:
|
||||
// TODO impl
|
||||
break;
|
||||
default:
|
||||
return arg_error();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return arg_error();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} // namespace gltfutil
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc == 1) return gltfutil::usage();
|
||||
if (argc > 1) return gltfutil::parse_args(argc, argv);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user