Transparency for Colorful Mesh

Hi there,

I am trying to visualize a colorful mesh contour with transparency. I have tried two ways to solve it. Either is not working. Hope someone could help me.

1.1 My mesh colorful code is using the method based on Dale’s CS code, shown in this link: “https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsColorfulMeshBox.cs”.

As I know in “Displaymode”, you could change transparency parameter from 0~100 in windows. However in C# code, could we do some similar thing, or shall I define a new “Displaymode” with transparency parameter changed? I could not find any sample code for this.

1.2 Maybe I could assign a material property for this mesh, like “DisplayMaterial”. And I could change the “transparency” parameter from 0.0 ~ 1.0. However, it will also change the color for my mesh which I want to keep. The code is like this link: “https://github.com/mcneel/rhinocommon/blob/master/examples/cs/ex_conduitdrawshadedmesh.cs”. Not sure where the problem is.

Thanks,

Chenglong

@jeff any ideas here?

Without actually running the code here, what exactly is it doing compared to what it is you want it to do? I’m not following the request here… You want to change the color and transparency of a mesh, but then you say you don’t want the color of the mesh to change…I’m lost at that point.

If you’re trying to only make parts of a mesh transparent, then that’s a completely different approach than the one you’re taking, and will require face-by-face drawing of the mesh…but can be optimized if done right…but again, I’m not really sure if that’s even what you want…

Can you perhaps put together a mockup screenshot that demonstrates what it is you want your end results to look like?

Thanks,
-Jeff

Hi Jeff,

I have built a colorful mesh contour based on Dale’s code, where the color gradient is based on the x coordinate of each mesh point. The result looks like the following picture. However, I want to change the transparency of this mesh object in case I have multiple object behind or overlapping with this mesh. There are two ways in my mind:

  1. I found I could change displaymode transparency property in windows user interface for the whole object. So I was thinking whether I could build any similar program for this, like defining a new “Shaded” displaymode with the transparency assigned in my program.

  2. In Opengl, I could assign material property for each mesh vertices, which will include transparency and color. This method will assign various transparency for different mesh objects, or even different parts within one mesh object. Could I use the same logic in RhinoCommon?

Not sure whether this is clear enough for you. Let me if you need more information.

Best,

Chenglong

1 Like

Transparency means that the color of any object behind the object in front is allowed to bleed through.

So you can either have transparency OR keep your color exact.

That said, vertex colors are ARGB colors, so if the mesh rendering system supports any transparency for vertex colors, you should be able to simply provide a Color with an appropriate A (alpha) value to make things transparent.
Providing a DisplayMaterial is a one-for-all option. You will loose the individual vertex color information. You may be able to use different colors per face, but you will still loose the smooth color blending.

Hi ! I have some questions.
How about this code working time ?
If my mesh number is about thirty thousand, the time is Long or short ??
May I work at triangular mesh because the diagram you provide look like a quadrangle mesh ?

Hi Hannes,

I think using alpha value for vortex color is a good choice for me. I forgot transparency is the “amount of blending” in this case, where alpha is the key value. There is no need for my case to set individual vertex color information then, since I don’t want to loose smoothness for color blending.

Thanks a lot.

Chenglong Wang

Hi Kaici,

I never tested the working time. But I tried a case with grasshopper with seven thousand mesh points which didn’t cost more than a second. So you could try then.

And I think you could easily work on a triangular mesh by adding triangular mesh Face numbering. The library is listed below:“http://4.rhino3d.com/5/rhinocommon/html/AllMembers_T_Rhino_Geometry_MeshFace.htm”.

Best,

Chenglong

Thank you.
By the way,did you know how to calculus the gradient of mesh ?

Not Sure. Maybe you could use normal direction of mesh face element to calculate.

Chenglong

Hi Hannes,

It still has some problems in transparency even I assign new alpha value. It looks like there is a “LockedTrans” in “Shaded” displaymode, which is in following data list exported from “Options/Displaymodes/Shaded”. Is the transparency controlled by this value?

Do you know which function could set this value in RhinoCommon, or how could I set up a new displaymode?

Best,

Chenglong

[DisplayMode\8bc8debe-c83b-4c47-b13c-9db074510cac\Objects]
CPSolidLines=n
CPSingleColor=n
CPHidePoints=n
CPHideSurface=n
CPHighlight=y
CPHidden=n
nCPWireThickness=1
nCVSize=2
eCVStyle=100
CPColor=0,0,0
AutoUpdateCaching=n
CachingEnabled=n
CacheEverything=n
CacheLists=0
GhostLockedObjects=n
LockedTrans=50
LockedUsage=2
LockedColor=100,100,100
LockedObjectsBehind=n
LayersFollowLockUsage=n

Thank you !
I am looking for the Rhino’s inbuilt function about the calculus gradient to meshes.
But, there seem to be not this function.