Download presentation

Presentation is loading. Please wait.

Published byJacob Tucker Modified over 4 years ago

1
10.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 10 – Introduction to 3D Graphics

2
10.2 Si23_03 Course Outline Image Display URL GIMP colour 2D vector graphics URL SVG Viewer lines, areas graphics algorithms interaction VRML viewer 3D Graphics URL surfaces viewing, shading Graphics Programming OpenGL API animation n Graphics programming – Using OpenGL with C, C++

3
10.3 Si23_03 2D Graphics – Picture Description n SVG is a vector graphics description language SVG Viewer

4
10.4 Si23_03 2D Graphics – Programming Approach n For programming graphics, there are a number of APIs, or Application Programming Interfaces n OpenGL is industry standard – Both 2D and 3D User Program calling OpenGL functions OpenGL Library

5
10.5 Si23_03 Objectives for This Part n To understand how 3D scenes can be modelled - in terms of geometry and appearance - and rendered on a display n To be able to program interactive 3D graphics applications using industry standard software (OpenGL)

6
10.6 Si23_03 Lecture Outline - The Basics n MODELLING and VIEWING – representing objects in 3D – transforming objects and composing scenes – specifying the camera viewpoint n PROJECTION – projecting 3D scenes onto a 2D display surface n RENDERING – illumination – shading – adding realism via textures, shadows

7
10.7 Si23_03 Basic Modelling and Viewing x y z objects represented as set of faces - ie polygons- and faces as a set of points scenes composed by scaling, rotating, translating objects to create a 3D world camera Camera position specified, together with its direction of view

8
10.8 Si23_03 Projection n Projection – 3D scene is projected onto a 2D plane camera view plane

9
10.9 Si23_03 A Puzzle

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

11
10.11 Si23_03 Rendering n texture n shadows

12
10.12 Si23_03 Creating 3D Graphics n OpenGL is an API that allows us to program 3D graphics – As well as 2D n VRML is a language that allows us to describe 3D graphics scenes – Cf SVG for 2D

13
10.13 Si23_03 Applications - Computer Games

14
10.14 Si23_03 Applications - Computer- Aided Design n This is Hubble Space Telescope modeled using the BRL-CAD system n Uses CSG modeling and ray tracing for rendering http://ftp.arl.mil/brlcad

15
10.15 Si23_03 Applications - Virtual Reality n Virtual oceanarium built for EXPO in Lisbon n Example taken from Fraunhofer Institute site http://www.igd.fhg.de

16
10.16 Si23_03 Before we begin...mathematics! n 3D Co-ordinate Systems LEFT RIGHT x y z x y z z points awayz 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.

17
10.17 Si23_03 Points and Vectors n We shall write points as column vectors xyzxyz P = Difference of two points gives a direction vector: D = P 2 - P 1 x y z P2P2 P1P1 x y z P Note: If P 1 and P 2 are on a plane, then D lies in the plane

18
10.18 Si23_03 Magnitude of a Vector n The magnitude of a vector V = (v 1,v 2,v 3 ) T is given by: |V| = sqrt(v 1 *v 1 + v 2 *v 2 + v 3 *v 3 ) eg (1,2,3) T has magnitude sqrt(14) n A unit vector has magnitude 1 n A unit vector in the direction of V is V / |V|

19
10.19 Si23_03 Scalar or Dot Product n The scalar product, or dot product, of two vectors U and V is defined as: U.V = u 1 *v 1 + u 2 *v 2 + u 3 *v 3 n It is important in computer graphics because we can show that also: U.V = |U|*|V|*cos where is the angle between U and V This lets us calculate angle as cos = (u 1 *v 1 + u 2 *v 2 + u 3 *v 3 ) / (|U|*|V|)

20
10.20 Si23_03 Diffuse Lighting n Diffuse reflection depends on angle between light direction and surface normal: reflected intensity = light intensity * cosine of angle between light direction and surface normal light normal scalar product lets us calculate cos

21
10.21 Si23_03 Vector or Cross Product n The vector or cross product is defined as: UxV = (u 2 v 3 - u 3 v 2, u 3 v 1 - u 1 v 3, u 1 v 2 - u 2 v 1 ) n We can also show that: UxV = N |U||V| sin where N is unit vector orthogonal to U and V (forming a right handed system) and is angle between U and V n This allows us to find the normal to a plane – cross-product of two directions lying in plane, eg (P 3 - P 2 ), (P 2 -P 1 ), where P 1, P 2, P 3 are three points in the plane

22
10.22 Si23_03 Exercises n Convince yourself that the x-axis is represented by the vector (1,0,0) n What is the unit normal in the direction (2,3,4)? n What is the angle between the vectors (1,1,0) and (1,0,0)? n Which vector is orthogonal to the vectors (1,0,0) and (0,1,0)? n What is the normal to the plane through the points (1,2,3), (3,4,5) and (0,0,0)?

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

24
10.24 Si23_03 Polygonal Representation n Objects with curved surfaces can be approximated by polygons - improved approximation by more polygons

25
10.25 Si23_03 Scene Organisation n Scene = list of objects n Object = list of surfaces n Surface = list of polygons n Polygon = list of vertices scene object surfacespolygons vertices

26
10.26 Si23_03 Polygon Data Structure V1 V2 V3 V4 V5 V8 V7 V6 P1 P2 Object Table Obj1 P1, P2, P3, P4, P5, P6 Object Obj1 Vertex Table V1X1, Y1, Z1 V2X2, Y2, Z2.... Polygon Table P1V1, V2, V3, V4 P2V1, V5, V6, V2.....

27
10.27 Si23_03 Typical Primitives Order of Vertices n Graphics systems such as OpenGL typically support: – triangles, triangle strips and fans – quads, quad strips – polygons n How are vertices ordered? – convention is that vertices are ordered counter- clockwise when looking from outside an object – allows us to distinguish outer and inner faces of a polygon

28
10.28 Si23_03 Complex Primitives n OpenGL has utility libraries (GLU and GLUT) which contain various high-level primitives – Sphere, cone, torus – Polygonal representation constructed automatically n Similarly for VRML n For conventional graphics hardware: – POLYGONS RULE!

29
10.29 Si23_03 Automatic Generation of Polygonal Objects n 3D laser scanners are able to generate computer representations of objects – for successive heights, 2d outline generated as object rotates – contours stitched together into 3D polygonal representation n Cyberware Cyberscanner in Med Physics at LGI able to scan human faces

30
10.30 Si23_03 Modelling Regular Objects n Sweeping n Spinning 2D Profile sweep axis spinning axis R1 R2

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

32
10.32 Si23_03 Exercise and Further Reading n Spinning: – Work out formulae to spin an outline (in the xy plane) about the y-axis n READING: – Hearn and Baker, Chapter 10

Similar presentations

Presentation is loading. Please wait....

OK

Essential Cell Biology

Essential Cell Biology

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google