port from perforce
This commit is contained in:
44
meshToolsV5/TestApp/ObjExporter.h
Normal file
44
meshToolsV5/TestApp/ObjExporter.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#if _DEBUG
|
||||
|
||||
#include "../src/Lib/mt/mt.h"
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
class Mesh;
|
||||
|
||||
class ObjExporter
|
||||
{
|
||||
public:
|
||||
static void Export(mt::Mesh* mesh, const std::string& filePath);
|
||||
|
||||
ObjExporter(mt::Mesh* mesh);
|
||||
void Export(const std::string& filePath);
|
||||
void WriteFaceGroups(std::ostringstream& builder, std::ostringstream& mtlBuilder);
|
||||
void WriteFaces(std::ostringstream& builder, const mt::FaceList& faces);
|
||||
void WritePositions(std::ostringstream& builder);
|
||||
void WriteNormals(std::ostringstream& builder);
|
||||
void WriteUVs(std::ostringstream& builder);
|
||||
|
||||
private:
|
||||
std::string replace(const std::string &input, const std::string &search, const std::string &replace)
|
||||
{
|
||||
auto s = input;
|
||||
for (size_t pos = 0;; pos += replace.length())
|
||||
{
|
||||
// Locate the substring to replace
|
||||
pos = s.find(search, pos);
|
||||
if (pos == std::string::npos) break;
|
||||
// Replace by erasing and inserting
|
||||
s.erase(pos, search.length());
|
||||
s.insert(pos, replace);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
private:
|
||||
mt::Mesh* mesh;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user