View Full Version : custom projections

12-10-2002, 04:51 PM
I need to calculate a projection matrix for a custom(non-frustum,non-ortho) viewing volume.What I have are the coords of the four verts of the near and far planes,sahred by the other planes of course.Do you have any pointers to info on calculting a projection matrix from this?

PS:Yes this is for a university assignment but the 'notes' on how to do it don't make much sense,and I can't find anything on google.Well unless someone answers quickly it'll propably be too late anyway but I'm curious anyway.

[This message has been edited by zen (edited 12-10-2002).]

12-10-2002, 06:16 PM
See documentation on glFrustum

Hope I'm on time http://www.opengl.org/discussion_boards/ubb/smile.gif


12-11-2002, 01:30 AM
You are but doesn't glFrustum create a frustum viewing volume.I need a random volume.Well not random but defined by:
near plane:
lower left corner (-50,-50,50)
upper right corner(50,50,50)
far plane:
lower left corner (-50,0,-50)
upper right corner(50,100,-50)

12-11-2002, 05:26 PM
I'm not an expert with matrices but maybe I can give some hints.

I think you want to have a skew matrix.
I have done this on my modelview matrix.

The idea (IIRC), is that the upper left 3x3 matrix in the frustum represents a set of vectors that define 3 dimensional space.


If any pair of those vectors are not orthogonal to each other, the result is called a skew matrix. To have a skew in the y + direction for example, you have to change one those vectors (I think vector 2).

Also, you may need to combine with a translation.... but you'll figure it out.


12-12-2002, 03:49 AM
Well if you connect the dots you'll see that I need a skewed cube.So I got the matrix produced by glOrtho(-50,50,-50,50,-50,50) and muptilied it by a 0.5 yz shearing matrix and got what he wanted.But I didn't get it the way he wanted...yeah right,well I got it isn't that what counts?

12-12-2002, 06:03 AM
If you need to do it by hand, instead of using GL functions, read the GL spec to find the formulas it uses to calculate the projection matrices.

12-12-2002, 09:05 AM
First of all, be sure that the frustum you want to configure in your projection matrix is convex and looks like a distorted cube.
By "convex", I mean that all distorted faces of your distorted cubes are quads and those quads should be coplanar.

Then I think a single glMultMatrix with the "good" matrix will do the trick. You have to know which matrix to multiply, though, since that's the real problem.

I'm thinking about few brute methods but I'm not sure they would work... hmm...

12-12-2002, 12:05 PM
zen: The way he wanted may indeed be an important part of the problem. He is wanting you to learn the techniques to solve this class of problem, not to get one particular matrix for this special case.

12-12-2002, 02:32 PM
coriolis:you're right of course.But he should also take the time to make some slides/notes/whatever that actually make sense(well either that or I should take the time to actually go to the lectures,but I dooubt they'd make more sense).
vincoof: I believe the viewwing volume looks like a convex distorted cube,but you can see for yourself.What I'm given are the corners of the near and far clipping plane(prev. post) an that it's an oblique parallel projection.Wouldn't that look more or less like:

/ /|
/____/ |
| | |
| | /

btw do you know of any good docs on the whole transformation pipeline from world coords to pixels in a more mathematical style?That would be quite interesting.

[Edit]Why the heck are my beautiful ascii art renderings ruined?

[This message has been edited by zen (edited 12-12-2002).]

12-13-2002, 04:10 AM
I don't know good online articles on the mathematics of 3D transformations, but have a look at this book:
http://www.amazon.com/exec/obidos/tg/det...=glance&s=books (http://www.amazon.com/exec/obidos/tg/detail/-/0201773430/qid=1039788403/sr=1-1/ref=sr_1_1/102-7796383-0112934?v=glance&s=books)

It contains most of the mathematics needed in 3D graphics, along with some very useful algorithms.

12-15-2002, 09:32 PM
You'll find all the math you need in OpenGL specifications, though it's not a friendly document since the specifications describe an API before all, and mathematics are not really explained. They're here, that's all.

Your "ascii art" looks crap because the forum removes dubbed whitespaces.