| 2093 | } |
| 2094 | |
| 2095 | bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes, |
| 2096 | std::vector<material_t> *materials, std::string *warn, |
| 2097 | std::string *err, const char *filename, const char *mtl_basedir, |
| 2098 | bool trianglulate, bool default_vcols_fallback) { |
| 2099 | attrib->vertices.clear(); |
| 2100 | attrib->normals.clear(); |
| 2101 | attrib->texcoords.clear(); |
| 2102 | attrib->colors.clear(); |
| 2103 | shapes->clear(); |
| 2104 | |
| 2105 | std::stringstream errss; |
| 2106 | |
| 2107 | std::ifstream ifs(filename); |
| 2108 | if (!ifs) { |
| 2109 | errss << "Cannot open file [" << filename << "]" << std::endl; |
| 2110 | if (err) { |
| 2111 | (*err) = errss.str(); |
| 2112 | } |
| 2113 | return false; |
| 2114 | } |
| 2115 | |
| 2116 | std::string baseDir = mtl_basedir ? mtl_basedir : ""; |
| 2117 | if (!baseDir.empty()) { |
| 2118 | #ifndef _WIN32 |
| 2119 | const char dirsep = '/'; |
| 2120 | #else |
| 2121 | const char dirsep = '\\'; |
| 2122 | #endif |
| 2123 | if (baseDir[baseDir.length() - 1] != dirsep) baseDir += dirsep; |
| 2124 | } |
| 2125 | MaterialFileReader matFileReader(baseDir); |
| 2126 | |
| 2127 | return LoadObj(attrib, shapes, materials, warn, err, &ifs, &matFileReader, |
| 2128 | trianglulate, default_vcols_fallback); |
| 2129 | } |
| 2130 | |
| 2131 | bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes, |
| 2132 | std::vector<material_t> *materials, std::string *warn, |
no test coverage detected