1#ifndef OE_SCENE_LOADER_GLTF_H
2#define OE_SCENE_LOADER_GLTF_H
4#include "../../lib/json.hpp"
9#include "../lighting.h"
11#include "gltf_extensions.h"
15 class SkinnedMeshNode;
105 Gltf(
const std::string& filename);
109 using MeshFlags = uint8_t;
114 std::map<size_t, scene::SolidMesh> solid_meshes;
117 std::map<size_t, scene::SkinnedMesh> skinned_meshes;
120 std::map<NodePtr, scene::skin::Armature> skins;
123 std::vector<std::pair<NodePtr, scene::Camera>> cameras;
126 std::vector<std::pair<NodePtr, scene::PointLight>> point_lights;
130 std::vector<std::pair<NodePtr, size_t>> render_mesh_nodes;
133 std::vector<bool> render_mesh_is_skinned;
136 std::vector<std::vector<ssize_t>> render_meshs_material_ids;
140 std::vector<std::vector<std::vector<bool>>> render_meshs_material_target;
295 tinygltf::TinyGLTF* _loader;
296 tinygltf::Model* _model;
298 void _custom_load(
const std::string& filename);
300 std::function<void(
const std::string& extension,
NodePtr root_node,
const nlohmann::json& extension_data,
const bool pre_load)> _custom_asset_extension_handler = {};
301 std::function<void(
const std::string& extension,
NodePtr node,
const nlohmann::json& extension_data)> _custom_node_extension_handler = {};
302 std::function<void(
const std::string& extension, Material& material,
const nlohmann::json& extension_data)> _custom_material_extension_handler = {};
331 template <
typename ExtensionManager = gltf::ExtensionManager<gltf::Extension>>
342 extensions(extension_manager)
344 _custom_asset_extension_handler = [
this] (
const std::string& extension,
NodePtr root_node,
const nlohmann::json& extension_data,
const bool pre_load)
346 extensions.applyOnAsset(extension, root_node, extension_data, pre_load);
349 _custom_node_extension_handler = [
this] (
const std::string& extension,
NodePtr node,
const nlohmann::json& extension_data)
351 extensions.applyOnNode(extension, node, extension_data);
360 void load(
const std::string& filename)
362 _custom_load(filename);
365 ExtensionManager extensions;
handles the load and deletion of textures/cubemaps
Definition texture_manager.h:49
Render agnostic material.
Definition material.h:90
Load a glTF asset with custom extensions registered.
Definition gltf.h:333
void load(const std::string &filename)
Load a glTF asset from a file.
Definition gltf.h:360
GltfWithExtensions(const ExtensionManager &extension_manager)
Init the glTF loader with a custom list of extensions.
Definition gltf.h:340
Loader to load Khronos glTF assets.
Definition gltf.h:98
GltfTextureList convertTextures(render::TextureManager &texture_manager, std::string_view prefix) const
Load model textures.
std::function< void(const GltfPbrMaterial &, Material &)> _material_filler
std::list<std::pair<oe::scene::Mesh, int32_t>> _primitives;
Definition gltf.h:290
Material generateDefaultMaterial() const
Generate a default material suitable for glTF rendering.
std::vector< Material > convertMaterials(GltfTextureList textures) const
Convert and return materials.
void setMaterialFiller(std::function< void(const GltfPbrMaterial &gltf_material, Material &oe_material)> material_filler)
Apply application specific properties on the materials.
Definition gltf.h:208
Gltf(const std::string &filename)
Load a glTF asset from a file.
GltfSceneData convertSceneData(oe::scene::NodePtr root_node, uint16_t id_scene=0) const
Convert the glTF asset into scene data under the specified node.
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 bezier.h:10
Scene related management (Render-agnostic Geometry, Manger, etc...)
Definition debug.h:19
Wrapper to a node reference to use pointers to node even if the actual node moves in memory.
Definition node_ptr.h:19
Common properties/textures tied to a Gltf PBR material.
Definition gltf.h:37
glm::vec4 albedoColor
Definition gltf.h:39
oe::render::Texture * emissiveTexture
Definition gltf.h:51
glm::vec3 emissiveColor
Definition gltf.h:42
oe::render::Texture * normalTexture
Definition gltf.h:54
oe::render::Texture * albedoTexture
Definition gltf.h:48
glm::vec3 rouMetAoColor
Definition gltf.h:45
oe::render::Texture * rouMetAoTexture
Definition gltf.h:57
Load the glTF asset into a scene (a new root node will be created)
Definition gltf.h:176
std::vector< oe::render::Texture * > imported
textured imported from the asset
Definition gltf.h:180
std::map< size_t, oe::render::Texture * > rou_met_ao
PBR textures converted from the material.
Definition gltf.h:187