Sheet 4: Interpolation & Transformation
Exercise: Colored Triangles (10 points)
The provided code for this exercise already contains parts from the previous task:
GLFW and GLEW initialization are encapsulated in classes inside the Utils folder.
That folder also contains matrix and vector classes, which will be used in this and upcoming exercises.
You do not need to modify the code in Utils.
For this assignment, it is sufficient to edit only the classes in the Hello_Triangles directory.
Your shader source files are located in the res subfolder.
The GLHelper files assist in compiling these shaders.
The example program main.cpp renders a simple white triangle
(see the left image in Figure triangles).
Extend the program so that it matches exactly the right image:
Three equilateral triangles with color-interpolated corners (red, magenta, yellow, blue, cyan, green).
Use the vector and matrix classes in the Utils folder,
as transformations will be essential for the following tasks.
Exercise: Transformations & Animations (10 points)
Extend your solution from the Colored Triangles task so that each of the three equilateral triangles rotates at 45 degrees per second — each around one of the primary axes:
- The top triangle (red-magenta-yellow) rotates around the x-axis, centered at half its height.
- The bottom right triangle (yellow-cyan-green) rotates around the y-axis, centered at half its width.
- The bottom left triangle (magenta-blue-cyan) rotates around the z-axis, centered at its geometric centroid.
Continue to use an orthographic projection as in the previous exercise. You can refer to the example below for visual verification.
Additionally, the program must support the following user input:
Spacebar: Toggles animation on/offRkey: Resets the animation to its initial state
When the application starts, the animation must be paused in the reset state.
Top – initial state. Bottom – color-interpolated Triforce.
Press Spacebar to toggle the animation. Press R to reset the animation.