Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.

Slides:



Advertisements
Similar presentations
OpenGL Computer Graphics
Advertisements

Today Composing transformations 3D Transformations
OPENGL.
3D Game Programming Geometric Transformations
Chapter 4.1 Mathematical Concepts
Viewing and Transformation
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
Drawing 3D Scenes in OpenGL We want to transform objects in order to orient and position them as desired in a 3D scene. OpenGL provides the necessary functions.
2.1 si SI31 Advanced Computer Graphics AGR Lecture 2 Basic Modelling.
1 Lecture 5 Rendering 3D graphical primitives. 2 3D Rendering Example:
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
10/5/04© University of Wisconsin, CS559 Fall 2004 Last Time Compositing Painterly Rendering Intro to 3D Graphics Homework 3 due Oct 12 in class.
CS 4731: Computer Graphics Lecture 9: Introduction to 3D Modeling Emmanuel Agu.
CS 470 Introduction to Computer Graphics Basic 3D in OpenGL.
Geometric Objects and Transformations Chapter 4. Points, Scalars and Vectors  Points - position in space  Scalars - real numbers, complex numbers obey.
3D coordinate systems X Y Z Right-Hand Coordinate System X Y Z Left-Hand Coordinate System OpenGL uses this! Direct3D uses this!
Chapter 4.1 Mathematical Concepts
UniS CS297 Graphics with Java and OpenGL Viewing, the model view matrix.
Transformations Dr. Amy Zhang.
Computer Graphics, KKU. Lecture 131 Transformation and Viewing in OpenGL.
OpenGL Matrices and Transformations Angel, Chapter 3 slides from AW, Red Book, etc. CSCI 6360.
Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin.
2D Transformations.
Lecture Notes: Computer Graphics.
2002 by Jim X. Chen George Mason University Transformation and Viewing.1. Plane Example: J2_0_2DTransform.
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
Transformations With OpenGL Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin.
Stages of Vertex Transformation To specify viewing, modeling, and projection transformations, you construct a 4 × 4 matrix M, which is then multiplied.
Geometric Objects and Transformation
1 Computer Graphics Week9 -3D Geometric Transformation.
Computer Graphics Bing-Yu Chen National Taiwan University.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Viewing CS418 Computer Graphics John C. Hart. Graphics Pipeline Homogeneous Divide Model Coords Model Xform World Coords Viewing Xform Still Clip Coords.
CSE Real Time Rendering Week 5. Slides(Some) Courtesy – E. Angel and D. Shreiner.
Viewing and Transformation. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
CGGM Lab. Tan-Chi Ho 2001 Viewing and Transformation.
OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla.
January 19, y X Z Translations Objects are usually defined relative to their own coordinate system. We can translate points in space to new positions.
CS552: Computer Graphics Lecture 4: 2D Graphics. Recap 2D Graphics Coordinate systems 2D Transformations o Translation o Scaling o Rotation Combining.
Chap 3 Viewing and Transformation
Computer Graphics Matrices
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
Comp 175C - Computer Graphics Dan Hebert Computer Graphics Comp 175 Chapter 4 Instructor: Dan Hebert.
CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008.
1 By Dr. HANY ELSALAMONY.  We have seen how to create models in the 3D world. We discussed transforms in lecture 3, and we have used some transformations.
Homogeneous Coordinates and Matrix Representations Cartesian coordinate (x, y, z) Homogeneous coordinate (x h, y h, z h, h) Usually h = 1. But there are.
Computer Graphics I, Fall 2010 Transformations.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
CS380 LAB II OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
Transformations. Transformations Introduce standard transformations ◦ Rotation ◦ Translation ◦ Scaling ◦ Shear Derive homogeneous coordinate transformation.
Modeling Transformations Mario Costa Sousa University of Calgary CPSC 453, Fall 2001 Mario Costa Sousa University of Calgary CPSC 453, Fall 2001.
Computer Graphics Lecture 42 Viewing Using OpenGL II Taqdees A. Siddiqi
Chapter 8 Three-dimensional Object Representations PART I
Modeling Transformations
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.
Chapter 5.6 Transformations of Objects © 2007, Prentice Hall
2D Transformations with Matrices
LAB 5 Drawing Objects Lab 5 Drawing Objects.
Reference1. [OpenGL course slides by Rasmus Stenholt]
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Computer Graphics, KKU. Lecture 13
Chapters 5/4 part2 understanding transformations working with matrices
LAB 5 Drawing Objects Lab 5 Drawing Objects.
LAB 5 Drawing Objects Lab 5 Drawing Objects.
Geometric Objects and Transformations (II)
Chapter 4 15 March 2006 EventPro Strategies is looking for a part-time programmer (any language) who knows SQL. For more info, contact Ryan Taylor,
Presentation transcript:

Chapter 4 10 February 2004

Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids

