Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Veranderlike

Pages: 1
Thanx for your input OasisGames, i thought nobody was going to respond...

I have some questions regarding your solution:

I assume the method matrixTranslate  is a custom method, is this the same as going:

glTranslatef(x, y, 1 - z);

Is this the correct order of the steps for the renedering loop?
 1 load the projection matrix (glMatrixMode)
 2 perform the perspective projection (glFrustum)
 3 set the modelview matrix
 4 translate the matrix by the head pos (glTranslateF)
 5 set the camera by calling the lookat method with the head coords as indicated in the original project (gluLookAt)
 6 render all objects in the scene

Thanx again :)

P.S I'm busy coding a simple game with this idea where you move through a tunnel specified with a BSpline and dodge objects with you head. If i can just get the perspective working right it will look awesome! If I manage to do it I'll upload the game...

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 :P) 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 :

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);
(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 :P

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.

But I had no luck implementing that either :(

Any help would be greatly appreciated!

Pages: 1