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
1
Thanx for your input OasisGames, i thought nobody was going to respond...

I have some questions regarding your solution:

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

glMatrixMode(GL_MODELVIEW);
glLoadIndentity();
glTranslatef(x, y, 1 - z);

2.
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...



2
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 : 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 :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.

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!


Pages: 1