viewing cs418 computer graphics john c. hart. graphics pipeline homogeneous divide model coords...
TRANSCRIPT
Viewing
CS418 Computer Graphics
John C. Hart
Graphics Pipeline
Homogeneous Divide
Homogeneous Divide
ModelCoords
ModelCoords
ModelXform
ModelXform
WorldCoords
WorldCoords
ViewingXform
ViewingXform
StillClip
Coords.
StillClip
Coords.ClippingClipping
WindowCoordinates
WindowCoordinates
Windowto
Viewport
Windowto
Viewport
ViewportCoordinates
ViewportCoordinates
ClipCoords.
ClipCoords.
ViewingCoords
ViewingCoords
PerspectiveDistortion
Graphics Pipeline
Homogeneous Divide
Homogeneous Divide
ModelCoords
ModelCoords Model
Xform
ModelXform World
Coords
WorldCoords Viewing
Xform
ViewingXform
StillClip
Coords.
StillClip
Coords. ClippingClipping
WindowCoordinates
WindowCoordinates
Windowto
Viewport
Windowto
ViewportViewport
Coordinates
ViewportCoordinates
ClipCoords.
ClipCoords.
ViewingCoords
ViewingCoords
PerspectiveDistortion
W2V Persp View Model0
1 1
s m
s m
m
x x
y y
z
Graphics Pipeline
Homogeneous Divide
Homogeneous Divide
ModelCoords
ModelCoords Model
Xform
ModelXform World
Coords
WorldCoords Viewing
Xform
ViewingXform
StillClip
Coords.
StillClip
Coords. ClippingClipping
WindowCoordinates
WindowCoordinates
Windowto
Viewport
Windowto
ViewportViewport
Coordinates
ViewportCoordinates
ClipCoords.
ClipCoords.
ViewingCoords
ViewingCoords
PerspectiveDistortion
0
1
s
s
x
y
1
m
m
m
x
y
z
M
Transformation Order
0
1
s
s
x
y
1
m
m
m
x
y
z
M
x
y
z
glutSolidTeapot(1); glRotate3f(-90, 0,0,1);glTranslate3f(0,1,0);glutSolidTeapot(1);
glTranslate3f(0,1,0);glRotate3f(-90, 0,0,1);glutSolidTeapot(1);
0
1
s
s
x
y
1
m
m
m
x
y
z
M R T 0
1
s
s
x
y
1
m
m
m
x
y
z
M T R
Viewing Transformation
Homogeneous Divide
Homogeneous Divide
ModelCoords
ModelCoords Model
Xform
ModelXform World
Coords
WorldCoords Viewing
Xform
ViewingXform
StillClip
Coords.
StillClip
Coords. ClippingClipping
WindowCoordinates
WindowCoordinates
Windowto
Viewport
Windowto
ViewportViewport
Coordinates
ViewportCoordinates
ClipCoords.
ClipCoords.
ViewingCoords
ViewingCoords
PerspectiveDistortion
W2V Persp View Model0
1 1
s m
s m
m
x x
y y
z
Viewing Transformation
W2V
Model
View
Persp
ModelCoords
WorldCoords
ViewingCoords
ClipCoords
ScreenCoords
x
y
z
x
ylookatpoint
eyepoint
x
y
z
WorldCoordinates
ViewingCoordinates
x
y
z
eye pointlookat point eye point(at origin)
lookat point(along –z axis)
x
y
z
WorldCoordinates
ViewingCoordinates
x
yeye pointlookat point lookat point
(along –z axis)
x
y
z
WorldCoordinates
ViewingCoordinates
x
yeye pointlookat point
y'x'
Why notthese axes?
x
y
z
WorldCoordinates
ViewingCoordinates
y
z
eye pointlookat point
up vectorup vector
up
1. Specify up direction in world coordinates
2. Transform up vector into viewing coordinates
3. Rotate about z-axis until up vector in x-y plane.
x
x
y
z
WorldCoordinates
ViewingCoordinates
y
z
eye pointlookat point
up vectorup vector
up
1. Specify up direction in world coordinates
2. Transform up vector into viewing coordinates
3. Rotate about z-axis until up vector in x-y plane.
x
Lookat Transformation
xy
z
lookatpoint
eyepoint
upvector
Lookat Transformation
1. Translate the eye point to the origin
xy
z
1
1
1
1
x
y
z
Lookat Transformation
1. Translate the eye point to the origin
2. Rotate the view vector into the negative z-axis
xy
z
1
1
1
1
x
yR
z
x
y
z
Easier Way
• Orthogonalize lookat vector system
x
y
z
upv
Easier Way
• Orthogonalize lookat vector system– Let r = v up/||vup||
x
y
z
up
r
v
Easier Way
• Orthogonalize lookat vector system– Let r = v up/||vup||– Let u = r v
x
y
z
upuv
r
Easier Way
• Orthogonalize lookat vector system– Let r = v up/||vup||– Let u = r v– Create rotation matrix from
<r,u,-v> to <x.y,z>
R r = x, R u = y, R v = -z
x
y
z
upuv
r
R=¿
Construct Lookat
• Translate eye point to origin• Rotate view into -z axis
– Let v = (lookat - eye)/||lookat - eye||– Let r = v up/||vup||– Let u = r v
x
y
z
xy
z
lookatpoint
eyepoint
upvector
Viewing Transformation
W2V
Model
View
Persp
ModelCoords
WorldCoords
ViewingCoords
ClipCoords
ScreenCoords
x
y
z
x
y
z
lookatpoint
eyepoint