1 / 18

CD2012 Principles of Interactive Graphics Lecture 03

CD2012 Principles of Interactive Graphics Lecture 03. Transforms Abir Hussain www.cms.livjm.ac.uk/cmsahus1. Previous Lecture. Some definitions for computer graphics Vertex and ways of drawing vertex glVertex2i() glVertex3f() Representing colours glColor3f(0.0, 0.0, 0.0);

Download Presentation

CD2012 Principles of Interactive Graphics Lecture 03

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. CD2012Principles of Interactive GraphicsLecture 03 Transforms Abir Hussain www.cms.livjm.ac.uk/cmsahus1

  2. Previous Lecture • Some definitions for computer graphics • Vertex and ways of drawing vertex • glVertex2i() • glVertex3f() • Representing colours • glColor3f(0.0, 0.0, 0.0); • glClear(GL_COLOR_BUFFER_BIT ); • Graphics content CD2012-03

  3. Today’s lecture and lab CD2012-03

  4. Introduction • The transformation process for viewing the desired scene is analogous to taking pictures using camera. • In this case, the following operation is required: • Pointing the camera to the desired scene (viewing transformation). • Arrange the scene in the desired position (modelling transformation). • Select the zoom (projection transformation) • Selecting how large the final scene (viewport transformation) CD2012-03

  5. Introduction • To Specify viewing, modelling and projection transformations, • it is required to construct a 44 matrix • The matrix is multiplied by the coordinate of each vertex in the scene to perform the transformation. CD2012-03

  6. What is transformation?

  7. Transformation • Once a picture or a diagram is constructed • it is usually required to modify it in some systematic way. • As an example, it may be required to enlarge or rotate around some point. • This is known as transformation. • There are three typed of transformations • are translation, rotation and scaling. • In this lecture, we will cover the three of them. CD2012-03

  8. Translation • A point in the (x, y, z) plane can be translated into new position • adding translation amounts to the coordinates of the points. • In OpenGL, this can be performed using • glTranslated(x,y,z) to change the current drawing location. CD2012-03

  9. Translation glTranslated(10.0, 10.0, 0); glRecti(0,0, 15, 10); CD2012-03

  10. Scaling • To scale an object, every coordinate is multiplied by the appropriate scaling factor. • The purpose of such operation is to enlarge or reduce the size of an object. • Using glScaled(x,y,z) in OpenGL, we can change the size of an object. • Where the sizes are multiplied in the relevant directions by x, y and z CD2012-03

  11. Scaling glScaled(2.0, 2.0, 0); glRecti(0,0, 15, 10); CD2012-03

  12. Rotation • The mathematical calculation for rotation is more complex than scaling and translation • In OpenGL, we can also rotate objects about the axes x, y and z with the function • glRotated(angle, x, y, z); CD2012-03

  13. Rotation glRotated( 45.0, 0.0, 0.0, 1.0); glRecti(0,0, 30,20) CD2012-03

  14. Combining transformation • Successive transforms are cumulative. • Each translation, rotation and scaling will work relative to the last transformation function we used. • This is because of the 44 transform matrix which is part of the current graphics context. • The transform matrix is used to re-calculate how the current drawing operation will be translated, rotated and/or scaled CD2012-03

  15. Combining transformation • We can reset the 4x4 matrix back to the origin values by calling glLoadIdentity(). • The function initialises the current projection matrix so that only the specified projection transformation has en effect. • The glMatrixMode() function can be called with the GL_MODELVIEW • indicates that successive transformations affect the modelling matrix and not the projection matrix. CD2012-03

  16. Lab • Continue with last week’s lab. • Perform three transformations: • translation, scaling and rotation. CD2012-03

  17. Lab • Perform three transformations: translation, scaling and rotation. CD2012-03

  18. Summary • Transforms • Translation • glTranslated(x, y, z) • Scaling • glScaled(x, y, z) • Rotation • glRotated(angle, x, y, z) • Combining transformations CD2012-03

More Related