Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

367 refactor seperate subsystems #436

Merged
merged 11 commits into from
Sep 30, 2022
3 changes: 3 additions & 0 deletions Source/Interface/Structs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Interface Structs

The interface structs are designed to be used as the name says - to provide interfaces between different modules. For example, the ModelLoader subsystem should link to the model class. If another system uses that model, it can get it from there without having to include any other struct. This will help to keep all the different modules *modular*.
22 changes: 16 additions & 6 deletions Source/Internal/ArgumentParser/ERS_ArgumentParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
#include <ERS_ArgumentParser.h>


ERS_ArgumentParser::ERS_ArgumentParser(ERS_LoggingSystem* Logger) {
namespace BrainGenix {
namespace ERS {
namespace Module {


ArgumentParser::ArgumentParser(ERS_LoggingSystem* Logger) {

Logger_ = Logger;
Logger_->Log("Initialiizng Argument Parser Subsystem", 4);
Expand All @@ -16,13 +21,13 @@ ERS_ArgumentParser::ERS_ArgumentParser(ERS_LoggingSystem* Logger) {

}

ERS_ArgumentParser::~ERS_ArgumentParser() {
ArgumentParser::~ArgumentParser() {

Logger_->Log("Argument Parser Destructor Called", 6);

}

bool ERS_ArgumentParser::ParseArguments(int NumberArguments, char** ArgumentValues) {
bool ArgumentParser::ParseArguments(int NumberArguments, char** ArgumentValues) {

Logger_->Log("Argument Parser Invoked, Populating Internal State With Argument Data", 5);
bool HasErrors = false;
Expand Down Expand Up @@ -86,10 +91,15 @@ bool ERS_ArgumentParser::ParseArguments(int NumberArguments, char** ArgumentValu

}

std::string ERS_ArgumentParser::GetArgumentString() {
std::string ArgumentParser::GetArgumentString() {
return ArgumentString_;
}

std::vector<std::pair<std::string, std::string>> ERS_ArgumentParser::GetArgumentPairs() {
std::vector<std::pair<std::string, std::string>> ArgumentParser::GetArgumentPairs() {
return ArgumentPairs_;
}
}


}
}
}
20 changes: 16 additions & 4 deletions Source/Internal/ArgumentParser/ERS_ArgumentParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@
// Internal Libraries (BG convention: use <> instead of "")
#include <ERS_LoggingSystem.h>


namespace BrainGenix {
namespace ERS {
namespace Module {


/**
* @brief Create Hardware Information Class
*
*/
class ERS_ArgumentParser {
class ArgumentParser {

private:

Expand All @@ -35,13 +41,13 @@ class ERS_ArgumentParser {
*
* @param Logger
*/
ERS_ArgumentParser(ERS_LoggingSystem* Logger);
ArgumentParser(ERS_LoggingSystem* Logger);

/**
* @brief Destroy the Hardware Information object
*
*/
~ERS_ArgumentParser();
~ArgumentParser();


/**
Expand Down Expand Up @@ -75,4 +81,10 @@ class ERS_ArgumentParser {



};
};



}
}
}
35 changes: 22 additions & 13 deletions Source/Internal/ExternalModelLoader/ERS_ExternalModelLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
#include <ERS_ExternalModelLoader.h>


ERS_ExternalModelLoader::ERS_ExternalModelLoader(ERS_STRUCT_SystemUtils* SystemUtils) {
namespace BrainGenix {
namespace ERS {
namespace Module {

ExternalModelLoader::ExternalModelLoader(ERS_STRUCT_SystemUtils* SystemUtils) {

SystemUtils_ = SystemUtils;

ImageProcessor_ = std::make_unique<Lucifer::Lucifer>();

}
ERS_ExternalModelLoader::~ERS_ExternalModelLoader() {
ExternalModelLoader::~ExternalModelLoader() {

}

Expand Down Expand Up @@ -85,7 +89,7 @@ std::pair<std::string, std::string> FindTextureMatches(ERS_STRUCT_Mesh* Mesh, st


// Model Loading Helpers
void ERS_ExternalModelLoader::DetectBoundingBox(ERS_STRUCT_Model* Model) {
void ExternalModelLoader::DetectBoundingBox(ERS_STRUCT_Model* Model) {

// Calculate Bounding Box
glm::vec3 ModelMinXYZ = Model->Meshes[0].Vertices[0].Position;
Expand Down Expand Up @@ -137,7 +141,7 @@ void ERS_ExternalModelLoader::DetectBoundingBox(ERS_STRUCT_Model* Model) {
SystemUtils_->Logger_->Log(LogMsg, 3);

}
void ERS_ExternalModelLoader::CalculateTotalVertsIndices(ERS_STRUCT_Model* Model) {
void ExternalModelLoader::CalculateTotalVertsIndices(ERS_STRUCT_Model* Model) {

// Get Vert/Indice Metadata Info
Model->TotalVertices_ = 0;
Expand All @@ -153,7 +157,7 @@ void ERS_ExternalModelLoader::CalculateTotalVertsIndices(ERS_STRUCT_Model* Model
}

}
void ERS_ExternalModelLoader::MergeTextures(ERS_STRUCT_Model* Model, std::vector<std::pair<std::string, FIBITMAP*>>* LoadedTextures) {
void ExternalModelLoader::MergeTextures(ERS_STRUCT_Model* Model, std::vector<std::pair<std::string, FIBITMAP*>>* LoadedTextures) {

// Create Pair Of All Textures With Opacity/Alpha Maps
std::vector<std::pair<std::string, std::string>> OpacityAlphaMaps;
Expand Down Expand Up @@ -202,7 +206,7 @@ void ERS_ExternalModelLoader::MergeTextures(ERS_STRUCT_Model* Model, std::vector
}

}
void ERS_ExternalModelLoader::ProcessModelTextures(ERS_STRUCT_ModelWriterData &Data) {
void ExternalModelLoader::ProcessModelTextures(ERS_STRUCT_ModelWriterData &Data) {

// Create List Of Texture Files To Be Copied
std::vector<std::pair<std::string, std::future<FIBITMAP*>>> ImageFutures;
Expand Down Expand Up @@ -301,7 +305,7 @@ void ERS_ExternalModelLoader::ProcessModelTextures(ERS_STRUCT_ModelWriterData &D
Data.ImageBytes = ImageBytes;

}
void ERS_ExternalModelLoader::ProcessNode(ERS_STRUCT_ModelWriterData &Data, ERS_STRUCT_Model* Model, aiNode *Node, const aiScene *Scene, std::string ModelDirectory) {
void ExternalModelLoader::ProcessNode(ERS_STRUCT_ModelWriterData &Data, ERS_STRUCT_Model* Model, aiNode *Node, const aiScene *Scene, std::string ModelDirectory) {

// Process Meshes In Current Node
for (unsigned int i = 0; i < Node->mNumMeshes; i++) {
Expand Down Expand Up @@ -386,7 +390,7 @@ void IdentifyMeshTextures(aiMaterial* Mat, ERS_STRUCT_Mesh* Mesh) {



ERS_STRUCT_Mesh ERS_ExternalModelLoader::ProcessMesh(ERS_STRUCT_ModelWriterData &Data, ERS_STRUCT_Model* Model, aiMesh *Mesh, const aiScene *Scene, std::string ModelDirectory) {
ERS_STRUCT_Mesh ExternalModelLoader::ProcessMesh(ERS_STRUCT_ModelWriterData &Data, ERS_STRUCT_Model* Model, aiMesh *Mesh, const aiScene *Scene, std::string ModelDirectory) {

// Create Data Holders
ERS_STRUCT_Mesh OutputMesh;
Expand Down Expand Up @@ -468,7 +472,7 @@ ERS_STRUCT_Mesh ERS_ExternalModelLoader::ProcessMesh(ERS_STRUCT_ModelWriterData



void ERS_ExternalModelLoader::HandleMeshTextures(ERS_STRUCT_ModelWriterData &Data, ERS_STRUCT_Model* Model, aiMaterial* Material, std::string ModelDirectory, ERS_STRUCT_Mesh* TargetMesh) {
void ExternalModelLoader::HandleMeshTextures(ERS_STRUCT_ModelWriterData &Data, ERS_STRUCT_Model* Model, aiMaterial* Material, std::string ModelDirectory, ERS_STRUCT_Mesh* TargetMesh) {

SystemUtils_->Logger_->Log("Identifying Mesh Textures", 3);
AddTexture(Data, Model, Material, aiTextureType_AMBIENT, "texture_ambient", ModelDirectory, TargetMesh);
Expand All @@ -491,7 +495,7 @@ void ERS_ExternalModelLoader::HandleMeshTextures(ERS_STRUCT_ModelWriterData &Dat
SystemUtils_->Logger_->Log("Finshed Mesh Texture Identification", 4);

}
void ERS_ExternalModelLoader::AddTexture(ERS_STRUCT_ModelWriterData &Data, ERS_STRUCT_Model* Model, aiMaterial *Mat, aiTextureType Type, std::string TypeName, std::string ModelDirectory, ERS_STRUCT_Mesh* TargetMesh) {
void ExternalModelLoader::AddTexture(ERS_STRUCT_ModelWriterData &Data, ERS_STRUCT_Model* Model, aiMaterial *Mat, aiTextureType Type, std::string TypeName, std::string ModelDirectory, ERS_STRUCT_Mesh* TargetMesh) {


for (unsigned int i=0; i< Mat->GetTextureCount(Type); i++) {
Expand All @@ -512,7 +516,7 @@ void ERS_ExternalModelLoader::AddTexture(ERS_STRUCT_ModelWriterData &Data, ERS_S
}

}
bool ERS_ExternalModelLoader::ReadFile(std::string FilePath, ERS_STRUCT_IOData* OutputData) {
bool ExternalModelLoader::ReadFile(std::string FilePath, ERS_STRUCT_IOData* OutputData) {

struct stat Buffer;
int FileStatus = stat(FilePath.c_str(), &Buffer);
Expand Down Expand Up @@ -553,7 +557,7 @@ bool ERS_ExternalModelLoader::ReadFile(std::string FilePath, ERS_STRUCT_IOData*

}

bool ERS_ExternalModelLoader::PerformModelSanityChecks(ERS_STRUCT_Model &Model) {
bool ExternalModelLoader::PerformModelSanityChecks(ERS_STRUCT_Model &Model) {

// Check For Meshes
if (Model.Meshes.size() == 0) {
Expand All @@ -578,7 +582,7 @@ bool ERS_ExternalModelLoader::PerformModelSanityChecks(ERS_STRUCT_Model &Model)
}

// Load Model From File
bool ERS_ExternalModelLoader::LoadModel(std::string ModelPath, ERS_STRUCT_ModelWriterData &Data) {
bool ExternalModelLoader::LoadModel(std::string ModelPath, ERS_STRUCT_ModelWriterData &Data) {

SystemUtils_->Logger_->Log(std::string("Loading External Model '") + ModelPath + "'", 5);

Expand Down Expand Up @@ -621,3 +625,8 @@ bool ERS_ExternalModelLoader::LoadModel(std::string ModelPath, ERS_STRUCT_ModelW
}

}


}
}
}
19 changes: 15 additions & 4 deletions Source/Internal/ExternalModelLoader/ERS_ExternalModelLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@



namespace BrainGenix {
namespace ERS {
namespace Module {



/**
* @brief Class for importing models (fbx, gltx, etc.) based on the ASSIMP library
*
*/
class ERS_ExternalModelLoader {
class ExternalModelLoader {


private:
Expand Down Expand Up @@ -158,13 +164,13 @@ class ERS_ExternalModelLoader {
* @param Logger
* @param TextureLoader
*/
ERS_ExternalModelLoader(ERS_STRUCT_SystemUtils*);
ExternalModelLoader(ERS_STRUCT_SystemUtils*);

/**
* @brief Destroy the Model Loader object
*
*/
~ERS_ExternalModelLoader();
~ExternalModelLoader();



Expand All @@ -181,4 +187,9 @@ class ERS_ExternalModelLoader {
*/
bool LoadModel(std::string ModelFilePath, ERS_STRUCT_ModelWriterData &ModelData);

};
};


}
}
}
2 changes: 1 addition & 1 deletion Source/Internal/ModelImporter/ERS_ModelImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ERS_ModelImporter::ERS_ModelImporter(ERS_STRUCT_SystemUtils* SystemUtils) {

// Setup Classes
ModelWriter_ = std::make_unique<ERS_CLASS_ModelWriter>(SystemUtils_->Logger_.get(), SystemUtils_->ERS_IOSubsystem_.get());
ModelLoader_ = std::make_unique<ERS_ExternalModelLoader>(SystemUtils_);
ModelLoader_ = std::make_unique<BrainGenix::ERS::Module::ExternalModelLoader>(SystemUtils_);

SystemUtils_->Logger_->Log("Starting Asset Import Thread", 4);
ImportThread_ = std::thread(&ERS_ModelImporter::ImportThread, this);
Expand Down
2 changes: 1 addition & 1 deletion Source/Internal/ModelImporter/ERS_ModelImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ERS_ModelImporter {
std::vector<std::future<void>> ProcessingItems_; /**<List of items currently being worked on by the threads*/

std::unique_ptr<ERS_CLASS_ModelWriter> ModelWriter_; /**<Instance of the model writer, used to save models to the ERS project*/
std::unique_ptr<ERS_ExternalModelLoader> ModelLoader_; /**<Used to load models from outside the ERS project*/
std::unique_ptr<BrainGenix::ERS::Module::ExternalModelLoader> ModelLoader_; /**<Used to load models from outside the ERS project*/

std::unique_ptr<ERS_CLASS_ModelWriter> ERS_ModelWriter_; /**<Pointer To ERS Model Writer Instance*/

Expand Down
2 changes: 1 addition & 1 deletion Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int main(int NumArguments, char** ArguemntValues) {
SystemUtils->Logger_->Log("Initialized Logging System", 5);

// Handle Command Line Arguments
ERS_ArgumentParser ArgumentParser = ERS_ArgumentParser(SystemUtils->Logger_.get());
BrainGenix::ERS::Module::ArgumentParser ArgumentParser = BrainGenix::ERS::Module::ArgumentParser(SystemUtils->Logger_.get());
ArgumentParser.ParseArguments(NumArguments, ArguemntValues);
SystemUtils->ArgumentString_ = ArgumentParser.GetArgumentString();
SystemUtils->Arguments_ = ArgumentParser.GetArgumentPairs();
Expand Down