Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Jinxiang Chai CSCE 441 Computer Graphics. 2 Midterm Time: 10:10pm-11:20pm, 10/20 Location: HRBB 113.

Similar presentations


Presentation on theme: "1 Jinxiang Chai CSCE 441 Computer Graphics. 2 Midterm Time: 10:10pm-11:20pm, 10/20 Location: HRBB 113."— Presentation transcript:

1 1 Jinxiang Chai CSCE 441 Computer Graphics

2 2 Midterm Time: 10:10pm-11:20pm, 10/20 Location: HRBB 113

3 3 What you’ve learned in this class? 2D Graphics  Drawing lines, polygons  Color 3D Graphics  Transformations Hidden surface removals

4 4 Scan Line Conversion How to draw a line? - Digital Differential Analyzer (DDA) - Midpoint algorithm - Understand both algorithms - Strengths and limitations

5 5 Scan Conversion of Polygons How to draw a polygons? - Active edge list - Boundary fill - Flood fill - Understand three algorithms - Limitations and strengths

6 6 Clipping Lines

7 7

8 8 Given a line with end-points (x 0, y 0 ), (x 1, y 1 ) and clipping window (x min, y min ), (x max, y max ), determine if line should be drawn and clipped end-points of line to draw. (x 0, y 0 ) (x 1, y 1 ) (x min, y min ) (x max, y max )

9 9 Line Clipping How to clip a line? - Simple line clipping algorithm - Cohen--Sutherland - Liang-Barsky

10 10 Clipping Polygons Clipping polygons is more complex than clipping the individual lines  - Input: polygon

11 11 Clipping Polygons Clipping polygons is more complex than clipping the individual lines  - Input: polygon  - Output: original polygon, new polygon, or nothing

12 12 Polygon Clipping How to clip a polygon? - Sutherland-Hodgman Clipping (convex polygons) - Weiler-Atherton Algorithm (general polygons)

13 13 2D/3D Transformation Various transform matrices - 2D/3D rotation - 2D/3D translation - 2D/3D scaling - 2D affine transform

14 14 Arbitrary Rotation Center To rotate about an arbitrary point P (px,py) by  : (px,py)

15 15 Arbitrary Rotation Center To rotate about an arbitrary point P (px,py) by  :  Translate the object so that P will coincide with the origin: T(-px, -py) (px,py)

16 16 Arbitrary Rotation Center To rotate about an arbitrary point P (px,py) by  :  Translate the object so that P will coincide with the origin: T(-px, -py)  Rotate the object: R(  ) (px,py)

17 17 Arbitrary Rotation Center To rotate about an arbitrary point P (px,py) by  :  Translate the object so that P will coincide with the origin: T(-px, -py)  Rotate the object: R(  )  Translate the object back: T(px,py) (px,py)

18 18 Translate the object so that P will coincide with the origin: T(-px, -py) Rotate the object: R(  ) Translate the object back: T(px,py) Put in matrix form: T(px,py) R(  ) T(-px, -py) * P x’ 1 0 px cos(  ) -sin(  ) 0 1 0 -px x y’ = 0 1 py sin(  ) cos(  ) 0 0 1 -py y 1 0 0 1 0 0 1 0 0 1 1 Arbitrary Rotation Center

19 19 The standard scaling matrix will only anchor at (0,0) Sx 0 0 0 Sy 0 0 0 1 What if I want to scale about an arbitrary pivot point? Scaling Revisit

20 20 2D/3D Coordinate Transformation Various transform matrix - 2D/3D rotation - 2D/3D translation - 2D/3D scaling - 2D affine transform How to do 2D/3D matrix composition

21 21 2D Coordinate Transformation Transform object description from to p 21

22 22 2D Coordinate Transformation 2D translation p 1 0 0 1 22

23 23 2D Coordinate Transformation 2D translation&rotation p 23

24 24 2D Coordinate Transformation 2D translation & scaling p 24

25 25 Hierarchical Modeling: Lamp What’s the current coordinate A ? 25 How to do opengl implementation?

26 26 A More Complex Example: Human Figure How to do opengl implementation?

27 27 Image space 3D->2D Geometry Pipeline 27 Normalized project space View space World spaceObject space Aspect ratio & resolution Focal length Rotate and translate the camera

28 28 3D Geometry Pipeline Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 28 Model space (Object space)

29 29 3D Geometry Pipeline Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 29 World space (Object space)

30 30 3D Geometry Pipeline Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 30 Eye space (View space)

31 31 Camera Coordinate 31

32 32 3D Coordinate Trans. Transform object description from camera to world 32

33 33 Viewing Trans: gluLookAt 33 gluLookAt (eye x,eye y,eye z,at x,at y,at z,up x, up y,up z )

34 34 Mapping from world to eye coordinates Viewing Trans: gluLookAt How to determine ? gluLookAt (eye x,eye y,eye z,at x,at y,at z,up x, up y,up z )

35 35 Mapping from world to eye coordinates Viewing Trans: gluLookAt gluLookAt (eye x,eye y,eye z,at x,at y,at z,up x, up y,up z )

36 36 Mapping from world to eye coordinates Viewing Trans: gluLookAt gluLookAt (eye x,eye y,eye z,at x,at y,at z,up x, up y,up z )

37 37 Mapping from world to eye coordinates Viewing Trans: gluLookAt H&B equation (7-1) gluLookAt (eye x,eye y,eye z,at x,at y,at z,up x, up y,up z )

38 38 3D Geometry Pipeline Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 38 Normalized projection space

39 39 Consider the projection of a point on the camera plane 3D->2D 39 By similar triangles, we can compute how much the x and y coordinates are scaled

40 40 Now we can rewrite the perspective projection equation as matrix-vector multiplications The Perspective Matrix 40 After the division by w, we have

41 41 Projections Parallel projection - definition - properties Perspective projection - definition - homogeneous coordinates - vanishing point - properties

42 42 3D Geometry Pipeline Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 42 Image space, window space, raster space, screen space, device space

43 43 Scan conversion 3D Rendering pipeline Modeling transformation lighting Viewing transformation Project transformation Clipping Image Transform into 3D world system Illuminate according to lighting and reflectance Transform into 3D camera coordinate system Transform into 2D camera system Clip primitives outside camera’s view Draw pixels (includes texturing, hidden surface, etc.)

44 44 Hidden Surface Removals Backface Culling Painter’s algorithm BSP Z-buffer Scan line Ray casting

45 45 5-2 2 7-2 For Example, BSP Tree 12 3 4 6 5-1 3 7-1 4 6 1 7-2 7-1 5-2 5-1 Traversal order? 1->6->(5-2)->(7-2)->3->4->(5-1)->(7-1)->2 b b bf f f b b

46 46 Color Understanding chromaticity diagram and its concept Understanding various color models: - RGB - CMY/CMYK - YUV/YIQ - HSV - XYZ, etc.

47 47 Chromaticity Diagram How to obtain chromaticity diagram? Where are spectral colors and non- spectral colors located? How to determine purity/saturation and dominant wave length/hues for a given color? How to identify complementary colors? How to compare color gamuts for different primaries? Why three primary colors are not sufficient to represent all colors? Image taken from http://fourier.eng.hmc.edu/e180/handouts /color1/node27.html

48 48 What you’ve learned in this class? 2D Graphics  Drawing lines, polygons Color 3D Graphics  Transformations


Download ppt "1 Jinxiang Chai CSCE 441 Computer Graphics. 2 Midterm Time: 10:10pm-11:20pm, 10/20 Location: HRBB 113."

Similar presentations


Ads by Google