0

Viewport2DVisual3D Transparency problem

Anonymous 5 years ago 0
This discussion was imported from CodePlex

milosgregor wrote at 2013-08-25 01:51:

Hi. I have one problem. I try to create in code my model. This model consist from three TruncatedConeVisual3D objects (wells) and three Viewport2DVisual3D objects (profiles between wells). See image (https://docs.google.com/file/d/0B5uL6M71wyn4OWx5eGhqWmU5UWs/edit?usp=sharing):

Image

I have problem with the transparency of Viewport2DVisual3D objects. As you see on picture the Viewport2DVisual3D between well PK-1 and PK-2 have the same background color as the background color of HelixViewport3D (white).

the Visual of Viewport2DVisual3D consist from canvas in that are plotted only polygons. The background of canvas and material of Viewport2DVisual3D are set to transparent.

Why is not visible the part of section between well PK-3 and PK-2? How to set it? Here is code for creating the section between wells:
Dim we As New Viewport2DVisual3D
Dim mesh = New MeshGeometry3D()
Dim pos As New Point3DCollection
pos.Add(New Point3D(Well1.X, Well1.Y, Zmax))
pos.Add(New Point3D(Well1.X, Well1.Y, Zmin))
pos.Add(New Point3D(Well2.X, Well2.Y, Zmin))
pos.Add(New Point3D(Well2.X, Well2.Y, Zmax))
mesh.TriangleIndices = New Int32Collection(New Integer() {0, 1, 2, 0, 2, 3})
mesh.TextureCoordinates = New PointCollection(New Point() {New Point(0, 0), New Point(0, 1), New Point(1, 1), New Point(1, 0)})
mesh.Positions = pos
we.Geometry = mesh
Dim material = New DiffuseMaterial(New SolidColorBrush(Colors.Transparent))
Viewport2DVisual3D.SetIsVisualHostMaterial(material, True)
we.Material = material
Dim SectionCanvas As New Canvas
SectionCanvas.Width = (Math.Sqrt(((Well2.X - Well1.X) * (Well2.X - Well1.X)) + ((Well2.Y - Well1.Y) * (Well2.Y - Well1.Y)))) * ScalingFactor
SectionCanvas.Height = (Zmax - Zmin) * ScalingFactor
SectionCanvas.Background = New SolidColorBrush(Colors.Transparent)
For geo As Integer = 0 To Sections3DDefinition(i).Section.SectionSegments.Count - 1
            Dim pol As New System.Windows.Shapes.Polygon
            pol.Stroke = New SolidColorBrush(Colors.Black)
            pol.ToolTip = Sections3DDefinition(i).Section.SectionSegments(geo).GeoID & " - " & Sections3DDefinition(i).Section.SectionSegments(geo).GeoName
            pol.StrokeThickness = 1
            pol.Fill = imgBrush
            For k As Integer = 0 To Sections3DDefinition(i).Section.SectionSegments(geo).TopPoints.Count - 1
                pol.Points.Add(New Point(Sections3DDefinition(i).Section.SectionSegments(geo).TopPoints(k).X * SectionCanvas.Width, Sections3DDefinition(i).Section.SectionSegments(geo).TopPoints(k).Y * SectionCanvas.Height))
   Next
            For k As Integer = 0 To Sections3DDefinition(i).Section.SectionSegments(geo).BottomPoints.Count - 1
                pol.Points.Add(New Point(Sections3DDefinition(i).Section.SectionSegments(geo).BottomPoints(k).X * SectionCanvas.Width, Sections3DDefinition(i).Section.SectionSegments(geo).BottomPoints(k).Y * SectionCanvas.Height))
            Next
        Next
        we.Visual = SectionCanvas
        my3D.Children.Add(we)

objo wrote at 2013-09-05 08:14:

I am not sure if this can be a problem with the Viewport2DVisual3D - but try to use a mesh with an image material instead.
Also note that the sections must be depth-sorted to get transparency (almost) right when rotating the model.