OgreBatchConverter.cpp 1.7 KB

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