Step 66: PC Software: Effect 1, ripples
This is the first effect we made for the PC software, and we think it turned out very nice.
While this may seem like a complicated effect, it's really not!
All the effect functions running on the micro controller mostly use if() statements to create effects. The effects on the PC software are built a little different. We use a lot of sin(), cos() and other math functions here. Most coordinates are calculated as floating point coordinates then typecast into integers before being drawn on the cube.
The effect you see in the video is actually just a sine wave eminating from the center of the cube, x=3.5, y=3.5.
Here is how it works:
1) Loop through the iteration counter.
2) Loop through all 64 x and y coordinates.
3) Calculate the distance between the center of the cube and the x/y coordinate.
4) The z coordinate is calculated with sin() based on the distance from the center + the iteration counter. The result is that the sine wave moves out from the center as the iteration counter increases.
Look how easy that was!