MCPcopy Create free account
hub / github.com/SaschaWillems/HowToVulkan / LoadObj

Function LoadObj

source/external/tinyobj/tiny_obj_loader.h:2563–2597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2561}
2562
2563bool 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
2599bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
2600 std::vector<material_t> *materials, std::string *warn,

Callers 3

mainFunction · 0.85
ParseFromFileMethod · 0.85
ParseFromStringMethod · 0.85

Calls 14

removeUtf8BomFunction · 0.85
parseVertexWithColorFunction · 0.85
parseReal3Function · 0.85
parseReal2Function · 0.85
parseIntFunction · 0.85
parseTripleFunction · 0.85
toStringFunction · 0.85
parseStringFunction · 0.85
exportGroupsToShapeFunction · 0.85
SplitStringFunction · 0.85
shape_tClass · 0.85
parseTagTripleFunction · 0.85

Tested by

no test coverage detected