How to get the x,y,z Co-ordinate from mouse pointer's posn in OCC Perspective Screen?

I have SetDefaultTypeOfView ( V3d_PERSPECTIVE ) in a Viewer,But I don't How to get the x,y,z Co-ordinate from mouse pointer's position in OCC Perspective Screen?

Venugopal Gudimetla's picture

Hi were you able to figure out? right now I am trying to switch between perspective view and orthographic views and also would like transform user mouse clicks to x,yz coordinates in perspective view exactly like the problem you have. Could you or anyone who figured out please help?

Thanks,

Venu

Thomas Paviot's picture

The Convert() method of the V3d_View class provide a set of tools to go from 2D to 3D (or the opposite). Have a look at the V3d_View.hxx header file in order to check available function prototypes. For instance :
"""
//! Converts the projected point into a point
//! in the reference frame of the view corresponding
//! to the intersection with the projection plane
//! of the eye/view point vector.
Standard_EXPORT void Convert(const Standard_Integer Xp,const Standard_Integer Yp,V3d_Coordinate& X,V3d_Coordinate& Y,V3d_Coordinate& Z) const;
"""

Thomas

Venugopal Gudimetla's picture

Hi Thomas, Thanks for showing me a direction, I will try that out and will post my findings for further direction if any.

Thanks,
Venu

Venugopal Gudimetla's picture

Little more digging after what Thomas said pointed me to ConvertClickToPoint function which transforms a mouse point to 3D point in perspective view.

Thanks,
Venu