Chapter 4
Chapter 4
Window- To-Viewport
Viewing Pipeline
o Modelling Transformation
o Viewing Transformation
o Projection Transformation
o Normalization and Clipping
o Viewport Transformation
o OpenGL Viewing Pipeline
– Modelview matrix
– Projection matrix
– Viewport matrix
Computer Graphics: Chapter Four
3
• Transforms primitives from world coordinates
Window-to- to viewport coordinates.
viewport
Tansformationr
• All primitives that lie outside the world window
must be clipped.
• Primitives are displayed in a viewport of the
screen window.
Normalization and
Clipping
ViewPort
Transformation
OpenGL Viewing
Pipline
Modeling Transformation
5
Modeling coordinate System: primitive coordinate
Modelling
Modeling: creating 3D scenes from basic primitives
Transformation
Modeling Transformation: transform primitives so
Viewing that they create the 3D scene we want.
Transformation World coordinate system: the resulted coordinate
system
Projection A wheel primitive being transformed in four different ways to form
Transformation the wheels of a car.
Normalization and
Clipping
ViewPort
Transformation
OpenGL Viewing
Pipline Modelling Transformation World Coordinate System
The Viewing Transformation
6
Normalization and
Clipping
ViewPort
Transformation
OpenGL Viewing
Pipline Viewing Coordinate System
Projection Transformation
7
ViewPort
Transformation
OpenGL Viewing
Pipline
Projection Transformation
8
ViewPort
Transformation Image Image plane
plane
Projection
Transformation
Normalization and
Clipping
Centre of projection Image plane
ViewPort
Transformation
OpenGL Viewing
Pipline
Normalization and Clipping
10
Clipping: the process of checking and deciding which
Modelling
Transformation primitives are visible by the camera and which ones are
not.
Viewing
Transformation
Clipping is performed by:
Projection Defining number of clipping planes
Transformation 6 clipping planes: left, right, bottom and top boarder
of the image plane and near and far planes.
Normalization and
Clipping
View Volume: bounded volume formed by the six
ViewPort clipping planes. primitives inside are visible and the rest
Transformation are not.
OpenGL Viewing
Pipline
Normalization and Clipping…
11
Modelling
Transformation
Viewing
Transformation
Projection
Transformation
Normalization and
Clipping
Near and Far Clipping Planes
ViewPort
Transformation
Volume of space between near and far clipping
planes defines what the camera can ‘see’.
OpenGL Viewing
Pipline
Modelling
Transformation
Viewing
Transformation
Projection
Transformation
Normalization and
Clipping
ViewPort
Transformation
OpenGL Viewing
Pipline
13
Modelling
Transformation
Viewing
Transformation
Projection
Transformation
Normalization and
Clipping
ViewPort
Transformation
OpenGL Viewing
Pipline
Normalization and Clipping…
14
ViewPort
Transformation All that is left now is to draw our picture into the
display window.
OpenGL Viewing
Pipline
Viewport Transformation
15
Normalization and
Clipping
ViewPort
Transformation
OpenGL Viewing
Pipline
OpenGL viewing pipeline
16
OpenGL Viewing
Pipline
OpenGL viewing pipeline
18
Modelling
Transformation • For example, the following 3 lines define a virtual camera
positioned at (8, 0, 8) in world coordinates, looking at the origin,
Viewing and with the y-axis as ‘up’.
Transformation
Projection glMatrixMode(GL_MODELVIEW);
Transformation glLoadIdentity();
gluLookAt(8,0,8,0,0,0,0,1,0);
Normalization and
Clipping
ViewPort
Transformation
OpenGL Viewing
Pipline
OpenGL viewing pipeline…
20
ViewPort
Transformation
OpenGL Viewing
Pipline
OpenGL viewing pipeline…
22
Projection
• gluPerspective
Transformation – theta is the height angle in degrees
– aspect is the ratio of the width to the height of
Normalization and
the image plane (the aspect ratio)
Clipping
– Centre of projection is the origin of the viewing
ViewPort coordinate system
Transformation – dnear, dfar are distances of clipping planes
OpenGL Viewing from centre of projection along z-axis
Pipline – Image plane is the near clipping plane
OpenGL viewing pipeline…
23
OpenGL Viewing
Pipline
OpenGL viewing pipeline(Example)
24
ViewPort
glMatrixMode(GL_PROJECTION);
Transformation glLoadIdentity();
// arguments are left, right, bottom, top, near, far
OpenGL Viewing glOrtho(-12, 12, -12, 12, 0, 30);
Pipline
OpenGL viewing pipeline(Example…)
25
Projection glMatrixMode(GL_PROJECTION);
glLoadIdentity();
Transformation gluPerspective(45, 1.0, 0.0, 50.0);
Normalization and
Clipping • gluFrustum
•Specifies a perspective projection in which the near clipping
ViewPort plane is defined by the four corners (-10, -10, -5), (-10, 10, -5),
Transformation (10, -10, -5) and (10, 10, -5).
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
OpenGL Viewing gluFrustum(-10,10,-10,10,5,50);
Pipline
OpenGL viewing pipeline …
26
OpenGL Viewing
Pipline
Any Question?
27