OnMaterial converting to DisplayMaterial

I am trying to convert some OnMaterial Code over to Rhino6 RhinoCommon DisplayMaterial

the original function starts like this:

public CSDisplayMaterial(string fileNameEmap, double emapAmount, Color color, double glossAmount, double trans,  string name)
{
OnMaterial onmat = new OnMaterial
        {
            m_ambient = new OnColor(0, 0, 0),
            m_diffuse = color,
            m_specular = OnColor.FromColor(Color.White),
            m_shine = glossAmount * OnMaterial.MaxShine(),
            m_transparency = trans
        };
    onmat.AddTexture(fileNameEmap, IOnTexture.TYPE.emap_texture);
    onmat.m_textures[0].m_blend_constant_A = emapAmount;
    onmat.m_textures[0].m_mode = IOnTexture.MODE.blend_texture;

    _mat = new MDisplayPipelineMaterial(onmat) { m_bUseBackMaterial = false };

}

so start the conversion:

    public CSDisplayMaterial(string fileNameEmap, double emapAmount, Color color, double glossAmount, double trans, string name)
    {
        DisplayMaterial onmat = new DisplayMaterial
        {
            Ambient = Color.Black,
            Diffuse = color,
            Specular = Color.White,
            Shine = glossAmount * Rhino.DocObjects.Material.MaxShine,
            Transparency = trans
        };
        /*
                    onmat.AddTexture(fileNameEmap, IOnTexture.TYPE.emap_texture);
                    onmat.m_textures[0].m_blend_constant_A = emapAmount;
                    onmat.m_textures[0].m_mode = IOnTexture.MODE.blend_texture;
        */
        _mat = new DisplayMaterial(onmat);
    }

So questions I have…
I sea Ambient is there but obsolete, I am setting it to black in this example, so probably does not matter, but in other code where I am using it, what should I be using instead.

then the emap texture.
I see there is:
onmat.SetEnvironmentTexture(filename,front);

how do I use this including the emapAmount, and IOnTexture.MODE.blend_texture.

Thanks

Hi Gordon,

I have not tried this…

public DisplayMaterial CreateDisplayMaterial(
    string filename, 
    double alpha, 
    Color color, 
    double shine, 
    double transparency
)
{
  var material = new DisplayMaterial
  {
    Diffuse = color,
    IsTwoSided = false,
    Shine = shine,
    Specular = Color.White,
    Transparency = transparency
  };

  // Set the environment map
  material.SetEnvironmentTexture(filename, true);

  // Tweak the environment map
  var texture = material.GetEnvironmentTexture(true);
  if (null != texture)
  {
    texture.TextureCombineMode = TextureCombineMode.Blend;
    double constant, a0, a1, a2, a3;
    texture.GetAlphaBlendValues(out constant, out a0, out a1, out a2, out a3);
    texture.SetAlphaBlendValues(alpha, a0, a1, a2, a3);
  }

  return material;
}