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).]
See documentation on glFrustum
Hope I’m on time
You are but doesn’t glFrustum create a frustum viewing volume.I need a random volume.Well not random but defined by:
lower left corner (-50,-50,50)
upper right corner(50,50,50)
lower left corner (-50,0,-50)
upper right corner(50,100,-50)
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.
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?
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.
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…
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.
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).]
I don’t know good online articles on the mathematics of 3D transformations, but have a look at this book:
It contains most of the mathematics needed in 3D graphics, along with some very useful algorithms.
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.