|
Oxygen Engine
Modern C++ 3D Engine using OpenGL
|
Loader to load Khronos glTF assets. More...
#include <OxygenEngine/scene/loader/gltf.h>
Inheritance diagram for oe::scene::loader::Gltf:Classes | |
| struct | GltfSceneData |
| struct | GltfTextureList |
| Load the glTF asset into a scene (a new root node will be created) More... | |
Public Types | |
| using | MeshFlags = uint8_t |
Public Member Functions | |
| 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. | |
| GltfTextureList | convertTextures (render::TextureManager &texture_manager, std::string_view prefix) const |
| Load model textures. | |
| void | setMaterialFiller (std::function< void(const GltfPbrMaterial &gltf_material, Material &oe_material)> material_filler) |
| Apply application specific properties on the materials. | |
| std::vector< Material > | convertMaterials (GltfTextureList textures) const |
| Convert and return materials. | |
| Material | generateDefaultMaterial () const |
| Generate a default material suitable for glTF rendering. | |
Protected Member Functions | |
| void | _custom_load (const std::string &filename) |
Protected Attributes | |
| std::function< void(const GltfPbrMaterial &, Material &)> | _material_filler = {} |
| std::list<std::pair<oe::scene::Mesh, int32_t>> _primitives; | |
| tinygltf::TinyGLTF * | _loader |
| tinygltf::Model * | _model |
| std::function< void(const std::string &extension, NodePtr root_node, const nlohmann::json &extension_data, const bool pre_load)> | _custom_asset_extension_handler = {} |
| std::function< void(const std::string &extension, NodePtr node, const nlohmann::json &extension_data)> | _custom_node_extension_handler = {} |
| std::function< void(const std::string &extension, Material &material, const nlohmann::json &extension_data)> | _custom_material_extension_handler = {} |
Loader to load Khronos glTF assets.
Example
The loader will automatically handle the following glTF extensions:
| oe::scene::loader::Gltf::Gltf | ( | const std::string & | filename | ) |
Load a glTF asset from a file.
| filename | path to the glTF asset |
| std::vector< Material > oe::scene::loader::Gltf::convertMaterials | ( | GltfTextureList | textures | ) | const |
Convert and return materials.
| GltfSceneData oe::scene::loader::Gltf::convertSceneData | ( | oe::scene::NodePtr | root_node, |
| uint16_t | id_scene = 0 |
||
| ) | const |
Convert the glTF asset into scene data under the specified node.
| root_node | Asset's root nodes will be imported as children of this node |
| id_scene | glTF scene to load |
| GltfTextureList oe::scene::loader::Gltf::convertTextures | ( | render::TextureManager & | texture_manager, |
| std::string_view | prefix | ||
| ) | const |
Load model textures.
prefix can be anything you want, but it must be unique for gltf asset (ie. if you load the same asset multiple times, the prefix should be the same)
Will generate textures named prefix_X and prefix_RMA_Y|Z in the Texture manager
| texture_manager | |
| prefix | Texture prefix in the texture manager |