GR2 Advanced Computer Graphics AGR

Slides:



Advertisements
Similar presentations
OpenGL Computer Graphics
Advertisements

Computer Graphics - Viewing -
Advanced Piloting Cruise Plot.
Chapter 1 The Study of Body Function Image PowerPoint
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
2 pt 3 pt 4 pt 5 pt 1 pt 2 pt 3 pt 4 pt 5 pt 1 pt 2 pt 3 pt 4 pt 5 pt 1 pt 2 pt 3 pt 4 pt 5 pt 1 pt 2 pt 3 pt 4 pt 5 pt 1 pt ShapesPatterns Counting Number.
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Points, Vectors, Lines, Spheres and Matrices
1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 2 Basic Modelling.
1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture.
1GR2-00 GR2 Advanced Computer Graphics AGR Ken Brodlie Lecture 1 - Overview.
GR2 Advanced Computer Graphics AGR
GR2 Advanced Computer Graphics AGR
GR2 Advanced Computer Graphics AGR
15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
GR2 Advanced Computer Graphics AGR
SI23 Introduction to Computer Graphics
GR2 Advanced Computer Graphics AGR
16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
1.1 SI31_2001 SI31 Advanced Computer Graphics AGR Ken Brodlie Lecture 1 - Overview.
9.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture.
8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
13.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 13 An Introduction to Ray Tracing.
VOORBLAD.
Computer Graphics An Introduction. What’s this course all about? 05/10/2014 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
© 2012 National Heart Foundation of Australia. Slide 2.
Graphics Lecture 1: Slide 1 Interactive Computer Graphics Lecturers:Duncan Gillies Daniel Rueckert Tutors:Paul Aljabar.
1Computer Graphics Homogeneous Coordinates & Transformations Lecture 11/12 John Shearer Culture Lab – space 2
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.
Lecture 8 Transparency, Mirroring
Splines I – Curves and Properties
Computer Graphics- SCC 342
25 seconds left…...
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
PSSA Preparation.
Transformations Ed Angel Professor Emeritus of Computer Science
Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
Computer Graphics Lecture 4 Geometry & Transformations.
Technische Universität München Fakultät für Informatik Computer Graphics SS 2014 Transformations Rüdiger Westermann Lehrstuhl für Computer Graphik und.
Graphics Pipeline.
Based on slides created by Edward Angel
3.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 3 Viewing Transformation Getting Started with OpenGL Introduction to Projections.
4.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 4 Projection Clipping Viewport Transformation.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
12.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 12 – 3D Graphics Transformation Pipeline: Projection and Clipping.
UniS CS297 Graphics with Java and OpenGL Viewing, the model view matrix.
UBI 516 Advanced Computer Graphics Three Dimensional Viewing
Advanced Computer Graphics Three Dimensional Viewing
Computer Graphics I, Fall 2010 Computer Viewing.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Three-Dimensional Viewing
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Lecture 7 Midterm Review. OpenGL Libraries gl: Basic OpenGL library, e.g. primitives. glu: OpenGL Utility library, a set of functions to create texture.
Coordinate Systems Lecture 1 Fri, Sep 2, The Coordinate Systems The points we create are transformed through a series of coordinate systems before.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Rendering Pipeline Fall, 2015.
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
Chapter V Vertex Processing
Computer Graphics Computer Viewing
Computer Viewing Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

GR2 Advanced Computer Graphics AGR Lecture 4 Viewing Pipeline Getting Started with OpenGL 1 1

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

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

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

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

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

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

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

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

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 = 1 0 0 -x0 0 1 0 -y0 0 0 1 -z0 0 0 0 1 10 10

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

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 0 0 0 1 where U = (u1 u2 u3 )T etc 12 12

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

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

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

View Frustum - Perspective Projection back plane view frustum view window camera front plane zV 16 16

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

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

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

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

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

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

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

OpenGL - Getting Started

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

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

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

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

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

How to Get Started Look at the GR2/AGR resources page: Points you to: http://www.scs.leeds.ac.uk/kwb/GR2/ resources.html Points you to: example programs information about GLUT information about OpenGL a simple exercise