{LYN2076} Add Material data types Behavior for the scene graph (#3605)
* {LYN2076} Add Material data types Behavior for the scene graph
Adding behavior to expose GraphData MaterialData to Python scripts so that scripters can read in the material properties from a scene graph
Signed-off-by: jackalbe <23512001+jackalbe@users.noreply.github.com>
* new warning fixed in code
Signed-off-by: Jackson <23512001+jackalbe@users.noreply.github.com>
This commit is contained in:
@@ -230,6 +230,19 @@ namespace AZ
|
||||
return m_uniqueId;
|
||||
}
|
||||
|
||||
namespace Helper
|
||||
{
|
||||
template <typename T>
|
||||
T ReturnOptionalValue(AZStd::optional<T> value)
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
return value.value();
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialData::Reflect(ReflectContext* context)
|
||||
{
|
||||
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
|
||||
@@ -285,6 +298,76 @@ namespace AZ
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialData::m_useAOMap, "Use Ambient Occlusion Map", "True to use an ambient occlusion map, false to ignore it.");
|
||||
}
|
||||
}
|
||||
|
||||
BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context);
|
||||
if (behaviorContext)
|
||||
{
|
||||
behaviorContext->Class<SceneAPI::DataTypes::IMaterialData>()
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "scene");
|
||||
|
||||
using namespace Helper;
|
||||
using DataTypes::IMaterialData;
|
||||
|
||||
behaviorContext->Class<MaterialData>()
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Module, "scene")
|
||||
->Constant("AmbientOcclusion", BehaviorConstant(TextureMapType::AmbientOcclusion))
|
||||
->Constant("BaseColor", BehaviorConstant(TextureMapType::BaseColor))
|
||||
->Constant("Bump", BehaviorConstant(TextureMapType::Bump))
|
||||
->Constant("Diffuse", BehaviorConstant(TextureMapType::Diffuse))
|
||||
->Constant("Emissive", BehaviorConstant(TextureMapType::Emissive))
|
||||
->Constant("Metallic", BehaviorConstant(TextureMapType::Metallic))
|
||||
->Constant("Normal", BehaviorConstant(TextureMapType::Normal))
|
||||
->Constant("Roughness", BehaviorConstant(TextureMapType::Roughness))
|
||||
->Constant("Specular", BehaviorConstant(TextureMapType::Specular))
|
||||
->Method("GetTexture", &MaterialData::GetTexture)
|
||||
->Method("GetMaterialName", &MaterialData::GetMaterialName)
|
||||
->Method("IsNoDraw", &MaterialData::IsNoDraw)
|
||||
->Method("GetDiffuseColor", &MaterialData::GetDiffuseColor)
|
||||
->Method("GetSpecularColor", &MaterialData::GetSpecularColor)
|
||||
->Method("GetEmissiveColor", &MaterialData::GetEmissiveColor)
|
||||
->Method("GetOpacity", &MaterialData::GetOpacity)
|
||||
->Method("GetUniqueId", &MaterialData::GetUniqueId)
|
||||
->Method("GetShininess", &MaterialData::GetShininess)
|
||||
->Method("GetUseColorMap", [](const MaterialData& self)
|
||||
{
|
||||
return ReturnOptionalValue(self.GetUseColorMap());
|
||||
})
|
||||
->Method("GetBaseColor", [](const MaterialData& self)
|
||||
{
|
||||
return ReturnOptionalValue(self.GetBaseColor());
|
||||
})
|
||||
->Method("GetUseMetallicMap", [](const MaterialData& self)
|
||||
{
|
||||
return ReturnOptionalValue(self.GetUseMetallicMap());
|
||||
})
|
||||
->Method("GetMetallicFactor", [](const MaterialData& self)
|
||||
{
|
||||
return ReturnOptionalValue(self.GetMetallicFactor());
|
||||
})
|
||||
->Method("GetUseRoughnessMap", [](const MaterialData& self)
|
||||
{
|
||||
return ReturnOptionalValue(self.GetUseRoughnessMap());
|
||||
})
|
||||
->Method("GetRoughnessFactor", [](const MaterialData& self)
|
||||
{
|
||||
return ReturnOptionalValue(self.GetRoughnessFactor());
|
||||
})
|
||||
->Method("GetUseEmissiveMap", [](const MaterialData& self)
|
||||
{
|
||||
return ReturnOptionalValue(self.GetUseEmissiveMap());
|
||||
})
|
||||
->Method("GetEmissiveIntensity", [](const MaterialData& self)
|
||||
{
|
||||
return ReturnOptionalValue(self.GetEmissiveIntensity());
|
||||
})
|
||||
->Method("GetUseAOMap", [](const MaterialData& self)
|
||||
{
|
||||
return ReturnOptionalValue(self.GetUseAOMap());
|
||||
});
|
||||
}
|
||||
}
|
||||
} // namespace GraphData
|
||||
} // namespace SceneData
|
||||
|
||||
Reference in New Issue
Block a user