This probably my last project in IMA besides capstone. So when I was writing my project proposal, I was thinking about what do I want to do most through this project.
Throughout the whole semester, flocking system is my favorite, and it is naturally to think about fish. So this became my starting point, which I did for my last assignment. I did a group of triangular flocking fish and used sine waves to simulate the wings of the fish. I was not satisfied with the overall visual at that moment. However, when I was debugging the wings with the body of the fish hidden from the screen, I was fascinated by the movement of the triangular wings. So I simply deleted the body and left the wings.
These are the butterflies in the first iteration, flocking in 2D. They look nice, but not intriguing enough.
My next challenge was to convert the 2D objects into 3D, based on the feedback I received during the presentation. In fact, the flocking algorithm was not that hard to implement into 3D. But I got stuck in figuring out the orientation.
In 2D, we can simply get the rotation angle by applying atan2 to the velocity, however this formula cannot work in 3D. My first attempt was to use the ofNode class to store the velocity and use its built-in methods. I thought this should be easy as I saw a getRoll() and getPitch() in the documentation. HOWEVER! THERE IS NO GETYAW()!!! which means I still need to manually calculate the rotation. Thankfully I got some help from a friend who is good at computer graphics. Here is how we solved this problem.
For the color, I mapped it to the number of neighbors of each butterfly. Wy when it has few neighbors, it will be pink; and when it has many neighbors it will has a more blue-ish color.
In terms of the user interaction, I was trying to apply an attraction to the butterflies that are close to the cursor. But that is also very different from what we normally do in 2D. And unfortunately I did not have enough time to finish this part. But what did is to let user apply some attraction and repulsion to the butterflies from the center by pressing different keys.
If I have time in the future, my next step is to put the whole sketch in VR to create an immersive experience. In the meantime I’m looking for libraries that connect openframeworks to VR devices. And I might just redo the same algorithm in Unity.