0
Box Selection
This discussion was imported from CodePlex
rinaldin wrote at 2013-10-27 13:25:
Hi all,
I'm trying for a long time to implement the box selection on the control using ContainerUIElement3D.
The last step in the box selection is to recognize which 3d objects are included, partially or totally, in the rectangle created with the mouse by the user ove the viewport.
To do this, I wrote the following code:
Can you help?
I'm trying for a long time to implement the box selection on the control using ContainerUIElement3D.
The last step in the box selection is to recognize which 3d objects are included, partially or totally, in the rectangle created with the mouse by the user ove the viewport.
To do this, I wrote the following code:
For Each element As ContainerUIElement3D In HelixViewport3D1.Children
Dim position = Overlay.GetPosition3D(element)
Dim position2D = matrix.Transform(position)
If position2D.X > rectOrig.X And position2D.X < (rectOrig.X + rect.Width) And _
position2D.Y > rectOrig.Y And position2D.Y < (rectOrig.Y + rect.Height) Then
' select element
Dim element1 = TryCast(sender, ModelUIElement3D)
Dim model = TryCast(element1.Model, GeometryModel3D)
If model.Material Is Materials.Green Then
model.Material = Materials.Yellow ' is selected!
ElseIf model.Material Is Materials.Yellow Then ' deselect
model.Material = Materials.Green
End If
End If
Next
but I receive every time an Invalid Cast exception in the first row (for each...); it seems I cannot use the ContainerUIElement3D inside the helixViewport.
Can you help?
Customer support service by UserEcho