3D vIEWING - PowerPoint PPT Presentation

1 / 71
About This Presentation
Title:

3D vIEWING

Description:

CA 302 Computer Graphics and Visual Programming Ayd n zt rk aydin.ozturk_at_ege.edu.tr http://www.ube.ege.edu.tr/~ozturk 3D VIEWING – PowerPoint PPT presentation

Number of Views:112
Avg rating:3.0/5.0
Slides: 72
Provided by: DavidLu155
Category:

less

Transcript and Presenter's Notes

Title: 3D vIEWING


1
CA 302 Computer Graphics and Visual Programming
Aydin Öztürk aydin.ozturk_at_ege.edu.tr http//www.u
be.ege.edu.tr/ozturk
  • 3D vIEWING

2
Overview
  • Viewing a 3D scene
  • Projections
  • Parallel and perspective

3
Overview
  • Depth cueing and hidden surfaces
  • Identifying visible lines and surfaces

4
Overview
  • Surface rendering

5
Overview
  • Exploded and cutaway views

6
Overview
  • 3D and stereoscopic viewing

7
3D Viewing Pipeline
MC
DC
ViewportTransformation
ModelingTransformation
NC
WC
Normalization Transformation and Clipping
ViewingTransformation
VC
PC
ProjectionTransformation
8
Viewing Coordinates
  • Generating a view of an object in 3D is similar
    to photographing the object.
  • Whatever appears in the viewfinder is projected
    onto the flat film surface.
  • Depending on the position, orientation and
    aperture size of the camera corresponding views
    of the scene is obtained.

9
Specifying The View Coordinates
xv
yv
  • For a particular view of a scene first we
    establish viewing-coordinate system.
  • A view-plane (or projection plane) is set up
    perpendicular to the viewing z-axis.
  • World coordinates are transformed to viewing
    coordinates, then viewing coordinates are
    projected onto the view plane.

