3D Computer Graphics (3080/GV10) Week 5-6 Tutorial 3 Andrew Cox
OpenGL Transformation Pipeline ModelView Matrix Camera Space Projection Matrix Object Space Homogeneous Clip Space Perspective Divide Normalized Device Coordinates Viewport Transform Viewport Coordinates Slide adapted from Eric Lengyel [1]
OpenGL Perspective Projection Matrix n, f = distances to near, far planes e = focal length = 1 / tan(FOV / 2) a = viewport height / width Picks up viewspace z and places negated in w: division by Z gives perspective Slide adapted from Eric Lengyel [1]
Slide courtesy of Eric Lengyel [1]
Matrix Multiplication and Concatenation
Order of OpenGL Transformations OpenGL calls define a matrix, then concatenate it with existing one Transformations applied in reverse of lexical program order
Matrix Modes GL tracks two matrix stacks Projection ModelView The matrix applied to vertices is The matrix commands apply to the current mode: glMatrixMode(GL_PROJECTION); glMatrixMode(GL_MODELVIEW);
glLoadIdentity() Matrix commands are concatenated with matrix of current mode Includes gluPerspective () etc. Clear out current matrix with glLoadIdentity()
References Eric Lengyel, Projection Matrix Tricks, Game Developers Conference 2007, <http://www.terathon.com/lengyel/>.