Using QPainter transform for perspective projection
-
QPainter draws on a 2D plane and is able to modify its coordinate system by .setTransform() in combination with QTransform.
The latter has a built-in kind of projection (using a constant distance to plane of 1024), for example used when rotating around the x-axis.
Is it possible to set the transforms to different z-Values (for each transform) in order to achieve a 3D projection (for example rotating a cube around its center x-axis, viewed from (0, 0,0))?
In QTransform doc it says: "Perspective transformation is achieved by setting both the projection factors and the scaling factors" [of the transform matrix]. https://doc.qt.io/qt-6/qtransform.html#basic-matrix-operations
But what would be the math behind that?Another solution could be using QMatrix4x4 transformation and the perspective() and toTransform() functions to get a QTransform object. But thats seems even more complicated.