Preloader image

Milestone

Introduction


In this project, we try to implement a 3D flocking simulation. All birds will move generally towards a designated direction but with some variation according to forces on them. The forces include internal forces like separation, alignment and cohesion, and external forces like wind. We adapt the nanoGUI from our last course project, and user can change the number of birds to simulate, the weight of each of the force as well as the designated direction using the sliding bars on the GUI.

Presentation slides: https://docs.google.com/presentation/d/11QU8uQsCKbf2oT6ux9RuYUnxBdJdNBXTSHDoqfBYK5I/edit?usp=sharing

Presentation video: https://www.youtube.com/watch?v=xvowkBw1n2o

3D Bird Model: Point Mass


To start with, we represent every bird as a point mass, and store its attributes position and speed. At the beginning of the simulation, every bird is put in a random position in the given 3D space. Once the simulation starts, all bird will move with an initial velocity in the designated direction set by x, y, z sliding bars. Once the bird reaches the edge of the space, which is defined as a (1,1,1)-size cube, the bird will "bounce" back.

More interactive features include changing overall simulation speed by changing frames/s and steps/frame under simulation on the panel. You can also change the number of birds for simulation. Random birds will be removed for reduction and new birds will be put in random position for addition.

To better visualize the space, we added 4 walls to represent 4 out of the 6 faces of the space cube.

We draw simple bird shapes using straight lines in 3D. Therefore, in different view points, the birds will look different. We also assign random colors for birds for fun!

Bird shape in different view points

We would like to change the 3D bird model to a more realistic one in the future. The draft is as below. For now, for better visualization, we will use colored balls to represent the point masss of birds.

Forces: Separation, Alignment and Cohesion


To make sure our point masses behave just like real birds, we need to further implement forces between birds. According to Boids Paper, there are mainly three forces: Separation, Alignment and Cohesion. According to Newton's Second Law F=ma, these force will produce acceleration, therefore cause on velocity(speed and direction) and position of birds. We apply a weight for each of the force and it can be adjusted by the sliding bar on the GUI.

Cohesion

We often see a large flock of birds flying together. That's reasonable, because birds want to stay together for attack protection and support. For each bird, the cohesion is calculated by average position of all the neighboring birds. Neighboring birds are defined as other birds within a given distance away from the bird.

Separation

Of course birds try to avoid colliding with each other, therefore there's also a separation force between each pair of birds close to each other. The force is calculated by averaging displacement from neighboring birds to the bird. Notice that the distance limit to define neighbors for separation should be smaller than the distance limit to define neighbors for cohesion. It means birds will only repel each other when they are very close.

Alignment

For birds to reach their destination, they need to have an overall heading direction instead of attracting and repelling each other without moving forward. The alignment is average of velocity difference between neighbor birds and the bird. The average of the velocity difference will be added to velocity of the bird directly.

There are also external forces. We implemented wind blowing to a random direction, although the effect may not be significant.

Of course there are speed limits for birds, so we also put speed limits in our model.

With all these forces implemented, we can now see how the points move like real flocks.

Interactive features


To summarize, the interactive features include:

  • Set designated direction (x, y, z).
  • Weights for Cohesion, Separation and Cohesion.
  • Set number of birds for simulation.
  • Set simulation speed of birds by number of frames/s and number of steps/frame.
  • Set a way to render birds (wireframe or ball).

Next step


  • Fix the behavoir when birds reach the edge of the space. Instead of bouncing back, birds should fly round back.
  • Use 3D bird-shaped model for every point mass.
  • Add tree features to make sure the particles(birds) can land on or take off from bars(trees).
    • Add trees to the space, either using bars or more sophiscated tree models.
    • The landing and takeoff should be smooth with reasonable acceleration.
    • During landing, the particles should randomly land on the bar with relatively even spacing. When the bar is clicked (tree is shaken), all birds take off again.