Purpose: Practice in perspective projection
and clipping
Add perspective
projection to your previous assignment and include multiple
cameras. This assignment must include parallel and perspective
projections including corresponding clippings.
When you start your
program it should automatically read a file called "cameras.txt".
This file contains the information about the cameras. Notice that
"cameras.txt' file may include information about multiple
cameras.
Load (Open) Input File This command is the same as the
previous assignment. except that it shows all the views from
different cameras (parallel, perspective)
simultaneously.
Notes:
All the
commands from the previous assignments should be functional in this
assignment.
The format of the "cameras.txt" file
is the same as the previous assignment, except it will include
multiple cameras.
The format of the input file is the
same as the previous assignment.
If any of the parameters are missing
then the default value should be used.
Boundaries of the viewports must be
displayed.
Viewports may be
overlapping.
Your program must display all the
viewports (for all the cameras) simultaneously.
Detail format of the cameras.txt
file::
c
// Start the definition of a new
camera.
i
camera_name //Name of the camera.
Default=""
t Parallel /
Perspective // Define camera type. Default=
parallel
Read the
"cameras.txt" file and calculate the composite matrix for each
camera (some of the cameras are defined as parallel and some as
perspective).
Read a
data file
For each
face in the data file:
Multiply
each vertex by the sequence of transforms to bring the vertices
from object space to world space. These transforms are the ones
which are specified by the user in assignment 02. Note that these
transformations are different from the parallel or perspective
projection transformations. (Same as previous assignment)
for each
camera in cameras list:
Multiply
each vertex by the composite matrix for corresponding projection
(parallel or perspective).
For each
side of a face:
if the
current camera is parallel: (Same as previous
assignment)
Clip
the line in 3d against the standard parallel volume bounded by
x=-1 ; x=1 ; y=-1 ; y=1 ; z=0 ; z=1 planes..
If the
result after clipping is not rejected:
Drop
the z value of the results after clipping (use the x and y of as
two dimensional data to be used for mapping from window to
viewport).
else:
Clip
the line in 3d against the standard perspective volume bounded by
x=z ; x=-z; y=z ; y=-z; z=zmin ; z=1 planes..
If the
result after clipping is not rejected:
Calculate the new x' and y' by dividing the x and y of each vertex
by its z. i.e., x'=x/z and y'=y/z. Use x' and y' as
two dimensional data for mapping from window to viewport.
Map from
window to viewport and draw the line on the screen(this part is
from assignment 01). Notice that the xwmin=-1 , ywmin=-1 ,
xwmax=1, and ywmax=1