| 451 | } |
| 452 | |
| 453 | std::unique_ptr<sg::SubMesh> GLTFLoader::read_model_from_file(const std::string &file_name, uint32_t index, bool storage_buffer, VkBufferUsageFlags additional_buffer_usage_flags) |
| 454 | { |
| 455 | PROFILE_SCOPE("Load GLTF Model"); |
| 456 | |
| 457 | std::string err; |
| 458 | std::string warn; |
| 459 | |
| 460 | tinygltf::TinyGLTF gltf_loader; |
| 461 | |
| 462 | std::string gltf_file = vkb::fs::path::get(vkb::fs::path::Type::Assets) + file_name; |
| 463 | |
| 464 | bool importResult = gltf_loader.LoadASCIIFromFile(&model, &err, &warn, gltf_file.c_str()); |
| 465 | |
| 466 | if (!importResult) |
| 467 | { |
| 468 | LOGE("Failed to load gltf file {}.", gltf_file.c_str()); |
| 469 | |
| 470 | return nullptr; |
| 471 | } |
| 472 | |
| 473 | if (!err.empty()) |
| 474 | { |
| 475 | LOGE("Error loading gltf model: {}.", err.c_str()); |
| 476 | |
| 477 | return nullptr; |
| 478 | } |
| 479 | |
| 480 | if (!warn.empty()) |
| 481 | { |
| 482 | LOGI("{}", warn.c_str()); |
| 483 | } |
| 484 | |
| 485 | size_t pos = file_name.find_last_of('/'); |
| 486 | |
| 487 | model_path = file_name.substr(0, pos); |
| 488 | |
| 489 | if (pos == std::string::npos) |
| 490 | { |
| 491 | model_path.clear(); |
| 492 | } |
| 493 | |
| 494 | return std::move(load_model(index, storage_buffer, additional_buffer_usage_flags)); |
| 495 | } |
| 496 | |
| 497 | vkb::scene_graph::SceneC GLTFLoader::load_scene(int scene_index, VkBufferUsageFlags additional_buffer_usage_flags) |
| 498 | { |
no test coverage detected