Copied updated libraries and compilers from main project over
This commit is contained in:
parent
70b6045453
commit
68c4e729a1
|
@ -1,47 +0,0 @@
|
|||
#include "Types/SHAnimationAsset.h"
|
||||
#include "Types/SHMeshAsset.h"
|
||||
|
||||
#include "Libraries/SHAssimpLibrary.h"
|
||||
#include "Libraries/SHMeshCompiler.h"
|
||||
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
SHADE::MeshVector meshes;
|
||||
SHADE::AnimVector anims;
|
||||
|
||||
std::vector<std::string> 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;
|
||||
}
|
|
@ -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"}
|
|
@ -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 <assimp/postprocess.h>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
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<SHAnimationAsset> 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<uint32_t>(meshDest.vertexPosition.size());
|
||||
meshDest.header.indexCount = static_cast<uint32_t>(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();
|
||||
}
|
||||
}
|
|
@ -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 <assimp/Importer.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <vector>
|
||||
#include "../SHAssetMacros.h"
|
||||
#include "../Types/SHMeshAsset.h"
|
||||
#include "../Types/SHAnimationAsset.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
using MeshVector = std::vector<SHMeshAsset>;
|
||||
using AnimVector = std::vector<SHAnimationAsset>;
|
||||
|
||||
class SHAssimpLibrary
|
||||
{
|
||||
private:
|
||||
using MeshVectorRef = std::vector<SHMeshAsset>&;
|
||||
using AnimVectorRef = std::vector<SHAnimationAsset>&;
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
|
@ -11,19 +11,148 @@
|
|||
* of DigiPen Institute of Technology is prohibited.
|
||||
*****************************************************************************/
|
||||
#include "SHMeshCompiler.h"
|
||||
#include <assimp/postprocess.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
std::string SHADE::SHMeshCompiler::CompileMeshBinary(SHMeshAsset const& asset) noexcept
|
||||
namespace SHADE
|
||||
{
|
||||
std::string newPath{ asset.parentPath };
|
||||
newPath += asset.header.meshName + MESH_EXTENSION;
|
||||
|
||||
Assimp::Importer SHMeshCompiler::aiImporter;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
for (size_t i{ 0 }; i < node.mNumChildren; ++i)
|
||||
{
|
||||
ProcessNode(*node.mChildren[i], scene, meshes);
|
||||
}
|
||||
}
|
||||
|
||||
void SHMeshCompiler::ExtractAnimations(aiScene const& scene, AnimVectorRef anims) noexcept
|
||||
{
|
||||
if (scene.HasAnimations())
|
||||
{
|
||||
std::vector<SHAnimationAsset> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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<uint32_t>(result->vertexPosition.size());
|
||||
result->header.indexCount = static_cast<uint32_t>(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<AssetPath> 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 writing mesh file: " << asset.parentPath << std::endl;
|
||||
std::cout << "Unable to open file for write: " << newPath << std::endl;
|
||||
return {};
|
||||
}
|
||||
|
||||
file.write(
|
||||
|
@ -36,8 +165,8 @@ std::string SHADE::SHMeshCompiler::CompileMeshBinary(SHMeshAsset const& asset) n
|
|||
sizeof(uint32_t)
|
||||
);
|
||||
|
||||
auto const vertexVec3Byte {sizeof(SHVec3) * asset.header.vertexCount};
|
||||
auto const vertexVec2Byte {sizeof(SHVec2) * asset.header.vertexCount};
|
||||
auto const vertexVec3Byte{ sizeof(SHVec3) * asset.header.vertexCount };
|
||||
auto const vertexVec2Byte{ sizeof(SHVec2) * asset.header.vertexCount };
|
||||
|
||||
file.write(
|
||||
reinterpret_cast<char const*>(asset.vertexPosition.data()),
|
||||
|
@ -67,4 +196,18 @@ std::string SHADE::SHMeshCompiler::CompileMeshBinary(SHMeshAsset const& asset) n
|
|||
file.close();
|
||||
|
||||
return newPath;
|
||||
}
|
||||
|
||||
void SHMeshCompiler::LoadAndCompile(AssetPath path) noexcept
|
||||
{
|
||||
std::vector<SHMeshAsset*> meshes;
|
||||
std::vector<SHAnimationAsset*> anims;
|
||||
|
||||
LoadFromFile(path, meshes, anims);
|
||||
|
||||
for (auto const& mesh : meshes)
|
||||
{
|
||||
CompileMeshBinary(*mesh, path.parent_path().string() + '/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,15 +12,30 @@
|
|||
*****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "../Types/SHMeshAsset.h"
|
||||
#include "../SHAssetMacros.h"
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <vector>
|
||||
|
||||
#include "Types/SHAnimationAsset.h"
|
||||
#include "Types/SHMeshAsset.h"
|
||||
#include "SHAssetMacros.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
class SHMeshCompiler
|
||||
{
|
||||
private:
|
||||
|
||||
using MeshVectorRef = std::vector<SHMeshAsset*>&;
|
||||
using AnimVectorRef = std::vector<SHAnimationAsset*>&;
|
||||
|
||||
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<AssetPath> CompileMeshBinary(SHMeshAsset const& asset, AssetPath path) noexcept;
|
||||
|
||||
public:
|
||||
static std::string CompileMeshBinary(SHMeshAsset const& asset) noexcept;
|
||||
static void LoadAndCompile(AssetPath path) noexcept;
|
||||
};
|
||||
}
|
|
@ -14,17 +14,6 @@
|
|||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
// 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
|
||||
|
|
|
@ -13,31 +13,29 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -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 <vector>
|
||||
#include <filesystem>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
std::vector<std::string> 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;
|
||||
}
|
|
@ -8,7 +8,8 @@ workspace "Assimp Compile Library"
|
|||
configurations
|
||||
{
|
||||
"Debug",
|
||||
"Release"
|
||||
"Release",
|
||||
"Publish"
|
||||
}
|
||||
|
||||
flags
|
||||
|
|
Loading…
Reference in New Issue