1
Wiimote Desktop VR/Head Tracking / Desktop VR openGL perspective projection issues
« on: January 21, 2008, 03:38:42 PM »
I implemented the DesktopVR project in OpenGL but I'm having some issues getting the perspective projection to work right. The original Direct X app uses a method called Matrix.PerspectiveOffCenterLH to calculate the perspective matrix. The openGL equivalent method is glFrustrum (after switching to the projection matrix mode
) wich accepts the same basic arguments (as dictated by parameter names anyway). However it is painfully obvious that the way these two methods work is very different, and I'm having trouble finding documentation explaining the Matrix.PerspectiveOffCenterLH method in more detail (apart from: Builds a customized, left-handed perspective projection matrix.) I did find some resourses on the OpenGL method though : http://www.glprogramming.com/red/chapter03.html#name3
My linear algrebra is really horrible and if anyone has implemented this in openGL or can help explain how I might solve the problem I would be eternally greatful.
changing the original paramters from :
(nearPlane*(-.5f * screenAspect + headX)/headDist,nearPlane*(.5f * screenAspect + headX)/headDist, nearPlane*(-.5f - headY)/headDist,nearPlane*(.5f - headY)/headDist,nearPlane, 100);
to
(nearPlane*(-.5f * screenAspect + headX)*headDist,nearPlane*(.5f * screenAspect + headX)*headDist, nearPlane*(-.5f - headY)*headDist,nearPlane*(.5f - headY)*headDist,nearPlane, 100);
seemed to produce more accurate results but it still doesnt look as cool as it does in the video
Also, openGL provides another method called glPerspective(GLdouble fovy, GLdouble aspect,
GLdouble near, GLdouble far) but then I need to calculate the FOV parameter (more detail in the link I posted)
I also read a reply on another form where the following solution was suggested:
For lateral (X-Y) headtracking, you need to rmultiply the projection matrix with M=
1 0 X X*znear
0 1 Y Y*znear
0 0 1 0
0 0 0 1
(newP = oldP*M)
X Y being the head position, znear being the near clipping pane distance.
http://www.ogre3d.org/phpBB2/viewtopic.php?t=38030&postdays=0&postorder=asc&start=50&sid=5085e0cd34bb1c6c8ff88d508aa21631
But I had no luck implementing that either
Any help would be greatly appreciated!

My linear algrebra is really horrible and if anyone has implemented this in openGL or can help explain how I might solve the problem I would be eternally greatful.
changing the original paramters from :
(nearPlane*(-.5f * screenAspect + headX)/headDist,nearPlane*(.5f * screenAspect + headX)/headDist, nearPlane*(-.5f - headY)/headDist,nearPlane*(.5f - headY)/headDist,nearPlane, 100);
to
(nearPlane*(-.5f * screenAspect + headX)*headDist,nearPlane*(.5f * screenAspect + headX)*headDist, nearPlane*(-.5f - headY)*headDist,nearPlane*(.5f - headY)*headDist,nearPlane, 100);
seemed to produce more accurate results but it still doesnt look as cool as it does in the video

Also, openGL provides another method called glPerspective(GLdouble fovy, GLdouble aspect,
GLdouble near, GLdouble far) but then I need to calculate the FOV parameter (more detail in the link I posted)
I also read a reply on another form where the following solution was suggested:
For lateral (X-Y) headtracking, you need to rmultiply the projection matrix with M=
1 0 X X*znear
0 1 Y Y*znear
0 0 1 0
0 0 0 1
(newP = oldP*M)
X Y being the head position, znear being the near clipping pane distance.
http://www.ogre3d.org/phpBB2/viewtopic.php?t=38030&postdays=0&postorder=asc&start=50&sid=5085e0cd34bb1c6c8ff88d508aa21631
But I had no luck implementing that either

Any help would be greatly appreciated!