I was wondering if it was possible to change the colour of a collection mesh faces separately to the whole mesh? An example use case might be to highlight a circular section on a mesh surface. Also, I'm not sure how to change the wireframe colour of the mesh. Commands similar to:
There is a way to define per vertex color, but it is not what you are asking about because per vertex color blends the color into all adjacent faces (simplices).
Frankly, per mesh face color does not make much sense to me as a built-in functionality. I am pretty sure the right way for doing this is extracting a sub-mesh for presentation as an entity and applying the color to it.
It is better to offset the presentation mesh outwards along normal slightly to avoid aliasing. IMesh_DG.Offset() is an easy way.
Extraction needs a bit of attention. A safe (not sure the best) way it to build a copy in code similar to the Morph sample. This way offsetting is easy as well.
Prashant, can you post a code snippet showing how to set the vertex color?
I am using 32-bit ocx. Using IMeshAlgor to create vertexes and IMeshTopol to create simplices. How can I set the color of each vertex in the mesh? I think I need to use IMeshShading_KC but so far I have not gotten the expected results.
Hi Measure,
It is a good question. It was a while since I touched this.
My quick look produced this:
We used to have "Shading" check box in Morph.
PerVertexMorph.png (122.9 KiB) Viewed 789 times
But it was removed a while ago. I do not remember the reason. I will dig in the next few days and will post more here. It works in v5.2. This is where the screenshot comes from.
Just recently I saw per vertex colors working in v7.2 where the mesh was imported via VRML. So, as the worst-case scenario you could generated the vrml in memory (not too bad coding). I think there should be a better way.
1) Use IMeshAlgor to add vertex points.
2) Use IMeshShading_KC to setShadingType and then update color for each vertex using SetVertexColor
3) Use IMeshTopol to add simplex from the verticies using AddSimplex
So that works but I have to manually load the mesh facet by facet.
If I create the mesh via loading the file, is there a way to iterate thru the mesh and update the vertex color? Should I use IIterator object for this?
v6.2 C++ Morph (the last version which has the CMorphDlg::OnShading() code) works in 64 bit with DGK 7.2 installed.
Replace int nDim = 0; in the code with EDim_DG nDim = e0D; to get it compiled.
So, old KC interface works for per vertex colors with the latest DGK.
IMesh_DG.EnableShading() and IMesh_DG.SetVertexColor() should work as well. Checking ....
It works. So, this is sample's problem. This check box and the handler was lost in v6.0 release. I have attached a fixed version of C++ Morph. It will be in the next update hopefully with other languages also.