56 lines
1.1 KiB
C++

#pragma once
#include "../../YoggieEngine/src/YoggieEngine.h"
#include <filesystem>
#include <string>
#include "uuid.h"
enum class ASSET_TYPE {
Unknown = -1,
Mesh,
Texture,
Material,
Shader,
Model,
File
};
class Asset {
public:
Asset(const char* name): name(name) {}
virtual ASSET_TYPE GetType() { return detectAssetType(); }
const char* GetName() const { return name.c_str(); }
void setName(std::string& name) { name = name.c_str(); }
void setFilPath(std::string& path) { file = std::filesystem::path(path); }
std::string getId() { return Id.String(); }
protected:
uuid::v4::UUID Id = uuid::v4::UUID::New();
std::string name;
std::filesystem::path file;
ASSET_TYPE detectAssetType() {
auto ext = (file.extension()).string();
if (ext == ".obj" || ext == ".gltf" || ext == ".fbx" || ext == ".stl") {
return ASSET_TYPE::Model;
}
else if (ext == ".yproj") {
return ASSET_TYPE::File;
}
else if (ext == ".vs" || ext == ".fs") {
return ASSET_TYPE::File;
}
else {
spdlog::warn("unknown file!");
return ASSET_TYPE::Unknown;
}
}
};