Utility: Add MTL exporting

Former-commit-id: cceef7a11d10cc235bd06655a7c5b10ee1cfdec6 [formerly e68c9322634c9a3f93771d941ae581f24dc98116]
Former-commit-id: 1a117f7cd11d869c1fb179cba54254c9ec6924f2
This commit is contained in:
Lynix
2016-07-12 08:11:03 +02:00
parent 269b0668cb
commit ab43085fe7
7 changed files with 316 additions and 91 deletions

View File

@@ -19,6 +19,22 @@ namespace Nz
class NAZARA_UTILITY_API MTLParser
{
public:
struct Material;
MTLParser() = default;
~MTLParser() = default;
inline Material* AddMaterial(const String& matName);
inline void Clear();
inline const Material* GetMaterial(const String& materialName) const;
inline const std::unordered_map<String, Material>& GetMaterials() const;
bool Parse(Stream& stream);
bool Save(Stream& stream) const;
struct Material
{
Color ambient = Color::White;
@@ -39,27 +55,26 @@ namespace Nz
unsigned int illumModel = 0;
};
MTLParser(Stream& stream$);
~MTLParser();
const Material* GetMaterial(const String& materialName) const;
const std::unordered_map<String, Material>& GetMaterials() const;
bool Parse();
private:
bool Advance(bool required = true);
void Error(const String& message);
void Warning(const String& message);
void UnrecognizedLine(bool error = false);
template<typename T> void Emit(const T& text) const;
inline void EmitLine() const;
template<typename T> void EmitLine(const T& line) const;
inline void Error(const String& message);
inline void Flush() const;
inline void Warning(const String& message);
inline void UnrecognizedLine(bool error = false);
std::unordered_map<String, Material> m_materials;
Stream& m_stream;
mutable Stream* m_currentStream;
String m_currentLine;
mutable StringStream m_outputStream;
bool m_keepLastLine;
unsigned int m_lineCount;
unsigned int m_streamFlags;
};
}
#include <Nazara/Utility/Formats/MTLParser.inl>
#endif // NAZARA_FORMATS_MTLPARSER_HPP