From f9cbe064860bd03beb914dc03f7c9d3a9dc9188e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Pinto?= Date: Wed, 6 Mar 2024 20:53:53 +0000 Subject: [PATCH] feat: support for .3d input --- engine/src/main.cpp | 34 ++++++++++++++++++++++---------- scenes/{test.xml => default.xml} | 0 2 files changed, 24 insertions(+), 10 deletions(-) rename scenes/{test.xml => default.xml} (100%) diff --git a/engine/src/main.cpp b/engine/src/main.cpp index 1bac018..d71f247 100644 --- a/engine/src/main.cpp +++ b/engine/src/main.cpp @@ -134,16 +134,23 @@ void processNormalKeys(unsigned char key, int x, int y) { void setupConfig(char* arg) { std::string filename; filename.assign(arg); - c = parseConfig(filename); - for (std::string file : c.models) { - std::string dir = MODELS; - dir.append(file); - - std::vector points = parseFile(dir); - if (points.empty()) { - std::cerr << "File not found"; - } + if (filename.substr(filename.size() - 4) == ".xml") { + c = parseConfig(filename); + for (std::string file : c.models) { + std::string dir = MODELS; + dir.append(file); + + std::vector points = parseFile(dir); + if (points.empty()) { + std::cerr << "File not found"; + } + + vectors.push_back(points); + } + } else { + c = parseConfig("../scenes/default.xml"); + std::vector points = parseFile(filename); vectors.push_back(points); } } @@ -155,7 +162,14 @@ int main(int argc, char** argv) { return 1; } - setupConfig(argv[1]); + std::string filepath = argv[1]; + if (filepath.substr(filepath.size() - 4) == ".xml") { + setupConfig(argv[1]); + } else { + c = parseConfig("../scenes/default.xml"); + std::vector points = parseFile(filepath); + vectors.push_back(points); + } // put GLUT�s init here glutInit(&argc, argv); diff --git a/scenes/test.xml b/scenes/default.xml similarity index 100% rename from scenes/test.xml rename to scenes/default.xml