I;m back from my holidays but still can’t really find the solution.
At the moment this is my code:
Public Class PatchConduitRight
Private _bbox As BoundingBox
Protected Overrides Sub CalculateBoundingBox(ByVal e As CalculateBoundingBoxEventArgs)
Protected Overrides Sub PreDrawObjects(ByVal e As DrawEventArgs)
If MyBrepDefinedSomewhereElseIsNot Nothing Then
If MyBrepDefinedSomewhereElse IsNot Nothing AndAlso MyBrepDefinedSomewhereElse.IsValid Then
_bbox = MyBrepDefinedSomewhereElse.GetBoundingBox(True)
Dim vp = e.Display.Viewport
Dim Mat As New Display.DisplayMaterial(Color.Red, Color.White, Color.Gray, Color.Black, 0.0, 0)
Mat.IsTwoSided = True
Mat.BackDiffuse = Color.Red
Mat.BackSpecular = Color.White
Mat.BackAmbient = Color.Gray
Mat.BackEmission = Color.Black
Mat.BackShine = 0.0
Mat.BackTransparency = 0
The lighting is the same as in my first post.
Any other solution?
It’s hard to tell from the pictures, but it looks to me like the “Normal” object is a closed solid polysurface, and the conduit drawn object(s) are single surfaces.
If that’s true, then that’s a pretty big distinction because it would mean that the reason you’re seeing a difference is because of the face Normals. The conduit drawn objects have their normals pointing away from the camera in the Bottom view, thus, the shading is black… Whereas, the polysurface will always have normals point outwards.
A simple test would be to just flip the normals on your Brep and see if they shade correctly. If they do, then my guess is that either the back face material isn’t getting setup correctly OR there’s a bug in DrawShadedBrep where the front and back face drawing isn’t getting handled properly. I haven’t looked yet, but my gut is telling me that DrawShadedBrep is probably not pushing and popping the Cull Face property for non-solid surfaces, which means single surfaces are probably being treated as solids (i.e. they have no back face materials).
I’m not sure if the cull face methods have been implemented for C#, but if they are you can try something like:
If MyBrep.IsNotASolid // <== something you’ll need to figure out
e.Display.PushCullFaceMode( CFM_DRAW_FRONT_AND_BACK ) // <== Not sure what the interface is here
Let me know if this helps… @Dale will probably be able to tell how the cull face methods are implemented (if they are)…
Can I please get a simple C# project to work with so that I can easily just test the SDK’s DrawShadedBrep using your conduit technique. I can probably fix this in the SDK (assuming this is the problem), but obviously that means you’ll need to wait until the next release…which is why I’m hoping the workaround above actually works.