Hello, I'm trying to implement a mesh viewer using the Qt3D framework and I cannot find a way get the "3D position" of the mouse cursor by picking the depth buffer.
How can I do something like this?: /// get 3d world point from clicked position QVector3D Forensic3DWindow::getMouse3DPoint(const QPoint& point2d) { float depth = 1; float x = point2d.x(); float y = height() - 1 - point2d.y(); glReadPixels(x, y , 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth); if (depth < 1) { int viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); // the following does the same as gluUnProject: QVector3D point = QVector3D(2 * (x - viewport[0]) / viewport[2] - 1, 2 * (height() - 1 - y - viewport[1]) / viewport[3] - 1, 2 * depth - 1); QMatrix4x4 world = camera()->projectionMatrix() * camera()->viewMatrix(); return world.inverted().map(point); } return QVector3D(); }
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest