Computer-Graphics Lab 7 Solved

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

1. Write a program that draws a color-changing cube.

  1. Set the window title to your student ID and the window size to (480,480).
  2. Start from the code in 7-Lighting&Shading slides. Draw a flat-shaded cube. Make sure camera manipulation shortcuts ‘1’, ‘3’, ‘2’, ‘w’ work.
  3. Use the following light setting:

lightPos = (3.,4.,5.,1.)

glLightfv(GL_LIGHT0, GL_POSITION, lightPos)

ambientLightColor = (.1,.1,.1,1.)

glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLightColor)

specularObjectColor = (1.,1.,1.,1.)

glMaterialfv(GL_FRONT, GL_SPECULAR, specularObjectColor)

glMaterialfv(GL_FRONT, GL_SHININESS, 10)

D. If you press or repeat a key, the diffuse & specular color of the light and the ambient & diffuse color of the object should be changed as shown in the Table:

Key

A S

D F Z

X C V

E. Files to submit: A Python source file (Name the file whatever you want (in English). Extension should be .py)

2. Write a program that draws a smooth-shaded cube.

  1. Set the window title to your student ID and the window size to (480,480).
  2. Start from the code in 7-Lighting&Shading slides. Make sure camera manipulation shortcuts ‘1’, ‘3’, ‘2’, ‘w’ work.
  3. Use glDrawElements(), not glDrawArray(). Refer the code in 6-Viewing&projection2, Mesh slides.

i. Hint: In Gouraud shading, one vertex has only one normal. This makes using glDrawElements() easier.

D. Use the following normal vector data:

Action

Change the light color to red

Change the light color to green

Change the light color to blue

Change the light color to white

Change the object color to red

Change the object color to green

Change the object color to blue

Change the object color to white

  1. If you press or repeat a key, the ambient & diffuse color of the object should be changed as shown in the Table:

    Key

    R G

    B

  2. Expected result: Uploaded LabAssignment7-2.mp4
  3. Files to submit: A Python source file (Name the file whatever you want (in English). Extension should be .py)
  • LabAssignment7-6z4lb9.zip