Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

**Scribd will begin operating the SlideShare business on December 1, 2020**
As of this date, Scribd will manage your SlideShare account and any content you may have on SlideShare, and Scribd's General Terms of Use and Privacy Policy will apply. If you wish to opt out, please close your SlideShare account. Learn more.

Successfully reported this slideshow.

Like this presentation? Why not share!

- CS 354 Transformation, Clipping, an... by Mark Kilgard 4575 views
- Projection Matrices by Syed Zaid Irshad 1188 views
- Homogeneous coordinate by Bed Dhakal 2331 views
- 3D transformation by Aditya Rawat 5456 views
- Secrets of CryENGINE 3 Graphics Tec... by Tiago Sousa 36521 views
- 2 d transformations and homogeneous... by Tarun Gehlot 9960 views

3,616 views

Published on

OpenGL Transformation

No Downloads

Total views

3,616

On SlideShare

0

From Embeds

0

Number of Embeds

216

Shares

0

Downloads

0

Comments

5

Likes

2

No embeds

No notes for slide

- 1. OpenGL Transformation http://www.learncax.com/ Centre for Computational TechnologiesCCTech Recruitment Brochure Simulation is The Future!
- 2. Outline1. Transformation2. Viewing Transformation3. Projection Matrix4. OpenGL Transformation Pipeline Centre for Computational Technologies OpenGL Simulation is The Future!
- 3. Geometric Objects and Operations• Primitive types: scalars, vectors, points• Primitive operations: dot product, cross product• Representations: coordinate systems, frames• Implementations: matrices, homogeneous coor.• Transformations: rotation, scaling, translation• Composition of transformations• OpenGL transformation matrices Centre for Computational Technologies OpenGL Simulation is The Future!
- 4. Current Transformation Matrix• Model-view matrix (usually affine)• Projection matrix (usually not affine)• Manipulated separately glMatrixMode (GL_MODELVIEW); glMatrixMode (GL_PROJECTION); Centre for Computational Technologies OpenGL Simulation is The Future!
- 5. Manipulating the Current Matrix• Load or postmultiply glLoadIdentity(); glLoadMatrixf(*m); glMultMatrixf(*m);• Library functions to compute matrices glTranslatef (dx, dy, dz); glRotatef (angle, vx, vy, vz); glScalef (sx, sy, sz);• Recall: last transformation is applied first! Centre for Computational Technologies OpenGL Simulation is The Future!
- 6. Transformation Matrices in OpenGL• Transformation matrices in OpenGl are vectors of 16 values (column-major matrices) m = {m1, m2, ..., m16} represents• In glLoadMatrixf(GLfloat *m);• Some books transpose all matrices! Centre for Computational Technologies OpenGL Simulation is The Future!
- 7. Camera in Modeling Coordinates• Camera position is identified with a frame• Either move and rotate the objects• Or move and rotate the camera• Initially, pointing in negative z-direction• Initially, camera at origin Centre for Computational Technologies OpenGL Simulation is The Future!
- 8. Moving Camera and World Frame• Move world frame relative to camera frame• glTranslatef(0.0, 0.0, -d); moves world frame Centre for Computational Technologies OpenGL Simulation is The Future!
- 9. Order of Viewing Transformations• Think of moving the world frame• Viewing transfn. is inverse of object transfn.• Order opposite to object transformationsglMatrixMode(GL_MODELVIEW);glLoadIdentity();glTranslatef(0.0, 0.0, -d); /*T*/glRotatef(-90.0, 0.0, 1.0, 0.0); /*R*/ Centre for Computational Technologies OpenGL Simulation is The Future!
- 10. Viewing Functions• Roll (about z), pitch (about x), yaw (about y) Centre for Computational Technologies OpenGL Simulation is The Future!
- 11. Outline1. Transformation2. Viewing Transformation3. Projection Matrix4. OpenGL Transformation Pipeline Centre for Computational Technologies OpenGL Simulation is The Future!
- 12. Viewing and Projection• In OpenGL we distinguish between: – Viewing: placing the camera – Projection: describing the viewing frustum of the camera (and thereby the projection transformation) – Perspective divide: computing homogeneous points Centre for Computational Technologies OpenGL Simulation is The Future!
- 13. OpenGL Transformations• The viewing transformation V transforms a point from world space to eye space: Centre for Computational Technologies OpenGL Simulation is The Future!
- 14. Placing the Camera• It is most natural to position the camera in world space as if it were a real camera• Identify the eye point where the camera is located• Identify the look-at point that we wish to appear in the center of our view• Identify an up-vector vector that we wish to be oriented upwards in our final image Centre for Computational Technologies OpenGL Simulation is The Future!
- 15. Look-At Positioning• We specify the view frame using the look-at vector a and the camera up vector up• The vector a points in the negative viewing direction• In 3D, we need a third vector that is perpendicular to both up and a to specify the view frame Centre for Computational Technologies OpenGL Simulation is The Future!
- 16. Constructing a Frame• The cross product between the up and the look-at vector a will get a vector that points to the right.• Finally, using the vector a and the vector r we can synthesize a new vector u in the up direction: Centre for Computational Technologies OpenGL Simulation is The Future!
- 17. gluLookAt()• OpenGL provides a very helpful utility function that implements the look-at viewing specification: gluLookAt ( eyex, eyey, eyez, // eye point atx, aty, atz, // lookat point upx, upy, upz ); // up vector• These parameters are expressed in world coordinates Centre for Computational Technologies OpenGL Simulation is The Future!
- 18. Outline1. Transformation2. Viewing Transformation3. Projection Matrix4. OpenGL Transformation Pipeline Centre for Computational Technologies OpenGL Simulation is The Future!
- 19. OpenGL Transformations• The projection transformation P transforms a point from eye space to clip space: Centre for Computational Technologies OpenGL Simulation is The Future!
- 20. Projection Transformations• Projections fall into two categories: – Parallel projections: Lines of projection are parallel to each other – Perspective projections: Lines of projection converge at a point Centre for Computational Technologies OpenGL Simulation is The Future!
- 21. Parallel Projections• The simplest form of parallel projection is simply along lines parallel to the z-axis onto the xy-plane• This form of projection is called orthographic Centre for Computational Technologies OpenGL Simulation is The Future!
- 22. Orthographic Frustum• The user specifies the orthographic viewing frustum by specifying minimum and maximum x/y coordinates• It is necessary to indicate a range of distances along the z- axis by specifying near and far planes Centre for Computational Technologies OpenGL Simulation is The Future!
- 23. Orthographic Projection in OpenGL• This matrix is constructed with the following OpenGL call: glOrtho(left, right, bottom, top, near, far);• And the 2D version (another GL utility function): gluOrtho2D(left, right, bottom, top); – Just a call to glOrtho() with near = -1 and far = +1 Centre for Computational Technologies OpenGL Simulation is The Future!
- 24. Properties of Parallel Projections• Not realistic looking• Good for exact measurements• A kind of affine transformation – Parallel lines remain parallel – Ratios are preserved – Angles (in general) not preserved• Most often used in CAD, architectural drawings, etc., where taking exact measurement is important Centre for Computational Technologies OpenGL Simulation is The Future!
- 25. Isometric Games• A special kind of parallel projection called isometric projection is often used in games• It’s essentially a shear and an orthographic projection• Easier to compute than a full perspective transformation Centre for Computational Technologies OpenGL Simulation is The Future!
- 26. Perspective Projections• Artists (Donatello, Brunelleschi, and Da Vinci) during the renaissance discovered the importance of perspective for making images appear realistic• Parallel lines intersect at a point Centre for Computational Technologies OpenGL Simulation is The Future!
- 27. Perspective Viewing Frustum• Just as in the orthographic case, we specify a perspective viewing frustum• Values for left, right, top, and bottom are specified at the near depth Centre for Computational Technologies OpenGL Simulation is The Future!
- 28. Perspective Viewing Frustum• OpenGL provides a function to set up this perspective transformation: glFrustum(left, right, bottom, top, near, far);• There is also a simpler OpenGL utility function: gluPerspective(fov, aspect, near, far); – fov = vertical field of view in degrees – aspect = image width / height at near depth• Can only specify symmetric viewing frustums where the viewing window is centered around the –z axis. Centre for Computational Technologies OpenGL Simulation is The Future!
- 29. gluPerspective()• Here are the parameters of gluPerspective() Centre for Computational Technologies OpenGL Simulation is The Future!
- 30. Properties of Perspective Projections• The perspective projection is an example of a projective transformation• Here are some properties of projective transformations: – Lines map to lines – Parallel lines do not necessarily remain parallel – Ratios are not preserved• One of the advantages of perspective projection is that size varies inversely with distance – looks realistic• A disadvantage is that we cant judge distances as exactly as we can with parallel projections Centre for Computational Technologies OpenGL Simulation is The Future!
- 31. Outline1. Transformation2. Viewing Transformation3. Projection Matrix4. OpenGL Transformation Pipeline Centre for Computational Technologies OpenGL Simulation is The Future!
- 32. OpenGL Transformations• The rest of the OpenGL transformation pipeline: Centre for Computational Technologies OpenGL Simulation is The Future!
- 33. Clipping & Perspective Division• The scenes objects are clipped against the clip space bounding box• This step eliminates any objects (and pieces of objects) that are not visible in the image• Hill describes an efficient clipping algorithm for homogeneous clip space• Perspective division divides all homogeneous coordinates through w• Clip space becomes Normalized Device Coordinate (NDC) space after the perspective division Centre for Computational Technologies OpenGL Simulation is The Future!
- 34. Viewport Transformation• OpenGL provides a function to set up the viewport transformation: glViewport(x, y, width, height); Centre for Computational Technologies OpenGL Simulation is The Future!
- 35. Screen Coordinate Systems Centre for Computational TechnologiesOpenGL Simulation is The Future!
- 36. 3D Graphics Pipeline• The rasterization step scan converts the object into pixels Centre for Computational Technologies OpenGL Simulation is The Future!
- 37. 3D Graphics Pipeline• A z-buffer depth test resolves visibility of the objects on a per-pixel basis and writes the pixels to the frame buffer Centre for Computational Technologies OpenGL Simulation is The Future!
- 38. Thank You Mail Us @ sandip@cctech.co.in Visit Us @ www.cctech.co.in @ www.learncax.com Call Us @ +91 20 4009 8381/82 Centre for Computational Technologies Pvt. Ltd. 1, Akshay Residancy, 50 Anand Park, Aundh, Pune -7 Centre for Computational TechnologiesOpenGL Simulation is The Future!

No public clipboards found for this slide

Login to see the comments