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

Method parse_node

framework/gltf_loader.cpp:1323–1366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1321 return std::move(submesh);
1322}
1323
1324std::unique_ptr<vkb::scene_graph::NodeC> GLTFLoader::parse_node(const tinygltf::Node &gltf_node, size_t index) const
1325{
1326 auto node = std::make_unique<vkb::scene_graph::NodeC>(index, gltf_node.name);
1327
1328 auto &transform = node->get_component<sg::Transform>();
1329
1330 if (!gltf_node.translation.empty())
1331 {
1332 glm::vec3 translation;
1333
1334 std::transform(gltf_node.translation.begin(), gltf_node.translation.end(), glm::value_ptr(translation), TypeCast<double, float>{});
1335
1336 transform.set_translation(translation);
1337 }
1338
1339 if (!gltf_node.rotation.empty())
1340 {
1341 glm::quat rotation;
1342
1343 std::transform(gltf_node.rotation.begin(), gltf_node.rotation.end(), glm::value_ptr(rotation), TypeCast<double, float>{});
1344
1345 transform.set_rotation(rotation);
1346 }
1347
1348 if (!gltf_node.scale.empty())
1349 {
1350 glm::vec3 scale;
1351
1352 std::transform(gltf_node.scale.begin(), gltf_node.scale.end(), glm::value_ptr(scale), TypeCast<double, float>{});
1353
1354 transform.set_scale(scale);
1355 }
1356
1357 if (!gltf_node.matrix.empty())
1358 {
1359 glm::mat4 matrix;
1360
1361 std::transform(gltf_node.matrix.begin(), gltf_node.matrix.end(), glm::value_ptr(matrix), TypeCast<double, float>{});
1362
1363 transform.set_matrix(matrix);
1364 }
1365
1366 return node;
1367}
1368
1369std::unique_ptr<sg::Camera> GLTFLoader::parse_camera(const tinygltf::Camera &gltf_camera) const

Callers

nothing calls this directly

Calls 7

emptyMethod · 0.80
endMethod · 0.80
set_scaleMethod · 0.80
set_matrixMethod · 0.80
beginMethod · 0.45
set_translationMethod · 0.45
set_rotationMethod · 0.45

Tested by

no test coverage detected