1 / 14

Viewing and Navigating using OpenGL

Viewing and Navigating using OpenGL. The LookAt Function. The GLU library contains the function gluLookAt to form the required modelview matrix through a simple interface Note the need for setting an up direction Still need to initialize Can concatenate with modeling transformations

tirzah
Download Presentation

Viewing and Navigating using OpenGL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Viewing and Navigatingusing OpenGL

  2. The LookAt Function • The GLU library contains the function gluLookAt to form the required modelview matrix through a simple interface • Note the need for setting an up direction • Still need to initialize • Can concatenate with modeling transformations • Example: isometric view of cube aligned with axes glMatrixMode(GL_MODELVIEW): glLoadIdentity(); gluLookAt(1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0., 1.0. 0.0);

  3. gluLookAt glLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz)

  4. Outside-In Viewing Object is centered. Observer navigates on a sphere surrounding the object.

  5. Inside-Out Viewing Viewer centered. Observer navigates, looks toward a point On the sphere. Sphere center moves with observer.

  6. Inside-Out Viewing Viewer centered. Observer navigates, looks toward a point On the sphere. Sphere center moves with observer.

  7. y x z Some Spherical Geometry (x,y,z) r q f

  8. y x z Viewing: Outside-In (x,y,z) gluLookAt(x,y,z,0,0,0,0,1,0);

  9. Outside In ViewingSample Code glLoadIdentity(); // start with an identity in the MODELVIEW transformation x = radius * cos(theta) * cos(phi); y = radius * sin(theta); z = -radius * cos(theta)* sin(phi); gluLookAt(x,y,z,0,0,0,0,1,0); //multiply viewing component of transformation glutSolidTeapot(1.0); // draw what is being looked at (around origin)

  10. Viewing: Outside In Possible Navigation Key Mapping • GLUT_KEY_LEFT increase phi • GLUT_KEY_RIGHT decrease phi • GLUT_KEY_UP increase theta • GLUT_KEY_DOWN decrease theta • GLUT_KEY_PAGE_UP increase radius • GLUT_KEY_PAGE_DOWN decrease radius

  11. y x z Viewing: Inside Out, from Origin (x,y,z) gluLookAt(0,0,0,x,y,z,0,1,0);

  12. Y’ X’ z’ Viewing: Inside Out, from Arbitrary Point (x,y,z) gluLookAt(x0,y0,z0,x,y,z,0,1,0);

  13. Inside Out ViewingSample Code glLoadIdentity(); // start with an identity in the MODELVIEW transformation x = radius * cos(theta) * cos(phi); y = radius * sin(theta); z = -radius * cos(theta)* sin(phi); gluLookAt(xo,yo,zo,xo+x,yo+y,zo+z,0,1,0); //multiply viewing transformation glutSolidTeapot(1.0);

  14. Viewing: Inside Out Possible Navigation Key Mapping • GLUT_KEY_LEFT increase phi (look left) • GLUT_KEY_RIGHT decrease phi (look right) • GLUT_KEY_UP increase theta (look up) • GLUT_KEY_DOWN decrease theta (look down) • GLUT_KEY_PAGE_UP walk in direction of view • GLUT_KEY_PAGE_DOWN walk away from direction of view

More Related