ON_BrepFace::MaterialIndex replacement?

In older versions of openNURBS, you could get the ON_BrepFace::MaterialIndex to see if a given face had a different material than the B-rep as a whole. In the current version of the code, this function is commented out, and there is a ON_BrepFace::m_face_material_channel variable instead. I gather the latter is supposed to replace the functionality of the former? There is an explanation starting line 1261 of opennurbs_brep.h, but it seems completely garbled, like it represents some intermediate way of handling the situation. (For instance, it refers to m_face_material_channel.m_j, but m_face_material_channel is an int, and so of course doesn’t have a .m_j member.

Ah, lamely (partially?) answering my own question, the comment at line 304 of opennurbs_material.h is much more useful.

Hilariously, here I am four years later looking at the same problem only for OpenNURBS 6.0. Just ran into the same garbled comment in opennurbs_brep.h, which is still garbled. I will look at opennurbs_material.h and see if that sheds some light on the situation, though at this point I’m not convinced that the code I wrote in 2014 was actually correct, though it seems to have at least somewhat worked.

Hi @colomon,

Yea, I’m sure what happened with the comments, perhaps a rougue copy/paste.

Let me know know if this helps.

– Dale

At first glance, that page seems perfect.

I do have two related questions.

  1. The page you sent says “New in Rhino 6 is per-Brep face render material assignment.” But what is described is identical to the OpenNURB 5 version, right?

  2. Does this happen anywhere other than Breps and Faces? Looking at my old code, it appears at one time I thought per face colors might also exist on Meshes?

Hi @colomon,

1.) The plumbing may have been there in V5. But Rhino had no user interface to use it until V6. I can’t speak for 3rd party renderers.

2.) Meshes do not (yet) support per-face rendering materials. They can, however, have vertex colors.

Just curious, what are you working on?

Thanks,

– Dale

Ha! I guess the reason I never received bug reports for our dodgy support for OpenNURBS 5.0 face colors is that Rhino didn’t actual support it! We tried to, but I’m fairly certain I had several major details wrong.

HarmonyWare OpenNURBS <-> SMLib/SOLIDS++ translator. We’ve supported OpenNURBS since… egads, 2002.

Hi @colomon

Don’t hesitate to contact if you ever have a question. Feel free contact me directly if needed.

Haha nice! Hey, we’ve all been in this forever. I’ll starting my 29th year here at McNeel next month…

Take care,

– Dale

One helpful thing (and I haven’t really looked at the new example files yet) would be a an example 3dm file which shows off easily recognizable face colors, just to make sure I’ve actually got it right this time.

Hi @colomon,

Here is a simple Brep cube with face materials. If you need to view it in Rhino, just download a 90-evaluation.

TestPerBrepFaceMaterial.3dm (302.3 KB)

– Dale

Thanks! Using this for testing right now…

Huh. I think I’ve always used the “ambient” color from a material. In TestPerBrepFaceMaterial.3dm that is always 0, 0, 0. It looks like “diffuse” is the right color to be using?

Hi @colomon,

The diffuse color provides the general color of the rendering material. This is the basic color you seen when Rhino is showing a rendered view. In wireframe and shade view, Rhino uses the object’s display color found on it’s attributes.

– Dale