Download presentation
Presentation is loading. Please wait.
Published byStephany Chapman Modified over 9 years ago
1
1 Basic Modelling
2
2 Lecture Objectives n To understand how 3D scenes can be modelled - in terms of geometry, appearance and behaviour - and rendered on a display n To understand how to deliver interactive animated 3D graphics over the Internet n To be able to create interactive 3D graphics applications using industry standard software (OpenGL and VRML)
3
3 The Basics n MODELLING – representing objects in 3D – transforming objects and composing scenes n VIEWING – projecting 3D scenes onto a 2D display surface n RENDERING – illumination – shading – adding realism via textures, shadows
4
4 Basic Modelling 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
5
5 Viewing n Clipping – selects a volume of interest – Projection – 3D scene is projected onto a 2D plane camera
6
6 Rendering shading: how do we use our knowledge of illumination to shade surfaces in our world? illumination: how is light reflected from surfaces?
7
7 Rendering n texture n shadows
8
8 Internet n VRML – ISO standard for 3D graphics over the Web – allows modelling of geometry, appearance and behaviour
9
9 Advanced Rendering n ADVANCED RENDERING – direct versus global illumination methods – ray tracing and radiosity n OTHER ADVANCED FEATURES – curve and surface modelling – image based rendering – non-photorealistic rendering
10
10 Advanced Rendering n Advanced Rendering - global illumination – ray tracing – radiosity based on physics of radioactive heat transfer between surfaces light eye screen objects
11
11 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.
12
12 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 P1 and P2 are on a plane, then D lies in the plane
13
13 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
14
14 Polygonal Representation n Objects with curved surfaces can be approximated by polygons - improved approximation by more polygons
15
15 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
16
16 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....
17
17 Typical Primitives n Graphics systems such as OpenGL typically support: – triangles, triangle strips and fans – quads, quad strips – polygons n Which way is front? – convention is that normal points towards you if vertices are specified counter- clockwise
18
18 Modelling Regular Objects n Sweeping n Spinning 2D Profile sweep axis spinning axis R1 R2
19
19 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
20
20 Complex Primitives n Some systems such as VRML have cylinders, cones, etc as primitives – polygonal representation calculated automatically n OpenGL has a utility library (GLU) which contains various high-level primitives – again converted to polygons n For conventional graphics hardware: – POLYGONS RULE!
21
21 Automatic Generation of Polygonal Objects n 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
22
22 A Puzzle
23
23 Modelling Objects and Creating Worlds boundary representations n We have seen how boundary representations of simple objects can be created co-ordinate system n Typically each object is created in its own co-ordinate system translationscaling rotation n 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
24
24 Transformations n 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 homogeneous n As in 2D graphics, we use homogeneous co-ordinates in order to express all transformations as matrices and allow them to be combined easily
25
25 Homogeneous Co-ordinates n In homogeneous coordinates, a 3D point P = (x,y,z) T is represented as: P = (x,y,z,1) T n That is, a point in 4D space, with its ‘extra’ co-ordinate equal to 1 n Note n Note: in homogeneous co-ordinates, multiplication by a constant leaves point unchanged – ie (x, y, z, 1) T = (wx, wy, wz, w) T
26
26 Translation n Suppose we want to translate P (x,y,z) T by a distance (Tx, Ty, Tz) T n We express P as (x, y, z, 1) T and form a translation matrix T as below n The translated point is P’ TP x’ y’ z’ 1 P’ = 1 0 0 Tx 0 1 0 Ty 0 0 1 Tz 0 0 0 1 xyz1xyz1 = x + Tx y + Ty z + Tz 1 =
27
27 Scaling relative to the origin n Scaling by Sx, Sy, Sz relative to the origin: x’ y’ z’ 1 Sx 0 0 0 0 Sy 0 0 0 0 Sz 0 0 0 0 1 xyz1xyz1 P’ = SP = = Sx. x Sy. y Sz. z 1
28
28 Rotation with respect to an axis n Rotation is specified with respect to an axis - easiest to start with co-ordinate axes n To rotate about the x-axis: a positive angle corresponds to counter-clockwise direction looking at origin from positive position on axis x’ y’ z’ 1 =1 0 0 0 0 cos -sin 0 0 sin cos 0 0 0 0 1 xyz1xyz1 P’= R z ( ) P
29
29 Composite Transformations n The attraction of homogeneous co-ordinates is that a sequence of transformations may be encapsulated as a single matrix with respect to a fixed position (a,b,c) n 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) n Thus: P’ = T(a,b,c) S T(-a,-b,-c) P = M P
30
30 Rotation about a Specified Axis n It is useful to be able to rotate about any axis in 3D space n This is achieved by composing 7 elementary transformations
31
31 Rotation through about Specified Axis x y z x y z rotate through requ’d angle, x y z x y z P2 P1 x y z P2 P1 x y z initial position translate P1 to origin rotate so that P2 lies on z-axis (2 rotations) rotate axis to orig orientation translate back
32
32 Inverse Transformations n As in this example, it is often useful to calculate the inverse of a transformation – ie the transformation that returns to original state n Translation: T -1 (a, b, c) = T (-a, -b, -c) n Scaling: S -1 ( Sx, Sy, Sz ) = S............ Rotation: R -1 z ( ) = R z (- )
33
33 Viewing - Projections SEN 992 Computer Graphics I
34
34 Viewing n Graphics display devices are 2D rectangular screens n Hence we need to understand how to transform our 3D world to a 2D surface n This involves: observer position – selecting the observer position (or camera position) view plane – selecting the view plane (or camera film plane) projection – selecting the type of projection
35
35 Perspective Projections perspectiveparallel n There are two types of projection: perspective and parallel perspective n In a perspective projection, object positions are projected onto the view plane along lines which converge at the observer P1 P2 P1’ P2’ view plane camera
36
36 Parallel Projection n In a parallel projection, the observer position is at an infinite distance, so the projection lines are parallel P1 P2 view plane
37
37 Perspective and Parallel Projection n Parallel projection preserves the relative proportions of objects, but does not give a realistic view n 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
38
38 Perspective and Parallel Projection perspective parallel
39
39 Viewing Coordinate System viewing co-ordinate system n 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 xVxV yVyV zVzV Camera is positioned at: (0, 0, z C )
40
40 View Plane n We assume the view plane is perpendicular to the viewing direction The view plane is positioned at: (0, 0, z VP ) Let d = z C - z VP be the distance between the camera and the plane xvxv yvyv zvzv
41
41 Perspective Projection Calculation xvxv yvyv zvzv zVzV view plane Q camera yVyV zCzC zQzQ z VP looking along x-axis
42
42 Perspective Projection Calculation zVzV view plane Q camera yVyV P By similar triangles, y P / y Q = (z C - z VP ) / (z C - z Q ) and so y P = y Q * (z C - z VP ) / (z C - z Q ) or y P = y Q * d / (z C - z Q ) zCzC zQzQ z VP x P likewise
43
43 Transformation Matrix for Perspective 1 0 0 0 0 1 0 0 0 0 -z VP /d z VP z C /d 0 0 -1/d z C /d xQyQzQ1xQyQzQ1 xHyHzHwHxHyHzHwH = Then x P = x H / w H ie x P = x H / ( (z C - z Q ) / d ) ie x P = x Q / ( (z C - z Q ) / d ) y P likewise
44
44 Note for Later n 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
45
45 Vanishing Points vanishing point n 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 view plane vanishing point one-point perspective projection of cube
46
46 One- and Two-Point Perspective Drawing
47
47 One-point Perspective Said to be the first painting in perspective This is: Trinity with the Virgin, St John and Donors, by Mastaccio in 1427
48
48 Two-point Perspective Edward Hopper Lighthouse at Two Lights -see www.postershop.com
49
49 Parallel Projection - Two types n Orthographic n Orthographic parallel projection has view plane perpendicular to direction of projection n Oblique n Oblique parallel projection has view plane at an oblique angle to direction of projection P1 P2 view plane P1 P2 view plane orthographic projection We shall only consider orthographic projection
50
50 Parallel Projection Calculation xvxv yvyv zvzv zVzV view plane Q yVyV zQzQ z VP looking along x-axis
51
51 Parallel Projection Calculation zVzV view plane Q yVyV P y P = y Q and similarly x P = x Q
52
52 Parallel Projection Calculation n So this is much easier than perspective! – x P = x Q – y P = y Q – z P = z VP n The transformation matrix is simply 1 0 0 0 0 1 0 0 0 0 z VP /z Q 0 0 0 0 1
53
53 View Volumes - View Window n Type of lens in a camera is one factor which determines how much of the view is captured – wide angle lens captures more than regular lens view window n Analogy in computer graphics is the view window, a rectangle in the view plane xvxv yvyv zvzv view window
54
54 View Volume - Front and Back Planes n We will also typically want to limit the view in the z V direction n We define two planes, each parallel to the view plane, to achieve this – front plane (or near plane) – back plane (or far plane) front plane back plane zVzV
55
55 View Frustum - Perspective Projection view window back plane front plane camera view frustum zVzV
56
56 View Volume - Parallel Projection view window back plane front plane zVzV view volume
57
57 View Volume clipping planes n The front and back planes act as important clipping planes n Can be used to select part of a scene we want to view n Front plane n Front plane important in perspective to remove near objects which will swamp picture
58
58 VRML - An Introduction SEN 992 Computer Graphics I
59
59 Good Ideas are Simple n Realization 1: – Hypertext + Internet = World Wide Web n Realization 2: – Adding images makes pages more interesting n Realization 3: – Images are pictures taken by the publisher - why not send 3D scenes and allow the user to take the picture! n VRML: Virtual Reality Modelling Language – a language to describe 3D worlds - for the Web
60
60 World Wide Web Pages AUTHORING PROCESS HTML file server INTERNET client WEB BROWSER text/ html.html MIME type
61
61 VRML AUTHORING PROCESS VRML file server INTERNET client VRML BROWSER x-world/ x-vrml.wrl Major browser: CosmoPlayer
62
62 Advantages of VRML n Transferring a 3D model - rather than a 2D image - to the browser has great advantages – viewer can choose how to look at the model - or world – viewer can navigate the world – file size can often be much less
63
63 How Did It All Begin? n Original brainwave – Mark Pesce and Tony Parisi - early 1994 – vision of a VR interface to the Web n VRML 1.0 – practical realisation based on Open Inventor (Silicon Graphics toolkit - similar to OpenGL but higher level) – Open Inventor file format PLUS hyperlinks – static, non-interactive worlds – Gavin Bell (SGI) - late 1994
64
64 Where are we now? n VRML97 dynamic – adds object behaviours and interaction to allow creation of dynamic worlds – ISO standard - December 1997 – Gavin Bell, Rikk Carey (ex-SGI) and Chris Marrin (SGI) n 2000 – being reworked as XML (X3D) – many new developments
65
65 A VRML File VRML file consists of: n header n nodes – objects such as cylinders and spheres – operations such as transformations n fields – parameters of nodes #VRML V2.0 utf8 Shape { geometry Cylinder { radius3 height6 }
66
66 As Seen By A Browser #VRML V2.0 utf8 Shape { geometry Cylinder { radius2 height4 }
67
67 Adding Color to the Scene #VRML V2.0 utf8 Shape { geometry Cylinder { radius2 height4 } appearance Appearance { material Material { diffuseColor 1 0 0 specularColor1 1 1 } }
68
68 Co-ordinate Systems n Each node is drawn within its own local co-ordinate system.. x z y
69
69 Modelling Transformations n...and can be subjected to a modelling transformation to scale, rotate, translate n Transform is a VRML node - treated just like an object n It applies to a group of children nodes #VRML V2.0 utf8 Transform{ scale5.0 0.5 1.0 children [ Shape { geometry Cylinder { radius2 height4 } appearance Appearance { material Material { diffuseColor 1 0 0 specularColor1 1 1 } } } ] }
70
70 Hierarchical Structure #VRML V2.0 utf8 Transform{ scale5.0 0.5 1.0 children [ Shape { geometry Cylinder { radius2 height4 } appearance Appearance { material Material { diffuseColor 1 0 0 specularColor1 1 1 } } } ] } TRANSFORM SHAPE parent child
71
71 Hierarchical Structure n This generalises to allow nodes to appear in a hierarchy scene graph n This is known as the VRML scene graph TRANSFORM SHAPE TRANSFORM SHAPE
72
72 Transformations n Here we see Cylinder, Sphere and Cone nodes n Each has been subjected to a modelling transformation in order to position them
73
73 Instances n A node can be given a ‘name’ and then used multiple times - with different transformations applied to each n DEF kwb Shape {...} gives it a name n USE kwb allows it to be included at other points in the scene graph
74
74 Anchors n A piece of geometry can act as a link to another URL
75
75 Textures n Texture mapping: Images can be mapped to geometry to provide texturing n VRML looks like: Shape{ geometry Sphere { } appearance Appearance{ texture ImageTexture{ url “http://..../kwb.gif”}
76
76 Polygonal Surfaces n The general primitive for drawing polygonal surfaces is: – IndexedFaceSet – coord field lists the points – coordIndex describes the polygons Shape{ geometry IndexedFaceSet { coord Coordinate { point [ 17.5 11.2 -1.2, 17.5 15.0 -1.2, … ] } coordIndex [ 0 1 2 3 -1, 4 1 0 5 -1, …] }
77
77 Lights n VRML includes: – DirectionalLight – PointLight – SpotLight n Note # sign is a comment Example: PointLight{ onTRUE intensity0.75 color1 0 0 #red location0 0 0 radius100 }
78
78 Viewing n Specified via the Viewpoint node n VRML file can have a number of Viewpoint nodes - browsers allow a user to jump from one viewpoint to another n Orientation = axis + angle of rotation Example: Viewpoint { position0 0 5 orientation 0 0 1 0.3 description“frontview” }
79
79 Other Basic Features n Inline node – incorporate VRML code from another url compose – this allows us to compose large worlds from many smaller ones n Level of Detail – different geometric representations depending on distance
80
80 Information About VRML n Web3D Consortium – http://www.web3d.org – links to specifications and resources n Web3D Information – http://web3d.about.com/compute/web3d n Leeds University VRML/Java3D Information Centre – http://www.scs.leeds.ac.uk/vrmljava3d n VRML Repository – http://www.sdsc.edu/vrml/
81
81 n Range of books now available – The VRML 2.0 Handbook (Addison Wesley) Jed Hartman and Josie Wernecke http://vrml.sgi.com/handbook – The Annotated VRML Reference Book (Addison Wesley) Rikk Carey and Gavin Bell http://www.best.com/~rikk/Book/ n Tutorials include: – Floppy’s guide: www.vapourtech.com/vrmlguide Books and Tutorials
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.