1 / 85

Computer Graphics I

Computer Graphics I. Basic Modelling. Lecture Objectives. To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered on a display To understand how to deliver interactive animated 3D graphics over the Internet

iolaj
Télécharger la présentation

Computer Graphics I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Graphics I Basic Modelling

  2. Lecture Objectives • To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered on a display • To understand how to deliver interactive animated 3D graphics over the Internet • To be able to create interactive 3D graphics applications using industry standard software (OpenGL and VRML)

  3. The Basics • MODELLING • representing objects in 3D • transforming objects and composing scenes • VIEWING • projecting 3D scenes onto a 2D display surface • RENDERING • illumination • shading • adding realism via textures, shadows

  4. Basic Modelling y objects represented as set of faces - ie polygons- and faces as a set of points x z scenes composed by scaling, rotating, translating objects to create a 3D world

  5. Viewing • Clipping • selects a volume of interest • Projection • 3D scene is projected onto a 2D plane camera

  6. Rendering illumination: how is light reflected from surfaces? shading: how do we use our knowledge of illumination to shade surfaces in our world?

  7. Rendering • texture • shadows

  8. Internet • VRML • ISO standard for 3D graphics over the Web • allows modelling of geometry, appearance and behaviour

  9. Advanced Rendering • ADVANCED RENDERING • direct versus global illumination methods • ray tracing and radiosity • OTHER ADVANCED FEATURES • curve and surface modelling • image based rendering • non-photorealistic rendering

  10. eye screen Advanced Rendering • Advanced Rendering - global illumination • ray tracing • radiosity based on physics of radioactive heat transfer between surfaces objects light

  11. Ray Tracing

  12. Radiosity

  13. Before we begin...mathematics! • 3D Co-ordinate Systems y y z x x z LEFT RIGHT z points away z points toward Align thumb with x, first finger with y, then second finger of appropriate hand gives z direction. Common now to use a RIGHT HANDED system.

  14. Points and Vectors • We shall write points as column vectors y P P = x y z x z Difference of two points gives a direction vector: D = P2 - P1 y P2 Note: If P1 and P2 are on a plane, then D lies in the plane x z P1

  15. Polygonal Representation • Any 3D object can be represented as a set of plane, polygonal surfaces V7 V6 V8 V5 V3 V2 V4 V1 Note:each vertex part of several polygons

  16. Polygonal Representation • Objects with curved surfaces can be approximated by polygons - improved approximation by more polygons

  17. Scene Organisation • Scene = list of objects • Object = list of surfaces • Surface = list of polygons • Polygon = list of vertices scene vertices object surfaces polygons

  18. Polygon Table Vertex Table V1 X1, Y1, Z1 P1 V1, V2, V3, V4 V2 X2, Y2, Z2 P2 V1, V5, V6, V2 . ... . ... Polygon Data Structure V7 V6 Object Obj1 V5 V8 V3 V2 P2 V4 V1 P1 Object Table Obj1 P1, P2, P3, P4, P5, P6

  19. Typical Primitives • Graphics systems such as OpenGL typically support: • triangles, triangle strips and fans • quads, quad strips • polygons • Which way is front? • convention is that normal points towards you if vertices are specified counter-clockwise

  20. Modelling Regular Objects • Sweeping • Spinning sweep axis 2D Profile R1 R2 spinning axis

  21. Sweeping a Circle to Generate a Cylinder as Polygons V12 V13 V11 V18 V3 V10 V4 V14 V2 V17 V15 V5 V1 vertices at z=depth V16 V6 V8 V7 V9 vertices at z=0 V1[x] = R; V1[y] = 0; V1[z] = 0 V2[x] = R cos ; V2[y] = R sin ; V2[z] = 0 (q=p/4) Vk[x] = R cos k; Vk[y] = R sin k; Vk[z] = 0 where k = 2 p (k - 1 )/8, k=1,2,..8

  22. Complex Primitives • Some systems such as VRML have cylinders, cones, etc as primitives • polygonal representation calculated automatically • OpenGL has a utility library (GLU) which contains various high-level primitives • again converted to polygons • For conventional graphics hardware: • POLYGONS RULE!

  23. Automatic Generation of Polygonal Objects • 3D scanners - or laser rangers - are able to generate computer representations of objects • object sits on rotating table • contour outline generated for a given height • scanner moves up a level and next contour created • successive contours stitched together to give polygonal representation

  24. A Puzzle

  25. Modelling Objects and Creating Worlds • We have seen how boundary representations of simple objects can be created • Typically each object is created in its own co-ordinate system • To create a world, we need to understand how to transform objects so as to place them in the right place - translation, at the right size - scaling, in the right orientation- rotation

  26. Transformations • The basic linear transformations are: • translation: P = P + T, where T is translation vector • scaling: P’ = S P, where S is a scaling matrix • rotation: P’ = R P, where R is a rotation matrix • As in 2D graphics, we use homogeneous co-ordinates in order to express all transformations as matrices and allow them to be combined easily

  27. Homogeneous Co-ordinates • In homogeneous coordinates, a 3D point P = (x,y,z)T is represented as: P = (x,y,z,1)T • That is, a point in 4D space, with its ‘extra’ co-ordinate equal to 1 • Note: in homogeneous co-ordinates, multiplication by a constant leaves point unchanged • ie (x, y, z, 1)T = (wx, wy, wz, w)T

  28. Translation • Suppose we want to translate P (x,y,z)T by a distance (Tx, Ty, Tz)T • We express P as (x, y, z, 1)T and form a translation matrix T as below • The translated point is P’ x y z 1 = x’ y’ z’ 1 1 0 0 Tx 0 1 0 Ty 0 0 1 Tz 0 0 0 1 = x + Tx y + Ty z + Tz 1 = T P P’

  29. = x’ y’ z’ 1 Sx 0 0 0 0 Sy 0 0 0 0 Sz 0 0 0 0 1 x y z 1 P’ S P = Scaling • Scaling by Sx, Sy, Sz relative to the origin: = Sx . x Sy . y Sz . z 1

  30. x’ y’ z’ 1 = 1 0 0 0 0 cos -sin 0 0 sin cos 0 0 0 0 1 x y z 1 P’ = Rz () P Rotation • Rotation is specified with respect to an axis - easiest to start with co-ordinate axes • To rotate about the x-axis: a positive angle corresponds to counter-clockwise direction looking at origin from positive position on axis

  31. Composite Transformations • The attraction of homogeneous co-ordinates is that a sequence of transformations may be encapsulated as a single matrix • For example, scaling with respect to a fixed position (a,b,c) can be achieved by: • translate fixed point to origin- say, T(-a,-b,-c) • scale- S • translate fixed point back to its starting position- T(a,b,c) • Thus: P’ = T(a,b,c) S T(-a,-b,-c) P = M P

  32. Rotation about a Specified Axis • It is useful to be able to rotate about any axis in 3D space • This is achieved by composing 7 elementary transformations

  33. y x z rotate so that P2 lies on z-axis (2 rotations) translate P1 to origin initial position y x z rotate axis to orig orientation translate back Rotation through  about Specified Axis y y P2 P1 x x z z y y P2 P1 x x z z rotate through requ’d angle, 

  34. Inverse Transformations • As in this example, it is often useful to calculate the inverse of a transformation • ie the transformation that returns to original state • Translation: T-1 (a, b, c) = T (-a, -b, -c) • Scaling: S-1 ( Sx, Sy, Sz ) = S ............ • Rotation: R-1z () = Rz (-)

  35. Computer Graphics I Viewing - Projections

  36. Viewing • Graphics display devices are 2D rectangular screens • Hence we need to understand how to transform our 3D world to a 2D surface • This involves: • selecting the observer position (or camera position) • selecting the view plane (or camera film plane) • selecting the type of projection

  37. Perspective Projections • There are two types of projection: perspective and parallel • In a perspective projection, object positions are projected onto the view plane along lines which converge at the observer P1 P1’ camera P2 P2’ view plane

  38. Parallel Projection • In a parallel projection, the observer position is at an infinite distance, so the projection lines are parallel P1 P2 view plane

  39. Perspective and Parallel Projection • Parallel projection preserves the relative proportions of objects, but does not give a realistic view • Perspective projection gives realistic views, but does not preserve proportions • Projections of distant objects are smaller than projections of objects of the same size which are closer to the view plane

  40. Perspective and Parallel Projection parallel perspective

  41. Puzzle

  42. Another Example

  43. yV xV zV Viewing Coordinate System • Viewing is easier if we work in a viewing co-ordinate system, where the observer or camera position is on the z-axis, looking along the negative z-direction Camera is positioned at: (0 , 0, zC)

  44. yv xv zv View Plane • We assume the view plane is perpendicular to the viewing direction The view plane is positioned at: (0, 0, zVP) Let d = zC - zVP be the distance between the camera and the plane

  45. yv Q xv yV camera zv zV view plane Perspective Projection Calculation zQ zVP zC looking along x-axis

  46. Q yV camera zV view plane Perspective Projection Calculation P zQ zVP zC By similar triangles, yP / yQ = (zC - zVP) / (zC - zQ) and so yP = yQ * (zC - zVP) / (zC - zQ) or yP = yQ * d / (zC - zQ) xP likewise

  47. Transformation Matrix for Perspective xQ yQ zQ 1 xH yH zH wH = 1 0 0 0 0 1 0 0 0 0 -zVP/d zVPzC/d 0 0 -1/d zC/d Then xP = xH / wH ie xP = xH / ( (zC - zQ) / d ) ie xP = xQ / ( (zC - zQ) / d ) yP likewise

  48. Note for Later • The original z co-ordinate of points is retained • we need relative depth in the scene in order to sort out which faces are visible to the camera

  49. Vanishing Points • When a 3D object is projected onto a view plane using perspective, parallel lines in object NOT parallel to the view plane converge to a vanishing point vanishing point one-point perspective projection of cube view plane

  50. One- and Two-Point Perspective Drawing

More Related