Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.
-
Upload
edwina-chase -
Category
Documents
-
view
217 -
download
3
Transcript of Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.
![Page 1: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/1.jpg)
Chapter 4
10 February 2004
![Page 2: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/2.jpg)
Agenda
Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids
![Page 3: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/3.jpg)
OpenGL Buffers
Color– can be divided into front and back for
double buffering Alpha Depth Stencil Accumulation
![Page 4: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/4.jpg)
Double Buffering
![Page 5: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/5.jpg)
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.
![Page 6: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/6.jpg)
Depth Buffering
![Page 7: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/7.jpg)
3D Coords --> Raster coords
Transformations Clipping Viewport transformation.
![Page 8: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/8.jpg)
Transformations
Prior to rendering: view, locate and orient– eye / camera position– 3D geometry
Manage the matrices– including the matrix stack
Combine (composite) transformations
![Page 9: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/9.jpg)
Camera Analogy
![Page 10: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/10.jpg)
Stages of Vertex Transformation
![Page 11: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/11.jpg)
Transformations
45-degree counterclockwise rotation about the origin around the z-axis
a translation down the x-axis
![Page 12: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/12.jpg)
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();
![Page 13: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/13.jpg)
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
![Page 14: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/14.jpg)
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.
![Page 15: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/15.jpg)
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.
![Page 16: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/16.jpg)
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
![Page 17: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/17.jpg)
Vectors
1 2 32 + 3 = 53 4 7
![Page 18: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/18.jpg)
Matrices
Rectangular array of numbers A vector in 3 space is a n x 1 matrix or
column vector. Multiplication
1 0 0 00 1 0 0 x 0 0 0 00 0 1/k 1
Cos α 0 sin α 0 0 1 0 m-sin α 0 cos α n 0 0 0 1
131
![Page 19: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/19.jpg)
Matrix Multiplication
A is an n x m matrix with entries aij
B is an m x p matrix with entries bij
AB is an n x p matrix with entries cij
m
cij = ais bsj
s=1
![Page 20: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/20.jpg)
2D Transformations
Translation: Pf = T + Pxf = xo + dx
yf = yo + dy Rotation: Pf = R · P
xf = xo * cos - yo *sin
yf = xo * sin + yo *cos Scale: Pf = S · P
xf = sx * xo
yf = sy * yo
![Page 21: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/21.jpg)
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
![Page 22: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/22.jpg)
Homogeneous Coordinates
1 0 dx x
0 1 dy · y
0 0 1 1
![Page 23: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/23.jpg)
Homogeneous Coordinates
sx 0 0 x
0 sy 0 · y
0 0 1 1
![Page 24: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/24.jpg)
Homogeneous Coordinates
Cos -sin 0 x
sin cos 0 · y
0 0 1 1
![Page 25: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/25.jpg)
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
![Page 26: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/26.jpg)
GLUT Solids
Sphere Cube Cone Torus Dodecahedron Octahedron Tetrahedron Icosahedron Teapot
![Page 27: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/27.jpg)
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).
![Page 28: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/28.jpg)
glutSolidCube and glutWireCube
void glutSolidCube(GLdouble size);
size – length of sides
![Page 29: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/29.jpg)
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.
![Page 30: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/30.jpg)
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.
![Page 31: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/31.jpg)
glutSolidDodecahedron and glutWireDodecahedron
void glutSolidDodecahedron(void);
![Page 32: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/32.jpg)
glutSolidOctahedron and glutWireOctahedron .
void glutSolidOctahedron(void);
![Page 33: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/33.jpg)
glutSolidTetrahedron and glutWireTetrahedron
void glutSolidTetrahedron(void);
![Page 34: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/34.jpg)
glutSolidIcosahedron and glutWireIcosahedron
void glutSolidIcosahedron(void);
![Page 35: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/35.jpg)
glutSolidTeapot and glutWireTeapot
void glutSolidTeapot(GLdouble size);
size - Relative size of the teapot.
![Page 36: Chapter 4 10 February 2004. Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.](https://reader035.fdocuments.in/reader035/viewer/2022062718/56649e795503460f94b78a74/html5/thumbnails/36.jpg)
Homework for next week.
Program 2 due 2/17 Study for Test on Chapters 1-4, 2/19