custom projection matrix

Started by
3 comments, last by LilBudyWizer 18 years, 4 months ago
Hello everyone! I want to create a custom projection matrix, and load it with glLoadMatrix* function. There are two difficulties that I encountered: 1) I have found no guidelines for doing this in the red book, at the viewing chapter. So I started searching the web, but I found nothing that would satisfy me. My problem is that I am really used to OpenGL GlFrustum and glOrtho calls to change the projection matrix, which define a "canonical volume" for viewing,and I don't really understand how I can use glLoadMatrix to load a matrix, and to "bypass" the canonical volume stuff. 2) I read in an article on the net - sorry I don't know how to use VB codes on this forum , are they turned on? - http://sjbaker.org/steve/omniv/projection_abuse.html I read here that "You *could* use glLoadMatrix to set up your own projection matrix (if you understand the restrictions and consequences)" So what are those "restrictions and consequences"? 3) Even though I am interested in the general aspect of the problem, I can be even more specific: I want to use in an opengl app an "oblique projection". Has anyone any idea how this can be done in OpenGL - an axonometric projection with default parameters, let's make it like an orthographic projection, but the angle between the normal and the viewing direction to be say 60 degrees - can anyone tell me how this can be done, eventually with some sample source code?
Advertisement
Details on the OpenGL matrix and how various ones are setup can be found in the appendix of the OpenGL Red Book.

This isn't really an 'answer' per se, but I thought I'd mention that I've also thought about the oblique projection problem (although I never derived the matrix for it). Basically I think you'll need to derive a matrix which does essentially what the standard frustum and orthographic matrices do, which is to map coordinates from one space (view space) to another (clip space). Your 'oblique' matrix will need to do the same, except that the space you're mapping from is not a frustum or rectangular prism, but an oblique rectangular prism. The first step will be understanding the frustum and orthographic matrices and how they're derived; then, you should be able to apply the same principles to derive the oblique version.

Note that this is all speculative; I haven't actually tried this myself.
anyone any ideas?

to be more specific: I want to use the following matrix as a perspective matrix:

GLdouble g_dOblicProj[]={
1 , 0 , -0.5 , 0 ,
0 , 1 , 3.25 , 0 ,
0 , 0 , 0 , 0,
0 , 0 , 0 , 1
};

I load this one using glLoadmatrix, but the result looks the same as though I were using glOrtho :(

I can do the math in order to compute the matrices of various projection matrices, but I don't understand how can I define the "viewing volume" - the one that is a frustum in perspective projection, and a box in orthographic projection
I believe after projection the viewing volume is -1<=x<=1, -1<=y<=1 and 0<=z<=1. You can verify that using the orthographic or prespective projection matrices used by OpenGL and running the corners of the viewing volume through it. Someone posted it is w, not 1, but since the perspective divide is done for you I don't know how you get w to be anything but 1.
Keys to success: Ability, ambition and opportunity.

This topic is closed to new replies.

Advertisement