Utility/OBJParser: Add saving

Former-commit-id: e05fec0cb2309c0a935ff1293b698433390675a7 [formerly bffd283b0c04e45df50adaa7b061aacdda10a0ec]
Former-commit-id: 7792044687e73fa8d5862aa15de373370023249a
This commit is contained in:
Lynix
2016-07-07 09:00:50 +02:00
parent 84e9b3e148
commit 087c3b104b
3 changed files with 169 additions and 0 deletions

View File

@@ -58,6 +58,8 @@ namespace Nz
bool Parse(Stream& stream, std::size_t reservedVertexCount = 100);
bool Save(Stream& stream) const;
private:
bool Advance(bool required = true);
template<typename T> void Emit(const T& text) const;

View File

@@ -63,12 +63,37 @@ namespace Nz
return m_texCoords.size();
}
template<typename T>
void OBJParser::Emit(const T& text) const
{
m_outputStream << text;
if (m_outputStream.GetBufferSize() > 1024 * 1024)
Flush();
}
inline void OBJParser::EmitLine() const
{
Emit('\n');
}
template<typename T>
void OBJParser::EmitLine(const T& line) const
{
Emit(line);
Emit('\n');
}
inline void OBJParser::Error(const String& message)
{
NazaraError(message + " at line #" + String::Number(m_lineCount));
}
inline void OBJParser::Flush() const
{
m_currentStream->Write(m_outputStream);
m_outputStream.Clear();
}
inline void OBJParser::Warning(const String& message)
{
NazaraWarning(message + " at line #" + String::Number(m_lineCount));