| 408 | } |
| 409 | |
| 410 | std::unique_ptr<vkb::scene_graph::SceneC> GLTFLoader::read_scene_from_file(const std::string &file_name, int scene_index, VkBufferUsageFlags additional_buffer_usage_flags) |
| 411 | { |
| 412 | PROFILE_SCOPE("Load GLTF Scene"); |
| 413 | |
| 414 | std::string err; |
| 415 | std::string warn; |
| 416 | |
| 417 | tinygltf::TinyGLTF gltf_loader; |
| 418 | |
| 419 | std::string gltf_file = vkb::fs::path::get(vkb::fs::path::Type::Assets) + file_name; |
| 420 | |
| 421 | bool importResult = gltf_loader.LoadASCIIFromFile(&model, &err, &warn, gltf_file.c_str()); |
| 422 | |
| 423 | if (!importResult) |
| 424 | { |
| 425 | LOGE("Failed to load gltf file {}.", gltf_file.c_str()); |
| 426 | |
| 427 | return nullptr; |
| 428 | } |
| 429 | |
| 430 | if (!err.empty()) |
| 431 | { |
| 432 | LOGE("Error loading gltf model: {}.", err.c_str()); |
| 433 | return nullptr; |
| 434 | } |
| 435 | |
| 436 | if (!warn.empty()) |
| 437 | { |
| 438 | LOGI("{}", warn.c_str()); |
| 439 | } |
| 440 | |
| 441 | size_t pos = file_name.find_last_of('/'); |
| 442 | |
| 443 | model_path = file_name.substr(0, pos); |
| 444 | |
| 445 | if (pos == std::string::npos) |
| 446 | { |
| 447 | model_path.clear(); |
| 448 | } |
| 449 | |
| 450 | return std::make_unique<vkb::scene_graph::SceneC>(load_scene(scene_index, additional_buffer_usage_flags)); |
| 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 | { |
no test coverage detected