1 / 23

On to 3D

On to 3D. Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast. Experiment 6.1. Run circularAnnuluses.cpp , three identical-looking circular annuluses are drawn in three different ways: Upper-left: the black disc overwrites the red disc

Download Presentation

On to 3D

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. On to 3D Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast

  2. Experiment 6.1 • Run circularAnnuluses.cpp, three identical-looking circular annuluses are drawn in three different ways: • Upper-left: the black disc overwrites the red disc • Upper-right: the black disc is draw closer to the viewer • Lower: a true circular annulus. • Interchange the drawing orders of the red and black discs in either of the top two annuluses. • Try to comment out glEnable(GL_DEPTH_TEST);andglDisable(GL_DEPTH_TEST);of the upper-right annulus.

  3. The Depth (z) Buffer • Eliminate prior to rendering parts of objects that are obscured by others. • Hidden surface removal • Depth testing • Visibility determination

  4. Enabling Hidden Surface Removal • glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);in main(). • glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); in the main drawing routine. • glEnable(GL_DEPTH_TEST);andglDisable(GL_DEPTH_TEST);in the main drawing routine.

  5. Experiment 6.2 • Run helix.cpp • x = Rcos(t), • y = Rsin(t), • z = t – 60.0, • -10p£ t £ 10p

  6. Experiment 6.2 • Try to modify helix.cpp, so that the helix spirals up the y-axis, and x-axis. • Modify the code to make the helix to coil more and less round about its axis.

  7. Perspective Projection • Frustum

  8. Frustum • glFrustum (left, right, bottom, top, near, far) ((far/near) left, (far/near) top, -far) ((far/near) right, (far/near) top, -far) ((far/near) left, (far/near) bottom, -far) (left, top, -near) (right, top, -near) ((far/near) right, (far/near) bottom, -far) (left, bottom, -near) (right, bottom, -near) (0,0,0)

  9. Frustum

  10. Experiment 6.3 • Modify helix.cpp, by replacing glOrtho(-50.0, 50.0, -50.0, 50.0, 0.0, 100.0) withglFrustum(-5.0, 5.0, -5.0, 5.0, 5.0, 100.0) • Compute the co-ordinates of the frustum • Try with the y-axis and x-axis versions of the helix • Replace the glfrustum() with • glFrustum(-5.0, 5.0, -5.0, 5.0, 10.0, 100.0) • glFrustum(-5.0, 5.0, -5.0, 5.0, 5.0, 120.0) • glFrustum(-10.0, 10.0, -10.0, 10.0, 10.0, 100.0)

  11. Experiment 6.4 • Run moveSphere.cpp, press left, right, up, and down keys to move the sphere, the space bar to rotate it, and the ‘r’ to reset.

  12. Perspective Distortion

  13. Perspective Distortion

  14. Perspective Distortion

  15. Perspective Distortion

  16. Perspective Distortion

  17. gluPerspective() • gluPerspective(fovy, aspect, near, far) • Calls a utility library routine built on top of glFrustum() • fovy – field of view angle • aspect – aspect ratio (width/height) • near, far – same as in glFrustum()

  18. gluPerspective()

  19. gluPerspective()

  20. Experiment 6.5 • The projection statement of helix.cpp is the sysmetric • glFrustum(-5.0, 5.0, -5.0, 5.0, 5.0, 100.0); • Determine the equivalent gluPerspective() call. • Change the near value to 10.0 as • glFrustum(-5.0, 5.0, -5.0, 5.0, 10.0, 100.0); • Determine the equivalent gluPerspective() call. • Determine the equivalent glFrustum() call of • gluPerspective(60.0, 2.0, 10.0, 100.0); • gluPerspective(60.0, 1.0, 5.0, 100.0);

  21. Experiment 6.6 • Run helix.cpp. • Drag a corner to change its size. • Replace the perspective projection with • gluPerspective(90.0, 1.0, 10.0, 100.0); • Try to change window size • Replace the perspective projection with • gluPerspective(90.0, (float)w/(float)h, 10.0, 100.0); • Try to change window size

  22. Assignment 3 • Draw a red box and a blue pyramid using perspective projection. • Draw a cone and a cylinder using perspective projection. You can freely color your objects. • Draw two lampshades as in the figures. Color them as you like.

  23. Assignment 3 • Note on assignment 3 • Make sure you have your shapes valid triangulation • Allow the user to toggle between the filled rendering and wireframe by pressing the space bar. • Instructions for user interaction should always be output to the main C++ Window and also be written as comments at the top of your program file.

More Related