| 2561 | } |
| 2562 | |
| 2563 | bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes, |
| 2564 | std::vector<material_t> *materials, std::string *warn, |
| 2565 | std::string *err, const char *filename, const char *mtl_basedir, |
| 2566 | bool triangulate, bool default_vcols_fallback) { |
| 2567 | attrib->vertices.clear(); |
| 2568 | attrib->normals.clear(); |
| 2569 | attrib->texcoords.clear(); |
| 2570 | attrib->colors.clear(); |
| 2571 | shapes->clear(); |
| 2572 | |
| 2573 | std::stringstream errss; |
| 2574 | |
| 2575 | std::ifstream ifs(filename); |
| 2576 | if (!ifs) { |
| 2577 | errss << "Cannot open file [" << filename << "]\n"; |
| 2578 | if (err) { |
| 2579 | (*err) = errss.str(); |
| 2580 | } |
| 2581 | return false; |
| 2582 | } |
| 2583 | |
| 2584 | std::string baseDir = mtl_basedir ? mtl_basedir : ""; |
| 2585 | if (!baseDir.empty()) { |
| 2586 | #ifndef _WIN32 |
| 2587 | const char dirsep = '/'; |
| 2588 | #else |
| 2589 | const char dirsep = '\\'; |
| 2590 | #endif |
| 2591 | if (baseDir[baseDir.length() - 1] != dirsep) baseDir += dirsep; |
| 2592 | } |
| 2593 | MaterialFileReader matFileReader(baseDir); |
| 2594 | |
| 2595 | return LoadObj(attrib, shapes, materials, warn, err, &ifs, &matFileReader, |
| 2596 | triangulate, default_vcols_fallback); |
| 2597 | } |
| 2598 | |
| 2599 | bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes, |
| 2600 | std::vector<material_t> *materials, std::string *warn, |
no test coverage detected