Skip to content

Adding ToRhino method for Texture #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Rhinoceros_Engine/Convert/ToRhino.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ****/
/***************************************************/
Expand Down