Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer...
-
Upload
nathaniel-reeves -
Category
Documents
-
view
214 -
download
0
Transcript of Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer...
![Page 1: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/1.jpg)
2
How to …
Establish your position in the scene Position objects within the scene Scale objects Establish a perspective transformation Moving around in OpenGL using a camera
![Page 2: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/2.jpg)
3
Terminology
Use Tnrasformation
Specifies the location of the viewer or camera Viewing
Moves objects around the scene Modeling
Describes the duality of viewing and modeling transformations
ModelView
Clips and sizes the viewing volume Projection
Scales the final output to the window Viewport
![Page 3: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/3.jpg)
4
The Pipeline
![Page 4: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/4.jpg)
5
Eye Coordinates
Viewpoint of the observer They are a virtual fixed coordinate system Used as a common frame of reference
![Page 5: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/5.jpg)
6
Viewing Transformations
Like placing and pointing the camera at the scene To be specified before any other transformation By default, the point of observation is at the
origin, looking down the negative Z-axis.
What about objects drawn with positive Z values?
![Page 6: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/6.jpg)
7
Modeling Transformation
Manipulate the model and the particular objects within it
Move objects into place, rotate them, and scale them
These are the most common modeling transformations
![Page 7: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/7.jpg)
8
Modeling Transformation - the ORDER matters
Final appearance of an object depends greatly on the order of transformations
![Page 8: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/8.jpg)
9
ModelView Duality
In fact, viewing and modeling transformations are the same
Induce the same effects on the final appearance of the scene
The distinctions is made as a convenience for the programmer
![Page 9: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/9.jpg)
10
Projection Transformations
Applied after the modelview transformation
Defines the viewing volume and the clipping planes
Specifies how a finished scene is projected to the screen
![Page 10: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/10.jpg)
11
Orthographic Vs. Perspective
In an Orthographic projection:‐ objects are mapped directly on the 2D screen using
parallel lines‐ No matter how far away something is
In Perspective projection:‐ Scenes are more realistic ‐ Distant objects appear smaller than nearby objects of
the same size‐ Parallel lines in 3D space do not always appear parallel
See Code Example 3
![Page 11: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/11.jpg)
12
The Pipeline - Recall
![Page 12: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/12.jpg)
13
Slow but steady..
Current Matrix is part of the OpenGL state Options are:
GL_MODELVIEW – changes, rotate, translate the model
GL_PROJECTION – changes, translate, rotate the camera
To specify which one is the “Current Matrix” : glMatrixMode(…)
Subsequent matrix operations affect the specified matrix One of this matrices could be change in a given time
![Page 13: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/13.jpg)
14
Translation
void glTranslatef(GLfloat x, GLfloat y, GLfloat z )
This function takes as parameters the amount to
translate along the x, y, and z directions
![Page 14: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/14.jpg)
15
Translation – (cont’)
glTranslate(0.0f, 10.0f, 0.0f)glutWireCube(10.0f)
Construct a translation matrix for positive 10 Y
Multiply it by the modelview matrix
![Page 15: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/15.jpg)
16
Rotation
void glRotatef(Glfloat angle,GLfloat x, GLfloat y, GLfloat z )
This function performs a rotation around the vector specified by the x, y, and z arguments. The angle
of rotation is in the counterclockwise direction.
A rotation around an arbitrary axis could be done.
![Page 16: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/16.jpg)
17
Scaling
void glScalef(GLfloat x, GLfloat y, GLfloat z )
Multiplies the x, y and z values by the scaling factors specified. Scaling does not
have to be uniform.
![Page 17: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/17.jpg)
18
The Identity Matrix
Matrix operations are cumulative Erroneous artifacts may occur to the scene You reset the origin by loading the modelview
matrix with the identity matrix
glTranslate(0.0f, 10.0f, 0.0f);
glutSolidSphere(1.0f);
glTranslatef(10.0f, 0.0f, 0.0f);
glutSolidSphere(1.0f)
![Page 18: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/18.jpg)
19
The Identity Matrix – (cont’)
glMatrixMode(GL_MODELVIEW)glLoadIdentity();
glTranslate(0.0f, 10.0f, 0.0f);
glutSolidSphere(1.0f);
glLoadIdentity();
glTranslatef(10.0f, 0.0f, 0.0f);
glutSolidSphere(1.0f)
![Page 19: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/19.jpg)
20
Matrix stack
Resetting the modelview matrix to identity before placing the every object is not always desirable
To save the current transformation state OpenGL maintains a matrix stack for both the
modelview and projection matrices
glPushMatrix() – push the current state matrix to the stack
glPopMatrix() – pop the top matrix out of the stack, and replace the current state matrix with it
![Page 20: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/20.jpg)
21
Matrix stack – (cont’)
See Code Example 4
![Page 21: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/21.jpg)
22
Viewing Volume
glOrtho(left, right, bottom, top, near, far)
![Page 22: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/22.jpg)
23
Viewing Volume – (cont’)
glFrustum(left, right, bottom, top, near, far)
gluPerspective(GLdouble fov ,GLdouble aspectRatio,GLdouble zNear,GLdouble zFar)
![Page 23: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/23.jpg)
24
Camera Management
gluLookAt(GLdouble eyex, GLdouble eyey, Gldouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz)
![Page 24: Geometric transformations The Pipeline Some slides are based on Shay Shalom slides from TAU Computer Graphics Ben-Gurion University of the Negev Fall 2012.](https://reader030.fdocuments.us/reader030/viewer/2022032708/56649e8a5503460f94b8f925/html5/thumbnails/24.jpg)
25
Buffers
Important aspect of the current state of OpenGL Buffers dimensions are the same as the
window’s dimension Color Buffer – stores the current color for each
pixel Depth Buffer – stores the depth of each pixel of
the scene (Z-Buffer) Accumulation buffer, stencil buffer, etc’ ..
glEnable(GL_DEPTH_TEST) – enables the Z-Buffer in OpenGL. ….. Otherwise?