1#ifndef OE_SCENE_LOADER_GLTF_H
2#define OE_SCENE_LOADER_GLTF_H
4#include "../../lib/json_fwd.hpp"
8#include "../node/multi_mesh.h"
11#include "gltf_extensions.h"
15 class SkinnedMeshNode;
74 Gltf(
const std::string& filename);
140 std::vector<std::shared_ptr<oe::scene::Node>> _scenes;
153 std::unordered_map<uint32_t, std::list<std::pair<std::shared_ptr<oe::scene::Mesh>, int32_t>>>
_meshes;
156 std::unordered_map<uint32_t, std::list<std::pair<std::shared_ptr<oe::scene::SkinnedMesh>, int32_t>>> _skinned_meshes;
159 std::unordered_map<oe::scene::SkinnedMeshNode*, uint32_t> _skinned_nodes_skins;
166 std::vector<std::shared_ptr<oe::render::Texture>> _textures;
169 std::function<void(
Node& node,
Material& node_material)> _node_material_modifier = {};
173 std::unique_ptr<tinygltf::TinyGLTF> _loader;
174 std::unique_ptr<tinygltf::Model> _model;
176 void _custom_load(
const std::string& filename);
178 std::function<void(
const std::string& extension,
Node& root_node,
const nlohmann::json& extension_data,
const bool pre_load)> _custom_asset_extension_handler = {};
179 std::function<void(
const std::string& extension, Node& node,
const nlohmann::json& extension_data)> _custom_node_extension_handler = {};
180 std::function<void(
const std::string& extension, Material& material,
const nlohmann::json& extension_data)> _custom_material_extension_handler = {};
209 template <
typename ExtensionManager = gltf::ExtensionManager<gltf::Extension>>
220 extensions(extension_manager)
222 _custom_asset_extension_handler = [
this] (
const std::string& extension,
Node& root_node,
const nlohmann::json& extension_data,
const bool pre_load)
224 extensions.applyOnAsset(extension, root_node, extension_data, pre_load);
227 _custom_node_extension_handler = [
this] (
const std::string& extension,
Node& node,
const nlohmann::json& extension_data)
229 extensions.applyOnNode(extension, node, extension_data);
238 void load(
const std::string& filename)
240 _custom_load(filename);
243 ExtensionManager extensions;
handles the load and deletion of textures/cubemaps
Definition texture_manager.h:51
Scene manager.
Definition manager.h:21
Render agnostic material.
Definition material.h:26
Load a glTF asset with custom extensions registered.
Definition gltf.h:211
void load(const std::string &filename)
Load a glTF asset from a file.
Definition gltf.h:238
GltfWithExtensions(const ExtensionManager &extension_manager)
Init the glTF loader with a custom list of extensions.
Definition gltf.h:218
Loader to load Khronos glTF assets.
Definition gltf.h:67
std::unordered_map< uint32_t, std::list< std::pair< std::shared_ptr< oe::scene::Mesh >, int32_t > > > _meshes
std::list<std::pair<oe::scene::Mesh, int32_t>> _primitives;
Definition gltf.h:153
void setNodeMaterialModifier(std::function< void(Node &node, Material &node_material)>)
Apply application specific properties on the material that will be applied to a node.
oe::scene::Node & addIntoSceneManager(oe::scene::Manager &scene_manager, uint16_t id_scene=0)
Load the glTF asset into a scene (under a new root node)
std::vector< Material > getMaterials()
Convert and return materials.
Gltf(const std::string &filename)
Load a glTF asset from a file.
oe::scene::Node & addIntoSceneManager(oe::scene::Manager &scene_manager, oe::scene::Node &root_node, uint16_t id_scene=0)
Load the glTF asset into a scene (using a specified node as root node)
void setMaterialFiller(std::function< void(const PbrMaterial &gltf_material, Material &oe_material)>)
Apply application specific properties on the materials.
void convertTextures(render::TextureManager &)
Load model textures.
Render related abstractions (Shader, Framebuffer, Cubemaps, Textures)
Definition opengl.h:10
Generators of geometry / scene by computation (eg. Bezier) or from files (eg. Gltf)
Definition base.h:9
Scene related management (Render-agnostic Geometry, Manger, etc...)
Definition debug.h:19
Common properties/textures tied to a PBR material.
Definition material.h:238