| 3168 | } |
| 3169 | |
| 3170 | bool ObjReader::ParseFromFile(const std::string &filename, |
| 3171 | const ObjReaderConfig &config) { |
| 3172 | std::string mtl_search_path; |
| 3173 | |
| 3174 | if (config.mtl_search_path.empty()) { |
| 3175 | // |
| 3176 | // split at last '/'(for unixish system) or '\\'(for windows) to get |
| 3177 | // the base directory of .obj file |
| 3178 | // |
| 3179 | size_t pos = filename.find_last_of("/\\"); |
| 3180 | if (pos != std::string::npos) { |
| 3181 | mtl_search_path = filename.substr(0, pos); |
| 3182 | } |
| 3183 | } else { |
| 3184 | mtl_search_path = config.mtl_search_path; |
| 3185 | } |
| 3186 | |
| 3187 | valid_ = LoadObj(&attrib_, &shapes_, &materials_, &warning_, &error_, |
| 3188 | filename.c_str(), mtl_search_path.c_str(), |
| 3189 | config.triangulate, config.vertex_color); |
| 3190 | |
| 3191 | return valid_; |
| 3192 | } |
| 3193 | |
| 3194 | bool ObjReader::ParseFromString(const std::string &obj_text, |
| 3195 | const std::string &mtl_text, |