Download presentation

Presentation is loading. Please wait.

1
**GR2 Advanced Computer Graphics AGR**

Lecture 4 Viewing Pipeline Getting Started with OpenGL 1 1

2
**The Story So Far ...Lecture 2**

We have seen how we can model objects, by transforming them from their local co-ordinate representation into a world co-ordinate system modelling co-ordinates world MODELLING TRANSFORMATION 2 2

3
**The Story So Far...Lecture 3**

And we have seen how we can transform from a special viewing co-ordinate system (camera on z-axis pointing along the axis) into a projection co-ordinate system viewing co-ordinates projection PROJECTION TRANSFORMATION 3 3

4
**Completing the Pipeline - Lecture 4**

We now need to fill in the missing part to get world co-ordinates viewing VIEWING TRANSFORMATION mod’g co-ords world view’g proj’n 4 4

5
**Viewing Coordinate System - View Reference Point**

yW In our world co-ordinate system, we need to specify a view reference point - this will become the origin of the view co-ordinate system This can be any convenient point, along the camera direction from the camera position indeed one possibility is the camera position itself P0 xW zW 5 5

6
**Viewing Coordinate System - View Plane Normal**

Next we need to specify the view plane normal, N - this will give the camera direction, or z-axis direction Some graphics systems require you to specify N ... ... others (including OpenGL) allow you to specify a ‘look at’ point, Q, from which N is calculated as direction to the ‘look at’ point from the view reference point yW P0 N xW zW yW P0 Q xW zW 6 6

7
**Viewing Coordinate System - View Up Direction**

Finally we need to specify the view-up direction, V - this will give the y-axis direction V yW P0 N xW zW 7 7

8
**Viewing Co-ordinate System**

This gives us a view reference point P0,and vectors N (corresponding to zV) and V (corresponding to yV) We can construct a vector U perpendicular to both V and N, and this will correspond to the xV axis How? V U yW P0 N xW zW 8 8

9
**Transformation from World to Viewing Co-ordinates**

Given an object with positions defined in world co-ordinates, we need to calculate the transformation to viewing co-ordinates The view reference point must be transformed to the origin, and lines along the U, V, N directions must be transformed to lie along the x, y, z directions 9 9

10
**Transformation from World to Viewing Co-ordinates**

Translate so that P0 lies at the origin V yW U N P0 (x0, y0, z0) xW zW - apply translation by (-x0, -y0, -z0) T = x0 y0 z0 10 10

11
**Transformation from World to Viewing Co-ordinates**

Apply rotations so that the U, V and N axes are aligned with the xW, yW and zW directions This involves three rotations Rx, then Ry, then Rz first rotate around xW to bring N into the xW-zW plane second, rotate around yW to align N with zW third, rotate around zW to align V with yW Composite rotation R = Rz. Ry. Rx 11 11

12
Rotation Matrix Fortunately there is an easy way to calculate R, from U, V and N: R = u1 u2 u3 0 v1 v2 v3 0 n1 n2 n3 0 where U = (u1 u2 u3 )T etc 12 12

13
**Viewing Transformation**

Thus the viewing transformation is: M = R . T This transforms object positions in world co-ordinates to positions in the viewing co-ordinate system.. .. with camera pointing along negative z-axis at a view plane parallel to x-y plane We can then apply the projection transformation 13 13

14
**Viewing Pipeline So Far**

We now should understand this viewing pipeline mod’g co-ords world view’g proj’n 14 14

15
Clipping Next we need to understand how the clipping to the view volume is performed Recall that with perspective projection we defined a view frustum outside of which we wanted to clip points and lines, etc The next slide is from lecture 3 ... 15 15

16
**View Frustum - Perspective Projection**

back plane view frustum view window camera front plane zV 16 16

17
**Clipping to View Frustum**

It is quite easy to clip lines to the front and back planes (just clip in z).. .. but it is difficult to clip to the sides because they are ‘sloping’ planes Instead we carry out the projection first which converts the frustum to a rectangular parallelepiped (ie a cuboid) 17 17

18
**Clipping for Parallel Projection**

In the parallel projection case, the viewing volume is already a rectangular parallelepiped view window back plane front zV view volume 18 18

19
**Normalized Projection Co-ordinates**

Final step before clipping is to normalize the co-ordinates of the rectangular parallelepiped to some standard shape for example, in some systems, it is the cube with limits +1 and -1 in each direction This is just a scale transformation Clipping is then carried out against this standard shape 19 19

20
**Viewing Pipeline So Far**

Our pipeline now looks like: mod’g co-ords world view’g proj’n normalized projection co-ordinates NORMALIZATION TRANSFORMATION 20 20

21
And finally... The last step is to position the picture on the display surface This is done by a viewport transformation where the normalized projection co-ordinates are transformed to display co-ordinates, ie pixels on the screen 21 21

22
**Viewing Pipeline - The End**

A final viewing pipeline is therefore: mod’g co-ords world view’g proj’n normalized projection co-ordinates device co-ordinates DEVICE TRANSFORMATION 22 22

23
Interlude Why does a mirror reflect left-right and not up-down?

24
**OpenGL - Getting Started**

25
What is OpenGL? OpenGL provides a set of routines (API) for advanced 3D graphics derived from Silicon Graphics GL acknowledged industry standard, even on PCs (OpenGL graphics cards available) integrates 3D drawing into X (and other window systems such as Windows NT) draws simple primitives (points, lines, polygons) but NOT complex primitives such as spheres provides control over transformations, lighting, etc Mesa is publically available equivalent 4 4

26
Geometric Primitives Defined by a group of vertices - for example to draw a triangle: glBegin (GL_POLYGON); glVertex3i (0, 0, 0); glVertex3i (0, 1, 0); glVertex3i (1, 0, 1); glEnd(); See Chapter 2 of the OpenGL Programming Guide 5 5

27
**Viewing OpenGL maintains two matrix transformation modes**

MODELVIEW to specify modelling transformations, and transformations to align camera PROJECTION to specify the type of projection (parallel or perspective) and clipping planes See Chapter 3 of OpenGL Programming Guide 6 6

28
**OpenGL Utility Library (GLU)**

Useful set of higher level utility routines to make some tasks easier written in terms of OpenGL and provided with the OpenGL implementation for example, gluLookAt() is a way of specifying the viewing transformation Described within the OpenGL Programming Guide eg gluLookAt() is described in Chap 3, pp19-21 7 7

29
**OpenGL Utility Toolkit (GLUT)**

Set of routines to provide an interface to the underlying windowing system - plus many useful high-level primitives (even a teapot - glutSolidTeapot()!) See Appendix D of OpenGL Guide Allows you to write ‘event driven’ applications you specify call back functions which are executed when an event (eg window resize) occurs 8 8

30
**How to Get Started Look at the GR2/AGR resources page: Points you to:**

resources.html Points you to: example programs information about GLUT information about OpenGL a simple exercise

Similar presentations

OK

Coordinate Systems Lecture 1 Fri, Sep 2, 2005. The Coordinate Systems The points we create are transformed through a series of coordinate systems before.

Coordinate Systems Lecture 1 Fri, Sep 2, 2005. The Coordinate Systems The points we create are transformed through a series of coordinate systems before.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on resistance temperature detector calibration Ppt on dressing etiquettes meaning Ppt on nature and scope of production and operation management Ppt on circles for class 9 free download Pdf to word ppt online Download ppt on obesity Complete ppt on hepatitis b Ppt on conservation of water resources Ppt on bio inspired robotics Ppt on phonetic transcription of words