2D Viewing - PowerPoint PPT Presentation

1 / 61
About This Presentation
Title:

2D Viewing

Description:

2D Viewing Contents 3D Rendering Pipeline 2D Rendering Pipeline Clipping Cohen-Sutherland Line Clipping Sutherland ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 62
Provided by: 4518
Category:

less

Transcript and Presenter's Notes

Title: 2D Viewing


1
2D Viewing
  • ????? ??? ???? ???

2
Contents
  • 3D Rendering Pipeline
  • 2D Rendering Pipeline
  • Clipping
  • Cohen-Sutherland Line Clipping
  • Sutherland-Hodgeman Polygon Clipping
  • Viewport Transformation
  • Scan Conversion
  • Summary of Transformation

3
3D Rendering Pipeline
3D Primitives
3D Modeling Coordinates
Model Transformation
3D World Coordinates
Lighting
3D World Coordinates
Viewing Transformation
3D Viewing Coordinates
Projection Transformation
2D Projection Coordinates
Clipping
2D Projection Coordinates
Viewport Transformation
2D Device Coordinates
Scan Conversion
2D Device Coordinates
Image
4
3D Rendering Pipeline
3D Primitives
3D Modeling Coordinates
Model Transformation
3D World Coordinates
Lighting
3D World Coordinates
Viewing Transformation
3D Viewing Coordinates
Projection Transformation
2D Projection Coordinates
Clipping
2D Projection Coordinates
Viewport Transformation
2D Device Coordinates
Scan Conversion
2D Device Coordinates
Image
5
2D Rendering Pipeline
3D Primitives
2D Primitives
Clipping
Clip portions of geometric primitives residing
outside window
Viewport Transformation
Transform the clipped primitives from screen to
image coordinates
Scan Conversion
Fill pixel representing primitives in screen
coordinates
Image
6
2D Rendering Pipeline
3D Primitives
2D Primitives
Clipping
Clip portions of geometric primitives residing
outside window
Viewport Transformation
Transform the clipped primitives from screen to
image coordinates
Scan Conversion
Fill pixel representing primitives in screen
coordinates
Image
7
Clipping
  • Avoid Drawing Parts of Primitives Outside Window
  • Window defines part of scene being viewed
  • Must draw geometric primitives only inside window

World Coordinates
8
Clipping
  • Avoid Drawing Parts of Primitives Outside Window
  • Window defines part of scene being viewed
  • Must draw geometric primitives only inside window

9
Clipping
  • Avoid Drawing Parts of Primitives Outside Window
  • Points
  • Lines
  • Polygons
  • Circles
  • etc.

10
Point Clipping
  • Is Point(x,y) Inside the Clip Window?

wy2
Inside (xgtwx1) (xltwx2)
(ygtwy1) (yltwy2)
(x, y)
wy1
wx2
wx1
11
Line Clipping
  • Find the Part of a Line Inside the Clip Window

P7
P1
P4
P8
P3
P2
P6
P10
P9
P5
Before Clipping
12
Line Clipping
  • Find the Part of a Line Inside the Clip Window

P7
P8
P4
P3
P6
P5
After Clipping
13
Cohen-Sutherland Line Clipping
  • Use Simple Tests to Classify Easy Cases First

P7
P1
P4
P8
P3
P2
P6
P10
P9
P5
14
Cohen-Sutherland Line Clipping
  • Classify Some Lines Quickly by AND of Bit Codes
    Representing Regions of Two Endpoints (Must Be 0)

P7
1001
0001
0101
Bit 4
P1
P4
P8
0100
0000
1000
P3
P2
P6
P10
Bit 3
0110
0010
1010
P5
P9
Bit 2
Bit 1
15
Cohen-Sutherland Line Clipping
  • Classify Some Lines Quickly by AND of Bit Codes
    Representing Regions of Two Endpoints (Must Be 0)

P7
1001
0001
0101
Bit 4
P1
P4
P8
0100
0000
1000
P3
P2
P6
P10
Bit 3
0110
0010
1010
P5
P9
Bit 2
Bit 1
16
Cohen-Sutherland Line Clipping
  • Classify Some Lines Quickly by AND of Bit Codes
    Representing Regions of Two Endpoints (Must Be 0)

P7
1001
0001
0101
Bit 4
P4
P8
0100
0000
1000
P3
P6
P10
Bit 3
0110
0010
1010
P5
P9
Bit 2
Bit 1
17
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

P7
1001
0001
0101
Bit 4
P4
P8
0100
0000
1000
P3
P6
P10
Bit 3
0110
0010
1010
P5
P9
Bit 2
Bit 1
18
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

