CG Homework 1 - Navigation in 2D

Due

Homework Due: 30/3/98

Implement

Implement an interactive navigator in 2D according to the following specifications:

  1. The program is invoked with two file names. The first file contains the 2D world in which the navigation is conducted. The second file contains the viewing and screen parameters.
    The format of these files is as follows (the // indicate explanatory comments not in the file; words between underscores appear as they are):

    scene file (ending with .scn):
    n // n is the number of vertices (integer)
    v0x v0y // vertex coordinates (real numbers)
    ...
    v(n-1)x v(n-1)y
    m // m is the number of edges (integer)
    e01 e02 // vertex numbers (integers)
    ...
    e(m-1)1 e(m-1)2

    view file (ending with .viw):
    _Origin_ ox oy // coordinates of center of window (real numbers)
    _Direction_ a // angle of window in degrees from the positive x (real)
    _Size_ ww wh // width and height of window (real numbers)
    _Resolution_ vw vh // width and height of viewport in pixels (integers)

    Programs that will not handle the formats correctly will not be graded.
    Example input files: example.scn , example.viw .

  2. The program opens a viewport of size (vw+40,vh+40) and displays the 2D world in a sub-window of size (vw,vh) centered in the screen window. The rectangle bounding the sub-window must be shown. Edges of objects in the scene should appear clipped to the sub-window.
    Note: There's no need to display vertices that appear in the vertex list, but are not endpoints of an edge.

  3. The entire screen window of size (w,h) is virtually divided into nine areas. The user navigates through the world by dragging the left mouse button:
    Translation: dragging in the middle area causes the world to translate in the dragging direction.
    Scale (actually, zoom in and zoom out): by dragging the area above, below, right and left of the middle area. Motion towards the middle is interpreted as zoom out; motion from the middle is interpreted as zoom in.
    Rotation: dragging in one of the four corner areas rotates the world. At each instance, compute the angle between the line from the origin to current position of the mouse and the line from the origin to the position where the dragging started, and rotate the world by that angle.
    The selected operation should not change while the user drags the mouse.

  4. Clicking "c" and "o" on the keyboard turns clipping on and off, respectively.

  5. Clicking "r" on the keyboard resets the view to its original position.

  6. Clicking "q" on the keyboard terminates the program.

  7. You should create interesting scene files and submit them with your program.

  8. Use a clear, well modularized programming style. Provide a short documentation for each module.

How To

To implement the program use the graphix library gax.c (and associated include file gax.h) which can be found here . You will also find a makefile and demo.c file.
For PC users: Windows version of the gax library can be downloaded as an archive: gsxw.zip .
DOS version of the gax library can be downloaded as an archive: gsx_pc.zip .
Read me files are included in these archives.

Submit

The exercise should be submitted by March 30. All the files should be in a directory ~you/graphics/ex1. The directory should also contain a README file saying who are the people submitting the exercise, which files are there, and document any modifications you have made to the specification.
E-mail the README file + the name of the directory containing the source and run files to: BODEK

We are aware of the fact that this specification may be incomplete. If you have any questions or problems, e-mail them to the TA, and stay tuned to future modifications and corrections.