Material.BackDiffuse is not working. How to make it work?


#1

.

I want the back side of the mesh as Cyan color , but it is showing black…
What is wrong below, that, back side shading is not working.
But other part of the code is working perfectly.
Could not find any sample on the net.
Best regards
Tahmina
public class TestMeshConduit : Rhino.Display.DisplayConduit
{
public Rhino.Geometry.Mesh Mesh { get; set; }

protected override void CalculateBoundingBox(Rhino.Display.CalculateBoundingBoxEventArgs e)
{
if (null != Mesh)
{
Rhino.Geometry.BoundingBox bbox = Mesh.GetBoundingBox(false);
e.IncludeBoundingBox(bbox);
}
}

        protected override void PostDrawObjects(Rhino.Display.DrawEventArgs e)
        {
            if (null != Mesh)
            {
                Rhino.Display.DisplayMaterial material = new Rhino.Display.DisplayMaterial();
                material.Diffuse = System.Drawing.Color.Blue;
                material.BackDiffuse = System.Drawing.Color.Cyan;
                e.Display.EnableLighting(true);
                e.Display.DrawMeshShaded(Mesh, material);
                e.Display.DrawMeshVertices(Mesh, System.Drawing.Color.Red);
                e.Display.DrawMeshWires(Mesh, System.Drawing.Color.Black);
            }
        }
    }

(Dale Fugier) #2

Don’t forget to do this:

material.IsTwoSided = true;

#3

Hi Dale, Nice to hear from you. Thanks for the response !.I wrote it but still not working… Blue is working perfect but back side is showing black again.


(Dale Fugier) #4

This seems to work for me:

https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsDrawMesh.cs


#5

Thanks , Dale it is actually working… I think something is wrong with that particular mash… I have to check…
What are the cause for showing a mesh black? please let me know the causes.

Some sort of vertex topological problem I guess.


(Dale Fugier) #6

Perhaps your mesh does not have normals.

Rhino.Geometry.Mesh mesh = ...;
mesh.Normals.ComputeNormals();
mesh.FaceNormals.ComputeFaceNormals();

#7

Many Thanks !
I thought I wrote , but I have missed both lines you wrote.
It is working now :slight_smile: