How does the unit of object coordinate relate to clipping volume unit?
Since the vertex data will be transformed through a projection matrix to get the clip coordinates. I wonder if the two units are the same?
For example, if I have a point P(20, 20, 20), and my clipping volume is defined as following:gluPerspective( 45.0, //The camera angle
( double )w / ( double )h, //The width-to-height ratio
开发者_运维技巧 2.0, //The near z clipping coordinate
2000.0 ); //The far z clipping coordinate
If I consider 20 as inches, then do 2.0 and 2000.0 must be in inches as well? Are they related to each other, or are they totally independent?
Thank you,
You may find the OpenGL Technical FAQ "Transformations" section useful here.
You've chosen inches as your base "World Coordinate" unit. You'll note that the FAQ defines "Object Coordinates", "Eye Coordinates", and "Clip Coordinates".
Transformations sit between these -- the ModelView matrix transforms from Object to Eye, the Projection matrix from Eye to Clip, etc.
It's useful to think of this as a number of black boxes (the projection matrices) taking in various coordinate systems, moving/scaling/shearing them a bit, and spitting out a new one.
Now, you can conceptually break the ModelView matrix black box apart into two: "Model" and "View" matrices. The songho.ca OpenGL Tutorials have a transformation page that shows this.
So you can look at:
Object coords -> (ModelView matrix) -> Eye coords -> ...
...as equivalent to:
Object coords -> (Model matrix) -> World coords -> (View matrix) -> Eye coords -> ...
This gives you "World coords" between those two boxes.
Note that your "Object coords" and "World coords" may often have the same units, but different origins.
They might also have slightly different units. For example, it may be convenient for you to define a standard-height character object and just modify your coordinate scaling in the associated Model matrix to make a taller or bulkier character object. 1 unit of object height might scale into 1.2 units of world height.
(Note you can subdivide this even more, having a "Arm matrix" to translate from "Arm space" into "Torso space", and a "Torso matrix" to go from there to "Object space", etc.)
It's fairly typical to only have cameras positioned and targeted -- i.e. translated and rotated. If this is the case, "World space" and "Eye space" also will share units.
By that roundabout process, we're now seeing that our "World space" and our "Eye space", and also likely many of our "Object spaces", are in the unit you've chosen: inches.
gluPerspective
always specifies near and far planes in terms of "distance from viewer" (aka distance from eye) -- see its manual page.
It's implied that the distance is in Eye coordinate space; we know the matrix they're showing transforms from Eye space to Clip space, and based on how the matrix is constructed it is clear that zNear and zFar etc will be in Eye space units.
The relationship between zNear
and zFar
is important for perspective division. This results in, among other things, more depth precision at the front of the view volume.
They also, of course, define the nearest and furthest things you'll render.
If you look at the aforementioned manual page for how the projection matrix is constructed, and you know a bit about the behavior of IEEE-754 floating point numbers, you can extrapolate some interesting behavior if you set your zNear too near, or your zFar either too far or at too high a multiple of zNear, etc.
(By the by, I'd highly recommend the Essential Math for Games and Interactive Applications book here. Also, if you want your mind blown a bit, there's a fun little GDC2007 presentation entitled "Projection Matrix Tricks" (pdf).)
Yes they are related the both share the same distance but (20,20,20) is the distance from the center point in the world while the values in gluPerspective refer to the distance from the camera. please let me no if i have miss understood your question.
精彩评论