MCPcopy Create free account
hub / github.com/ddiakopoulos/polymer / import_model

Method import_model

libraries/lib-model-io/src/model-io.cpp:25–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23using namespace tinyply;
24
25std::unordered_map<std::string, runtime_mesh> polymer::import_model(const std::string & path)
26{
27 std::unordered_map<std::string, runtime_mesh> models;
28
29 std::string ext = get_extension(path);
30 std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
31
32 if (ext == "obj")
33 {
34 auto asset = import_obj_model(path);
35 for (auto & a : asset) models[a.first] = a.second;
36 }
37 else if (ext == "ply")
38 {
39 auto asset = import_ply_model(path);
40 for (auto & a : asset) models[a.first] = a.second;
41 }
42 else if (ext == "mesh")
43 {
44 auto m = import_polymer_binary_model(path);
45 models[get_filename_without_extension(path)] = m;
46 }
47 else if (ext == "gltf" || ext == "glb")
48 {
49 auto asset = import_gltf_model(path);
50 for (auto & a : asset) models[a.first] = a.second;
51 }
52 else
53 {
54 throw std::runtime_error("cannot import model format");
55 }
56
57 // Compute tangents and bitangents...
58 for (auto & m : models)
59 {
60 compute_tangents(m.second);
61 }
62
63 return models;
64}
65
66std::unordered_map<std::string, runtime_mesh> polymer::import_obj_model(const std::string & path)
67{

Callers

nothing calls this directly

Calls 6

get_extensionFunction · 0.85
transformClass · 0.85
compute_tangentsFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected