TDME2  1.9.200
importtscene-main.cpp
Go to the documentation of this file.
1 #include <memory>
2 #include <string>
3 
4 #include <tdme/tdme.h>
9 #include <tdme/engine/Version.h>
13 #include <tdme/utilities/Console.h>
15 
16 using std::string;
17 using std::unique_ptr;
18 
29 
30 int main(int argc, char** argv)
31 {
32  Console::println(string("importtscene ") + Version::getVersion());
33  Console::println(Version::getCopyright());
34  Console::println();
35 
36  if (argc != 2) {
37  Console::println("Usage: importtscene scenemodel");
38  Application::exit(Application::EXITCODE_FAILURE);
39  }
40  string sceneModelFileName = string(argv[1]);
41  try {
42  Console::println("Loading scene: " + sceneModelFileName);
43  // TODO: this needs some love, does not work correctly right now
44  auto scene = SceneReader::readFromModel(
45  FileSystem::getInstance()->getPathName(sceneModelFileName),
46  FileSystem::getInstance()->getFileName(sceneModelFileName)
47  );
48  Console::println("Saving scene: " + sceneModelFileName);
49  SceneWriter::write(
50  FileSystem::getInstance()->getPathName(sceneModelFileName),
51  Tools::ensureFileExtension(FileSystem::getInstance()->getFileName(sceneModelFileName), "tscene"),
52  scene
53  );
54  } catch (Exception& exception) {
55  Console::println("An error occurred: " + string(exception.what()));
56  }
57 
58  //
59  Application::exit(Application::EXITCODE_SUCCESS);
60 }
Application base class, please make sure to allocate application on heap to have correct application ...
Definition: Application.h:41
Scene definition.
Definition: Scene.h:50
File system singleton class.
Definition: FileSystem.h:17
Console class.
Definition: Console.h:29
int main(int argc, char **argv)
std::exception Exception
Exception base class.
Definition: Exception.h:18