/* In this lab, we will consider interpolation, and how we can do an affine mapping between two different 2-D shapes. NOTE: you won't attempt to compile until step 7 below... 1. Scroll through the source code below. Take particular note of the - Point2 and Color 3 vectors - delta and deltaT variables - TWEEN vector - note how the IDLE function, CalcTween, calculates the new vertices and then posts a redisplay - note how the display function simply renders the 6 vertices of the TWEEN vector - note that the clipping volume is (-100,-100) to (100,100) 2. Fill in the x-y values for 6 vertices of some 2-D shape, in the shape1 vector 3. Fill in the x-y values for 6 vertices of some 2-D shape, in the shape2 vector 4. Define your two colors in color1 and color2 vectors 5. fill in the code to calculate the interpolated colors 6. fill-in the code to calculate the interpolated vertices 7. compile your code, fixing any errors, and then run it 8. demo the code for your instructor */ #include #include #include using namespace std; #define WINDOWSIZE 400 // defining a type "point," of size 2 typedef GLfloat Point2[2]; // defining a type "color," of size 3 typedef GLfloat Color3[3]; #define NUMPOINTS 6 // define a 2-d shape, using 6 vertices Point2 shape1[NUMPOINTS]={ { , },{ , },{ , },{ , },{ , },{ , } }; // define another 2-d shape, using 6 vertices Point2 shape2[NUMPOINTS]={ { , },{ , },{ , },{ , },{ , },{ , } }; // array used for the points beTWEEN shapes Point2 tween[NUMPOINTS]; // define your first color Color3 color1={ , , }; // define your second color Color3 color2={ , , }; // define the parameters GLfloat t=0.0; GLfloat deltaT=0.005; void myInit() { // initialize the beTWEEN array GLint i,j; for (i=0;i=1.0 || t<= 0.0) deltaT = -deltaT; glutPostRedisplay(); } void mouse (GLint btn, GLint state, GLint x, GLint y) { if (btn==GLUT_LEFT_BUTTON && state==GLUT_DOWN) { glutIdleFunc(CalcTween); } if (btn==GLUT_RIGHT_BUTTON && state==GLUT_DOWN) { glutIdleFunc(NULL); } } int main( int argc , char **argv ) { glutInit(&argc,argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize(WINDOWSIZE,WINDOWSIZE); glutInitWindowPosition(0,0); glutCreateWindow("Interpolation"); myInit(); glutDisplayFunc(display); glutMouseFunc(mouse); glutMainLoop(); return 0; }