Asset Manager restructure #123
|
@ -13,9 +13,9 @@
|
|||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <vector>
|
||||
#include "../SHAssetMacros.h"
|
||||
#include "../Asset Types/SHMeshAsset.h"
|
||||
#include "../Asset Types/SHAnimationAsset.h"
|
||||
#include "Assets/SHAssetMacros.h"
|
||||
#include "Assets/Asset Types/SHMeshAsset.h"
|
||||
#include "Assets/Asset Types/SHAnimationAsset.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
|
@ -21,7 +21,7 @@ namespace SHADE
|
|||
{
|
||||
std::string SHShaderSourceCompiler::CompileShaderSourceToBinary(AssetPath path, SHShaderAsset const& data) noexcept
|
||||
{
|
||||
std::string newPath{ path.string() + SHADER_SPRV_EXTENSION.data() };
|
||||
std::string newPath{ path.string() + SHADER_EXTENSION.data() };
|
||||
|
||||
std::ofstream file{ newPath, std::ios::binary | std::ios::out | std::ios::trunc };
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
* of DigiPen Institute of Technology is prohibited.
|
||||
*****************************************************************************/
|
||||
#pragma once
|
||||
#include "../SHAssetMacros.h"
|
||||
#include "../Asset Types/SHMeshAsset.h"
|
||||
#include "Assets/SHAssetMacros.h"
|
||||
#include "Assets/Asset Types/SHMeshAsset.h"
|
||||
#include "SHAssetLoader.h"
|
||||
|
||||
namespace SHADE
|
|
@ -10,7 +10,7 @@
|
|||
*****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "Assets/Libraries/SHAssetLoader.h"
|
||||
#include "Assets/Libraries/Loaders/SHAssetLoader.h"
|
||||
#include "Assets/SHAssetMacros.h"
|
||||
|
||||
namespace SHADE
|
|
@ -12,8 +12,8 @@
|
|||
#pragma once
|
||||
#define TINYDDSLOADER_IMPLEMENTATION
|
||||
|
||||
#include "../SHAssetMacros.h"
|
||||
#include "../Asset Types/SHTextureAsset.h"
|
||||
#include "Assets/SHAssetMacros.h"
|
||||
#include "Assets/Asset Types/SHTextureAsset.h"
|
||||
#include "tinyddsloader.h"
|
||||
#include "SHAssetLoader.h"
|
||||
|
|
@ -68,34 +68,39 @@ constexpr std::string_view ASSET_ROOT {"../../Assets"};
|
|||
|
||||
// ASSET EXTENSIONS
|
||||
constexpr std::string_view META_EXTENSION {".shmeta"};
|
||||
constexpr std::string_view IMAGE_EXTENSION {".png"};
|
||||
constexpr std::string_view AUDIO_EXTENSION {".ogg"};
|
||||
constexpr std::string_view AUDIO_WAV_EXTENSION {".wav"};
|
||||
constexpr std::string_view SHADER_EXTENSION{ ".glsl" };
|
||||
constexpr std::string_view SHADER_SPRV_EXTENSION {".sprv"};
|
||||
constexpr std::string_view SHADER_EXTENSION{".shshader"};
|
||||
constexpr std::string_view SCRIPT_EXTENSION {".cs"};
|
||||
constexpr std::string_view SCENE_EXTENSION {".SHADE"};
|
||||
constexpr std::string_view PREFAB_EXTENSION {".SHPrefab"};
|
||||
constexpr std::string_view MATERIAL_EXTENSION {".SHMat"};
|
||||
constexpr std::string_view SCENE_EXTENSION {".shade"};
|
||||
constexpr std::string_view PREFAB_EXTENSION {".shprefab"};
|
||||
constexpr std::string_view MATERIAL_EXTENSION {".shmat"};
|
||||
constexpr std::string_view TEXTURE_EXTENSION {".shtex"};
|
||||
constexpr std::string_view DDS_EXTENSION {".dds"};
|
||||
constexpr std::string_view FBX_EXTENSION {".fbx"};
|
||||
constexpr std::string_view GLTF_EXTENSION {".gltf"};
|
||||
constexpr std::string_view MESH_EXTENSION {".shmesh"};
|
||||
|
||||
// EXTERNAL EXTENSIONS
|
||||
constexpr std::string_view GLSL_EXTENSION{ ".glsl" };
|
||||
constexpr std::string_view IMAGE_EXTENSION{ ".png" };
|
||||
constexpr std::string_view DDS_EXTENSION{ ".dds" };
|
||||
constexpr std::string_view FBX_EXTENSION{ ".fbx" };
|
||||
constexpr std::string_view GLTF_EXTENSION{ ".gltf" };
|
||||
|
||||
constexpr std::string_view EXTENSIONS[] = {
|
||||
AUDIO_EXTENSION,
|
||||
SHADER_EXTENSION,
|
||||
SHADER_SPRV_EXTENSION,
|
||||
MATERIAL_EXTENSION,
|
||||
IMAGE_EXTENSION,
|
||||
TEXTURE_EXTENSION,
|
||||
DDS_EXTENSION,
|
||||
MESH_EXTENSION,
|
||||
SCRIPT_EXTENSION,
|
||||
SCENE_EXTENSION,
|
||||
PREFAB_EXTENSION,
|
||||
AUDIO_WAV_EXTENSION,
|
||||
};
|
||||
|
||||
constexpr std::string_view EXTERNALS[] = {
|
||||
GLSL_EXTENSION,
|
||||
IMAGE_EXTENSION,
|
||||
DDS_EXTENSION,
|
||||
FBX_EXTENSION,
|
||||
GLTF_EXTENSION
|
||||
};
|
||||
|
|
|
@ -14,13 +14,14 @@
|
|||
#include "SHAssetMetaHandler.h"
|
||||
#include "Filesystem/SHFileSystem.h"
|
||||
|
||||
#include "Libraries/SHAssimpLibrary.h"
|
||||
#include "Libraries/SHMeshLoader.h"
|
||||
#include "Libraries/SHTextureLoader.h"
|
||||
#include "Libraries/SHShaderSourceLoader.h"
|
||||
#include "Libraries/Loaders/SHMeshLoader.h"
|
||||
#include "Libraries/Loaders/SHTextureLoader.h"
|
||||
#include "Libraries/Loaders/SHShaderSourceLoader.h"
|
||||
|
||||
#include "Libraries/SHMeshCompiler.h"
|
||||
#include "Libraries/SHTextureCompiler.h"
|
||||
|
||||
#include "Libraries/Compilers/SHAssimpLibrary.h"
|
||||
#include "Libraries/Compilers/SHMeshCompiler.h"
|
||||
#include "Libraries/Compilers/SHTextureCompiler.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -65,7 +66,20 @@ namespace SHADE
|
|||
// TODO
|
||||
}
|
||||
|
||||
AssetPath SHAssetManager::GenerateLocalPath(AssetPath path) noexcept
|
||||
void SHAssetManager::Exit() noexcept
|
||||
{
|
||||
for (auto const& loader : loaders)
|
||||
{
|
||||
delete loader;
|
||||
}
|
||||
|
||||
for (auto const& data : assetData)
|
||||
{
|
||||
delete data.second;
|
||||
}
|
||||
}
|
||||
|
||||
AssetPath SHAssetManager::GenerateLocalPath(AssetPath path) noexcept
|
||||
{
|
||||
if (!IsRecognised(path.extension().string().c_str()))
|
||||
{
|
||||
|
@ -255,6 +269,7 @@ namespace SHADE
|
|||
result.type = SHAssetMetaHandler::GetTypeFromExtension(path.extension().string());
|
||||
result.id = GenerateAssetID(result.type);
|
||||
result.path = path;
|
||||
result.location = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -264,8 +279,7 @@ namespace SHADE
|
|||
loaders[static_cast<size_t>(AssetType::AUDIO)] = nullptr;
|
||||
loaders[static_cast<size_t>(AssetType::SHADER)] = dynamic_cast<SHAssetLoader*>(new SHShaderSourceLoader());
|
||||
loaders[static_cast<size_t>(AssetType::MATERIAL)] = nullptr;
|
||||
loaders[static_cast<size_t>(AssetType::IMAGE)] = dynamic_cast<SHAssetLoader*>(new SHTextureLoader());
|
||||
loaders[static_cast<size_t>(AssetType::TEXTURE)] = nullptr;
|
||||
loaders[static_cast<size_t>(AssetType::TEXTURE)] = dynamic_cast<SHAssetLoader*>(new SHTextureLoader());
|
||||
loaders[static_cast<size_t>(AssetType::MESH)] = dynamic_cast<SHAssetLoader*>(new SHMeshLoader());
|
||||
loaders[static_cast<size_t>(AssetType::SCRIPT)] = nullptr;
|
||||
loaders[static_cast<size_t>(AssetType::SCENE)] = nullptr;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "tinyddsloader.h"
|
||||
#include "SHAsset.h"
|
||||
#include "Asset Types/SHAssetData.h"
|
||||
#include "Libraries/SHAssetLoader.h"
|
||||
#include "Assets/Libraries/Loaders/SHAssetLoader.h"
|
||||
#include <memory>
|
||||
|
||||
#include "SH_API.h"
|
||||
|
@ -37,6 +37,8 @@ namespace SHADE
|
|||
static void Unload() noexcept;
|
||||
static void Unload(AssetID assetId) noexcept;
|
||||
|
||||
static void Exit() noexcept;
|
||||
|
||||
/****************************************************************************
|
||||
* \brief Load all resources that are in the folder
|
||||
****************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue