diff --git a/Rhinoceros_Engine/Convert/ToRhino.cs b/Rhinoceros_Engine/Convert/ToRhino.cs index 8028d20..16447dc 100644 --- a/Rhinoceros_Engine/Convert/ToRhino.cs +++ b/Rhinoceros_Engine/Convert/ToRhino.cs @@ -829,6 +829,24 @@ public static object ToRhino(this RenderCurve renderCurve) return ToRhino(renderCurve.Curve as dynamic); } + /***************************************************/ + + [Description("Returns the Rhino version of the Texture.")] + [Input("texture", "Input BHoM Texture.")] + [Output("rhMat", "The Rhino display material.")] + public static DisplayMaterial ToRhino(this BH.oM.Graphics.Texture texture) + { + if (texture == null) + return null; + + DisplayMaterial material = new DisplayMaterial(texture.Diffuse, texture.Specular, texture.Ambient, texture.Emission, texture.Shine, texture.Transparency); + if (!string.IsNullOrWhiteSpace(texture.BitmapTexture) && System.IO.File.Exists(texture.BitmapTexture)) + { + material.SetBitmapTexture(texture.BitmapTexture, true); + } + return material; + } + /***************************************************/ /**** Miscellanea ****/ /***************************************************/