This assignment is worth 10 points.
Your application should provide the shader with a uniform variable which represents global time. This variable should also range between 0 and 3. The global time should be incremented by a constant amount at each animation step. It should be reset to 0 once it reaches 3.
For each point, calculate a local time as a combination of the global time and the time offset for the point. Using this local time, animate the point as follows. I combined the two values, and if the result was outside of the range [0, 3] I remapped the local time to that range. Finally I scaled to value to be in the range [0,1].
Each point should be displayed with a z coordinate between -1, when local time is at 0 and 1, when local time is at 1. The diameter of the pixel should increase from 1, when local time is at 0, to 4 when local time is at 1. The x and y coordinates for each point should change between 0,0 when local time is at 0 and the random location when local time is at 1.
Finally generate a color for the points. Using the HSV color space, a point should start out as blue (h=240) and transition smoothly to red h=0 as it moves toward the viewer. You can find a program that converts from HSV to RGB at the end of these notes
Please note: All computations, other the the original generation of the points and the time offset, should be done in the vertex shader.
You should provide the user the ability to adjust the speed at which time passes. One way to do this might be to use the + and - keys (or up and down arrows) to change the constant by which time is incremented.
I used the void glutTimerFunc(unsigned int msecs, void (*func)(int value), value); to control animation. To do this I changed the following functions in UI.C
bool DoAnimation = false; // 1000 ms per sec, 60 frames per second int delay = 1000/60; void Animate(int value) { if(DoAnimation) { glutTimerFunc(delay, Animate,0); } glutPostRedisplay(); return; } void StartAnimation() { glutTimerFunc(delay, Animate,0); DoAnimation = true; return; } void StopAnimation() { DoAnimation = false;; return; }
There must be a reasonable set of controls, which are documented on screen when the program begins.