CSE 694A: Lab 1
Due Oct. 1

LAB 1: Implement a rotating cube that's rotating around a central axis


PRELIMINARY NOTES
ASSIGNMENT

The basic task is to write a program to rotate a cube around one of its own axes as it rotates around the y-axis (in three dimensions).

The animation part of this lab is trivial. This lab is mainly intended to get everybody to organize a simulation system and associated support routines that they can use in future labs and to make sure everyone has the programming and OpenGL skills necessary for the class.

For the viewer (camera/observer/eye position) implement a polar coordinate view specification with initial parameters corresponding to the observer along the positive z-axis, 10 units from the origin looking at the origin. Use polar coordinates of (a,b) where a is the rotation around the x-axis and b is the rotation around the y-axis.

Set up a couple of light sources at, for example, (0,10,-10) and (-10,-10,5).

Rotate a cube (+/- 0.5, +/- 0.5, +/- 0.5) around the y-axis displaced 5 units away from the axis.

Represent the y-axis by a cuboid (+/- 0.5, +/- 10.0, +/- 0.5)


SOFTWARE

For the labs in this class, there will 3 types of files:

  1. Control:
    1. Once written, this procedure can be used in each of the labs to follow will either minimal or no change.
    2. 'main()' sets up interactive OpenGL view environment: camera, lights, calling the simulation routines below. Calls 'init()'
    3. includes interaction handling routines to handle:
      1. mouse (left): mouse up-down, right-left -> polar coordinats of camera
      2. mouse (middle): mouse up and down -> zoom-in and zoom-out
      3. buttons or key strokes:
        • reset simulation parameters,
        • reset view parameters: handled in the Control program,
        • stop/start simulation: toggles between calling 'run()' and 'render()',
        • step simulation: put in 'stop()' mode and call 'step()'.
  2. Simulation - the lab-specific algorithm to be implemented. The actual algorithm will obviously change from lab to lab, but each will have the same interface to the main routine. The simulation routine should support the following functions callable by Main:
    1. init() - initializes the simulation (allocates memory, sets up data structures, initializes parameters)
    2. reset() - resets the simulation to start over (reinitializes parameters and data structure values)
    3. run() - advance the simulation and render. It may be the case for some simulations that not every call to this will update the world-space data.
    4. step() - (optional) advance the simulation until a new render is needed and then renders. This differs from run only when there are more one iteration per render; useful for debugging.
    5. render() - render the simulation system (without taking any steps)
  3. Support - making these separate files is optional, but it will facilitate reuse in other labs
    Classes of utility routines:
    1. Drawing geometry such as cubes and prisms. For this lab you only need 'draw_cube()', but later on 'draw_tetrahedron()' and others will be useful.
    2. Setting material properties (e.g., set_material("bluePlastic")')
    3. Performing vector, matrix and quaternion operations - For this lab, you don't need any other than what's provided by OpenGL. In any case, you don't have to write your own if you have access to some other matrix/vector library (although it's not that hard to do and it's not a bad exercise to do).

OpenGL Commands

These are the OpenGL commands that I used. I make no claims about these being the only commands to use or the best commands to use or even that you need to use all of them. They are simply the ones I used.