Java程序辅导

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

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
The University of Melbourne
Department of Computer Science and Software Engineering
433-380 Graphics and computation
Lab 3
held in ICT 1.08 (during your normal tutorial time)
To be done in pairs
Aim
The purpose of this laboratory excercise is:
• For you to practice programming in OpenGL and JOGL
• For you to practice viewing transformations in JOGL
• For you to familiarise yourself (if necessary) with the KeyListener and KeyEvent classes (see
http://java.sun.com/j2se/1.3/docs/api/java/awt/event/KeyEvent.html)
The Task
Download and run the Java code from the 380 project resources web page (Lab3.java) under the
directory nehe tutorials. Note the new code fragments.
Your task will be to make the camera rotate around the scene, transcribing an arc through the y-z
plane at a distance of 10 units from the centre. The rate at which the camera “travels” will be
determined by pressing the up key ↑ (clockwise in the plane) and the down key ↓ (anti-clockwise in
the plane). You should also output a message to a JLabel when a key is pressed.
For the viewing transformation, you will need to use the gluLookAt() method of a GLU object.
(You will find the section in the Red Book on Viewing Transformations useful.) You may wish to
familiarise yourself with the Nate Robins Projection tutorial, available from the 380 project resources
web page under the directory nate robins tutorials, specifically, the significance of the “eye”, “center”
and “up” parameters.
There are three different ways you can achieve the circular motion of the camera:
1. Using the code to draw a circle from Lab 2,
2. Using the glRotatef() method, or
3. Using matrix algebra for a rotation about the origin in the y-z plane.
You will need to use both the KeyPressed and KeyTyped methods for keyboard input.
The camera should rotate using a system similar to how the polygons rotated in the earlier labs,
except that a rotation variable should be incremented, rather than a constant. The amount of
increment should be determined by pressing the ↑ key (more positive) and the ↓ key (more negative).
Some message should be displayed when a key is typed. e.g. “A pressed” for ‘A’ etc. You may need
to familiarise yourself with JLabel methods from the Java API above.