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:
parent
fbf46e223c
commit
c821575ea4
1 changed files with 11 additions and 8 deletions
|
@ -410,19 +410,22 @@ void ModelEditor::compile_model() {
|
||||||
if(infile.good())
|
if(infile.good())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
nlohmann::json j;
|
Material mat;
|
||||||
|
|
||||||
j["version"] = 1;
|
|
||||||
|
|
||||||
aiColor4D color;
|
aiColor4D color;
|
||||||
aiGetMaterialColor(sc->mMaterials[i], AI_MATKEY_COLOR_DIFFUSE,&color);
|
aiGetMaterialColor(sc->mMaterials[i], AI_MATKEY_COLOR_DIFFUSE,&color);
|
||||||
|
|
||||||
j["baseColor"] = prism::float3(color.r, color.g, color.b);
|
mat.colorProperty.type = DataType::Vector3;
|
||||||
j["metallic"] = 0.0f;
|
mat.colorProperty.value = prism::float3(color.r, color.g, color.b);
|
||||||
j["roughness"] = 0.5f;
|
|
||||||
|
|
||||||
std::ofstream out(path);
|
aiString diffuse_path;
|
||||||
out << j;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue