Initialized a material.

Add warning message to `err` when material file not found.
This commit is contained in:
Syoyo Fujita
2015-06-25 20:24:24 +09:00
parent 3058419d7d
commit 164c152216

View File

@@ -414,7 +414,9 @@ std::string LoadMtl(std::map<std::string, int> &material_map,
std::istream &inStream) { std::istream &inStream) {
std::stringstream err; std::stringstream err;
// Create a default material anyway.
material_t material; material_t material;
InitMaterial(material);
int maxchars = 8192; // Alloc enough size. int maxchars = 8192; // Alloc enough size.
std::vector<char> buf(maxchars); // Alloc enough size. std::vector<char> buf(maxchars); // Alloc enough size.
@@ -623,7 +625,13 @@ std::string MaterialFileReader::operator()(const std::string &matId,
} }
std::ifstream matIStream(filepath.c_str()); std::ifstream matIStream(filepath.c_str());
return LoadMtl(matMap, materials, matIStream); std::string err = LoadMtl(matMap, materials, matIStream);
if (!matIStream) {
std::stringstream ss;
ss << "WARN: Material file [ " << filepath << " ] not found. Created a default material.";
err += ss.str();
}
return err;
} }
std::string LoadObj(std::vector<shape_t> &shapes, std::string LoadObj(std::vector<shape_t> &shapes,