Materials: Editor UI enhancements
When creating a new material, assigning the basic rendering model to the material resulted in an all black color. This will now be assigned the default color as specified in the preferences. The name of the material Properties tab has been changed to Physical for improved consistency in the user interface.
This commit is contained in:
committed by
Chris Hennes
parent
b057e6eb74
commit
7d3f6e2ad1
@@ -138,10 +138,8 @@ bool MaterialManager::isMaterial(const QFileInfo& file) const
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<Material> MaterialManager::defaultMaterial()
|
||||
std::shared_ptr<App::Material> MaterialManager::defaultAppearance()
|
||||
{
|
||||
MaterialManager manager;
|
||||
|
||||
ParameterGrp::handle hGrp =
|
||||
App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
|
||||
|
||||
@@ -149,8 +147,9 @@ std::shared_ptr<Material> MaterialManager::defaultMaterial()
|
||||
uint32_t packed = color.getPackedRGB();
|
||||
packed = hGrp->GetUnsigned(parameter, packed);
|
||||
color.setPackedRGB(packed);
|
||||
color.a = 1.0; // The default color sets fully transparent, not opaque
|
||||
};
|
||||
auto intRandom = [] (int min, int max) -> int {
|
||||
auto intRandom = [](int min, int max) -> int {
|
||||
static std::mt19937 generator;
|
||||
std::uniform_int_distribution<int> distribution(min, max);
|
||||
return distribution(generator);
|
||||
@@ -163,7 +162,7 @@ std::shared_ptr<Material> MaterialManager::defaultMaterial()
|
||||
float red = static_cast<float>(intRandom(0, 255)) / 255.0F;
|
||||
float green = static_cast<float>(intRandom(0, 255)) / 255.0F;
|
||||
float blue = static_cast<float>(intRandom(0, 255)) / 255.0F;
|
||||
mat.diffuseColor = App::Color(red, green, blue);
|
||||
mat.diffuseColor = App::Color(red, green, blue, 1.0);
|
||||
}
|
||||
else {
|
||||
getColor("DefaultShapeColor", mat.diffuseColor);
|
||||
@@ -175,24 +174,34 @@ std::shared_ptr<Material> MaterialManager::defaultMaterial()
|
||||
|
||||
long initialTransparency = hGrp->GetInt("DefaultShapeTransparency", 0);
|
||||
long initialShininess = hGrp->GetInt("DefaultShapeShininess", 90);
|
||||
mat.shininess = ((float)initialShininess / 100.0F);
|
||||
mat.transparency = ((float)initialTransparency / 100.0F);
|
||||
|
||||
return std::make_shared<App::Material>(mat);
|
||||
}
|
||||
|
||||
std::shared_ptr<Material> MaterialManager::defaultMaterial()
|
||||
{
|
||||
MaterialManager manager;
|
||||
|
||||
auto mat = defaultAppearance();
|
||||
auto material = manager.getMaterial(defaultMaterialUUID());
|
||||
if (!material) {
|
||||
material = manager.getMaterial(QLatin1String("7f9fd73b-50c9-41d8-b7b2-575a030c1eeb"));
|
||||
}
|
||||
if (material->hasAppearanceModel(ModelUUIDs::ModelUUID_Rendering_Basic)) {
|
||||
material->getAppearanceProperty(QString::fromLatin1("DiffuseColor"))
|
||||
->setColor(mat.diffuseColor);
|
||||
->setColor(mat->diffuseColor);
|
||||
material->getAppearanceProperty(QString::fromLatin1("AmbientColor"))
|
||||
->setColor(mat.ambientColor);
|
||||
->setColor(mat->ambientColor);
|
||||
material->getAppearanceProperty(QString::fromLatin1("EmissiveColor"))
|
||||
->setColor(mat.emissiveColor);
|
||||
->setColor(mat->emissiveColor);
|
||||
material->getAppearanceProperty(QString::fromLatin1("SpecularColor"))
|
||||
->setColor(mat.specularColor);
|
||||
->setColor(mat->specularColor);
|
||||
material->getAppearanceProperty(QString::fromLatin1("Transparency"))
|
||||
->setFloat((float)initialTransparency / 100.0F);
|
||||
->setFloat(mat->transparency);
|
||||
material->getAppearanceProperty(QString::fromLatin1("Shininess"))
|
||||
->setFloat((float)initialShininess / 100.0F);
|
||||
->setFloat(mat->shininess);
|
||||
}
|
||||
|
||||
return material;
|
||||
|
||||
Reference in New Issue
Block a user