Utility/OBJParser: Add saving

Former-commit-id: 5fa9694afeed1cdb19b17dca2642d391e628a25e [formerly 47991e12efca44a545a464f7d623019687e9bfa9]
Former-commit-id: 4635953b18b9b1a48c1375f55a0d907536de3c85
This commit is contained in:
Lynix
2016-07-07 09:00:50 +02:00
parent 00a3818489
commit 62ae81821e
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));