Java OpenGL Animation
$100-120 USD
Pago na entrega
Draw an analog clock using JOGL. At minimum, the clock should have a cylinder as the main body and three hands for hour, minute, and second, as shown in the attachment. The cylinder can be drawn with two circles and a set of rectangles (e.g., quad). A circle can be drawn as a set of lines. In other words, you can draw a cylinder with glLines and glQuads.
The clock should the correct time and update every second. You can use the Java FPSAnimator class to update the clock.
You are also required to use the mouse and keyboard to control the movement of the entire clock. Three types of transformations are required: translation, rotation and scale. To implement this function, the glTranslatef, glRotatef, and glScalef functions should be used. The transformation should be controlled by both keyboard and mouse:
? Translate: arrow keys and mouse movement when holding the left mouse button.
? Rotate: mouse movement when holding the right mouse button. glRotatef is defined as rotation around an axis. Only rotation around the x-aix (1, 0, 0) or the y-axis (0,1, 0) is required.
? Scale (zoom in/out): 'i' for zoom in, and 'o' for zoom out. Uniform scale should be used.
? 'r': reset the position and scale of the clock, which should be centered at the screen center (e.g., the origin of the OpenGL coordinate system).
Typically, the program should respond to mouse event to record the starting position of a mouse click, then respond to mouse motion event to obtain the delta x and y since the initial click. The delta values are used to set the amount of translation or rotation. Keep in mind that OpenGL is a state machine. It keeps track of the current transformation matrix.
All the transformation functions mentioned above are multiplied with the current matrix. If you want to keep the current matrix, you can just glPushMatrix (and glPopMatrix) to record a copy in the OpenGL matrix stack, which is usually at least 32 levels deep. See the sample program for
example.
Getting Started:
A skeletal program on the class web page is supplied to get you started. In the skeleton program
a 2D clock is drawn for you. It is also rotating around the y-axis. Uncomment the line with
"OGL_STACK" (there are two lines) and see the difference in the output.
ID do Projeto: #3640572