#include "Mesh.h" #include "Engine/AssetManager.h" #include "gcml.h" #include "../Engine/AssetManager.h" extern AssetManager g_AssetManager; //TODO: Make this have a OBJ path, make indexCount derive from AssetManager //TODO: and make texture id also get from AssetManager //? Procastinate const std::string MeshComponent::name = "Mesh"; MeshComponent::MeshComponent() : vao(0), indexCount(0), textureID(0), MeshPath("assets/models/DefaultMesh.obj") { } const std::string& MeshComponent::GetName() const { return name; } const std::string& MeshComponent::GetStaticName() { return name; } YAML::Node MeshComponent::Serialize() { YAML::Node node; node["vao"] = static_cast(vao); node["indexCount"] = static_cast(indexCount); node["textureID"] = static_cast(textureID); node["MeshPath"] = static_cast(MeshPath); return node; } void MeshComponent::Deserialize(const YAML::Node& node) { if (node["vao"]) { vao = static_cast(node["vao"].as()); } if (node["indexCount"]) { indexCount = static_cast(node["indexCount"].as()); } if (node["textureID"]) { textureID = static_cast(node["textureID"].as()); } if (node["MeshPath"]) { MeshPath = static_cast(node["MeshPath"].as()); g_AssetManager.DebugAssetMap(); #if 1 DEBUG_PRINT("Loading Mesh: >%s<", MeshPath.c_str()); Model* model = g_AssetManager.loadAsset(AssetType::MODEL, MeshPath.c_str()); DEBUG_PRINT("Model loaded successfully with %lld vertices and %lld indices.", model->vertices.size(), model->indices.size()); #else DEBUG_PRINT("Automatic Mesh Loading Disabled."); #endif } }