ImportConfig.cpp 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include "../Core/Context.h"
  23. #include "../IO/Log.h"
  24. #include "../IO/File.h"
  25. #include "../IO/FileSystem.h"
  26. #include "JSONFile.h"
  27. #include "../Graphics/GraphicsDefs.h"
  28. #include "ImportConfig.h"
  29. namespace Atomic
  30. {
  31. ImportConfig ImportConfig::importConfig_;
  32. bool ImportConfig::LoadAIFlagsDefaultConfig(const JSONValue& jflags)
  33. {
  34. if (!jflags.IsObject())
  35. return false;
  36. for (JSONObject::ConstIterator i = jflags.Begin(); i != jflags.End(); ++i)
  37. {
  38. String key = i->first_;
  39. const JSONValue& jvalue = i->second_;
  40. if (key == "convertToLeftHanded")
  41. valueMap_["aiProcess_ConvertToLeftHanded"] = GetBoolValue(jvalue, true);
  42. else if (key == "joinIdenticalVertices")
  43. valueMap_["aiProcess_JoinIdenticalVertices"] = GetBoolValue(jvalue, true);
  44. else if (key == "triangulate")
  45. valueMap_["aiProcess_Triangulate"] = GetBoolValue(jvalue, true);
  46. else if (key == "genSmoothNormals")
  47. valueMap_["aiProcess_GenSmoothNormals"] = GetBoolValue(jvalue, true);
  48. else if (key == "limitBoneWeights")
  49. valueMap_["aiProcess_LimitBoneWeights"] = GetBoolValue(jvalue, true);
  50. else if (key == "improveCacheLocality")
  51. valueMap_["aiProcess_ImproveCacheLocality"] = GetBoolValue(jvalue, true);
  52. else if (key == "fixInFacingNormals")
  53. valueMap_["aiProcess_FixInfacingNormals"] = GetBoolValue(jvalue, true);
  54. else if (key == "fixInfacingNormals")
  55. valueMap_["aiProcess_FixInfacingNormals"] = GetBoolValue(jvalue, true);
  56. else if (key == "findInvalidData")
  57. valueMap_["aiProcess_FindInvalidData"] = GetBoolValue(jvalue, true);
  58. else if (key == "genUVCoords")
  59. valueMap_["aiProcess_GenUVCoords"] = GetBoolValue(jvalue, true);
  60. else if (key == "findInstances")
  61. valueMap_["aiProcess_FindInstances"] = GetBoolValue(jvalue, true);
  62. else if (key == "optimizeMeshes")
  63. valueMap_["aiProcess_OptimizeMeshes"] = GetBoolValue(jvalue, true);
  64. }
  65. return true;
  66. }
  67. bool ImportConfig::LoadDesktopConfig(JSONValue root)
  68. {
  69. const JSONValue& jdesktop = root["desktop"];
  70. if (!jdesktop.IsObject())
  71. return false;
  72. const JSONValue& jflags = jdesktop["aiFlagsDefault"];
  73. if (jflags.IsObject())
  74. LoadAIFlagsDefaultConfig(jflags);
  75. return true;
  76. }
  77. }