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

Anonymous 10 years ago 0
This discussion was imported from CodePlex

fdhaene wrote at 2012-10-25 18:32:


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.



objo wrote at 2012-10-26 08:53:

See Viewport3DHelper.Point2DtoPoint3D and Viewport3DHelper.Point3DtoPoint2D

fdhaene wrote at 2012-10-26 10:10:

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

objo wrote at 2012-11-02 22:36:

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...