// Copyright (c) Wojciech Figat. All rights reserved. #pragma once #include "../BinaryAsset.h" #include "Engine/Graphics/Materials/IMaterial.h" #include "Engine/Graphics/Materials/MaterialParams.h" /// /// Base class for and . /// /// API_CLASS(Abstract, NoSpawn) class FLAXENGINE_API MaterialBase : public BinaryAsset, public IMaterial { DECLARE_ASSET_HEADER(MaterialBase); public: /// /// The material parameters collection. /// MaterialParams Params; /// /// Event called when parameters collections gets modified. /// Action ParamsChanged; /// /// Returns true if material is a material instance. /// virtual bool IsMaterialInstance() const = 0; public: /// /// Gets the material parameters collection. /// API_PROPERTY() const Array& GetParameters() const { return Params; } /// /// Gets the material info, structure which describes material surface. /// API_PROPERTY() FORCE_INLINE const MaterialInfo& Info() const { return GetInfo(); } /// /// Gets the material parameter. /// API_FUNCTION() FORCE_INLINE MaterialParameter* GetParameter(const StringView& name) { return Params.Get(name); } /// /// Gets the material parameter value. /// /// The parameter value. API_FUNCTION() Variant GetParameterValue(const StringView& name); /// /// Sets the material parameter value (and sets IsOverride to true). /// /// The parameter name. /// The value to set. /// True to warn if parameter is missing, otherwise will do nothing. API_FUNCTION() void SetParameterValue(const StringView& name, const Variant& value, bool warnIfMissing = true); /// /// Creates the virtual material instance of this material which allows to override any material parameters. /// /// The created virtual material instance asset. API_FUNCTION() MaterialInstance* CreateVirtualInstance(); public: // [BinaryAsset] #if USE_EDITOR void GetReferences(Array& assets, Array& files) const override; #endif };