EncoderArguments.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #ifndef ENCODERARGUMENTS_H_
  2. #define ENCODERARGUMENTS_H_
  3. namespace gameplay
  4. {
  5. /**
  6. * EncoderArguments handles parsing the command line arguments for the GamePlay Encoder.
  7. */
  8. class EncoderArguments
  9. {
  10. public:
  11. enum FileFormat
  12. {
  13. FILEFORMAT_UNKNOWN,
  14. FILEFORMAT_DAE,
  15. FILEFORMAT_FBX,
  16. FILEFORMAT_TTF,
  17. FILEFORMAT_GPB
  18. };
  19. struct HeightmapOption
  20. {
  21. std::vector<std::string> nodeIds;
  22. std::string filename;
  23. bool isHighPrecision;
  24. };
  25. /**
  26. * Constructor.
  27. */
  28. EncoderArguments(size_t argc, const char** argv);
  29. /**
  30. * Destructor.
  31. */
  32. ~EncoderArguments(void);
  33. /**
  34. * Gets the EncoderArguments instance.
  35. */
  36. static EncoderArguments* getInstance();
  37. /**
  38. * Gets the file format from the file path based on the extension.
  39. */
  40. FileFormat getFileFormat() const;
  41. /**
  42. * Returns the file path.
  43. */
  44. const std::string& getFilePath() const;
  45. /**
  46. * Returns the char pointer to the file path string.
  47. */
  48. const char* getFilePathPointer() const;
  49. /**
  50. * Returns the path to where the DAE output should be written to.
  51. */
  52. const std::string& getDAEOutputPath() const;
  53. /**
  54. * Returns the output path/folder.
  55. * Example: "C:/dir"
  56. */
  57. std::string getOutputDirPath() const;
  58. /**
  59. * Returns the output file path.
  60. * Example: "C:/dir/scene.gpb"
  61. */
  62. std::string getOutputFilePath() const;
  63. const std::vector<std::string>& getGroupAnimationNodeId() const;
  64. const std::vector<std::string>& getGroupAnimationAnimationId() const;
  65. bool containsGroupNodeId(const std::string& nodeId) const;
  66. const std::string getAnimationId(const std::string& nodeId) const;
  67. const std::vector<HeightmapOption>& getHeightmapOptions() const;
  68. /**
  69. * Returns true if an error occurred while parsing the command line arguments.
  70. */
  71. bool parseErrorOccured() const;
  72. /**
  73. * Tests if a file exists on the file system.
  74. *
  75. * @return True if the file exists; false otherwise.
  76. */
  77. bool fileExists() const;
  78. /**
  79. * Prints the usage information.
  80. */
  81. void printUsage() const;
  82. bool fontPreviewEnabled() const;
  83. bool textOutputEnabled() const;
  84. bool DAEOutputEnabled() const;
  85. bool optimizeAnimationsEnabled() const;
  86. const char* getNodeId() const;
  87. unsigned int getFontSize() const;
  88. static std::string getRealPath(const std::string& filepath);
  89. private:
  90. /**
  91. * Reads the command line option from the list of options starting at the given index.
  92. *
  93. * @param options The list of command line options.
  94. * @param index Pointer to the index within the options list. The index will be changed
  95. * if an option takes multiple arguments.
  96. */
  97. void readOption(const std::vector<std::string>& options, size_t *index);
  98. void setInputfilePath(const std::string& inputPath);
  99. /**
  100. * Sets the output file path that the encoder will write to.
  101. */
  102. void setOutputfilePath(const std::string& outputPath);
  103. /**
  104. * Replaces all instance of oldChar with newChar in str.
  105. */
  106. static void replace_char(char* str, char oldChar, char newChar);
  107. private:
  108. std::string _filePath;
  109. std::string _fileOutputPath;
  110. std::string _nodeId;
  111. std::string _daeOutputPath;
  112. unsigned int _fontSize;
  113. bool _parseError;
  114. bool _fontPreview;
  115. bool _textOutput;
  116. bool _daeOutput;
  117. bool _optimizeAnimations;
  118. std::vector<std::string> _groupAnimationNodeId;
  119. std::vector<std::string> _groupAnimationAnimationId;
  120. std::vector<HeightmapOption> _heightmaps;
  121. };
  122. void unittestsEncoderArguments();
  123. }
  124. #endif