| 2923 | } |
| 2924 | |
| 2925 | bool ObjReader::ParseFromFile(const std::string &filename, |
| 2926 | const ObjReaderConfig &config) { |
| 2927 | std::string mtl_search_path; |
| 2928 | |
| 2929 | if (config.mtl_search_path.empty()) { |
| 2930 | // |
| 2931 | // split at last '/'(for unixish system) or '\\'(for windows) to get |
| 2932 | // the base directory of .obj file |
| 2933 | // |
| 2934 | if (filename.find_last_of("/\\") != std::string::npos) { |
| 2935 | mtl_search_path = filename.substr(0, filename.find_last_of("/\\")); |
| 2936 | } |
| 2937 | } |
| 2938 | |
| 2939 | valid_ = LoadObj(&attrib_, &shapes_, &materials_, &warning_, &error_, |
| 2940 | filename.c_str(), mtl_search_path.c_str(), |
| 2941 | config.triangulate, config.vertex_color); |
| 2942 | |
| 2943 | return valid_; |
| 2944 | } |
| 2945 | |
| 2946 | bool ObjReader::ParseFromString(const std::string &obj_text, |
| 2947 | const std::string &mtl_text, |