AB4D Forum
IMultiMapMaterial read only - Printable Version

+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab3d.DXEngine (https://forum.ab4d.com/forumdisplay.php?fid=11)
+--- Thread: IMultiMapMaterial read only (/showthread.php?tid=4352)



IMultiMapMaterial read only - GraPhiX - 01-26-2023

the interface imultimapmaterial is read only so how do i add my material list ??

Code:
#Region "Assembly Ab3d.DXEngine, Version=5.1.8153.1045, Culture=neutral, PublicKeyToken=d45c8e156fba2841"
' F:\Users\kevan\Documents\VS2022 Projects\x3DViewer\DLL\Ab3d.DXEngine.dll
#End Region

Imports System.Collections.Generic
Imports SharpDX.Direct3D11

Namespace Ab3d.DirectX.Materials
    '
    ' Summary:
    '     IMultiMapMaterial interface defines TextureMaps property that is a list of Ab3d.DirectX.Materials.TextureMapInfo
    '     objects and is used to define a material that uses multiple texture maps.
    Public Interface IMultiMapMaterial
        '
        ' Summary:
        '     Gets a list of Ab3d.DirectX.Materials.TextureMapInfo object that defines texture
        '     maps that should be rendered with this material.
        ReadOnly Property TextureMaps As List(Of TextureMapInfo)
        '
        ' Summary:
        '     Gets a BlendState that is used to render the base texture. If null a Ab3d.DirectX.CommonStates.Opaque
        '     or a Ab3d.DirectX.CommonStates.PremultipliedAdditiveBlend (in case of transparency)
        '     will be used.
        ReadOnly Property BlendState As BlendState
    End Interface
End Namespace

i have this declared
    Public Property MY_PBRmaterial As IMultiMapMaterial

when i try to add a texture to the list my app crashes

MY_PBRmaterial.TextureMaps.Add(_textureMapInfo) 'BREAKS HERE

so how do i add my textures to the list ?


RE: IMultiMapMaterial read only - abenedik - 03-13-2023

What exception is thrown when you call Add method. If it is Null reference exception, then you need to make sure that the material that implements the IMultiMapMaterial will create the TextureMaps list in constructor - see MultiMapMaterial.cs:


Code:
        /// <summary>
        /// Constructor
        /// </summary>
        public MultiMapMaterial()
        {
            TextureMaps = new System.Collections.Generic.List<TextureMapInfo>();
            HasTransparency = false;
            Alpha = 1.0f;
            AmbientColor = Color3.Black;
            DiffuseColor = Color3.White; // This is a mask that is multiplied with diffuse texture color - by default render diffuse texture without any mask - using White diffuse color
            SpecularColor = Color3.Black;
            SpecularPower = 0.0f;
            EmissiveColor = Color3.Black;
        }