OpenGL Buffers Color –can be divided into front and back for double buffering Alpha Depth Stencil Accumulation

Double Buffering

Animating Using Double Buffering Request a double buffered color buffer glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE); Clear color buffer –glClear(GL_COLOR_BUFFER_BIT); Render Scene Request swap of front and back buffers –glutSwapBuffers(); Repeat steps 2-4 for animation.

Depth Buffering

3D Coords --> Raster coords Transformations Clipping Viewport transformation.

Transformations Prior to rendering: view, locate and orient –eye / camera position –3D geometry Manage the matrices –including the matrix stack Combine (composite) transformations

Camera Analogy

Stages of Vertex Transformation

Transformations 45-degree counterclockwise rotation about the origin around the z-axis a translation down the x-axis

Order of transformations transformed vertex is NMLv glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMultMatrixf(N); /* apply transformation N */ glMultMatrixf(M); /* apply transformation M */ glMultMatrixf(L); /* apply transformation L */ glBegin(GL_POINTS); glVertex3f(v); /* draw transformed vertex v */ glEnd();

Translation void glTranslate{fd} (TYPE x, TYPE y, TYPE z); Multiplies the current matrix by a matrix that moves (translates) an object by the given x, y, and z values

Rotation void glRotate{fd}(TYPE angle, TYPE x, TYPE y, TYPE z); Multiplies the current matrix by a matrix that rotates an object in a counterclockwise direction about the ray from the origin through the point (x, y, z). The angle parameter specifies the angle of rotation in degrees.

Scale void glScale{fd} (TYPEx, TYPE y, TYPEz); Multiplies the current matrix by a matrix that stretches, shrinks, or reflects an object along the axes.

Vectors N tuple of real numbers (n = 2 for 2D, n = 3 for 3D) Directed line segment Example –Velocity vector (speed and direction) Operations –Addition –Multiplication by a scalar –Dot product

Vectors =

Matrices Rectangular array of numbers A vector in 3 space is a n x 1 matrix or columnvector. Multiplication x /k 1 Cos α 0 sin α m -sin α 0 cos α n

Matrix Multiplication A is an n x m matrix with entries a ij B is an m x p matrix with entries b ij AB is an n x p matrix with entries c ij m c ij =  a is b sj s=1

2D Transformations Translation: Pf = T + P x f = x o + dx y f = y o + dy Rotation: Pf = R · P x f = x o * cos  - y o *sin  y f = x o * sin  + y o *cos  Scale: Pf = S · P x f = sx * x o y f = sy * y o

Homogeneous Coordinates Want to treat all transforms in a consistent way so they can be combined easily Developed in geometry (‘46 in cambridge) and applied to graphics Add a third coordinate to a point (x, y, w) (x1, y1, w1) is the same point as (x2, y2, w2) if one is a multiple of another Homogenize a point by dividing by w

Homogeneous Coordinates 1 0 dxx 0 1 dy ·y

Homogeneous Coordinates sx 0 0 x 0 sy 0 · y

Homogeneous Coordinates Cos  -sin  0 x sin  cos  0 · y

Combining 2D Transformations Rotate a house about the origin Rotate the house about one of its corners –translate so that a corner of the house is at the origin –rotate the house about the origin –translate so that the corner returns to its original position

GLUT Solids Sphere Cube Cone Torus Dodecahedron Octahedron Tetrahedron Icosahedron Teapot

glutSolidSphere and glutWireSphere void glutSolidSphere(GLdouble radius, GLint slices, GLint stacks); radius - The radius of the sphere. slices - The number of subdivisions around the Z axis (similar to lines of longitude). stacks - The number of subdivisions along the Z axis (similar to lines of latitude).

glutSolidCube and glutWireCube void glutSolidCube(GLdouble size); size – length of sides

glutSolidCone and glutWireCone void glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks); base - The radius of the base of the cone. height - The height of the cone. slices - The number of subdivisions around the Z axis. stacks - The number of subdivisions along the Z axis.

glutSolidTorus and glutWireTorus void glutSolidTorus(GLdouble innerRadius,GLdouble outerRadius, GLint nsides, GLint rings); innerRadius - Inner radius of the torus. outerRadius - Outer radius of the torus. nsides - Number of sides for each radial section. rings - Number of radial divisions for the torus.

glutSolidDodecahedron and glutWireDodecahedron void glutSolidDodecahedron(void);

glutSolidOctahedron and glutWireOctahedron. void glutSolidOctahedron(void);

glutSolidTetrahedron and glutWireTetrahedron void glutSolidTetrahedron(void);

glutSolidIcosahedron and glutWireIcosahedron void glutSolidIcosahedron(void);

glutSolidTeapot and glutWireTeapot void glutSolidTeapot(GLdouble size); size - Relative size of the teapot.

Homework for next week. Program 2 due 2/17 Study for Test on Chapters 1-4, 2/19