Unformatted text preview:

Viewing With OpenGL Courtesy of Drs Carol O Sullivan Yann Morvan Trinity College Dublin OpenGL Geometry Pipeline x y z w original vertex MODELVIEW matrix perspective division PROJECTION matrix xeye y eye zeye w eye vertex in the eye coordinate space x proj y proj w proj 2d projection of vertex onto viewing plane viewport transformation xdev y dev 1 normalised device coordinates foreshortened xwin y win final window coordinates Summary 1 Object Coordinates are transformed by the ModelView matrix to produce Eye Coordinates Eye Coordinates are transformed by the Projection matrix to produce Clip Coordinates Clip Coordinates X Y and Z are divided by Clip Coordinate W to produce Normalized Device Coordinates Normalized Device Coordinates are scaled and translated by the viewport parameters to produce Window Coordinates Summary 2 Object coordinates are the raw coordinates you submit to OpenGL with a call to glVertex or glVertexPointer They represent the coordinates of your object or other geometry you want to render Many programmers use a World Coordinate system Objects are often modeled in one coordinate system then scaled translated and rotated into the world you re constructing World Coordinates result from transforming Object Coordinates by the modelling transforms stored in the ModelView matrix However OpenGL has no concept of World Coordinates World Coordinates are purely an application construct Summary 3 Eye Coordinates result from transforming Object Coordinates by the ModelView matrix The ModelView matrix contains both modelling and viewing transformations that place the viewer at the origin with the view direction aligned with the negative Z axis Clip Coordinates result from transforming Eye Coordinates by the Projection matrix Clip Coordinate space ranges from Wc to Wc in all three axes where Wc is the Clip Coordinate W value OpenGL clips all coordinates outside this range Summary 4 Perspective division performed on the Clip Coordinates produces Normalized Device Coordinates ranging from 1 to 1 in all three axes Window Coordinates result from scaling and translating Normalized Device Coordinates by the viewport The parameters to glViewport and glDepthRange control this transformation With the viewport you can map the Normalized Device Coordinate cube to any location in your window and depth buffer The Camera System To create a view of a scene we need a description of the scene geometry a camera or view definition Default OpenGL camera is located at the origin looking down the z axis The camera definition allows projection of the 3D scene geometry onto a 2D surface for display This projection can take a number of forms orthographic parallel lines preserved perspective foreshortening 1 point 2 point or 3 point skewed orthographic Camera Types Before generating an image we must choose our viewer The pinhole camera model is most widely used infinite depth of field everything is in focus Advanced rendering systems model the camera double gauss lens as used in many professional cameras model depth of field and non linear optics including lens flare Photorealistic rendering systems often employ a physical model of the eye for rendering images model the eyes response to varying brightness and colour levels model the internal optics of the eye itself diffraction by lens fibres etc Pinhole Camera Model Modeling the Eye s Response Adaptation see aside on Eye Glare Diffraction Camera Systems A camera model implemented in Princeton University 1995 Viewing System We are only concerned with the geometry of viewing at this stage The camera s position and orientation define a viewvolume or view frustrum view frustrum objects completely or partially within this volume are potentially visible on the viewport objects fully outside this volume cannot be seen clipped clipping planes clipped Camera Models Each vertex in our model must be projected onto the 2D camera viewport plane in order to be displayed on the screen The CTM is employed to determine the location of each vertex in the camera coordinate system x M x CTM We then employ a projection matrix defined by GL PROJECTION to map this to a 2D viewport coordinate Finally this 2D coordinate is mapped to device coordinates using the viewport definition given by glViewport Camera Modeling in OpenGL camera coordinate system viewport coordinate system glMatrixMode GL MODELVIEW glMatrixMode GL PROJECTION device screen coordinate system glViewport 0 0 xres yres 3D 2D Projection Type of projection depends on a number of factors location and orientation of the viewing plane viewport direction of projection described by a vector projection type Projection Perspective Parallel 1 point Orthographic 2 point Axonometric 3 point Oblique Parallel Projections axonometric oblique orthographic Orthogonal Projections The simplest of all projections parallel project onto viewplane Usually view plane is axis aligned often at z 0 x y z 1 x 1 y 0 P MP where M 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 Orthogonal Projections The result is an orthographic projection if the object is axis aligned otherwise it is an axonometric projection If the projection plane intersects the principle axes at the same distance from the origin the projection is isometric x y z 1 Parallel Projections in OpenGL glOrtho xmin xmax ymin ymax zmin zmax Note we always view in z direction need to transform world in order to view in other arbitrary directions Perspective Projections Perspective projections are more complex and exhibit fore shortening parallel appear to converge at points Parameters centre of projection COP field of view projection direction up direction Perspective Projections 3 point perspective 1 point perspective 2 point perspective Perspective Projections Perspective Projections Consider a perspective projection with the viewpoint at the origin and a viewing direction oriented along the positive z axis and the view plane located at z d y yP y yP z d zd a similar construction for xp d y yp z x xP z d x 1 y y y 0 P zP z d z 0 d z d 1 0 1 0 0 1 0 0 1 0 1d divide by homogenous ordinate to map back to 3D space 0 x 0 y 0 z 0 1 Perspective Projections Details x 1 y 0 z 0 1 0 0 0 1 0 0 1 0 0 0 x 0 y 0 z 0 1 Flip z to transform to a left handed co ordinate system increasing z values mean increasing distance from the viewer x xP z d x y y y P zP z d z d z d 1 1 PROJECTION matrix perspective division Perspective Projection Depending on the application we can use different mechanisms to


View Full Document

SBU CSE 332 - Viewing With OpenGL

Download Viewing With OpenGL
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Viewing With OpenGL and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Viewing With OpenGL and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?