Utility/OBJParser: Add saving

Former-commit-id: f991f0a66a82a68659f14a7ba887b49a2690f5a7 [formerly e4c96019484ad436048d001bd307ac549dfc615a]
Former-commit-id: 946f9e5f99ff46c26741f1877391506b23602517
This commit is contained in:
Lynix
2016-07-07 09:00:50 +02:00
parent a92a3a2901
commit bbb218f9a0
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));