getting bounds of viewport...

Aug 22, 2011 at 2:45 PM

I was wondering how I could get the cordinate bounds that are being displayed in a viewport?  For instance the top left corner is (-100,100) and the bottom left corner is (100,-100).

Aug 22, 2011 at 6:37 PM
Edited Aug 22, 2011 at 7:06 PM

hi NMorgan, I don't quite understand what coordinates you need. Do you need the actual client rectangle of the HelixView control? Did you try

new Rect(VisualOffset.X, VisualOffset.Y, ActualWidth, ActualHeight);

(Temporarily arranging a control to VisualOffset=(0,0) helped me out in another project when I was rendering to a RenderTargetBitmap..)

If you need to project 3D coordinates on the 2D view, see the Helpers/ViewPort3DHelper class.

Aug 23, 2011 at 12:49 PM

Hello, thanks for the reponse what I am looking for a rectangle (or just the coordinates of the points) that represents the area being displayed by the viewport. 

Aug 23, 2011 at 1:48 PM

Still do not understand. The HelixView control displays a 3D frustum (when using a ProjectionCamera).

Aug 23, 2011 at 1:50 PM

I am using a orthographic camera not a projection. Basicly if I wanted to draw a point at the upper right hand corner of the viewpoint how would I go about getting the coordinates of that point.

Aug 23, 2011 at 6:24 PM


HelixToolkit.Viewport3DHelper.Point2DtoRay3D(yourViewport, new Point(yourViewport.ActualWidth,0))

I have not tested it, but I think this will work with an orthographic camera. Note that this will give you a ray, you can use the Point2DtoPoint3D method if you want a point at the near or far clip plane.
Petzold's 3D programming book could also be a good source for more solutions to this!