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