yw
zv
P0(x0 , y0 , z0)
xw
zw
10
Specifying The View Coordinates
  • To establish the viewing reference frame, we
    first pick a world coordinate position P0(x0
    , y0 , z0) calle the view point or viewing
    position (sometimes the eye position or the
    camera position.
  • This point is the origin of our viewing
    coordinate
  • system.
  • If we choose a point on an object we can
  • think of this point as the position where we aim
    a
  • camera to take a picture of the object.

11
Specifying The View Coordinates
  • Next, we select the positive direction for the
    viewing z-axis, and the orientation of the view
    plane, by specifying the view-plane normal
    vector, N.

yv
xv
xv
yw
zv
N
P0
P
xw
zw
12
Specifying The View Coordinates
  • We choose a world coordinate position P on an
    object (we can
  • think of this point as the position where we aim
    a camera to take a picture of the object and this
    point establishes the direction for N.

yv
xv
xv
yw
zv
N
P0
P
xw
zw
13
Specifying The View Coordinates
  • OpenGL establishes the direction for N using the
    point P as a look at point relative to the
    viewing coordinate origin

yv
xv
xv
yw
zv
N
P0
P
xw
zw
14
Specifying The View Coordinates
  • Finally, we choose the up direction for the view
    by specifying view-up vector V.
  • This vector is used to establish the positive
    direction for the yv axis.
  • The vector V is perpendicular to N and is
    defined by selecting a positon relative to the
    world coordinate origin.

yv
xv
V
yw
zv
N
P0
P
xw
zw
15
Specifying The View Coordinates
  • Using N and V, we can compute a third vector U,
    perpendicular to both N and V, to define the
    direction for the xv axis.

yv
xv
V
yw
zv
N
P0
P
xw
zw
16
Specifying The View Coordinates
  • Usually, it can be difficult to determine a
    direction for V that is precisely prependicular
    to N.
  • Therefore, the user defined orientation of V is
    projected onto a plane that is prependicular to
    N.
  • Any direction for the view-up vector V can be
    chosen. A convenient choice is often in a
    direction parallel to the world yw axis that is
    V(0,1,0)

yv
xv
V
yw
zv
N
P0
P
xw
zw
17
Specifying The View Coordinates
  • To obtain a series of views of a scene , we can
    keep the the view reference point fixed and
    change the direcion of N. This corresponds to
    generating views as we move around the viewing
    coordinate origin.

V
P0
N
N
18
Transformation From World To Viewing Coordinates
  • Conversion of object descriptions from world to
    viewing coordinates is equivalent to
    transformation that superimpoes the viewing
    reference frame onto the world frame using the
    translation and rotation.

yw
xw
zw
19
Transformation From World To Viewing Coordinates
  • First, we translate the view reference point to
    the origin of the world coordinate system

yw
xw
zw
20
Transformation From World To Viewing Coordinates
  • Second, we apply rotations to align the xv,, yv
    and zv axes with the world xw, yw and zw axes,
    respectively.

yw
xw
xv
zw
21
Transformation From World To Viewing Coordinates
  • If the view reference point is specified at word
    position (x0, y0, z0), this point is translated
    to the world origin with the translation matrix T.

22
Transformation From World To Viewing Coordinates
  • The rotation sequence requires 3 coordinate-axis
    transformation depending on the direction of N.
  • First we rotate around xw-axis to bring zv into
    the xw -zw plane.

23
Transformation From World To Viewing Coordinates
  • Then, we rotate around the world yw axis to align
    the zw and zv axes.

24
Transformation From World To Viewing Coordinates
  • The final rotation is about the world zw axis to
    align the yw and yv axes.

25
Transformation From World To Viewing Coordinates
  • The complete transformation from world to viewing
    coordinate transformation matrix is obtaine as
    the matrix product

26
Transformation From World To Viewing Coordinates
  • Another method for generating the
    rotation-transformation matrix is to calculate
    uvn vectors and obtain the composite rotation
    matrix directly. Given the vectors N and V
    , these unit vectors are calculated as

27
Transformation From World To Viewing Coordinates
  • This method also automatically adjusts the
    direction for V so that v is
    perpendicular to n. The rotation matrix for the
    viewing transformation is then

28
Transformation From World To Viewing Coordinates
  • The matrix for translating the viewing origin to
    the world origin is

29
Transformation From World To Viewing Coordinates
  • The composite matrix for the viewing
    transformation is then

30
Transformation From World To Viewing Coordinates
An Example For 2D System
y
P(5,5)
y'
2
x'
T300
2
0 2 4 6

P0(4,3)
x
0 2 4 6

31
Transformation From World To Viewing Coordinates
An Example For 2d System
  • Translation

y
0 2 4 6

P
y'
x'
2
2
T300
P0
x
2 4 6

32
Transformation From World To Viewing Coordinates
An Example For 2d System
  • Rotation

0 2 4 6

33
Transformation From World To Viewing Coordinates
An Example For 2d System
  • New coordinates

34
Transformation From World To Viewing Coordinates
An Example For 2d System
  • Alternative Method

y
0 1 2 3

P
1
x'
y'
1
n
v
T300
x
1 2 3
P0
35
Projections
  • Once WC description of the objects in a scene are
    converted to VC we can project the 3D objects
    onto 2D view-plane.
  • Two types of projections
  • -Parallel Projection
  • -Perspective Projection

36
Classical Viewings
  • Hand drawings Determined by a specific
    relationship between the object and the viewer.

37
Parallel Projections
  • Coordinate Positions are transformed to the view
    plane along parallel lines.

View Plane
P'2
P2
P1
P'1
38
Parallel Projections
  • Orthographic parallel projection The projection
    is perpendicular to the view plane.
  • Oblique parallel projecion The parallel
    projection is not perpendicular to the view
    plane.

39
Orthographic Parallel Projection
  • The orthographic transformation

40
Orthographic Parallel Projection
41
Oblique Parallel Projection
  • The projectors are still ortogonal to the
    projection plane
  • But the projection plane can have any orientation
    with respect to the object.
  • It is used extensively in architectural and
    mechanical design.

42
Oblique Parallel Projection
  • Preserve parallel lines but not angles
  • Isometric view Projection plane is placed
    symmetrically with respect to the three principal
    faces that meet at a corner of object.
  • Dimetric view Symmetric with two faces.
  • Trimetric view General case.

43
Oblique Parallel Projection
  • Preserve parallel lines but not angles
  • Isometric view Projection plane is placed
    symmetrically with respect to the three principal
    faces that meet at a corner of object.
  • Dimetric view Symmetric with two faces.
  • Trimetric view General case.

44
Oblique Parallel Projection
yv
(xp, yp)
a
(x, y, z)
L
f
xv
(x, y)
zv
45
Oblique Parallel Projection
  • The oblique transformation

46
Oblique Parallel Projection
47
Perspective Projections
  • First discovered by Donatello, Brunelleschi, and
    DaVinci during Renaissance
  • Objects closer to viewer look larger
  • Parallel lines appear to converge to single point

48
Perspective Projections
  • In perspective projection object positions are
    transformed to the view plane along lines that
    converge to a point called the projection
    reference point (or center of projection)

49
Perspective Projections
  • In the real world, objects exhibit perspective
    foreshortening distant objects appear smaller
  • The basic situation

50
Perspective Projections
  • When we do 3-D graphics, we think of the screen
    as a 2-D window onto the 3-D world

51
Perspective Projections
  • The geometry of the situation is that of similar
    triangles. View from above

View plane
(xp, yp)
d
52
Perspective Projections
  • Desired result for a point x, y, z, 1T
    projected onto the view plane

53
Perspective Projections
54
Perspective Projections
55
Projection Matrix
  • We talked about geometric transforms, focusing on
    modeling transforms
  • Ex translation, rotation, scale, gluLookAt()
  • These are encapsulated in the OpenGL modelview
    matrix
  • Can also express projection as a matrix
  • These are encapsulated in the OpenGL projection
    matrix

56
View Volumes
  • When a camera used to take a picture, the type of
    lens used determines how much of the scene is
    caught on the film.
  • In 3D viewing, a rectangular view window in the
    view plane is used to the same effect. Edges of
    the view window are parallel to the xv-yv axes
    and window boundary positions are specified in
    viewing coordinates.

57
View Volumes
View volume
View volume (frustum)
window
zv
  • Back Plane

window
Front Plane
Back Plane
Projection Reference Point
Front Plane
Parallel Projection
Parallel Projection
Perspective Projection
58
Clipping
  • An algorithm for 3D clipping identifies and saves
    all surface segments within the view volume for
    display.
  • All parts of object that are outside the view
    volume are discarded.

59
Clipping Lines
  • To clip a line against the view volume, we need
    to test the relative position of the line using
    the view volumes boundary plane equation.
  • An end point (x,y,z) of a line segment is outside
    a boundary plane if
  • where A, B, C and D are the plane parameters
    for that boundary.

60
Clipping Polygon Surface
  • To clip a polygon surface, we can clip the
    individual polygon edges.
  • First we test the coordinate extends against each
    boundary of the view volume to determine whether
    the object is completely inside or completely
    outside of that boundary.
  • If the object has intersection with the boundary
    then we apply intersection calculations.

61
Clipping Polygon Surface
  • The projection operation can take place before
    the view- volume clipping or after clipping.
  • All objects within the view volume map to the
    interior of the specified projection window.
  • The last step is to transform the window contents
    to a 2D view port.

62
Clipping Polygon Surface
Viev volume
63
Steps For Normalized View Volumes
  • A scene is constructed by transforming object
    descriptions from modeling coordinates to wc.
  • The world descriptions are converted to viewing
    coordinates.
  • The viewing coordinates are transformed to
    projection coordinates which effectively converts
    the view volume into a rectangular
    parallelepiped.
  • The parallelepiped is mapped into the unit cube
    called normalized projection coordinate system.
  • A 3D viewport within the unit cube is
    constructed.
  • Normalized projection coordinates are converted
    to device coordinates for display.

64
Normalized View Volumes
(Xvmax,Yvmax, Zvmax)
65
OpenGL Projection Commands
66
OpenGL Look-At Function
  • OpenGL utility function
  • VRP eyePoint (eyex, eyey, eyez)
  • VPN ( atPoint eyePoint ) (atx, aty, atz)
    (eyex, eyey, eyez)
  • VUP (upPoint eyePoint) (upx, upy, upz)
  • gluLookAt(eyex, eyey, eyez, atx, aty, atz,
    upx, upy, upz)

look-at positioning
67
Projections in OpenGL
  • Angle of view, field of view
  • Only objects that fit within the angle of view of
    the camera appear in the image
  • View volume, view frustum
  • Be clipped out of scene
  • Frustum truncated pyramid

68
Projections in OpenGL
69
Perspective in OpenGL
  • Specification of a frustum
  • near, far positive number !!
  • ? zmax far
  • ? zmin near
  • glMatrixMode(GL_PROJECTION)
  • glLoadIdentity( )
  • glFrustum(xmin, xmax, ymin, ymax, near, far)

70
Perspective in OpenGL
  • Specification using the field of view
  • fov angle between top and
  • bottom planes
  • fovy the angle of view in the
  • up (y) direction
  • aspect ratio width / height
  • glMatrixMode(GL_PROJECTION)
  • glLoadIdentity( )
  • gluPerspective(fovy, aspect, near, far)

71
Parallel Viewing in OpenGL
  • Orthographic viewing function
  • OpenGL provides only this parallel-viewing
    function
  • near lt far !!
  • ? no restriction on the sign
  • ? zmax far
  • ? zmin near
  • glMatrixMode(GL_PROJECTION)
  • glLoadIdentity( )
  • glOrtho(xmin, xmax, ymin, ymax, near, far)
Write a Comment
User Comments (0)
About PowerShow.com