wrapping my viewport around cylindrical projection surface

Started by
0 comments, last by V-man 15 years, 9 months ago
Hi all, I'm writing an app which has a very wide aspect ratio of 8:1 (3840x480). This will be projected onto the outside of a large (6m diameter) cylindrical projection surface (viewers will view from outside the cylinder). My scene is 3D with a fixed camera (pointing along Z as default). I have objects (very long snakelike physical objects made up of lots of springs) moving around in 3D. And I would like to give the illusion that the cylindrical projection surface is a real cylinder, with things moving inside it. My main problem is that of perspective. I think I need a vanishing point for every x position, i.e. a vanishing line (which runs horizontally down the middle of my viewport). Is this even possible to do? And if so how would I do it? I'm guessing its with glFrustum (usually I just use gluPerspective), but I'm not sure how to set it up! My second problem is that of wrapping the objects around when they cross the left or the right edge. I'm hoping that once the first problem is solved, this should just be a simple 2D check of object.x against my viewport boundaries and moving the object by screenWidth in 3D space. One other concern I have is how to deal with situations when half the object is on one side, and the other half on the other side - so I was thinking I could render the object twice if its near the edge (once normally, and once offset by screenWidth). Is there a better way to deal with this?
Advertisement
glFrustum and gluPerspective setup a perspective matrix but the transformation is linear. If you draw 2 horizontal lines, they will always be parallel.

If you want to do some other type of effect, you will likely need to have some custom matrix or even more likely, you need to do the math in a vertex shader.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement