Improving Material shader code generation
This commit is contained in:
@@ -28,16 +28,16 @@ void AssetRegistry::importFile(const std::string &filePath)
|
||||
if (extension.compare(".fbx") == 0
|
||||
|| extension.compare(".obj") == 0)
|
||||
{
|
||||
get().registerMesh(fsPath);
|
||||
get().importMesh(fsPath);
|
||||
}
|
||||
if (extension.compare(".png") == 0
|
||||
|| extension.compare(".jpg") == 0)
|
||||
{
|
||||
get().registerTexture(fsPath);
|
||||
get().importTexture(fsPath);
|
||||
}
|
||||
if (extension.compare(".semat") == 0)
|
||||
{
|
||||
get().registerMaterial(fsPath);
|
||||
get().importMaterial(fsPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,16 @@ PMaterialAsset AssetRegistry::findMaterial(const std::string &filePath)
|
||||
return get().materials[filePath];
|
||||
}
|
||||
|
||||
std::ofstream AssetRegistry::createWriteStream(const std::string& relativePath, std::ios_base::openmode openmode)
|
||||
{
|
||||
return get().internalCreateWriteStream(relativePath, openmode);
|
||||
}
|
||||
|
||||
std::ifstream AssetRegistry::createReadStream(const std::string& relativePath, std::ios_base::openmode openmode)
|
||||
{
|
||||
return get().internalCreateReadStream(relativePath, openmode);
|
||||
}
|
||||
|
||||
PTextureAsset AssetRegistry::findTexture(const std::string &filePath)
|
||||
{
|
||||
return get().textures[filePath];
|
||||
@@ -75,17 +85,49 @@ void AssetRegistry::init(const std::filesystem::path &rootFolder, Gfx::PGraphics
|
||||
reg.materialLoader = new MaterialLoader(graphics);
|
||||
}
|
||||
|
||||
void AssetRegistry::registerMesh(const std::filesystem::path &filePath)
|
||||
std::string AssetRegistry::getRootFolder()
|
||||
{
|
||||
return get().rootFolder.generic_string();
|
||||
}
|
||||
|
||||
void AssetRegistry::importMesh(const std::filesystem::path &filePath)
|
||||
{
|
||||
meshLoader->importAsset(filePath);
|
||||
}
|
||||
|
||||
void AssetRegistry::registerTexture(const std::filesystem::path &filePath)
|
||||
void AssetRegistry::importTexture(const std::filesystem::path &filePath)
|
||||
{
|
||||
textureLoader->importAsset(filePath);
|
||||
}
|
||||
|
||||
void AssetRegistry::registerMaterial(const std::filesystem::path &filePath)
|
||||
void AssetRegistry::importMaterial(const std::filesystem::path &filePath)
|
||||
{
|
||||
materialLoader->queueAsset(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
void AssetRegistry::registerMesh(PMeshAsset mesh)
|
||||
{
|
||||
PMeshAsset existingMesh = meshes[mesh->getFileName()];
|
||||
if(existingMesh != nullptr)
|
||||
{
|
||||
auto newMeshes = mesh->getMeshes();
|
||||
for(uint32 i = 0; i < newMeshes.size(); ++i)
|
||||
{
|
||||
existingMesh->addMesh(newMeshes[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
meshes[mesh->getFileName()] = mesh;
|
||||
}
|
||||
}
|
||||
|
||||
std::ofstream AssetRegistry::internalCreateWriteStream(const std::string& relativePath, std::ios_base::openmode openmode)
|
||||
{
|
||||
return std::ofstream(rootFolder.generic_string().append(relativePath), openmode);
|
||||
}
|
||||
|
||||
std::ifstream AssetRegistry::internalCreateReadStream(const std::string& relativePath, std::ios_base::openmode openmode)
|
||||
{
|
||||
return std::ifstream(rootFolder.generic_string().append(relativePath), openmode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user