2020-06-02 11:46:18 +02:00
|
|
|
#pragma once
|
|
|
|
|
#include "MinimalEngine.h"
|
|
|
|
|
#include "Containers/List.h"
|
2023-01-21 18:43:21 +01:00
|
|
|
#include "Component/Collider.h"
|
2020-08-11 22:38:19 +02:00
|
|
|
#include <filesystem>
|
2020-06-02 11:46:18 +02:00
|
|
|
|
2020-10-03 11:00:10 +02:00
|
|
|
struct aiScene;
|
|
|
|
|
struct aiTexel;
|
2020-06-02 11:46:18 +02:00
|
|
|
namespace Seele
|
|
|
|
|
{
|
2021-04-01 16:40:14 +02:00
|
|
|
DECLARE_REF(Mesh)
|
|
|
|
|
DECLARE_REF(MeshAsset)
|
2023-02-13 14:56:13 +01:00
|
|
|
DECLARE_REF(MaterialAsset)
|
2021-04-01 16:40:14 +02:00
|
|
|
DECLARE_NAME_REF(Gfx, Graphics)
|
2023-02-01 22:13:04 +01:00
|
|
|
struct MeshImportArgs
|
|
|
|
|
{
|
|
|
|
|
std::filesystem::path filePath;
|
|
|
|
|
std::string importPath;
|
|
|
|
|
};
|
2020-06-02 11:46:18 +02:00
|
|
|
class MeshLoader
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
MeshLoader(Gfx::PGraphics graphic);
|
|
|
|
|
~MeshLoader();
|
2023-02-01 22:13:04 +01:00
|
|
|
void importAsset(MeshImportArgs args);
|
2020-06-02 11:46:18 +02:00
|
|
|
private:
|
2023-02-13 14:56:13 +01:00
|
|
|
void loadMaterials(const aiScene* scene, const std::string& baseName, const std::filesystem::path& meshDirectory, const std::string& importPath, Array<PMaterialAsset>& globalMaterials);
|
|
|
|
|
void loadTextures(const aiScene* scene, const std::filesystem::path& meshDirectory, const std::string& importPath);
|
|
|
|
|
void loadGlobalMeshes(const aiScene* scene, const Array<PMaterialAsset>& materials, Array<PMesh>& globalMeshes, Component::Collider& collider);
|
2020-10-03 11:00:10 +02:00
|
|
|
void convertAssimpARGB(unsigned char* dst, aiTexel* src, uint32 numPixels);
|
|
|
|
|
|
2023-02-01 22:13:04 +01:00
|
|
|
void import(MeshImportArgs args, PMeshAsset meshAsset);
|
2020-06-02 11:46:18 +02:00
|
|
|
Gfx::PGraphics graphics;
|
|
|
|
|
};
|
2021-04-01 16:40:14 +02:00
|
|
|
DEFINE_REF(MeshLoader)
|
2020-06-02 11:46:18 +02:00
|
|
|
} // namespace Seele
|