8#include <glm/gtc/type_ptr.hpp>
14 Ecs::LocalTransform extractNodeTransform(
const tinygltf::Node& node) {
17 if (!node.translation.empty()) {
18 transform.setLocation(glm::vec3(
25 if (!node.rotation.empty()) {
27 transform.setRotationQuat(glm::quat(
28 static_cast<float>(node.rotation[3]),
29 static_cast<float>(node.rotation[0]),
30 static_cast<float>(node.rotation[1]),
31 static_cast<float>(node.rotation[2])
35 if (!node.scale.empty()) {
36 transform.setScale(glm::vec3(
43 return Ecs::LocalTransform{ transform.toMatrix() };
49 const std::filesystem::path& gltfPath)
51 std::vector<StaticMeshActor*> spawnedActors;
67 spawnedActors.reserve(model.nodes.size());
69 for (
const tinygltf::Node& node : model.nodes) {
79 spawnedActors.push_back(actor);
void loadEcsModel(const std::filesystem::path &path)
Submits a gltf model for loading. You provide the path of the model to load. This can include 3D data...
tinygltf::Model loadMetadataOnly(const std::filesystem::path &path) const
Loads only the GLTF metadata (nodes, names, transforms) without loading buffer data.
static std::vector< StaticMeshActor * > spawnAll(Scene *scene, const std::filesystem::path &gltfPath)
A scene is the overarching structure which can spawn actors.
T * spawnActor(const Ecs::LocalTransform &spawnTransform, Args &&... args)
Spawns an actor from a specific class in somewhere into the scene.
AssetManager * getAssetManager() const
Gets the asset manager for this scene.
Wrapper for entt component creation which ensures types safety and attaches the correct component wit...
Log category system implementation.