You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
44 lines
1.4 KiB
```cpp
|
|
void getTexturePath(std::string material, std::string libPath, subMesh &currMesh) {
|
|
std::ifstream file(libPath);
|
|
std::string line;
|
|
std::string texturePath;
|
|
bool foundMat = false;
|
|
while(std::getline(file, line)) {
|
|
std::stringstream ss(line);
|
|
std::string keyword;
|
|
ss.unsetf(std::ios_base::skipws);
|
|
|
|
ss >> std::ws;
|
|
|
|
ss >> std::ws >> keyword;
|
|
std::string currMat;
|
|
if (foundMat) {
|
|
std::string matName;
|
|
ss >> std::ws >> matName;
|
|
if (keyword.length() >= 3) {
|
|
if (keyword.substr(0, 3) == "map") {
|
|
texturePath = line.substr(6 + (keyword.length() - 5));
|
|
|
|
currMesh.subTex = new olc::Sprite(texturePath);
|
|
currMesh.hasTexture = true;
|
|
currMesh.texPath = texturePath;
|
|
return;
|
|
}
|
|
}
|
|
else if (matName == "") {
|
|
currMesh.hasTexture = false;
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (keyword == "newmtl") {
|
|
currMat = line.substr(7);
|
|
if (currMat == material) {
|
|
foundMat = true;
|
|
}
|
|
}
|
|
}
|
|
currMesh.hasTexture = false;
|
|
}
|
|
``` |