| 3271 | } |
| 3272 | |
| 3273 | bool ObjReader::ParseFromFile(const std::string &filename, |
| 3274 | const ObjReaderConfig &config) { |
| 3275 | std::string mtl_search_path; |
| 3276 | |
| 3277 | if (config.mtl_search_path.empty()) { |
| 3278 | // |
| 3279 | // split at last '/'(for unixish system) or '\\'(for windows) to get |
| 3280 | // the base directory of .obj file |
| 3281 | // |
| 3282 | size_t pos = filename.find_last_of("/\\"); |
| 3283 | if (pos != std::string::npos) { |
| 3284 | mtl_search_path = filename.substr(0, pos); |
| 3285 | } |
| 3286 | } else { |
| 3287 | mtl_search_path = config.mtl_search_path; |
| 3288 | } |
| 3289 | |
| 3290 | valid_ = LoadObj(&attrib_, &shapes_, &materials_, &warning_, &error_, |
| 3291 | filename.c_str(), mtl_search_path.c_str(), |
| 3292 | config.triangulate, config.vertex_color); |
| 3293 | |
| 3294 | return valid_; |
| 3295 | } |
| 3296 | |
| 3297 | bool ObjReader::ParseFromString(const std::string &obj_text, |
| 3298 | const std::string &mtl_text, |