P7
1001
0001
0101
Bit 4
P4
P8
0100
0000
1000
P3
P6
P10
Bit 3
0110
0010
1010
P5
P9
Bit 2
Bit 1
19
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

P7
1001
0001
0101
Bit 4
P4
P8
0100
0000
1000
P3
P6
P10
Bit 3
P5
0110
0010
1010
P9
Bit 2
Bit 1
20
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

P7
1001
0001
0101
Bit 4
P4
P8
0100
0000
1000
P3
P6
P10
Bit 3
P5
0110
0010
1010
P9
Bit 2
Bit 1
21
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

P7
1001
0001
0101
Bit 4
P4
P8
0100
0000
1000
P3
P6
P10
Bit 3
P5
0110
0010
1010
P9
Bit 2
Bit 1
22
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

P7
1001
0001
0101
Bit 4
P4
P8
0100
0000
1000
P3
P6
P10
Bit 3
P5
0110
0010
1010
P9
Bit 2
Bit 1
23
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

1001
0001
0101
P7
Bit 4
P4
P8
0100
0000
1000
P3
P6
P10
Bit 3
P5
0110
0010
1010
P9
Bit 2
Bit 1
24
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

1001
0001
0101
P7
Bit 4
P4
P8
0100
0000
1000
P3
P6
P10
Bit 3
P5
0110
0010
1010
P9
Bit 2
Bit 1
25
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

1001
0001
0101
P7
Bit 4
P8
P4
0100
0000
1000
P3
P6
P10
Bit 3
P5
0110
0010
1010
P9
Bit 2
Bit 1
26
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

1001
0001
0101
P7
Bit 4
P8
P4
0100
0000
1000
P3
P6
P10
Bit 3
P5
0110
0010
1010
P9
Bit 2
Bit 1
27
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

1001
0001
0101
P7
Bit 4
P8
P4
0100
0000
1000
P3
P6
P10
Bit 3
P5
0110
0010
1010
P9
Bit 2
Bit 1
28
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

1001
0001
0101
P7
Bit 4
P8
P4
0100
0000
1000
P3
P6
P10
Bit 3
P5
0110
0010
1010
P9
Bit 2
Bit 1
29
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

1001
0001
0101
P7
Bit 4
P8
P4
0100
0000
1000
P3
P6
P10
Bit 3
P5
P9
0110
0010
1010
Bit 2
Bit 1
30
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

1001
0001
0101
P7
Bit 4
P8
P4
0100
0000
1000
P3
P6
P10
Bit 3
P5
P9
0110
0010
1010
Bit 2
Bit 1
31
Cohen-Sutherland Line Clipping
  • Compute Intersections with Window Boundary for
    Lines That Cant be Classified Quickly

1001
0001
0101
P7
Bit 4
P8
P4
0100
0000
1000
P3
P6
Bit 3
P5
0110
0010
1010
Bit 2
Bit 1
32
Polygon Clipping
  • Find the Part of a Polygon Inside the Clip Window?

Before Clipping
33
Polygon Clipping
  • Find the Part of a Polygon Inside the Clip Window?

After Clipping
34
Sutherland-Hodgeman Polygon Clipping
  • Clip to Each Window Boundary One at a Time

35
Sutherland-Hodgeman Polygon Clipping
  • Clip to Each Window Boundary One at a Time

36
Sutherland-Hodgeman Polygon Clipping
  • Clip to Each Window Boundary One at a Time

37
Sutherland-Hodgeman Polygon Clipping
  • Clip to Each Window Boundary One at a Time

38
Sutherland-Hodgeman Polygon Clipping
  • Clip to Each Window Boundary One at a Time

39
Clipping to a Boundary
  • Do Inside Test for Each Point in Sequence,
  • Insert New Points When Cross Window Boundary,
    Remove Points Outside Window Boundary

P1
P2
Window Boundary
Inside
Outside
P5
P3
P4
40
Clipping to a Boundary
  • Do Inside Test for Each Point in Sequence,
  • Insert New Points When Cross Window Boundary,
    Remove Points Outside Window Boundary

P1
P2
Window Boundary
Inside
Outside
P5
P3
P4
41
Clipping to a Boundary
  • Do Inside Test for Each Point in Sequence,
  • Insert New Points When Cross Window Boundary,
    Remove Points Outside Window Boundary

P1
P2
Window Boundary
Inside
Outside
P5
P3
P4
42
Clipping to a Boundary
  • Do Inside Test for Each Point in Sequence,
  • Insert New Points When Cross Window Boundary,
    Remove Points Outside Window Boundary

