Assignment 01 (Due Sept. 22, 2024)
Computer Graphics
Assignment 01
DUE DATE: Sept. 22, 2024
Purpose:
  • Practice in
    • 2-dimensional window to viewport mapping
 Task:
 
Using the provided template, create a Graphical User Interface (GUI) with two buttons: "Browse" and "Draw." The program should be able to read data from an input file and display it on the viewport.
 
"Browse" Button: Opens a file dialog, allowing the user to select a text file. Once selected, the program automatically reads the data and parameters from the file. The data should not be displayed at this stage.
 
"Draw" Button: Displays the loaded data on the viewport.
 
Text File Structure:
Each line in the input file represents either a vertex, a face, or a viewing parameter. These are defined as follows:
Vertices:
v <x1> <y1> <z1>  //Defines a vertex at coordinates (x1, y1, z1)
v <x2> <y2> <z2>
.
.
.
v <xn> <yn> <zn>
Faces:
f <k1> <l1> <m1> //Define a face (k, l , and m are integers corresponding to the vertex number)
f <k2> <l2> <m2>
.
.
.
f <km> <lm> <mm>
w <xmin> <ymin> <xmax> <ymax>   // Define 2D Window in world coordinates.
s <xmin><ymin><xmax> <ymax. //Define viewport (normalized device coordinates)
 
Notes:
  • Each "v" line defines a new vertex with the specified x,y,z coordinates.
  • Each vertex is given a unique identifier starting from 1 (not 0).
  • Each "f" line defines a triangular face by referencing three vertices.
  • An s line defines the viewport in the normalized coordinates
  • No clipping is required for this lab.
  
For simplicity this lab assumes a parallel projection with direction of projection being parallel to the z axis with no clipping in the 3- dimensional world (these features will be added in the future labs).
It is assumed that all data are given in right-handed coordinate system. The positive direction of rotation is counter clock-wise when viewed from plus infinity.
Your program should display the data by simply dropping (ignoring) the z coordinates of each vertex (map your data to 2- dimensional world coordinate system), and then map data from 2D window to viewport. You do not need to implement clipping for this lab.
  
  • You can download the template for this assignment here.
  • Your program should draw the boundaries of the viewport.
  • Resizing the canvas should automatically resize the viewport accordingly.
  • You do not need to rename the .txt files
  • You program will be graded according to the grading Assignment_01 grading guidelines
 
Sample data files: