CPTR 425 Computer Graphics Assignment 2

Write a C++ program that reads in a text file containing the coordinates of two-dimensional points. The file format is

 n             

 x1 y1
 x2 y2
 x3 y3
   .
   .
   .
 xn yn
 
 x1' y1'
 x2' y2'
 x3' y3'
   .
   .
   .
 xn' yn'

where

One way to do this is to use an ifstream object to read in the individual values (they are all integers, so you can use your ifstream object just like using cin getting integers from the keyboard). You will need to store the points in a data structure, and a C++ vector or array is a good choice.

To draw the figure represented by the points, draw a line from the first to the second point, the second to the third point, etc., ending with a line from the next to the last point to the last point. Use a 400×400 window with the origin in the lower left corner.

Your program should first render the "before" picture. A click of the mouse should cause the "before" picture to change to the "after" picture in a smooth tweening motion. The "after" image should then remain until the user clicks the mouse again, at which point the "after" image should morph back to the "before" image. If the user clicks the mouse button at any time during the tweening process (any time in between "before" and "after"), the tweening animation pauses until the use clicks the mouse button again. This allows the user to freeze a frame in the middle of a transformation.

The following data file:

    10                  

    20.0  20.0
    20.0 220.0
    170.0 370.0
    320.0 220.0
    320.0  20.0
    220.0  20.0
    220.0 120.0
    120.0 120.0
    120.0  20.0
     20.0  20.0

     20.0 220.0
     20.0 280.0
    170.0 280.0
    320.0 280.0
    320.0 220.0
    200.0 220.0
    200.0  20.0
    140.0  20.0
    140.0 220.0
     20.0 220.0

tweens between the house and "T" images shown below.

The "before" picture of the above data file is:

The "after" picture of the above data file is:

Once your program has been checked out, please submit your source code to eclass