How to get the viewport 2D coordinates from a Point3D and viceversa?

Oct 25, 2012 at 4:32 PM
Edited Oct 25, 2012 at 4:35 PM

Hi,

Is it possible to get the Viewport3D screen 2D coordinates from a Point3D and

viceversa: getting the Point3D from a 2D point in the Viewport3D.

thanks,

Filip 

Coordinator
Oct 26, 2012 at 6:53 AM

See Viewport3DHelper.Point2DtoPoint3D and Viewport3DHelper.Point3DtoPoint2D

Oct 26, 2012 at 8:10 AM
Edited Oct 26, 2012 at 8:27 AM
Hello, I'm trying to convert a 2D screen coordinate to a Point3D in the Viewport. But the following code don't give any result. How exactly should I get the 3D coordinates from 2D screen coordinates with this function?
 Point3D p1, p2;
 Point pIn = new Point(3, 3);
 if (Viewport3DHelper.Point2DtoPoint3D(viewport3D.Viewport, pIn, out p1, out p2))
 {
      MessageBox.Show(p1.X.ToString() + "," + p1.Y.ToString());
 }
In the HelixToolit source code the Viewport3DHelper.Point2DtoPoint3D function has no inverse of the matrixCamera and returns with false
thanks, filip
Coordinator
Nov 2, 2012 at 9:36 PM

hi Filip, if your MatrixCamera has no inverse for the view/projection matrix I don't think it will be possible to un-project the point...