| 23 | using namespace tinyply; |
| 24 | |
| 25 | std::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 | |
| 66 | std::unordered_map<std::string, runtime_mesh> polymer::import_obj_model(const std::string & path) |
| 67 | { |
nothing calls this directly
no test coverage detected