The mesh is displayed, but constant colored, so there is no shading or lighting. Is there a way to draw in the my conduit with shading / lighting and vertex colors ?
I’ve tried all combinations of DisplayPipelineAttributes:
If i add my mesh to the document, it is displayed with vertex colors and shading (right image). I have “shade vertex colors” checked in the display panel. So it seems possible in a regular display mode but not in a conduit ?
Why are you using DrawFalseColorMesh? I believe that routine is used for analysis modes and specifically and purposely turns off lighting and shading.
Just draw the mesh as you would any mesh…if it has vertex colors Rhino will use them…according to the display attributes set…which it looks like you are setting correctly.
Hmmmm…ok. Sounds like a bug in Common then (i.e. vertex colors getting stripped before calling into the core draw routine)… I’ll see if I can reproduce it here in a bit…but a simple example would help speed the process.
Thanks for the example… found the reason immediately…
The color count on the vertex color array is purposely getting set to 0 (temporarily) just before calling into the core… There is a comment in the Common function:
// don’t permit false color drawing in this function.
… I’m not sure why this was/is done… I’ll see if Steve knows why. The concept of “false color” is not the same as “vertex coloring” IMO… but it seems like the two are being conflated across the mesh drawing API.
I’ll let you know what we find/decide…and if there is another way you can do this from within a script.
Thank you @jeff, maybe we’ll just need another flag to let users control this in the attributes of the DisplayPipeline. I’d prefer to have a toggle between lit and unlit mesh vertex coloring.
It looks like if you use the other DrawMeshShaded (the one that takes a face list), then the vertex color list won’t get zeroed out…
# Just draw all faces for the given mesh...
face_list = list(range(0, self.m_mesh.Faces.Count - 1))
e.Display.DrawMeshShaded(self.m_mesh, self.m_material, face_list)
That seems to be working here.
Haven’t had a chance to discuss the other issue with Steve yet.
NOTE: manually calling e.Display.DrawMeshWires(m_mesh, Color.Black); obviously adds wires, but they are drawn back/front facing without any depth test (even if depth test flags are set) and I do not want my preview mesh to look “see-through”.
That’s basically what the DynamicDraw routine does…it turns off all depth testing/writing, and executes any/all pending (queued up) dynamic draws…and it does this post-everything-else. It’s primary function/design was for feedback processing for commands…which usually only involves wires and annotative type objects, and it is assumed to always draw everything on top of the current frame buffer.
The usual way to implement this type of thing, where you’ve got your own GetPoint, and you want to draw depth-buffered, shaded meshes, is that you do so in a Display Conduit, and your GetPoint invocation enables/disables the conduit. Then in your conduit, you can determine in which channel you want to draw your geometry (usually in the Pre/Post draw channels), and you make the appropriate calls to do so… This way your geometry will interact (and play nice) with all of the other objects in the scene.
A simple example of what you’re doing and what you want to achieve will go a long way here… and I’ll be glad to modify or add to it to show you what I mean.