EncoderArguments.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. #ifndef ENCODERARGUMENTS_H_
  2. #define ENCODERARGUMENTS_H_
  3. #include <set>
  4. #include "Vector3.h"
  5. #include "Font.h"
  6. namespace gameplay
  7. {
  8. /**
  9. * EncoderArguments handles parsing the command line arguments for the GamePlay Encoder.
  10. */
  11. class EncoderArguments
  12. {
  13. public:
  14. enum FileFormat
  15. {
  16. FILEFORMAT_UNKNOWN,
  17. FILEFORMAT_DAE,
  18. FILEFORMAT_FBX,
  19. FILEFORMAT_TTF,
  20. FILEFORMAT_GPB,
  21. FILEFORMAT_PNG,
  22. FILEFORMAT_RAW
  23. };
  24. struct HeightmapOption
  25. {
  26. std::vector<std::string> nodeIds;
  27. std::string filename;
  28. bool isHighPrecision;
  29. int width;
  30. int height;
  31. };
  32. struct NormalMapOption
  33. {
  34. std::string inputFile;
  35. std::string outputFile;
  36. Vector3 worldSize;
  37. };
  38. enum AnimationGroupOption
  39. {
  40. ANIMATIONGROUP_PROMPT,
  41. ANIMATIONGROUP_AUTO,
  42. ANIMATIONGROUP_OFF
  43. };
  44. /**
  45. * Constructor.
  46. */
  47. EncoderArguments(size_t argc, const char** argv);
  48. /**
  49. * Destructor.
  50. */
  51. ~EncoderArguments(void);
  52. /**
  53. * Gets the EncoderArguments instance.
  54. */
  55. static EncoderArguments* getInstance();
  56. /**
  57. * Gets the file format from the file path based on the extension.
  58. */
  59. FileFormat getFileFormat() const;
  60. /**
  61. * Returns the file path.
  62. */
  63. const std::string& getFilePath() const;
  64. /**
  65. * Returns the char pointer to the file path string.
  66. */
  67. const char* getFilePathPointer() const;
  68. /**
  69. * Returns the output path/folder.
  70. * Example: "C:/dir"
  71. */
  72. std::string getOutputDirPath() const;
  73. /**
  74. * Returns the output file path.
  75. * Example: "C:/dir/scene.gpb"
  76. */
  77. std::string getOutputFilePath() const;
  78. /**
  79. * Returns the output file extension.
  80. */
  81. std::string getOutputFileExtension() const;
  82. const std::vector<std::string>& getGroupAnimationNodeId() const;
  83. const std::vector<std::string>& getGroupAnimationAnimationId() const;
  84. bool containsGroupNodeId(const std::string& nodeId) const;
  85. const std::string getAnimationId(const std::string& nodeId) const;
  86. AnimationGroupOption getAnimationGrouping() const;
  87. const std::vector<HeightmapOption>& getHeightmapOptions() const;
  88. /**
  89. * Returns the number of node IDs that were marked as needing to compute tangents and binormals.
  90. */
  91. unsigned int tangentBinormalIdCount() const;
  92. /**
  93. * Returns true if the given node ID was marked as needing to generate tangents and binormals.
  94. */
  95. bool isGenerateTangentBinormalId(const std::string& id) const;
  96. /**
  97. * Returns true if normal map generation is turned on.
  98. */
  99. bool normalMapGeneration() const;
  100. /**
  101. * Returns the supplied intput heightmap resolution.
  102. *
  103. * This option is only applicable for normal map generation.
  104. */
  105. void getHeightmapResolution(int* x, int* y) const;
  106. /**
  107. * Returns world size option.
  108. *
  109. * This option is only applicable for normal map generation.
  110. */
  111. const Vector3& getHeightmapWorldSize() const;
  112. /**
  113. * Returns true if an error occurred while parsing the command line arguments.
  114. */
  115. bool parseErrorOccured() const;
  116. /**
  117. * Tests if a file exists on the file system.
  118. *
  119. * @return True if the file exists; false otherwise.
  120. */
  121. bool fileExists() const;
  122. /**
  123. * Prints the usage information.
  124. */
  125. void printUsage() const;
  126. std::vector<unsigned int> getFontSizes() const;
  127. bool fontPreviewEnabled() const;
  128. Font::FontFormat getFontFormat() const;
  129. bool textOutputEnabled() const;
  130. bool optimizeAnimationsEnabled() const;
  131. bool outputMaterialEnabled() const;
  132. const char* getNodeId() const;
  133. static std::string getRealPath(const std::string& filepath);
  134. private:
  135. /**
  136. * Reads the command line option from the list of options starting at the given index.
  137. *
  138. * @param options The list of command line options.
  139. * @param index Pointer to the index within the options list. The index will be changed
  140. * if an option takes multiple arguments.
  141. */
  142. void readOption(const std::vector<std::string>& options, size_t *index);
  143. void setInputfilePath(const std::string& inputPath);
  144. /**
  145. * Sets the output file path that the encoder will write to.
  146. */
  147. void setOutputfilePath(const std::string& outputPath);
  148. /**
  149. * Replaces all instance of oldChar with newChar in str.
  150. */
  151. static void replace_char(char* str, char oldChar, char newChar);
  152. private:
  153. std::string _filePath;
  154. std::string _fileOutputPath;
  155. std::string _nodeId;
  156. bool _normalMap;
  157. Vector3 _heightmapWorldSize;
  158. int _heightmapResolution[2];
  159. bool _parseError;
  160. std::vector<unsigned int> _fontSizes;
  161. bool _fontPreview;
  162. Font::FontFormat _fontFormat;
  163. bool _textOutput;
  164. bool _optimizeAnimations;
  165. AnimationGroupOption _animationGrouping;
  166. bool _outputMaterial;
  167. std::vector<std::string> _groupAnimationNodeId;
  168. std::vector<std::string> _groupAnimationAnimationId;
  169. std::vector<HeightmapOption> _heightmaps;
  170. std::set<std::string> _tangentBinormalId;
  171. };
  172. void unittestsEncoderArguments();
  173. }
  174. #endif