Upload
nolan-prince
View
40
Download
0
Embed Size (px)
DESCRIPTION
Viewing in 3D. Chapter 6. The 3D viewing process is inherently more complex than is the 2D viewing process. In 2D, we simply specify a window on the 2D world and a viewport on the 2D view surface. - PowerPoint PPT Presentation
Citation preview
Viewing in 3D
Chapter 6Chapter 6
Chapter 6 -- Viewing in 3D 2
The 3D viewing process is inherently more The 3D viewing process is inherently more complex than is the 2D viewing process. complex than is the 2D viewing process. In 2D, we simply specify a window on the 2D world In 2D, we simply specify a window on the 2D world
and a viewport on the 2D view surface.and a viewport on the 2D view surface. Conceptually, objects in the world are clipped Conceptually, objects in the world are clipped
against the window and then transformed into the against the window and then transformed into the viewport for display.viewport for display.
Although 3D viewing may seem overwhelming at Although 3D viewing may seem overwhelming at first, it is less daunting when viewed as a series of first, it is less daunting when viewed as a series of easily understood steps, many of which we have easily understood steps, many of which we have prepared for in earlier chapters.prepared for in earlier chapters.
Chapter 6 -- Viewing in 3D 3
1. The Synthetic Camera and Steps in 3D Viewing A useful metaphor for creating 3D scenes is A useful metaphor for creating 3D scenes is
the notion of a synthetic camerathe notion of a synthetic camera
Chapter 6 -- Viewing in 3D 4
While the synthetic camera is a useful concept, While the synthetic camera is a useful concept, there is a bit more to producing an image than there is a bit more to producing an image than just pushing a button.just pushing a button.
Creation of our photo is accomplished as a Creation of our photo is accomplished as a series of steps:series of steps: Specification of projection typeSpecification of projection type Specification of viewing parametersSpecification of viewing parameters Clipping in three dimensionsClipping in three dimensions Projection and DisplayProjection and Display
Chapter 6 -- Viewing in 3D 5
2. Projections
In general, projections transform points in a In general, projections transform points in a coordinate system of dimension n into points in coordinate system of dimension n into points in a coordinate system of dimension less than n. a coordinate system of dimension less than n.
For now we shall limit ourselves to 3D to 2D.For now we shall limit ourselves to 3D to 2D.
Chapter 6 -- Viewing in 3D 6
The projection of a 3D object is defined by The projection of a 3D object is defined by straight projection rays, called projectors, straight projection rays, called projectors, emanating from a center of projection, passing emanating from a center of projection, passing through each point of the object, and through each point of the object, and intersecting a projection plane to form the intersecting a projection plane to form the projection.projection. Two locations for the center of projection: Two locations for the center of projection:
• finite distance (perspective projection) and finite distance (perspective projection) and
• infinite distance (parallel projection)infinite distance (parallel projection)
Chapter 6 -- Viewing in 3D 7
Chapter 6 -- Viewing in 3D 8
2.1 Perspective Projections
The perspective projections of any set of The perspective projections of any set of parallel lines that are not parallel to the parallel lines that are not parallel to the projection plane converge to a vanishing point.projection plane converge to a vanishing point. if the set of lines is parallel to one of the three if the set of lines is parallel to one of the three
principal axes, the vanishing point is called an axes principal axes, the vanishing point is called an axes vanishing pointvanishing point
Chapter 6 -- Viewing in 3D 9
Perspective projections are categorized by their Perspective projections are categorized by their number of principal vanishing pointsnumber of principal vanishing points One point perspective projectionOne point perspective projection
Chapter 6 -- Viewing in 3D 10
Two point perspective projectionTwo point perspective projection
Chapter 6 -- Viewing in 3D 11
2.2 Parallel Projections
Parallel projections are categorized into two Parallel projections are categorized into two types, depending on the relation between the types, depending on the relation between the direction of projection and the normal to the direction of projection and the normal to the projection plane.projection plane.
The two most common are:The two most common are: orthographic -- direction of the projection and the orthographic -- direction of the projection and the
normal of the plane are the samenormal of the plane are the same oblique -- they are not the same.oblique -- they are not the same.
Chapter 6 -- Viewing in 3D 12
The most common types of orthographic The most common types of orthographic projections areprojections are front-elevationfront-elevation top-elevationtop-elevation side-elevationside-elevation
Chapter 6 -- Viewing in 3D 13
A special sub-type of orthographic projections A special sub-type of orthographic projections are isometric projections. The projection plan are isometric projections. The projection plan normal makes equal angles with each principal normal makes equal angles with each principal axis. axis.
Chapter 6 -- Viewing in 3D 14
The other type of parallel projection is an The other type of parallel projection is an Oblique projectionOblique projection the projection plane normal and the direction of the the projection plane normal and the direction of the
projection differ.projection differ.
Chapter 6 -- Viewing in 3D 15
3. Specification of an Arbitrary 3D View
3D viewing involves not just a projection, but 3D viewing involves not just a projection, but also a view volume against which the 3D world also a view volume against which the 3D world is clipped.is clipped.
The projection and the view volume together The projection and the view volume together provide all the information that we need to clip provide all the information that we need to clip and project into 2D space.and project into 2D space.
Then the 2D transformation into physical Then the 2D transformation into physical device coordinates is straightforward.device coordinates is straightforward.
Chapter 6 -- Viewing in 3D 16
The projection plane (view plane in the The projection plane (view plane in the graphics literature) is defined by graphics literature) is defined by a point in the plane called a a point in the plane called a view reference pointview reference point
(VRP) and(VRP) and a normal to the plane called the a normal to the plane called the view-plane normalview-plane normal
(VPN)(VPN)
Chapter 6 -- Viewing in 3D 17
To define a window on the view plane, we To define a window on the view plane, we need to specify minimum and maximum need to specify minimum and maximum window coordinateswindow coordinates
Chapter 6 -- Viewing in 3D 18
for a perspective for a perspective projection it looks like:projection it looks like:
for a parallel projection for a parallel projection it looks like:it looks like:
The center of projection and direction of projection The center of projection and direction of projection are defined by the Projection Reference Point (PRP)are defined by the Projection Reference Point (PRP)
Chapter 6 -- Viewing in 3D 19
At times we may want the view volume to be At times we may want the view volume to be finite, in order to limit the number of output finite, in order to limit the number of output primitives projected onto the view plane.primitives projected onto the view plane. You specify the front and back clipping planesYou specify the front and back clipping planes For parallel projections it looks like:For parallel projections it looks like:
for perspective projections it looks like:for perspective projections it looks like:
Chapter 6 -- Viewing in 3D 20
4. Examples of 3D Viewing
In this section, we consider how we can apply In this section, we consider how we can apply the basic viewing concepts introduced in the basic viewing concepts introduced in Section 3 to create a variety of projections.Section 3 to create a variety of projections. such as this house.such as this house.
Chapter 6 -- Viewing in 3D 21
Because this house is used throughout this Because this house is used throughout this section, it will be helpful to remember its section, it will be helpful to remember its dimensions and position, which are indicated dimensions and position, which are indicated here:here:
Chapter 6 -- Viewing in 3D 22
4.1 Perspective Projections
To obtain the front one-point perspective view To obtain the front one-point perspective view shown here:shown here:
position the center of projection (the viewer) at position the center of projection (the viewer) at (8,6,84)(8,6,84)
Chapter 6 -- Viewing in 3D 23
To make the vie larger and centered, To make the vie larger and centered, make the view plane and the front of the house make the view plane and the front of the house
coincide.coincide. place the viewer at (8, 6, 30) in front of this plane.place the viewer at (8, 6, 30) in front of this plane.
Chapter 6 -- Viewing in 3D 24
Other views could look like:Other views could look like:
Chapter 6 -- Viewing in 3D 25
AndAnd
Chapter 6 -- Viewing in 3D 26
4.2 Parallel Projections
Chapter 6 -- Viewing in 3D 27
4.3 Finite View Volumes
In all the examples so far, the view volume has In all the examples so far, the view volume has been assumed to be infinite.been assumed to be infinite.
If we start with this setupIf we start with this setup
Chapter 6 -- Viewing in 3D 28
and add a far clipping plane right in front of the and add a far clipping plane right in front of the far wall of the house, we can end up with an far wall of the house, we can end up with an image that looks like:image that looks like:
Chapter 6 -- Viewing in 3D 29
5. The Mathematics of Planar Geometric Projections Here we introduce the basic mathematics of Here we introduce the basic mathematics of
planar geometric projections.planar geometric projections. For simplicity, we start by assuming that, For simplicity, we start by assuming that,
in the perspective projection, the projection in the perspective projection, the projection plane is normal to the plane is normal to the zz axis at axis at z=dz=d, ,
and that in the parallel projection, the and that in the parallel projection, the projection plane is at projection plane is at z=0z=0..
Chapter 6 -- Viewing in 3D 30
Each of the projections can be defined by a Each of the projections can be defined by a 4x44x4 matrix.matrix.
This is convenient, because the projection matrix This is convenient, because the projection matrix can be composed with the transformation matrices, can be composed with the transformation matrices, allowing two operations (transform then project) to allowing two operations (transform then project) to be represented in a single matrix.be represented in a single matrix.
In this section we derive In this section we derive 4x44x4 matrices for matrices for several projectionsseveral projections
Chapter 6 -- Viewing in 3D 31
Given a point Given a point PP to be to be projected onto the projected onto the plane, calculate the plane, calculate the point point PPpp=(x=(xpp, y, ypp, z, zpp) )
which is the projection.which is the projection. We use similar We use similar
triangles as found in triangles as found in this figurethis figure
and calculate ratios for and calculate ratios for the transformation as:the transformation as:
x
d
x
zp
y
d
y
zp
xd x
z
x
z dp
/
yd y
z
y
z dp
/
Chapter 6 -- Viewing in 3D 32
These ratios lead to a transformation matrix for These ratios lead to a transformation matrix for a perspective projection of:a perspective projection of:
M
d
per
1 0 0 0
0 1 0 0
0 0 1 0
0 0 1 0/
Chapter 6 -- Viewing in 3D 33
The orthographic projection pane at The orthographic projection pane at z=0z=0 is is straightforward, and ends up as:straightforward, and ends up as:
Mort
1 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
Chapter 6 -- Viewing in 3D 34
6. Implementation of Planar Geometric Projections Given a view volume and a projection, let us Given a view volume and a projection, let us
consider how the viewing operation of clipping consider how the viewing operation of clipping and projecting is applied.and projecting is applied.
The brute force method was:The brute force method was: clip each line with the 6 planes of the volume.clip each line with the 6 planes of the volume. project remaining lines by solving simultaneous project remaining lines by solving simultaneous
equations for the projection onto the view planeequations for the projection onto the view plane Then transform these to 2D space...Then transform these to 2D space...
Chapter 6 -- Viewing in 3D 35
The large number of calculations required for The large number of calculations required for this process, repeated for many lines, involves this process, repeated for many lines, involves considerable computing.considerable computing.
Happily there is a more efficient procedure, Happily there is a more efficient procedure, based on the divide-and-conquer strategy of based on the divide-and-conquer strategy of breaking down a difficult problem into a series breaking down a difficult problem into a series of simpler ones.of simpler ones. And they are much easier if you use the canonical And they are much easier if you use the canonical
volumes shown here:volumes shown here:
Chapter 6 -- Viewing in 3D 36
Our goal is to find the normalizing Our goal is to find the normalizing transformations transformations NNparpar and and NNperper that transform an that transform an
arbitrary parallel or perspective projection view arbitrary parallel or perspective projection view volume into the parallel and perspective view volume into the parallel and perspective view volumesvolumes
Then the rest of the process is doneThen the rest of the process is done clipping, clipping, projection into 2Dprojection into 2D
Chapter 6 -- Viewing in 3D 37
6.1 The Parallel Projection Case
In this section, we derive the normalizing In this section, we derive the normalizing transformation transformation NNparpar for parallel projections. for parallel projections.
This is done in order to transform world-This is done in order to transform world-coordinate positions such that the view volume coordinate positions such that the view volume is transformed into the canonical view volume.is transformed into the canonical view volume.
Then we clip and project.Then we clip and project.
Chapter 6 -- Viewing in 3D 38
Transformation Transformation NNparpar is derived for the most is derived for the most
general case, the oblique (rather than the general case, the oblique (rather than the orthographic) parallel projection.orthographic) parallel projection.
NNparpar thus includes a shear transformation that thus includes a shear transformation that
causes the direction of projection in viewing causes the direction of projection in viewing coordinates to be parallel to coordinates to be parallel to zz.. By including this shear we can do the projection By including this shear we can do the projection
onto onto z=0z=0 plane simply by setting plane simply by setting z=0z=0..
Chapter 6 -- Viewing in 3D 39
The series of transformations that make up The series of transformations that make up NNparpar
is as follows:is as follows: Translate the VRP to the originTranslate the VRP to the origin Rotate VRC such that the Rotate VRC such that the n axisn axis (VPN) becomes the (VPN) becomes the
z axisz axis, the , the u axisu axis becomes the becomes the x axisx axis, and the , and the v axisv axis becomes the becomes the y axisy axis..
Shear such that the direction of projection becomes Shear such that the direction of projection becomes parallel to the parallel to the z axisz axis..
Translate and scale into the parallel-projection Translate and scale into the parallel-projection canonical view volume.canonical view volume.
Chapter 6 -- Viewing in 3D 40
6.2 The Perspective Projection Case
We now develop the normalizing transformation NWe now develop the normalizing transformation Nperper
for perspective projections.for perspective projections.
NNperper transforms world-coordinate positions such that transforms world-coordinate positions such that
the view volume becomes the perspective-projection the view volume becomes the perspective-projection canonical view volume, the truncated pyramid with canonical view volume, the truncated pyramid with the apex at the origin.the apex at the origin.
Then you clip and project using Then you clip and project using MMper per derived in derived in
section 6.5.section 6.5.
Chapter 6 -- Viewing in 3D 41
The series of transformations making up The series of transformations making up NNperper as as
follows:follows: Translate VRP to the originTranslate VRP to the origin Rotate VRC such that the Rotate VRC such that the n axisn axis (VPN) becomes the (VPN) becomes the
z axisz axis, the , the u axisu axis becomes the becomes the x axisx axis, and the , and the v axisv axis becomes the becomes the y axisy axis..
Translate such that the center of projection (COP), Translate such that the center of projection (COP), given by the PRP, is at the origin.given by the PRP, is at the origin.
Shear that the center line of the view volume Shear that the center line of the view volume becomes the becomes the z axisz axis
Scale such that the view volume becomes the Scale such that the view volume becomes the canonical perspective view volume, the truncated canonical perspective view volume, the truncated right pyramid.right pyramid.
Chapter 6 -- Viewing in 3D 42
This figure presents the view volume before This figure presents the view volume before and after the steps just described.and after the steps just described.
Chapter 6 -- Viewing in 3D 43
6.3 Clipping Against a Canonical View Volume in 3D
The canonical view volumes are:The canonical view volumes are: the 2x2x1 prism for parallel projectionsthe 2x2x1 prism for parallel projections the truncated right regular pyramid for perspective the truncated right regular pyramid for perspective
projectionsprojections
Chapter 6 -- Viewing in 3D 44
Both the Cohen-Sutherland and Cyrus-Beck Both the Cohen-Sutherland and Cyrus-Beck clipping algorithms discussed in Chapter 3 clipping algorithms discussed in Chapter 3 readily extend to 3Dreadily extend to 3D
There are also other clipping algorithms that are There are also other clipping algorithms that are based on parametric expressions that can be based on parametric expressions that can be more efficient than the simple Cohen-more efficient than the simple Cohen-Sutherland algorithm (see Chapters 6 and 19 of Sutherland algorithm (see Chapters 6 and 19 of Foley, vanDam, et.al. --the big white book).Foley, vanDam, et.al. --the big white book).
Chapter 6 -- Viewing in 3D 45
6.4 Clipping in Homogeneous Coordinates
There are two reasons to clip in homogeneous There are two reasons to clip in homogeneous coordinates:coordinates: efficiencyefficiency
• translate perspective canonical to parallel canonical and translate perspective canonical to parallel canonical and do a single clip -- Hardware does this.do a single clip -- Hardware does this.
if you get a point with negative W it can be clipped if you get a point with negative W it can be clipped in homogeneous, but not in 3Din homogeneous, but not in 3D
• get negative W’s from unusual homogeneous get negative W’s from unusual homogeneous transformations and from the use of parametric splines.transformations and from the use of parametric splines.
Chapter 6 -- Viewing in 3D 46
With regard to clipping, it can be shown that With regard to clipping, it can be shown that the transformation from the perspective-the transformation from the perspective-projection canonical view volume to the projection canonical view volume to the parallel-projection canonical view volume is:parallel-projection canonical view volume is:
Mz
z
zz
1 0 0 0
0 1 0 0
0 01
1 10 0 1 0
0 1
min
min
min
min,
Chapter 6 -- Viewing in 3D 47
This matrix translates the canonical view volumes This matrix translates the canonical view volumes as shown:as shown:
As we will see in Chapter 9, it is sometimes As we will see in Chapter 9, it is sometimes desirable to represent points directly in desirable to represent points directly in homogeneous coordinates with arbitrary W.homogeneous coordinates with arbitrary W.
Chapter 6 -- Viewing in 3D 48
6.5 Mapping into a Viewport
Output primitives are clipped in the normalized Output primitives are clipped in the normalized projection coordinate system, which is also projection coordinate system, which is also called the 3D screen coordinate systemcalled the 3D screen coordinate system
Chapter 6 -- Viewing in 3D 49
6.6 Implementation Summary
There are two generally used implementations There are two generally used implementations of the overall viewing transformationof the overall viewing transformation The first was discussed in Sections 6.6.1 through The first was discussed in Sections 6.6.1 through
6.6.3 6.6.3 • appropriate when primitives are defined in 3D and the appropriate when primitives are defined in 3D and the
transformations never create a negative W.transformations never create a negative W.
The second was discussed in Section 6.6.4The second was discussed in Section 6.6.4• required whenever primitives are defined and might have required whenever primitives are defined and might have
W<0, when transformations might create a W<0, or a W<0, when transformations might create a W<0, or a single clip algorithm is implemented.single clip algorithm is implemented.
Chapter 6 -- Viewing in 3D 50
7. Coordinate Systems
Several different coordinate systems have been Several different coordinate systems have been used in Chapters 5 and 6. used in Chapters 5 and 6.
In this section we summarize all the systems, In this section we summarize all the systems, and also discuss their relationships to one and also discuss their relationships to one another. another.
Chapter 6 -- Viewing in 3D 51
Object Coordinate SystemObject Coordinate System This is the system farthest removed from the actual This is the system farthest removed from the actual
display device.display device. The term The term local coordinate systemlocal coordinate system is also commonly is also commonly
used hereused here
World Coordinate SystemWorld Coordinate System Objects are transformed into this system by a modeling Objects are transformed into this system by a modeling
transformation.transformation. This system is sometimes called the This system is sometimes called the application-application-
coordinate systemcoordinate system
Chapter 6 -- Viewing in 3D 52
The View-Reference coordinate systemThe View-Reference coordinate system used by some systems to define a view volume.used by some systems to define a view volume. sometimes called the sometimes called the eye-coordinate systemeye-coordinate system or the or the
camera-coordinate systemcamera-coordinate system..
Normalized-Projection coordinate systemNormalized-Projection coordinate system or 3D screen coordinates.or 3D screen coordinates. it is called normalized because the values are in the it is called normalized because the values are in the
interval [0,1] (or [-1,1])interval [0,1] (or [-1,1])
Chapter 6 -- Viewing in 3D 53
The 2D Device coordinate systemThe 2D Device coordinate system projections from 3D into 2D creates this.projections from 3D into 2D creates this. also called many other things: screen coordinate also called many other things: screen coordinate
system,...system,...
Unfortunately there is no single standard usage Unfortunately there is no single standard usage for many of these terms.for many of these terms. for example, the term screen-coordinate system is for example, the term screen-coordinate system is
used by different authors to refer to the last three used by different authors to refer to the last three systems discussed.systems discussed.