CZ2104, Lab 5, due Wednesday, 18 October 2000

 

This set of exercises is again for 3D graphics. Part 1 and 2 are compulsory (100 marks). Part 3 is optional and will give you extra 20 marks of bonus.

 

[Best viewed by IE5 or Word]

 

Questions:

 

 

Comments, hints, and what to hand in:

 

Part 1

 

In Lab 4, you have programmed the temple with wire frame.

Modify your last lab such that program can display either wire frame or filled polygons via command-line option. That is, if you start your program as

 

a.out

 

it will use filled polygons, each face of your polygon will be drawn in different color of your choice. However, if you run your program as

 

a.out w

 

the program will draw as wire frame, using the same color as for the filled polygons.

 

[Also re-organize your program, so that it is clean and concise.]

1.: hand in the code. Your code should be carefully commented. Also keep your soft copy in your directory for TA to inspect. Same for Part 2.

 

You need to use the argc, argv[] information in the main(). Changing between wire frame and filled polygon shall be done by calling a OpenGL function. Look at the OpenGL document or example programs to find out which function to use.

 

 

 

Part 2

 

Continue with the resulting program in Part 1, develop an interactive viewing of the temple, with the perspective projection, as follows:

(a)   Let the camera always look at the origin (0,0,0), and with up direction in (0,0,1). Using the keys x,y,z and X,Y,Z to position the location of the camera interactively. Press key x will decrease the x value by a small delta; press key X will increase the x value by a small delta, and similarly for y and z value of the position of the camera.

 

(b)   Find a way to change the position of the look-at point of the camera interactively.

 

(c)   Dislay the current camera position (x,y,z) and the look at point (x,y,z) at the upper right corner of your graphics.

 

 

 

 

 

Study the example program A.5 Moving Viewer (1st ed).

 

Use the functions gluLookAt(.), glFrustum(..), or gluPerspective().

 

 

 

 

Using keys or mouse.

 

This part is challenging. See the Paint Program for some hint.

 

 

 

 

 

Part 3

 

Extra bonus, switch between orthographic projection and perspective projection with a command line switch

 

a.out p

 

(dedault to orthographic projection). User should be able to use your program in any of the fellowing ways:

 

a.out (default filled polygons, orthographic projection)

a.out w (wire frame, orthographic projection)

a.out p (filled polygons, perspective projections)

a.out p w, or a.out w p (wire frame with perspective projection).

 

a.out h (display a help menu for using your program).

 

 

 

 

Part 4 (extra programming for fun only, on credit)

 

Do texture mapping and adding lighting effect to the temple.

You may have to modify your object rendering, e.g., adding the norm of a surface.

 

 

 

 

 

 

 

 

Note that a.out can be replaced by a name of your choice of your program.