Preloader image

Final implementation

Abstract


In this project, we try to improve the common existing 2D boid models by implementing it in 3D with more delicate bird models and more verisimilar behaviors. All birds will move generally towards a designated direction but with some variation according to forces on them. The forces include separation, alignment and cohesion. There is also a stop mode that the birds will rest on a branch when it's close enough to that branch and take off again after some time. 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, the neighborhood size for determining the forces, as well as the designated direction using the sliding bars on the GUI.

Demo

Overview video: https://youtu.be/nFwdyjc1hvc

Demo video: https://youtu.be/7BwFCAx3YVU

Technical approaches

GUI

The nanoGUI we used in this project is adapted from last course project. Besides the commands P/N/R implemented already, we add command S for turning on/off the stop mode.

  • P: pause/continue
  • N: next time frame
  • R: reset
  • S: turn on/off stop mode

Point mass model

We represent every bird as a point mass, and there are three forces coherence, separation, and alignment between them. The implementation is based on boids algorithm. However, with this implementation, the speed of birds will go crazy when we increase the weights of the forces and then decrease it back to the original value. Therefore, we added a maximum speed for the birds to make sure the speed is always reasonable.

  • Coherence force cause acceleration in the direction of average position of nerghbor birds.
  • Separation force cause acceleration in the opposite direction of average position difference between the bird and its neighbor birds.
  • Alignment cause the velocity of the bird increase by the average velocity difference between its neighbor birds' and itself.

Then we add some interative features, so user can use sliding bars on GUI to change:

  • Weights for the three forces (the larger the weight, the more obvious the behavior is)
  • Neighborhood size for the three forces (radius for the circle)
  • flock size (number of point masses)
  • heading position (general direction birds will fly to)

Bird model


To further picture the details of birds, we build a 3D build model using Blender. By aligning the model axis with the velocity direction, we can make sure birds fly with their head facing the front. We also manually painted a texture to add more details like feathers beak, and claws.

Stop mode & Tree model

To include more realistic and interesting behaviors, we also added stop mode that the birds can stop at a random position on the nearest branch if it's close enough to the branch.


We start by adding ground and a single pole to the scene. Every time when the distance between a bird and the pole is within a fixed value, the bird will fly towards a random position on the pole calculated by implicit equation with deceleration until it rests on the pole. According to probability theory, the birds should have even spacing between them. After some fixed time, birds will take off again randomly with a probability according to Russian Roulette. After we see everything works well on the single pole, we added more branches and make a tree via rotation and scale. The birds now will stop on the nearest branch.

Lessons learned

To conclude, what we learned from lectures and put in this project includes:

Besides, it's always important to set restrictions according to physical conditions. For example, we know the bird speed must has an upper bound, and the speed change is continous and smooth, so there must be deceleration when birds try to stop on the branch.

Results


Following are demonstrations of the three forces respectively.

coherence

separation

alignment


There are two additional behaviors: interaction with the tree, and leading direction.

Birds will try to stop on the closest branch when it's close enough to the branch.

The bird will take off again after resting for some time.

Birds will fly to the coordinate set by user.

Contributions


  • Huibo Yang: adapt nanoGUI and add sliding bars to change variables, develope three forces with speed limit to avoid weird behaviors, build bird model using blender, create bird texture, add takeoff behavior, create demo video
  • Sainan Chen: build point mass models and implement three forces, add ground to the space, build stop mode and enable birds to stop on a branch, create webpages
  • Tianqi Yang: build point mass models and implement three forces, add poles and assembles them into a tree in the space, create overview video
  • Yizhou Chi: adapt nanoGUI and add sliding bars to change variables, developed three forces with speed and acceleration limit to make the simulation more realistic, implemented the feature to allow birds to randomly land on fly off the branch in real time
  • Everyone: create slides and did wonderful presentations!