Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Source/OBJ_Loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ namespace objl
std::vector<unsigned int> Indices;

std::vector<std::string> MeshMatNames;
std::string lastMat;
bool matAddedToMesh = false;

bool listening = false;
std::string meshname;
Expand Down Expand Up @@ -517,6 +519,11 @@ namespace objl
meshname.clear();

meshname = algorithm::tail(curline);

if (matAddedToMesh == false)
{
MeshMatNames.push_back(lastMat);
}
}
else
{
Expand All @@ -534,6 +541,8 @@ namespace objl
std::cout << std::endl;
outputIndicator = 0;
#endif

matAddedToMesh = false;
}
// Generate a Vertex Position
if (algorithm::firstToken(curline) == "v")
Expand Down Expand Up @@ -606,7 +615,9 @@ namespace objl
// Get Mesh Material Name
if (algorithm::firstToken(curline) == "usemtl")
{
MeshMatNames.push_back(algorithm::tail(curline));
lastMat = algorithm::tail(curline);
matAddedToMesh = true;
MeshMatNames.push_back(lastMat);

// Create new Mesh, if Material changes within a group
if (!Indices.empty() && !Vertices.empty())
Expand Down Expand Up @@ -681,6 +692,11 @@ namespace objl

// Insert Mesh
LoadedMeshes.push_back(tempMesh);

if (matAddedToMesh == false)
{
MeshMatNames.push_back(lastMat);
}
}

file.close();
Expand Down