Subclassing DzViewTool and opengl picking
Alessandro Mastronardi
Posts: 2,620
Hello. After subclassing DzViewTool and creating a derived one, I need now to perform opengl picking, i.e. raycasting mouse coordinates and getting the 3D point in space that is hit (or not) when I click in the viewport. I can't find a way to actually get the 2D mouse position, and also the currently selected camera matrix. Any chance you can help? Thanks.
Post edited by Alessandro Mastronardi on
Comments
Are you sure you don't want to be subclassing DzPickTool instead? Then you can use DzPickTool::mousePress(...) which gives you a QMouseEvent you can get the coordinates from by calling pos().
If not, you could do something like
or, look at the documentation for Dz3DViewport::pickOnNode...
I'm not sure about the camera matrix; would it be the same as the camera world space rotation?
@Omniflux thanks a lot, really appreciate your hints, I'll try those. I have to say however that this SDK would need a MAJOR overhaul, it's lacking everything from documentation to some good samples.
Not sure what I was thinking when I suggested world space rotation, I meant world space transform. getWSTransform() instead of getWSRot().
No worries, thanks for the help!