internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FDatasmithFacadeMaterialExpressionScalar obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public static void ParseMaterial(FDatasmithFacadeUEPbrMaterial DSMaterial, Material RhinoMaterial, DatasmithRhinoSceneParser SceneParser) { Color MaterialDiffuseColor = RhinoMaterial.DiffuseColor; MaterialDiffuseColor = Color.FromArgb(255 - (byte)(255 * RhinoMaterial.Transparency), MaterialDiffuseColor); Texture[] MaterialTextures = RhinoMaterial.GetTextures(); for (int TextureIndex = 0; TextureIndex < MaterialTextures.Length; ++TextureIndex) { Texture RhinoTexture = MaterialTextures[TextureIndex]; if (RhinoTexture != null) { RhinoTextureInfo TextureInfo = SceneParser.GetTextureInfoFromRhinoTexture(RhinoTexture.Id); if (TextureInfo != null) { AddTextureToMaterial(DSMaterial, TextureInfo, MaterialDiffuseColor); } } } // Set a diffuse color if there's nothing in the BaseColor if (DSMaterial.GetBaseColor().GetExpression() == null) { FDatasmithFacadeMaterialExpressionColor ColorExpression = DSMaterial.AddMaterialExpressionColor(); ColorExpression.SetName("Diffuse Color"); ColorExpression.SetsRGBColor(MaterialDiffuseColor.R, MaterialDiffuseColor.G, MaterialDiffuseColor.B, MaterialDiffuseColor.A); ColorExpression.ConnectExpression(DSMaterial.GetBaseColor()); } if (RhinoMaterial.Transparency > 0) { DSMaterial.SetBlendMode(/*EBlendMode::BLEND_Translucent*/ 2); if (DSMaterial.GetOpacity().GetExpression() == null) { // Transparent color FDatasmithFacadeMaterialExpressionScalar Scalar = DSMaterial.AddMaterialExpressionScalar(); Scalar.SetName("Opacity"); Scalar.SetScalar(1 - (float)RhinoMaterial.Transparency); Scalar.ConnectExpression(DSMaterial.GetOpacity()); } else { // Modulate the opacity map with the color transparency setting FDatasmithFacadeMaterialExpressionGeneric Multiply = DSMaterial.AddMaterialExpressionGeneric(); Multiply.SetExpressionName("Multiply"); FDatasmithFacadeMaterialExpressionScalar Scalar = DSMaterial.AddMaterialExpressionScalar(); Scalar.SetName("Opacity Output Level"); Scalar.SetScalar(1 - (float)RhinoMaterial.Transparency); Scalar.ConnectExpression(Multiply.GetInput(0)); FDatasmithFacadeMaterialExpression CurrentOpacityExpression = DSMaterial.GetOpacity().GetExpression(); CurrentOpacityExpression.ConnectExpression(Multiply.GetInput(1)); DSMaterial.GetOpacity().SetExpression(Multiply); } } float Shininess = (float)(RhinoMaterial.Shine / Material.MaxShine); if (Math.Abs(Shininess) > float.Epsilon) { FDatasmithFacadeMaterialExpressionScalar ShininessExpression = DSMaterial.AddMaterialExpressionScalar(); ShininessExpression.SetName("Roughness"); ShininessExpression.SetScalar(1f - Shininess); ShininessExpression.ConnectExpression(DSMaterial.GetRoughness()); } float Reflectivity = (float)RhinoMaterial.Reflectivity; if (Math.Abs(Reflectivity) > float.Epsilon) { FDatasmithFacadeMaterialExpressionScalar ReflectivityExpression = DSMaterial.AddMaterialExpressionScalar(); ReflectivityExpression.SetName("Metallic"); ReflectivityExpression.SetScalar(Reflectivity); ReflectivityExpression.ConnectExpression(DSMaterial.GetMetallic()); } }
public FDatasmithFacadeMaterialExpressionScalar AddMaterialExpressionScalar() { FDatasmithFacadeMaterialExpressionScalar ret = new FDatasmithFacadeMaterialExpressionScalar(DatasmithFacadeCSharpPINVOKE.FDatasmithFacadeUEPbrMaterial_AddMaterialExpressionScalar(swigCPtr), true); return(ret); }