| 3469 | } |
| 3470 | |
| 3471 | bool ObjReader::ParseFromFile(const std::string &filename, |
| 3472 | const ObjReaderConfig &config) { |
| 3473 | std::string mtl_search_path; |
| 3474 | |
| 3475 | if (config.mtl_search_path.empty()) { |
| 3476 | // |
| 3477 | // split at last '/'(for unixish system) or '\\'(for windows) to get |
| 3478 | // the base directory of .obj file |
| 3479 | // |
| 3480 | size_t pos = filename.find_last_of("/\\"); |
| 3481 | if (pos != std::string::npos) { |
| 3482 | mtl_search_path = filename.substr(0, pos); |
| 3483 | } |
| 3484 | } else { |
| 3485 | mtl_search_path = config.mtl_search_path; |
| 3486 | } |
| 3487 | |
| 3488 | valid_ = LoadObj(&attrib_, &shapes_, &materials_, &warning_, &error_, |
| 3489 | filename.c_str(), mtl_search_path.c_str(), |
| 3490 | config.triangulate, config.vertex_color); |
| 3491 | |
| 3492 | return valid_; |
| 3493 | } |
| 3494 | |
| 3495 | bool ObjReader::ParseFromString(const std::string &obj_text, |
| 3496 | const std::string &mtl_text, |