MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / read_scene_from_file

Method read_scene_from_file

framework/gltf_loader.cpp:410–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 11

load_sceneMethod · 0.45
load_sceneMethod · 0.45
load_sceneMethod · 0.45
load_assetsMethod · 0.45
load_assetsMethod · 0.45
load_assetsMethod · 0.45
RaytracingSceneMethod · 0.45
load_sceneMethod · 0.45
load_assetsMethod · 0.45
RaytracingSceneMethod · 0.45

Calls 3

emptyMethod · 0.80
getFunction · 0.50
clearMethod · 0.45

Tested by

no test coverage detected