CS计算机代考程序代写 CITY UNIVERSITY OF HONG KONG ______________________________________________________________________________

CITY UNIVERSITY OF HONG KONG ______________________________________________________________________________
Course code & title Session
Time allowed
: EE 5808 Topics for Computer Graphics : Semester B 2020/21 Quiz 2
: 65 minutes
: Answers should be hand written and submitted as a pdf. Copy the following on the first page of your test answer sheet.
“I pledge that the answers in this examination are my own and that I will not seek or obtain an unfair advantage in producing these answers. Specifically,
1. I will not plagiarize (copy without citation) from any source;
2. I will not communicate or attempt to communicate with any other person during the
examination; neither will I give or attempt to give assistance to another student taking the
examination; and
3. I will use only approved devices (e.g., calculators) and/or approved device models.
4. I understand that any act of academic dishonesty can lead to disciplinary action.”
Name _________________ SID _____________ Signature ________________
Qn 1 (25 marks)
Instructions ______________________________________________________________________________
a) If it is desired to simulate accelerate-then-decelerate motion using an empirical function, what is the form of the function and the angle range?
b) 𝛼𝛼 is the angle of a part in your object. You wish to change 𝛼𝛼 from 40𝑜𝑜 to 160𝑜𝑜 in an accelerate-then-decelerate motion in 3 seconds. Write the corresponding glutIdle function. Use the empirical function in a) to simulate the motion.
1

Qn 2 (25 marks)
a) Draw a green ground plane whose 4 corners are (-150, -150, 2), (150, -150, 2), (150, 150, 2) and (-150, 150, 2). The ground plane has equation 𝑍𝑍 = 2. Write the function ground_plane ( ) which draws the plane.
b) Draw a blue cube of length 10 sitting on the ground plane with center (0, 0, 7). Write the function cube ( ) which draws the cube.
c) Write OpenGL code to draw the ground plane, the cube and its shadow on the ground plane. The point light source is at (10, 20, 30). Also, show the derivation of the projection matrix.
b) Name the type of the projection in a).
c) List two limitations for the shadow generated in Qn 2.
Qn 3 (25 marks)
a) In Qn 2, if the light source is changed to a lighting direction (−1, 1, 2√2), what should be the 4 × 4 projection matrix.
(Qn 4 on the next page)
2

Qn 4 (25 marks)
An OpenGL scene has the following settings for shading calculations:
glEnable (GL_LIGHTING);
GLdouble V1 [ ] = {0.0, -1.0/sqrt(2), 1.0/sqrt(2), 0.0} GLdouble V2 [ ] = {0.2, 0.2, 0.2, 1.0}
GLdouble V3 [ ] = {0.8, 0.8, 0.8, 1.0}
GLdouble V4 [ ] = {0.8, 0.8, 0.8, 1.0}
glLightfv (GL_LIGHT1, GL_POSITION, V1); glEnable (GL_LIGHT1);
glLightfv (GL_LIGHT1, GL_AMBIENT, V2); glLightfv (GL_LIGHT1, GL_DIFFUSE, V3); glLightfv (GL_LIGHT1, GL_SPECULAR, V4);
GLdouble V5 [ ] = {0.1, 0.1, 0.1, 1.0}
GLdouble V6 [ ] = {0.8, 0.8, 0.8, 1.0}
GLdouble V7 [ ] = {0.1, 0.1, 0.1, 1.0}
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT, V5); glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, V6); glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, V7); glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 2.0)
a) Compute the result of back face detection at the point of the plane the camera is pointing at. b) Derive the intensity at the point of the plane the camera is pointing at.
— END —
gluLookAt (100, 100, 100, 0, 0, 0, 0, 1, 0);
A plane 𝑍𝑍 = 0 has the following material characteristics:
3