Finality Engine
Loading...
Searching...
No Matches
ModelAsset.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <Core/Core.h>
14#include "MeshImporter.h"
15#include "ModelImportOptions.h"
16#include <filesystem>
17#include <map>
18
19namespace FINALITY
20{
21 class Scene;
22 class Entity;
23 struct RenderPacket;
24
26 struct ModelMesh
27 {
28 std::string Name;
29 std::string Key;
30 uint32_t Material = 0;
32 };
33
36 {
37 std::string Name;
38 glm::vec4 Color{1};
39 std::string Texture;
40 std::string Asset;
41 bool DoubleSided = false;
42 std::map<std::string,std::string> Properties;
43 };
44
46 struct ModelNode
47 {
48 std::string Name;
49 int Parent = -1;
50 glm::mat4 Transform{1};
51 std::vector<uint32_t> Meshes;
52 };
53
55 struct ModelData
56 {
57 std::vector<ModelMesh> Meshes;
58 std::vector<ModelMaterial> Materials;
59 std::vector<ModelNode> Nodes;
60 std::vector<std::string> Dependencies;
61 std::vector<std::string> Diagnostics;
62 glm::vec3 Minimum{0}, Maximum{0};
63 };
64
75 {
76 public:
77 static void Configure(const std::filesystem::path& engineAssets, const ModelImportOptions& options = {});
78 static std::shared_ptr<ModelData> Load(const std::string& reference, bool force = false);
79 static bool Import(const std::filesystem::path& source, const std::filesystem::path& target);
80 static void MakePortable(const std::filesystem::path& path, const std::filesystem::path& sourceDirectory = {});
81 static std::shared_ptr<Mesh> LoadMesh(const std::string& reference);
82 static Entity Instantiate(Scene& scene, const std::string& reference);
83 static std::vector<RenderPacket> BuildPreview(const std::string& reference);
84 static void Clear();
85 static bool Supports(const std::filesystem::path& path);
86 static ModelImportOptions GetImportOptions(const std::string& reference);
87 static bool SaveImportOptions(const std::string& reference, const ModelImportOptions& options, std::string& error);
88 static bool ExtractMaterials(const std::string& reference, const std::filesystem::path& directory, std::string& error);
89 };
90}
#define FAPI
Definition Core.h:22
Defines model conversion and import policy.
Provides a scene-bound handle for component and hierarchy operations.
Definition Entity.h:34
Loads imported model data and instantiates preserved model hierarchies.
Definition ModelAsset.h:75
static Entity Instantiate(Scene &scene, const std::string &reference)
static void MakePortable(const std::filesystem::path &path, const std::filesystem::path &sourceDirectory={})
static void Configure(const std::filesystem::path &engineAssets, const ModelImportOptions &options={})
static std::shared_ptr< ModelData > Load(const std::string &reference, bool force=false)
static bool Supports(const std::filesystem::path &path)
static bool ExtractMaterials(const std::string &reference, const std::filesystem::path &directory, std::string &error)
static ModelImportOptions GetImportOptions(const std::string &reference)
static std::shared_ptr< Mesh > LoadMesh(const std::string &reference)
static bool Import(const std::filesystem::path &source, const std::filesystem::path &target)
static std::vector< RenderPacket > BuildPreview(const std::string &reference)
static bool SaveImportOptions(const std::string &reference, const ModelImportOptions &options, std::string &error)
static void Clear()
Owns entities and dispatches script simulation.
Definition Scene.h:36
Imported nodes, submeshes, materials, dependencies, diagnostics and model-space bounds.
Definition ModelAsset.h:56
std::vector< std::string > Dependencies
Definition ModelAsset.h:60
std::vector< ModelMaterial > Materials
Definition ModelAsset.h:58
std::vector< ModelNode > Nodes
Definition ModelAsset.h:59
std::vector< ModelMesh > Meshes
Definition ModelAsset.h:57
std::vector< std::string > Diagnostics
Definition ModelAsset.h:61
Imported material appearance, texture reference and extracted asset mapping.
Definition ModelAsset.h:36
std::map< std::string, std::string > Properties
Definition ModelAsset.h:42
One imported submesh, with geometry and an index into ModelData::Materials.
Definition ModelAsset.h:27
std::string Name
Definition ModelAsset.h:28
MeshGeometry Geometry
Definition ModelAsset.h:31
std::string Key
Definition ModelAsset.h:29
One hierarchy node with a parent index, local transform and attached mesh indices.
Definition ModelAsset.h:47
std::vector< uint32_t > Meshes
Definition ModelAsset.h:51
glm::mat4 Transform
Definition ModelAsset.h:50
std::string Name
Definition ModelAsset.h:48
Scene draw submission retaining geometry, material and visibility inputs until backend recording.