| 2291 | } |
| 2292 | |
| 2293 | bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes, |
| 2294 | std::vector<material_t> *materials, std::string *warn, |
| 2295 | std::string *err, const char *filename, const char *mtl_basedir, |
| 2296 | bool triangulate, bool default_vcols_fallback) { |
| 2297 | attrib->vertices.clear(); |
| 2298 | attrib->normals.clear(); |
| 2299 | attrib->texcoords.clear(); |
| 2300 | attrib->colors.clear(); |
| 2301 | shapes->clear(); |
| 2302 | |
| 2303 | std::stringstream errss; |
| 2304 | |
| 2305 | std::ifstream ifs(filename); |
| 2306 | if (!ifs) { |
| 2307 | errss << "Cannot open file [" << filename << "]\n"; |
| 2308 | if (err) { |
| 2309 | (*err) = errss.str(); |
| 2310 | } |
| 2311 | return false; |
| 2312 | } |
| 2313 | |
| 2314 | std::string baseDir = mtl_basedir ? mtl_basedir : ""; |
| 2315 | if (!baseDir.empty()) { |
| 2316 | #ifndef _WIN32 |
| 2317 | const char dirsep = '/'; |
| 2318 | #else |
| 2319 | const char dirsep = '\\'; |
| 2320 | #endif |
| 2321 | if (baseDir[baseDir.length() - 1] != dirsep) baseDir += dirsep; |
| 2322 | } |
| 2323 | MaterialFileReader matFileReader(baseDir); |
| 2324 | |
| 2325 | return LoadObj(attrib, shapes, materials, warn, err, &ifs, &matFileReader, |
| 2326 | triangulate, default_vcols_fallback); |
| 2327 | } |
| 2328 | |
| 2329 | bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes, |
| 2330 | std::vector<material_t> *materials, std::string *warn, |
no test coverage detected