To main page
Center of Viewport
Center of viewport
(or camera center
) is X,Y coordinates right in the middle of current screen space
can be found as:
(viewport-viewport)/2 , (viewport-viewport)/2
is the viewport matrix
that can be loaded via glGetIntegerv
Why not (Width of window / 2) ?
There are some times that center of window isn't really center of "virtual camera", like when you are drawing multiple views
of the same scene
- there might be 2,3,4 or more "camera centers", each in the middle of it's respective viewport.
3D world coordinates
In real math,
C(x,y,z) = -R' * t , where ' is transpose
but remember about column major
ordering. R is rotation matrix
(modelview's upper left 3x3 matrix, transposed), t is translation 3x1 matrix (in terms of right-up-back vectors).
3D coordinates of current camera center in PyOpenGL
gluUnProject( (viewport-viewport)/2 , (viewport-viewport)/2,
buffer = glGetDoublev(GL_MODELVIEW_MATRIX) # 
cXYZ = -1 * numpy.mat(buffer[:3,:3]) * numpy.mat(buffer[3,:3]).T
 Avoid glGetFloat in Python