P1
P2
Window Boundary
Inside
Outside
P5
P3
P4
43
Clipping to a Boundary
  • Do Inside Test for Each Point in Sequence,
  • Insert New Points When Cross Window Boundary,
    Remove Points Outside Window Boundary

P1
P2
Window Boundary
Inside
P
Outside
P5
P3
P4
44
Clipping to a Boundary
  • Do Inside Test for Each Point in Sequence,
  • Insert New Points When Cross Window Boundary,
    Remove Points Outside Window Boundary

P1
P2
Window Boundary
Inside
P
Outside
P5
P3
P4
45
Clipping to a Boundary
  • Do Inside Test for Each Point in Sequence,
  • Insert New Points When Cross Window Boundary,
    Remove Points Outside Window Boundary

P1
P2
Window Boundary
Inside
P
Outside
P5
P3
P4
46
Clipping to a Boundary
  • Do Inside Test for Each Point in Sequence,
  • Insert New Points When Cross Window Boundary,
    Remove Points Outside Window Boundary

P1
P2
Window Boundary
Inside
P
P
Outside
P5
P3
P4
47
Clipping to a Boundary
  • Do Inside Test for Each Point in Sequence,
  • Insert New Points When Cross Window Boundary,
    Remove Points Outside Window Boundary

P1
P2
Window Boundary
Inside
P
P
Outside
48
2D Rendering Pipeline
3D Primitives
2D Primitives
Clipping
Clip portions of geometric primitives residing
outside window
Viewport Transformation
Transform the clipped primitives from screen to
image coordinates
Scan Conversion
Fill pixel representing primitives in screen
coordinates
Image
49
Viewport Transformation
  • Transform 2D Geometric Primitives from Screen
    Coordinate System (Projection Coordinates) to
    Image Coordinate System (Device Coordinates)

Screen
Image
Viewport
50
Window vs. Viewport
  • Window
  • World-coordinate area selected for display
  • What is to be viewed
  • Viewport
  • Area on the display device to which a window is
    mapped
  • Where it is to be displayed

51
Viewport Transformation
  • Window-to-Viewport Mapping

Window
Viewport
wy2
vy2
(wx, wy)
(vx, vy)
wy1
vy1
wx2
wx1
vx2
vx1
Screen Coordinates
Image Coordinates
vx vx1 (wx wx1) (vx2 vx1) / (wx2
wx1) vy vy1 (wy wy1) (vy2 vy1) / (wy2
wy1)
52
2D Rendering Pipeline
3D Primitives
2D Primitives
Clipping
Clip portions of geometric primitives residing
outside window
Viewport Transformation
Transform the clipped primitives from screen to
image coordinates
Scan Conversion
Fill pixel representing primitives in screen
coordinates
Image
53
Scan Conversion
  • Definition
  • Figure out which pixels to fill
  • Example
  • Filling the inside of a triangle

P1
P2
P3
54
Triangle Scan Conversion
  • Simple Algorithm
  • Color all pixels inside a triangle
  • Inside triangle test
  • A point is inside a triangle if it is in the
    positive halfspace of all three boundary lines

L1
L3
P
L2
55
Triangle Scan Conversion
  • Triangle Sweep-Line Algorithm
  • Take advantage of spatial coherence
  • Compute which pixels are inside using horizontal
    spans
  • Process horizontal spans in scan-line order
  • Take advantage of edge linearity
  • Use edge slopes to update coordinates
    incrementally

dx
dy
56
Polygon Scan Conversion
  • Fill Pixels Inside a Polygon
  • Triangle
  • Quadrilateral
  • Convex
  • Star-Shaped
  • Concave
  • Self-Intersecting
  • Holes

57
Inside Polygon Rule
  • Need Better Test for Points Inside a Polygon
  • Inside triangle test works only for convex
    polygon

Convex Polygon
Concave Polygon
58
Inside Polygon Rule
  • Odd-Parity Rule
  • Any ray from P to infinity crosses odd number of
    edges

Concave
Self-Intersecting
With Holes
59
Polygon Scan Conversion
  • Polygon Line-Sweep Algorithm
  • Incremental algorithm to find spans, and
    determine insideness with odd-parity rule

Triangle
Polygon
60
Polygon Scan Conversion
  • Hardware Scan Conversion
  • Convert everything into Triangles

61
Summary of Transformation
P(x, y, z)
3D Object Coordinates
Modeling Transformation
3D World Coordinates
Viewing Transformation
3D Viewing Coordinates
Projection Transformation
2D Projection Coordinates
Window-to-Viewport Transformation
2D Device Coordinates
P(x, y)
Write a Comment
User Comments (0)
About PowerShow.com