Qt3d tank example: projection of click position
-
Hi,
I played around with the qt3d tank example and found that when creating new tanks, they are not exactly placed at the position I double clicked. This is only true for the middle of the plane but not for the edges. At the edges there is a shift which depends on the distance to the middle of the plane. I could not find any obvious errors when looking at the code.Any ideas?
link to tank example:
http://qt.gitorious.org/qt/qt3d/trees/1ce13f86c7066721ce80258d6a89baccc4030066/examples/qt3d/tank -
I've found the error.
The camera's upVector has not been updated (default: 0,1,0). When the camera's direction (eye-center) is not parallel to the plane (as it is in the example), then the initial upVector is no longer orthogonal to the camera direction. For a correct projection, however, it must be. So you have to calculate a new upVector in initializeGL, after having positioned the eye.