1 3D modelling with OpenGL Brian Farrimond Robina Hetherington.

Slides:



Advertisements
Similar presentations
Transformations Ed Angel Professor Emeritus of Computer Science
Advertisements

Flash Animation Using Linear Transformations By Kevin Hunter Kevin Hunter Marcus Yu Marcus Yu.
Picture Manipulation The manipulation of (already created) pictures. May be applied to vector graphics or bitmaps. We will consider bitmaps and introduce.
1 Computer Graphics Week6 –Basic Transformations- Translation & Scaling.
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
3-D Geometry.
REFLECTIONS, ROTATIONS AND TRANSLATIONS. Reflections.
OpenGL (II). How to Draw a 3-D object on Screen?
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
1 Computer Graphics Week7 -2D Rotation. 3-Rotation A shape can be rotated about any of the three axes. A rotation about the z-axis will actually rotate.
UNIT - 5 3D transformation and viewing. 3D Point  We will consider points as column vectors. Thus, a typical point with coordinates (x, y, z) is represented.
Mouse-Based Viewing & Navigation Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 3, 2003.
UniS CS297 Graphics with Java and OpenGL Viewing, the model view matrix.
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
Graphics Graphics Korea University kucg.korea.ac.kr Transformations 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Lecture 3 Transformations.
2003CS Hons RW778 Graphics1 Chapter 5: Transforming Objects 5.2 Introduction to Transformations 5.2 Introduction to Transformations –Affine transformations.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Geometric transformations The Pipeline
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
Lecture 11: Exam Revision 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271  Coursework.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Geometric Objects and Transformation
Computer Graphics I, Fall 2010 Computer Viewing.
SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.
10/7/04© University of Wisconsin, CS559 Fall 2004 Last Time Transformations Homogeneous coordinates Directions Rotation Geometry 101 – Points, edges, triangles/polygons.
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.
1 A first OpenGL program Brian Farrimond Robina Hetherington.
Image Synthesis Rabie A. Ramadan, PhD 4. 2 Review Questions Q1: What are the two principal tasks required to create an image of a three-dimensional scene?
More on GLUT Programming Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, September 15, 2003.
Advanced Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 31, 2003.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Lecture 3 Transformations. 2D Object Transformations The functions used for modifying the size, location, and orientation of objects or of the camera.
The Camera Analogy ► Set up your tripod and point the camera at the scene (viewing transformation) ► Arrange the scene to be photographed into the desired.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
CGGM Lab. Tan-Chi Ho 2001 Viewing and Transformation.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Computer Graphics Matrices
Visualization Recreate the ping pong scene in 3D using ball and racket coordinates.
Honors Geometry.  We learned how to set up a polygon / vertex matrix  We learned how to add matrices  We learned how to multiply matrices.
Computer Graphics I, Fall 2010 Transformations.
1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Transformations Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
OpenGL LAB III.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
Computer Graphics Lecture 41 Viewing Using OpenGL Taqdees A. Siddiqi
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
Objectives Introduce standard transformations Introduce standard transformations Derive homogeneous coordinate transformation matrices Derive homogeneous.
- Introduction - Graphics Pipeline
School of Computer Science
Camera Position (5.6) we specify the position and orientation of the camera to determine what will be seen. use gluLookAt (eye x, y, z, at x, y, z, up.
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.
The User Interface Lecture 2 Mon, Aug 27, 2007.
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Projection in 3-D Glenn G. Chappell
Last Time Canonical view pipeline Projection Local Coordinate Space
Preview of 3-D Graphics Glenn G. Chappell
Presentation transcript:

1 3D modelling with OpenGL Brian Farrimond Robina Hetherington

2 A standard 3D OpenGL Program Draws a wire cube Ex02

3 Looking at the wire cube Default position

4 Program overview Drawing the scene Initialising the graphics Program start

5 Program overview What to do when the window is created, resized or moved Response to keyboard presses

6 main

7 Always there

8 main Setting up the window

9 main Initialise the graphics

10 init

11 init Does nothing in this case

12 main Name of the function that will draw the scene

13 main Name of the function that will respond to the keyboard

14 keyboard ASCII code of pressed key ASCII code for Esc key Terminate the program

15 main Name of the function that will be called when the window is created, resized or moved

16 reshape

17 Getting OpenGL to view the wire cube Two separate tasks: –Controlling the camera settings –Positioning the camera and the objects to be photographed Achieved by using matrices Matrix = Mathematical representation of a sequence of operations

18 OpenGL Matrices Controlling the camera settings –PROJECTION MATRIX Positioning the camera and the objects –MODELVIEW MATRIX

19 Ex02 The state of the matrices after the program has drawn the wire cube

20 Using orthographic projection The state of the matrices after the program has drawn the wire cube with orthographic projection

21 reshape Always the same

22 reshape PROJECTION Setting up the camera settings: perspective projection

23 reshape MODELVIEW Getting ready to position the camera and objects

24 Nate Robin’s Tutorial example Projection

25 display Position the camera

26 Where the camera is

27 Where the camera is looking

28 gluLookAt Always the same

29 gluLookAt

30 Changing the camera position gluLookAt(0, 5, 6, 0, 0, 0, 0, 1, 0);

31 display Position the camera Draw the object

32 Interacting with OpenGL

33 Interacting through the keyboard We have already met: Use Esc key to stop the program

34 Ex03 Now look at this … If key ‘a’ is pressed Increase variable g_yeye by 1 Redraw the scene

35 display Camera position stored in three variables

36 Declaring and initialising the camera position

37 Exercise Modify the code so that, in addition, ‘n’ moves the viewer left and ‘m’ moves the viewer right.

38 Using special keys

39 Using special keys GLUT codes for special keys

40 Other special keys

41 Exercise Modify Ex03.cpp to use the arrow keys to move the viewer left, right, up and down.

42 Animation Objects change position and appearance over time In an animation program: Repeat change the position/appearance data redraw the scene Until end of program

43 Example – rotating a cube Ex04 Note the poor quality of the animation

44 Example – rotating a cube If this continually changes then redrawing would visualise the change

45 The matrices Camera settings Camera and object positions

46 Repeatedly calling spin Tells OpenGL to call spin whenever there is nothing else to do

47 Handling the rotation angle Calling this function changes the rotation angle and redraws the scene This sets the initial rotation angle to 0 The rotation angle

48 The overall main function

49 Improving the quality – double buffering The problem –The OpenGL program continually writes new image data into the frame buffer –Before previous version has been fully displayed

50 Improving the quality – double buffering The solution –Two buffers (double buffering) –The OpenGL program writes new image data into one buffer –Digital to Analogue Converter reads from the other buffer –Buffers swapped as DAC prepares to draw another picture

51 Double buffering in OpenGL

52 Transformations Positioning objects in a scene is achieved by combinations of –Translation –Scaling –Rotation

53 Translation This performs a movement: –3 units in the positive x direction, –7 units in the negative y direction and –2 units in the positive z direction

54 Scaling stretches the scene –twofold in the x direction –and leaves the other directions unchanged.

55 Rotation Performs a rotation about an axis defined by a line joining the origin to the point (x, y, z). Rotations are usually made around one of the axes

56 Applying sets of transformations Object vertices can be expressed as column vectors Here is point P with coordinates x, y, z:

57 Applying sets of transformations The extra 1 at the bottom of the column vector enables the all transformations to be represented by 4x4 matrices.

58 Applying sets of transformations A 3D transformation is performed mathematically as a matrix multiplication. Here a transformation by matrix A moves the point P to (x’, y’, z’)

59 Applying sets of transformations We can represent this more neatly as P’ = A.P If another transformation, B, is carried out on P’ we get P’’ P’’ = B.P’ Hence we have: P’’ = B.A.P

60 Applying sets of transformations Modelling transformations are held in the modelview matrix In a sequence of transformations, the modelview matrix is multiplied by the corresponding sequence of 4x4 transformation matrices Order is crucial –A.B is not the same as B.A

61 Example 1 The cube is drawn Wire cube MODELVIEW MATRIX

62 Example 2 The cube is drawn, the cube is scaled Scale / Wire cube MODELVIEW MATRIX

63 Example 3 The cube is drawn, the cube is scaled, the cube is rotated, the cube is translated Translate / Rotate / Scale / Wire cube MODELVIEW MATRIX

64 Example 4 The cube is drawn, the cube is scaled, the cube is translated, the cube is rotated Rotate / Translate / Scale / Wire cube MODELVIEW MATRIX