MCPcopy Create free account
hub / github.com/Apress/Ray-Tracing-Gems-II / LoadObj

Function LoadObj

Chapter_39/tiny_obj_loader.h:2095–2129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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,

Callers 3

MeshMethod · 0.70
ParseFromFileMethod · 0.70
ParseFromStringMethod · 0.70

Calls 15

assertFunction · 0.85
stringFunction · 0.85
eraseMethod · 0.80
c_strMethod · 0.80
parseVertexWithColorFunction · 0.70
parseReal3Function · 0.70
parseReal2Function · 0.70
parseTripleFunction · 0.70
exportGroupsToShapeFunction · 0.70
SplitStringFunction · 0.70
parseStringFunction · 0.70
parseTagTripleFunction · 0.70

Tested by

no test coverage detected