OgreBatchConverter.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // OgreBatchConverter.cpp : Defines the entry point for the console application.
  2. //
  3. #include <Urho3D/Core/Context.h>
  4. #include <Urho3D/IO/FileSystem.h>
  5. #include <Urho3D/Core/ProcessUtils.h>
  6. #include <stdio.h>
  7. using namespace Urho3D;
  8. SharedPtr<Context> context(new Context());
  9. SharedPtr<FileSystem> fileSystem(new FileSystem(context));
  10. int main(int argc, char** argv)
  11. {
  12. // Take in account args and place on OgreImporter args
  13. const Vector<String>& args = ParseArguments(argc, argv);
  14. Vector<String> files;
  15. String currentDir = fileSystem->GetCurrentDir();
  16. // Try to execute OgreImporter from same directory as this executable
  17. String ogreImporterName = fileSystem->GetProgramDir() + "OgreImporter";
  18. printf("\n\nOgreBatchConverter requires OgreImporter.exe on same directory");
  19. printf("\nSearching Ogre file in Xml format in %s\n" ,currentDir.CString());
  20. fileSystem->ScanDir(files, currentDir, "*.xml", SCAN_FILES, true);
  21. printf("\nFound %d files\n", files.Size());
  22. #ifdef WIN32
  23. if (files.Size()) fileSystem->SystemCommand("pause");
  24. #endif
  25. for (unsigned i = 0 ; i < files.Size(); i++)
  26. {
  27. Vector<String> cmdArgs;
  28. cmdArgs.Push(files[i]);
  29. cmdArgs.Push(ReplaceExtension(files[i], ".mdl"));
  30. cmdArgs.Push(args);
  31. String cmdPreview = ogreImporterName;
  32. for (unsigned j = 0; j < cmdArgs.Size(); j++)
  33. cmdPreview += " " + cmdArgs[j];
  34. printf("\n%s", cmdPreview.CString());
  35. fileSystem->SystemRun(ogreImporterName, cmdArgs);
  36. }
  37. printf("\nExit\n");
  38. #ifdef WIN32
  39. fileSystem->SystemCommand("pause");
  40. #endif
  41. return 0;
  42. }