Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
THE AUSTRALIAN NATIONAL UNIVERSITY 
Final Examinations (Semester 2) 2011 
COMP4610/COMP6461
(Computer Graphics) 
Final Exam
Writing Period: 3 hours duration 
Study Period: 15 minutes duration 
         - you may read text files and pdfs but you are
           not permitted to start answering questions. 
Permitted Materials: A4 page (one sheet) with notes on both sides
Note the standard lab tools are available including: Java, eclipse, 
ooffice, kate, dia, gcc, ...  Also your home directory contains an 
OpenGL command summary.
Please Read The Following Instructions Carefully. 
This exam will be marked out of 100 and consists of 4 questions. Questions are of unequal value. 
The value of each question is shown in square brackets. Questions that are partitioned into parts 
show the number of marks given to each part within square brackets. 
Students should attempt all questions.   Answers must be saved into the question's directory (Q1, 
Q2, Q3, Q4) using the file(s) described in the question statement.  Marks may be lost for giving 
information that is irrelevant. 
Network traffic may be monitored for inappropriate communications between students, or attempts 
to gain access to the Internet. 
1/5
Question 1 - Short Answer [40 marks] 
Highest marks are gained by providing: clear, concise, and short answers. Save your answers in the 
in the file 'Q1Answers.odt' in the directory Q1.  This file can be edited using 'ooffice'.   Please make 
certain that this file is saved both as you progress through the exam and before the exam ends.
i. [4 marks]   State how the screen co-ordinate of a pixel is translated into a memory address in 
the frame buffer.
ii. [4 marks]   Why is it impossible to accurately display the CIE xy chromaticity diagram's 
colour on a RGB monitor?
iii. [4 marks]  Explain one approach for determining if a point is in the interior of a polygon or 
not (assume both the polygon and point are on the same plane).   
iv. [4 marks] Why are homogeneous coordinates so useful in Computer Graphics?  Explain 
how they can be used to create perspective projections. 
v. [4 marks] Provide an example of temporal aliasing.  Give two approaches that could be used 
to help address this problem. 
vi. [4 marks] State two different approaches used for specifying a 3D rotation.  Contrast some 
advantages/disadvantages of these approaches.  
vii. [4 marks] What are the three main steps for radiosity rendering?  What is the 'form factor'? 
How would radiosity and ray-casting often be combined?
viii. [4 marks] The equation for the Phong reflection model is:
I p=ka ia+∑lights (k d(L.N )id+k s(R.V )
α is)
Describe the variables and parameters of this equation.  How would you set up these 
parameters to make an object very shiny?  
ix. [4 marks] What is the distinction between diffuse and ambient lighting?  Why would you 
expect the parameters of the material properties of an object in a scene to be the same for 
both these lighting effects? 
x. [4 marks] What is the relationship between the vertex and fragment shaders in modern 
GPUs?  State an effect that can be achieved by making use of programmable fragment 
shader?
2/5
Question 2 Lab [15 marks]
The Q2 directory contains the 'ScreenSaverOGL.java' and 'ScreenSaverOGL.c'  files.  These are a 
simple screen saver programs.      Copy and rename one of these files for your answer file, call it 
SimplePoly.java (or SimplePoly.c). Save this in the Q2 directory.   
Create a simple polygon that rotates in 3D on it's y-axis. 
Duplicate this polygon 4 times so that the same polygon is rotating simultaneously in 4 different 
places on the screen. In doing this you should use either a method for drawing the shape which you 
call 4 times or by using a display list (i.e. glNewList, glEndList, and glCallList). This will also 
involve using glPushMatrix and glPopMatrix. 
Add a comment in your answer file which gives the commands used to compile and run your code, 
also in this comment add a very brief summary of what you did. 
3/5
Question 3 Lab [15 marks]
The Q3 directory contains  DrawIt.java and DrawArea.java,  these form a simple drawing program. 
Compile and run them ("javac *.java; java DrawIt").   When you drag the mouse around the 
window single pixels will be marked by the dragging action. 
Modify the code such that it draws a continuous line. 
Add menu items (or buttons) that enable you to change the colour and thickness of the lines drawn. 
4/5
Question 4 Lab [30 marks]
Note part marks in these questions may be gained for: partial working solutions; or just a viable 
description of how you would approach such a problem.   Please copy code as needed from either 
the Q2 and Q3 directories.  Do only ONE of the following two options:
A) A painter will use a palette to help mix the colours of paints before they apply the paints to their 
picture.  This often involves moving some paint from two different colours into an unused area of 
the palette and then moving the paint brush around to mix the colours into the desired colour.  This 
paint can then be used for draw the picture.   
Extend the drawing program from Question 3 such that approximately one third of the screen is 
used for a palette and the rest of the screen is used for the 
painting area.   An initial set of unmixed paints can be 
added to the palette,  also a button for cleaning and 
resetting the palette area should be added.  You may also 
wish to add a way of cleaning any residual paint off the 
paint brush. 
A screen shot of the type of program expected is given. 
Note the bottom right corner of the screen is used for the 
'rag' for cleaning the paint brush.  The is achieved by 
dragging on the rag area. 
The README file should contain a description of how 
you modelled the mixing of paint on the palette and also a 
short summary of what you did. 
B)  Using OpenGL create a 3D rolling marble simulation.  Each marble (or billiard ball) is just a 
sphere.  The simulation starts with a large number of stationary marbles.  Another moving marble 
(or more if you like) enters the scene and strikes a marble, which in tern sets others in motion.  The 
simulation should include angled deflections, not just straight continuations.  It should also include 
a 'fan-out' where one marble hits two others.  An example of an initial set up is shown in the 
diagram to the right.
The README file should contain a short summary of what 
you did. 
Hint: A simple way of simulating marbles is to maintain 
position and velocity vectors for each marble.  Let pi  
denote the position and v i  the velocity of marble i .
Position update can be done with:
pi
'=pi+v i
A collision between marbles i and j with:
v i
'=v i−proj( p j−pi)vi+proj( pi− p j)v j
v j
'=v j+proj(p j− pi)v i−proj( pi−p j)v j
where projab=( a .b∣a∣2 )a
5/5