Topic 6 Graphic Transformation and Viewing
Topic 6 Graphic Transformation and Viewing
Why transformations?
Basic transformations:
translation, rotation, scaling
Combining transformations
homogenous coordinates, transform. Matrices
instantiation…
world
train animation…
viewing…
wheel
modelling…
image
Why transformation?
Model of objects
world coordinates: km, mm, etc.
Hierarchical models::
human = torso + arm + arm + head + leg + leg
arm = upperarm + lowerarm + hand …
Viewing
zoom in, move drawing, etc.
Animation
Buffer
Define a buffer by its spatial resolution (n x m) and its depth k, the
number of bits/pixel
pixel
OpenGL Frame Buffer
OpenGL Buffers
Color buffers can be displayed
Front
Back
Auxiliary
Overlay
Depth
Accumulation
High resolution buffer
Stencil
Holds masks
Writing in Buffers
memory
source frame buffer
(destination)
writing into frame buffer
Buffer Selection
OpenGL can draw into or read from any of the color buffers
(front, back, auxiliary)
Default to the back buffer
Change with glDrawBuffer and glReadBuffer
Note that format of the pixels in the frame buffer is different
from that of processor memory and these two types of
memory reside in different places
Need packing and unpacking
Drawing and reading can be slow
Bitmaps
increments in
raster
position after
bitmap drawn
rendering pipeline
Very efficient because few polygons pass down the
geometric pipeline
Is it simple?
Although the idea is simple---map an image to a
surface---there are 3 or 4 coordinate systems
involved
2D image
3D surface
Coordinate Systems
Parametric coordinates
May be used to model curved surfaces
Texture coordinates
Used to identify points in the image to be
mapped
World Coordinates
Conceptually, where the mapping takes place
Screen Coordinates
Where the final image is really produced
Texture Mapping
parametric coordinates
s
Backward Mapping
We really want to go backwards
Given a pixel, we want to know to which point on an
object it corresponds
Given a point on an object, we want to know to which
parametric cylinder
x = r cos 2 u
y = r sin 2u
z = v/h
maps rectangle in u,v space to cylinder of radius r and height h in
world coordinates
s=u
t=v
x = r cos 2u
y = r sin 2u cos 2v
z = r sin 2u sin 2v
actual intermediate
Mapping a Texture
Based on parametric texture coordinates
glTexCoord*() specified at each vertex
c (0.4, 0.2)
b
B C
0, 0 1, 0 s (0.8, 0.4)
Accumulation Buffer
Compositing and blending are limited by resolution of the
frame buffer
Typically 8 bits per color component
The accumulation buffer is a high resolution buffer (16 or more
bits per component) that avoids this problem
Write into it or read from it with a scale factor
Slower than direct compositing into the frame buffer
Computer Graphics Viewing
Clipping Window
ywmax
World Coordinates
xwmin xwmax
Viewing world has its own
Viewport
yvmax coordinates, which may be
a non-uniform scaling of
world coordinates.
yvmin
Viewport Coordinates
xvmin xvmax
2D viewing transformation pipeline
Construct World-
Modeling World Convert World-
Coordinates Coordinate Scene Coordinates Coordinates to
From Modeling-
Viewing-
Coordinate
Coordinates
Transformations
Viewing Coordinates
Each test clips the line and the remaining is tested again
for full inclusion or certain exclusion, until remaining is
either empty or fully contained.
xend , yend
xwmin xwmax
ywmax
x0 , y0 ywmin
This is more efficient than Cohen-Sutherland Alg,
which computes intersection with clipping window
borders for each undecided line, as a part of the
feasibility tests.
Nicholl-Lee-Nicholl Line Clipping
Algorithm
Creates more regions around clipping window to
avoid multiple line intersection calculations.
Performs fewer comparisons and divisions than
Cohen-Sutherland and Liang-Barsky, but cannot
be extended to 3D, while they can.
For complete inclusion in clipping window or
certain exclusion we’ll use Cohen-Sutherland.
The four clippers can work in parallel.
Once a pair of endpoints it output by the first
clipper, the second clipper can start working.
The more edges in a polygon, the more
effective parallelism is.
successively.
3D Viewing Concepts
Construct World-
Coordinate Scene Convert World-
Projection
From Modeling- Coordinates to
Coordinate Viewing- Transformation
Transformations Coordinates
Projection Coordinates
View Plane
Plane View
Front
Elevation Side
View Elevation
View
Far
Clipping
Plane
Near
Clipping yview
Plane
Clipping window
xview
zview
Normalizing Orthogonal Projection
Orthogonal Projection View Volume ynorm
yview
zview xview 1, 1, 1
Normalized View Volume
y Vanishing
Point
z
Principle axes for cube One-Point perspective Projection
View
Rectangular Frustum
Plane
View Volume
Near yview
Clipping
Plane
xview
Field-of-view Angle Projection
zview Reference Point
Settings of Perspective Projection
Perspective projection point
Where the viewer (camera, eye) is positioned in the world.
Positioning viewing plane with respect to viewing
coordinates
Results vanishing points, one, two or three.
Clipping window on viewing plane
Defines the infinite pyramid view volume.
Near and far clipping planes (parallel to view plane)
Define the rectangular frustum view volume.
Scale and translation parameters of perspective
matrix
Define the normalization range.
Applications
Compositing
Image Filtering (convolution)
Whole scene antialiasing
Motion effects