Archived
1
Fork 0

Write new materials from model editor

This now uses the same saving function as the regular editor, so now it's no
longer constantly out of date with the new material changes.
This commit is contained in:
Joshua Goins 2022-02-03 10:02:26 -05:00
parent fbf46e223c
commit c821575ea4

View file

@ -410,19 +410,22 @@ void ModelEditor::compile_model() {
if(infile.good())
continue;
nlohmann::json j;
j["version"] = 1;
Material mat;
aiColor4D color;
aiGetMaterialColor(sc->mMaterials[i], AI_MATKEY_COLOR_DIFFUSE,&color);
j["baseColor"] = prism::float3(color.r, color.g, color.b);
j["metallic"] = 0.0f;
j["roughness"] = 0.5f;
mat.colorProperty.type = DataType::Vector3;
mat.colorProperty.value = prism::float3(color.r, color.g, color.b);
std::ofstream out(path);
out << j;
aiString diffuse_path;
if(aiReturn_SUCCESS == aiGetMaterialTexture(sc->mMaterials[i], aiTextureType_DIFFUSE, 0, &diffuse_path)) {
mat.colorProperty.type = DataType::AssetTexture;
mat.colorProperty.value_tex.handle = new Texture();
mat.colorProperty.value_tex->path = diffuse_path.C_Str();
}
save_material(&mat, path);
}
}