diff --git a/Assimp Compile Application/main.cpp b/Assimp Compile Application/main.cpp deleted file mode 100644 index c1ca2fd..0000000 --- a/Assimp Compile Application/main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "Types/SHAnimationAsset.h" -#include "Types/SHMeshAsset.h" - -#include "Libraries/SHAssimpLibrary.h" -#include "Libraries/SHMeshCompiler.h" - -#include -#include - -int main(int argc, char* argv[]) -{ - SHADE::MeshVector meshes; - SHADE::AnimVector anims; - - std::vector paths; - - if (argc == 1) - { - - for (auto const& dir : std::filesystem::recursive_directory_iterator{"./Assets/"}) - { - if (dir.path().extension().string() == GLTF_EXTENSION) - { - paths.push_back(dir.path().string()); - } - } - } - else if (argc > 1) - { - for (int i { 1 }; i < argc; ++i) - { - paths.emplace_back(argv[i]); - } - } - - for (auto const& path : paths) - { - SHADE::SHAssimpLibrary::LoadFromFile(path, meshes, anims); - } - - for (auto const& mesh : meshes) - { - SHADE::SHMeshCompiler::CompileMeshBinary(mesh); - } - - return 0; -} diff --git a/Assimp Compile Application/premake5.lua b/Assimp Compile Application/premake5.lua index f6ffd32..68893e6 100644 --- a/Assimp Compile Application/premake5.lua +++ b/Assimp Compile Application/premake5.lua @@ -47,14 +47,25 @@ project "Assimp Compile Library" "xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\"" } + filter "configurations:Publish" + postbuildcommands + { + "xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\"" + } + warnings 'Extra' filter "configurations:Debug" symbols "On" - defines {"_DEBUG", "SHEDITOR"} + defines {"_DEBUG"} links{"assimp-vc142-mtd.lib"} filter "configurations:Release" optimize "On" - defines{"_RELEASE", "SHEDITOR"} + defines{"_RELEASE"} + links{"assimp-vc142-mt.lib"} + + filter "configurations:Publish" + optimize "On" + defines{"_RELEASE, _PUBLISH"} links{"assimp-vc142-mt.lib"} \ No newline at end of file diff --git a/Assimp Compile Application/src/Libraries/SHAssimpLibrary.cpp b/Assimp Compile Application/src/Libraries/SHAssimpLibrary.cpp deleted file mode 100644 index b0b2d67..0000000 --- a/Assimp Compile Application/src/Libraries/SHAssimpLibrary.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/*************************************************************************//** - * \file SHAssimpLibrary.cpp - * \author Loh Xiao Qi - * \date October 2022 - * \brief - * - * Copyright (C) 2022 DigiPen Institute of Technology. Reproduction or - * disclosure of this file or its contents without the prior written consent - * of DigiPen Institute of Technology is prohibited. - *****************************************************************************/ -#include "SHAssimpLibrary.h" -#include -#include -#include - -namespace SHADE -{ - Assimp::Importer SHAssimpLibrary::aiImporter; - - void SHAssimpLibrary::ProcessNode(aiNode const& node, aiScene const& scene, MeshVectorRef meshes) noexcept - { - for (size_t i {0}; i < node.mNumMeshes; ++i) - { - aiMesh* mesh = scene.mMeshes[node.mMeshes[i]]; - meshes.emplace_back(); - ProcessMesh(*mesh, meshes.back()); - } - - for (size_t i{ 0 }; i < node.mNumChildren; ++i) - { - ProcessNode(*node.mChildren[i], scene, meshes); - } - } - - void SHAssimpLibrary::ExtractAnimations(aiScene const& scene, AnimVectorRef anims) noexcept - { - if (scene.HasAnimations()) - { - std::vector anims(scene.mNumAnimations); - for (auto i{0}; i < scene.mNumAnimations; ++i) - { - auto const& anim {*scene.mAnimations[i]}; - - anims[i].name = anim.mName.C_Str(); - - anims[i].duration = anim.mDuration; - anims[i].ticksPerSecond = anim.mTicksPerSecond; - - std::copy_n(anim.mChannels, anim.mNumChannels, anims[i].nodeChannels.data()); - std::copy_n(anim.mMeshChannels, anim.mNumMeshChannels, anims[i].meshChannels.data()); - std::copy_n(anim.mMorphMeshChannels, anim.mNumMorphMeshChannels, anims[i].morphMeshChannels.data()); - } - } - } - - void SHAssimpLibrary::ProcessMesh(aiMesh const& mesh, SHMeshAsset& meshDest) noexcept - { - meshDest.compiled = false; - meshDest.changed = false; - - for (size_t i{0}; i < mesh.mNumVertices; ++i) - { - // Vertex position - SHVec3 vertex; - vertex.x = mesh.mVertices[i].x; - vertex.y = mesh.mVertices[i].y; - vertex.z = mesh.mVertices[i].z; - meshDest.vertexPosition.push_back(vertex); - - // Tex coords - SHVec2 texCoord{0.f, 0.f}; - if (mesh.mTextureCoords[0]) - { - texCoord.x = mesh.mTextureCoords[0][i].x; - texCoord.y = mesh.mTextureCoords[0][i].y; - } - meshDest.texCoords.push_back(texCoord); - - // Normals - SHVec3 normal{0.f, 0.f, 0.f}; - if (mesh.mNormals) - { - normal.x = mesh.mNormals[i].x; - normal.y = mesh.mNormals[i].y; - normal.z = mesh.mNormals[i].z; - } - meshDest.vertexNormal.push_back(normal); - - // Tangent - SHVec3 tangent{0.f, 0.f, 0.f}; - if (mesh.mTangents) - { - tangent.x = mesh.mTangents[i].x; - tangent.y = mesh.mTangents[i].y; - tangent.z = mesh.mTangents[i].z; - } - meshDest.vertexTangent.push_back(tangent); - } - - for (size_t i {0}; i < mesh.mNumFaces; ++i) - { - aiFace face = mesh.mFaces[i]; - for (size_t j{0}; j < face.mNumIndices; ++j) - { - meshDest.indices.push_back(face.mIndices[j]); - } - } - - meshDest.header.vertexCount = static_cast(meshDest.vertexPosition.size()); - meshDest.header.indexCount = static_cast(meshDest.indices.size()); - meshDest.header.meshName = mesh.mName.C_Str(); - } - - void SHAssimpLibrary::LoadFromFile(AssetPath path, MeshVectorRef meshes, AnimVectorRef anims) noexcept - { - const aiScene* scene = aiImporter.ReadFile(path.string().c_str(), - aiProcess_Triangulate // Make sure we get triangles rather than nvert polygons - | aiProcess_GenUVCoords // Convert any type of mapping to uv mapping - | aiProcess_TransformUVCoords // preprocess UV transformations (scaling, translation ...) - | aiProcess_FindInstances // search for instanced meshes and remove them by references to one master - | aiProcess_CalcTangentSpace // calculate tangents and bitangents if possible - | aiProcess_JoinIdenticalVertices // join identical vertices/ optimize indexing - | aiProcess_RemoveRedundantMaterials // remove redundant materials - | aiProcess_FindInvalidData // detect invalid model data, such as invalid normal vectors - | aiProcess_FlipUVs // flip the V to match the Vulkans way of doing UVs - ); - - if (!scene || !scene->HasMeshes()) - { - std::cout << "ERROR in GLTF::ASSIMP: " << aiImporter.GetErrorString() << "\nFile: " << path.string() << std::endl; - return; - } - - ExtractAnimations(*scene, anims); - - MeshVector localMesh(scene->mNumMeshes); - ProcessNode(*scene->mRootNode, *scene, localMesh); - - for (auto& mesh : localMesh) - { - mesh.parentPath = path.parent_path().string(); - } - - std::ranges::move(localMesh.begin(), localMesh.end(), meshes.end()); - - aiImporter.FreeScene(); - } -} diff --git a/Assimp Compile Application/src/Libraries/SHAssimpLibrary.h b/Assimp Compile Application/src/Libraries/SHAssimpLibrary.h deleted file mode 100644 index c779e6c..0000000 --- a/Assimp Compile Application/src/Libraries/SHAssimpLibrary.h +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************//** - * \file SHAssimpLibrary.h - * \author Loh Xiao Qi - * \date October 2022 - * \brief - * - * Copyright (C) 2022 DigiPen Institute of Technology. Reproduction or - * disclosure of this file or its contents without the prior written consent - * of DigiPen Institute of Technology is prohibited. - *****************************************************************************/ - -#pragma once -#include -#include -#include -#include "../SHAssetMacros.h" -#include "../Types/SHMeshAsset.h" -#include "../Types/SHAnimationAsset.h" - -namespace SHADE -{ - using MeshVector = std::vector; - using AnimVector = std::vector; - - class SHAssimpLibrary - { - private: - using MeshVectorRef = std::vector&; - using AnimVectorRef = std::vector&; - - static Assimp::Importer aiImporter; - static void ProcessNode(aiNode const& node, aiScene const& scene,MeshVectorRef meshes) noexcept; - static void ExtractAnimations(aiScene const& scene, AnimVectorRef anims) noexcept; - static void ProcessMesh(aiMesh const& mesh, SHMeshAsset& meshDest) noexcept; - - public: - static void LoadFromFile(AssetPath path, MeshVectorRef meshes, AnimVectorRef anims) noexcept; - }; -} \ No newline at end of file diff --git a/Assimp Compile Application/src/Libraries/SHMeshCompiler.cpp b/Assimp Compile Application/src/Libraries/SHMeshCompiler.cpp index 06cc0e9..0e29ec4 100644 --- a/Assimp Compile Application/src/Libraries/SHMeshCompiler.cpp +++ b/Assimp Compile Application/src/Libraries/SHMeshCompiler.cpp @@ -11,60 +11,203 @@ * of DigiPen Institute of Technology is prohibited. *****************************************************************************/ #include "SHMeshCompiler.h" +#include #include #include -std::string SHADE::SHMeshCompiler::CompileMeshBinary(SHMeshAsset const& asset) noexcept +namespace SHADE { - std::string newPath{ asset.parentPath }; - newPath += asset.header.meshName + MESH_EXTENSION; - std::ofstream file{ newPath, std::ios::out | std::ios::binary | std::ios::trunc }; - if (!file.is_open()) - { - std::cout << "Unable to open file for writing mesh file: " << asset.parentPath << std::endl; - } + Assimp::Importer SHMeshCompiler::aiImporter; - file.write( - reinterpret_cast(&(asset.header.vertexCount)), - sizeof(uint32_t) - ); + void SHMeshCompiler::ProcessNode(aiNode const& node, aiScene const& scene, MeshVectorRef meshes) noexcept + { + for (size_t i{ 0 }; i < node.mNumMeshes; ++i) + { + aiMesh* mesh = scene.mMeshes[node.mMeshes[i]]; + meshes.push_back(ProcessMesh(*mesh)); + } - file.write( - reinterpret_cast(&(asset.header.indexCount)), - sizeof(uint32_t) - ); + for (size_t i{ 0 }; i < node.mNumChildren; ++i) + { + ProcessNode(*node.mChildren[i], scene, meshes); + } + } - auto const vertexVec3Byte {sizeof(SHVec3) * asset.header.vertexCount}; - auto const vertexVec2Byte {sizeof(SHVec2) * asset.header.vertexCount}; + void SHMeshCompiler::ExtractAnimations(aiScene const& scene, AnimVectorRef anims) noexcept + { + if (scene.HasAnimations()) + { + std::vector anims(scene.mNumAnimations); + for (auto i{ 0 }; i < scene.mNumAnimations; ++i) + { + auto const& anim{ *scene.mAnimations[i] }; - file.write( - reinterpret_cast(asset.vertexPosition.data()), - vertexVec3Byte - ); - - file.write( - reinterpret_cast(asset.vertexTangent.data()), - vertexVec3Byte - ); - - file.write( - reinterpret_cast(asset.vertexNormal.data()), - vertexVec3Byte - ); - - file.write( - reinterpret_cast(asset.texCoords.data()), - vertexVec2Byte - ); + anims[i].name = anim.mName.C_Str(); - file.write( - reinterpret_cast(asset.indices.data()), - sizeof(uint32_t) * asset.header.indexCount - ); + anims[i].duration = anim.mDuration; + anims[i].ticksPerSecond = anim.mTicksPerSecond; - file.close(); + std::copy_n(anim.mChannels, anim.mNumChannels, anims[i].nodeChannels.data()); + std::copy_n(anim.mMeshChannels, anim.mNumMeshChannels, anims[i].meshChannels.data()); + std::copy_n(anim.mMorphMeshChannels, anim.mNumMorphMeshChannels, anims[i].morphMeshChannels.data()); + } + } + } - return newPath; + SHMeshAsset* SHMeshCompiler::ProcessMesh(aiMesh const& mesh) noexcept + { + SHMeshAsset* result = new SHMeshAsset(); + result->compiled = false; + result->changed = false; + + for (size_t i{ 0 }; i < mesh.mNumVertices; ++i) + { + // Vertex position + SHVec3 vertex; + vertex.x = mesh.mVertices[i].x; + vertex.y = mesh.mVertices[i].y; + vertex.z = mesh.mVertices[i].z; + result->vertexPosition.push_back(vertex); + + // Tex coords + SHVec2 texCoord{ 0.f, 0.f }; + if (mesh.mTextureCoords[0]) + { + texCoord.x = mesh.mTextureCoords[0][i].x; + texCoord.y = mesh.mTextureCoords[0][i].y; + } + result->texCoords.push_back(texCoord); + + // Normals + SHVec3 normal{ 0.f, 0.f, 0.f }; + if (mesh.mNormals) + { + normal.x = mesh.mNormals[i].x; + normal.y = mesh.mNormals[i].y; + normal.z = mesh.mNormals[i].z; + } + result->vertexNormal.push_back(normal); + + // Tangent + SHVec3 tangent{ 0.f, 0.f, 0.f }; + if (mesh.mTangents) + { + tangent.x = mesh.mTangents[i].x; + tangent.y = mesh.mTangents[i].y; + tangent.z = mesh.mTangents[i].z; + } + result->vertexTangent.push_back(tangent); + } + + for (size_t i{ 0 }; i < mesh.mNumFaces; ++i) + { + aiFace face = mesh.mFaces[i]; + for (size_t j{ 0 }; j < face.mNumIndices; ++j) + { + result->indices.push_back(face.mIndices[j]); + } + } + + result->header.vertexCount = static_cast(result->vertexPosition.size()); + result->header.indexCount = static_cast(result->indices.size()); + result->header.name = mesh.mName.C_Str(); + + return result; + } + + void SHMeshCompiler::LoadFromFile(AssetPath path, MeshVectorRef meshes, AnimVectorRef anims) noexcept + { + const aiScene* scene = aiImporter.ReadFile(path.string().c_str(), + aiProcess_Triangulate // Make sure we get triangles rather than nvert polygons + | aiProcess_GenUVCoords // Convert any type of mapping to uv mapping + | aiProcess_TransformUVCoords // preprocess UV transformations (scaling, translation ...) + | aiProcess_FindInstances // search for instanced meshes and remove them by references to one master + | aiProcess_CalcTangentSpace // calculate tangents and bitangents if possible + | aiProcess_JoinIdenticalVertices // join identical vertices/ optimize indexing + | aiProcess_RemoveRedundantMaterials // remove redundant materials + | aiProcess_FindInvalidData // detect invalid model data, such as invalid normal vectors + | aiProcess_FlipUVs // flip the V to match the Vulkans way of doing UVs + ); + + if (!scene || !scene->HasMeshes()) + { + std::cout << "ERROR in GLTF::ASSIMP: " << aiImporter.GetErrorString() << "\nFile: " << path.string() << std::endl; + return; + } + + //ExtractAnimations(*scene, anims); + + ProcessNode(*scene->mRootNode, *scene, meshes); + + aiImporter.FreeScene(); + } + + std::optional SHMeshCompiler::CompileMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept + { + std::string newPath{ path.string() + asset.header.name + MESH_EXTENSION.data() }; + + std::ofstream file{ newPath, std::ios::out | std::ios::binary | std::ios::trunc }; + if (!file.is_open()) + { + std::cout << "Unable to open file for write: " << newPath << std::endl; + return {}; + } + + file.write( + reinterpret_cast(&(asset.header.vertexCount)), + sizeof(uint32_t) + ); + + file.write( + reinterpret_cast(&(asset.header.indexCount)), + sizeof(uint32_t) + ); + + auto const vertexVec3Byte{ sizeof(SHVec3) * asset.header.vertexCount }; + auto const vertexVec2Byte{ sizeof(SHVec2) * asset.header.vertexCount }; + + file.write( + reinterpret_cast(asset.vertexPosition.data()), + vertexVec3Byte + ); + + file.write( + reinterpret_cast(asset.vertexTangent.data()), + vertexVec3Byte + ); + + file.write( + reinterpret_cast(asset.vertexNormal.data()), + vertexVec3Byte + ); + + file.write( + reinterpret_cast(asset.texCoords.data()), + vertexVec2Byte + ); + + file.write( + reinterpret_cast(asset.indices.data()), + sizeof(uint32_t) * asset.header.indexCount + ); + + file.close(); + + return newPath; + } + + void SHMeshCompiler::LoadAndCompile(AssetPath path) noexcept + { + std::vector meshes; + std::vector anims; + + LoadFromFile(path, meshes, anims); + + for (auto const& mesh : meshes) + { + CompileMeshBinary(*mesh, path.parent_path().string() + '/'); + } + } } diff --git a/Assimp Compile Application/src/Libraries/SHMeshCompiler.h b/Assimp Compile Application/src/Libraries/SHMeshCompiler.h index 41c1d57..46fb9d1 100644 --- a/Assimp Compile Application/src/Libraries/SHMeshCompiler.h +++ b/Assimp Compile Application/src/Libraries/SHMeshCompiler.h @@ -12,15 +12,30 @@ *****************************************************************************/ #pragma once -#include "../Types/SHMeshAsset.h" -#include "../SHAssetMacros.h" +#include +#include +#include + +#include "Types/SHAnimationAsset.h" +#include "Types/SHMeshAsset.h" +#include "SHAssetMacros.h" namespace SHADE { class SHMeshCompiler { - private: - public: - static std::string CompileMeshBinary(SHMeshAsset const& asset) noexcept; + + using MeshVectorRef = std::vector&; + using AnimVectorRef = std::vector&; + + static Assimp::Importer aiImporter; + static void ProcessNode(aiNode const& node, aiScene const& scene, MeshVectorRef meshes) noexcept; + static void ExtractAnimations(aiScene const& scene, AnimVectorRef anims) noexcept; + static SHMeshAsset* ProcessMesh(aiMesh const& mesh) noexcept; + static void LoadFromFile(AssetPath path, MeshVectorRef meshes, AnimVectorRef anims) noexcept; + static std::optional CompileMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept; + + public: + static void LoadAndCompile(AssetPath path) noexcept; }; } \ No newline at end of file diff --git a/Assimp Compile Application/src/SHAssetMacros.h b/Assimp Compile Application/src/SHAssetMacros.h index 61c5879..b44807a 100644 --- a/Assimp Compile Application/src/SHAssetMacros.h +++ b/Assimp Compile Application/src/SHAssetMacros.h @@ -14,17 +14,6 @@ #include #include -// FMOD Fwd Declare -namespace FMOD -{ - class Sound; - class System; - class ChannelGroup; - class Channel; -} -enum FMOD_RESULT : int; -enum FMOD_SPEAKERMODE : int; - // Typedefs typedef uint32_t AssetID; typedef std::string AssetName; @@ -32,74 +21,34 @@ typedef std::filesystem::path AssetPath; typedef unsigned char* AssetData; typedef std::string AssetMetaVersion; typedef std::string AssetExtension; -typedef unsigned char AssetTypeMeta; - -typedef FMOD::Sound* SHSound; - -// Asset Meta Version -#define ASSET_META_VER "1.0" - -// Asset type enum -enum class AssetType : AssetTypeMeta -{ - INVALID = 0, - AUDIO = 1, - SHADER, - MATERIAL, - IMAGE, - TEXTURE, - MESH, - SCRIPT, - SCENE, - PREFAB, - AUDIO_WAV, - DDS -}; +typedef size_t AssetTypeMeta; //Directory #ifdef _PUBLISH -#define ASSET_ROOT "Assets" +constexpr std::string_view ASSET_ROOT{ "Assets" }; +constexpr std::string_view BUILT_IN_ASSET_ROOT{ "Built_In" }; #else -#define ASSET_ROOT "../../Assets" +constexpr std::string_view ASSET_ROOT{ "../../Assets" }; +constexpr std::string_view BUILT_IN_ASSET_ROOT{ "../../Built_In" }; #endif - // ASSET EXTENSIONS -#define META_EXTENSION ".shmeta" -#define IMAGE_EXTENSION ".png" -#define AUDIO_EXTENSION ".ogg" -#define AUDIO_WAV_EXTENSION ".wav" -#define SHADER_EXTENSION ".glsl" -#define SCRIPT_EXTENSION ".cs" -#define SCENE_EXTENSION ".SHADE" -#define PREFAB_EXTENSION ".SHPrefab" -#define MATERIAL_EXTENSION ".SHMat" -#define TEXTURE_EXTENSION ".shtex" -#define DDS_EXTENSION ".dds" -#define FBX_EXTENSION ".fbx" -#define GLTF_EXTENSION ".gltf" -#define MESH_EXTENSION ".shmesh" +constexpr std::string_view TEXTURE_EXTENSION {".shtex"}; +constexpr std::string_view MESH_EXTENSION {".shmesh"}; -std::string const EXTENSIONS[] = { - AUDIO_EXTENSION, - SHADER_EXTENSION, - MATERIAL_EXTENSION, - IMAGE_EXTENSION, - TEXTURE_EXTENSION, - DDS_EXTENSION, - MESH_EXTENSION, - SCRIPT_EXTENSION, - SCENE_EXTENSION, - PREFAB_EXTENSION, - AUDIO_WAV_EXTENSION, +// EXTERNAL EXTENSIONS +constexpr std::string_view FBX_EXTENSION{ ".fbx" }; +constexpr std::string_view GLTF_EXTENSION{ ".gltf" }; + +constexpr std::string_view EXTERNALS[] = { FBX_EXTENSION, GLTF_EXTENSION }; // Error flags -#define FILE_NOT_FOUND_ERR "FILE NOT FOUND" -#define META_NOT_FOUND_ERR "META NOT FOUND" -#define ASSET_NOT_FOUND_ERR "ASSET NOT FOUND" -#define EXT_DOES_NOT_EXIST "TYPE DOES NOT HAVE EXTENSION DEFINED" +constexpr std::string_view FILE_NOT_FOUND_ERR {"FILE NOT FOUND"}; +constexpr std::string_view META_NOT_FOUND_ERR {"META NOT FOUND"}; +constexpr std::string_view ASSET_NOT_FOUND_ERR {"ASSET NOT FOUND"}; +constexpr std::string_view EXT_DOES_NOT_EXIST {"TYPE DOES NOT HAVE EXTENSION DEFINED"}; #endif // !SH_ASSET_MACROS_H diff --git a/Assimp Compile Application/src/Types/SHMeshAsset.h b/Assimp Compile Application/src/Types/SHMeshAsset.h index 051d9dc..52d5c59 100644 --- a/Assimp Compile Application/src/Types/SHMeshAsset.h +++ b/Assimp Compile Application/src/Types/SHMeshAsset.h @@ -13,31 +13,29 @@ #pragma once #include -#include -#include namespace SHADE { - struct SHVec3 - { - float x, y, z; - }; struct SHVec2 { float x, y; }; + struct SHVec3 + { + float x, y, z; + }; + struct SHMeshAssetHeader { uint32_t vertexCount; uint32_t indexCount; - std::string meshName; + std::string name; }; struct SHMeshAsset { - std::string parentPath; bool compiled; bool changed; diff --git a/Assimp Compile Application/src/main.cpp b/Assimp Compile Application/src/main.cpp new file mode 100644 index 0000000..50e7dcb --- /dev/null +++ b/Assimp Compile Application/src/main.cpp @@ -0,0 +1,51 @@ +/****************************************************************************** + * \file main.cpp + * \author Loh Xiao Qi + * \date 31 October 2022 + * \brief + * + * \copyright Copyright (c) 2021 Digipen Institute of Technology. Reproduction + * or disclosure of this file or its contents without the prior + * written consent of Digipen Institute of Technology is prohibited. + ******************************************************************************/ +#include "Libraries/SHMeshCompiler.h" + +#include +#include + +int main(int argc, char* argv[]) +{ + std::vector paths; + + if (argc == 1) + { + if (std::filesystem::is_directory(ASSET_ROOT)) + { + for (auto const& dir : std::filesystem::recursive_directory_iterator{ "./Assets/" }) + { + if (dir.path().extension().string() == GLTF_EXTENSION) + { + paths.push_back(dir.path().string()); + } + } + } + else + { + return 1; + } + } + else if (argc > 1) + { + for (int i { 1 }; i < argc; ++i) + { + paths.emplace_back(argv[i]); + } + } + + for (auto const& path : paths) + { + SHADE::SHMeshCompiler::LoadAndCompile(path); + } + + return 0; +} diff --git a/premake5.lua b/premake5.lua index e69c37e..e5ebd94 100644 --- a/premake5.lua +++ b/premake5.lua @@ -8,7 +8,8 @@ workspace "Assimp Compile Library" configurations { "Debug", - "Release" + "Release", + "Publish" } flags