Presentation is loading. Please wait.

Presentation is loading. Please wait.

On to 3D Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast.

Similar presentations


Presentation on theme: "On to 3D Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast."— 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); and glDisable(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); and glDisable(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, - 10   t  10 

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 glFrustum (left, right, bottom, top, near, far) (0,0,0) (left, top, -near) (right, top, -near) (right, bottom, -near) (left, bottom, -near) ((far/near) left, (far/near) top, -far) ((far/near) right, (far/near) top, -far) ((far/near) right, (far/near) bottom, -far) ((far/near) left, (far/near) bottom, -far)

9 Frustum

10 Experiment 6.3 Modify helix.cpp, by replacing glOrtho(-50.0, 50.0, -50.0, 50.0, 0.0, 100.0) with glFrustum(-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

14

15

16

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

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 1.Draw a red box and a blue pyramid using perspective projection. 2.Draw a cone and a cylinder using perspective projection. You can freely color your objects. 3.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.


Download ppt "On to 3D Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast."

Similar presentations


Ads by Google