Open GL The Viewing Pipeline Definition a series

  • Slides: 17
Download presentation
Open. GL The Viewing Pipeline: • Definition: a series of operations that are applied

Open. GL The Viewing Pipeline: • Definition: a series of operations that are applied to the Open. GL matrices, in order to create a 2 D representation from 3 D geometry. • Processes can be broken up into four main areas: 1. The movement of the object is called a modeling transformation. 2. The movement of the camera is called a viewing transformation. 3. The conversion from 3 D to 2 D is called a projection transformation. 4. The 2 D picture plane, which is mapped to the screen viewport, called a viewport transformation.

The Camera Analogy Camera Open. GL Modeling: position model Viewing: position camera lens position

The Camera Analogy Camera Open. GL Modeling: position model Viewing: position camera lens position viewing volume choose vv shape choose photo size choose portion of screen Projection: choose Viewport:

Viewing Pipeline & Open. GL • Can also be thought of as a production

Viewing Pipeline & Open. GL • Can also be thought of as a production line. • Matrix operations are foundation of pipeline. • Pipeline transforms vertices (coordinates).

Viewing Pipeline & Coordinates Pipeline transforms vertices (coordinates) object eye modelview matrix clip projection

Viewing Pipeline & Coordinates Pipeline transforms vertices (coordinates) object eye modelview matrix clip projection matrix ndc perspective division window viewport Coordinate systems are key to computer graphics!

The Model Coordinates and Transformations • The coordinates we specify using the gl. Vertex*

The Model Coordinates and Transformations • The coordinates we specify using the gl. Vertex* commands are the model coordinates. • The gl. Rotate, gl. Translate and gl. Scale commands are used to transform the model into the desired orientation and size. • These operations are applied to the modelview matrix. • We did these matrix transformations as an exercise and in test 1. • Open. GL does them for us using one-liners (thank goodness). • After applying the modeling transformations to the model coordinates what we get are world coordinates.

The Model Coordinates and Transformations To begin transformation of this matrix, we need to

The Model Coordinates and Transformations To begin transformation of this matrix, we need to specify it in the matrix mode function, then initialize the matrix to the Identity matrix, and perform your transformations thereafter:

Overview

Overview

The Camera Coordinates and Viewing Transformation • The next step is to convert the

The Camera Coordinates and Viewing Transformation • The next step is to convert the world coordinates into camera coordinates. • For this we use: glu. Look. At(eye. X, eye. Y, eye. Z, refer. X, refer. Y, refer. Z, up. X, up. Y, up. Z); • This performs translations and rotations to transform a point from world coordinates to camera coordinates. So the matrix generated is a combination of translation and rotation matrices. • The default Open. GL viewpoint is located at the origin, looking down the negative Z axis. • Two options: The geometry that we wish to view must either be moved to a position from which it can be seen from the default viewpoint, or the viewpoint must be moved so that it can see the geometry. • • • eye. X, eye. Y, eye. Z represents the viewpoint. refer. X, refer. Y, refer. Z represents a point along the desired line of sight. up. X, up. Y, up. Z represents the view up vector.

The Camera Coordinates and Viewing Transformation Note that although the modeling and viewing transformations

The Camera Coordinates and Viewing Transformation Note that although the modeling and viewing transformations can be considered logically separate operations, Open. GL concatenates all of the modeling and viewing transformations into a single matrix (i. e. the Model. View Matrix) • Panning or Tilting: move reference point horizontally or vertically.

Overview

Overview

Projection Transformation • After applying the modelview matrix Open. GL must now take the

Projection Transformation • After applying the modelview matrix Open. GL must now take the camera coordinates to the image space. This is done using the projection transformation. • Two types of projection: Orthographic and Perspective • Each of these transformations defines a volume of space called a frustum. • Only geometry that is inside of the frustum is displayed on the screen. Any portion of geometry that is outside of the frustum is clipped.

Projection Transformation Orthographic: • Maps objects directly onto the screen without affecting their relative

Projection Transformation Orthographic: • Maps objects directly onto the screen without affecting their relative size. • Given by: gl. Ortho(left, right, bottom, top, near, far); • Defines a rectangular parallelepiped frustum (a box). • Creates a matrix for an orthographic parallel viewing volume and multiplies the current matrix by it. (left, bottom, -near) and (right, top, -near) are points on the near plane that are mapped to the lower-left and upper-right corners of the viewport window, respectively. (left, bottom, -far) and (right, top, -far) are points on the far plane that are mapped to the same respective corners of the viewport. Both near and far can be positive or negative. The direction of projection is parallel to the z-axis, and the viewpoint faces toward the negative z-axis.

Projection Transformation Perspective: • Makes objects that are farther away appear smaller. • Given

Projection Transformation Perspective: • Makes objects that are farther away appear smaller. • Given by: glu. Perspective(fov, aspect, near, far); • Creates a matrix for a symmetric perspective-view frustum and multiplies the current matrix by it. fovy is the angle of the field of view in the x-z plane; its value must be in the range [0. 0, 180. 0]. aspect is the aspect ratio of the frustum, its width divided by its height. Near and far values are the distances between the viewpoint and the clipping planes, along the negative z-axis.

Overview

Overview

Clipping and Perspective Divison • Steven’s section

Clipping and Perspective Divison • Steven’s section

Viewport Transformation • Determines the size of the rendered image. • By default the

Viewport Transformation • Determines the size of the rendered image. • By default the viewport is set to the entire pixel rectangle of the window. • The gl. Viewport(GLint x, GLint y, GLsizei width, GLsizei height); command can be used to choose a smaller drawing region. • The viewport aspect ratio should be the same as that of the view frustum or the image appears distorted. • The 2 D picture plane from the previous transformation forms the world coordinate window, which can be mapped to the screen viewport, which ends up on our screen.

Code Execution Order Since the order of the transformations is significant, we want to

Code Execution Order Since the order of the transformations is significant, we want to invoke the Open. GL functions in the proper order, i. e. in the reverse order in which they will be applied: