Blender Tutorial

Jahka Particles (Boids)
 
 
Skill Level: Beginner

Blender Version: January 31, 2008 compile (svn experimental)

Tutorial Version: January 31, 2008

Resources: none




Introduction.

This tutorial attempts to recreate Jahka's boids2.avi in a "step by step" manner.


Since the purpose of this tutorial is merely to explore how to use the new particle features, I will not be going into too much detail with regards to basic Blender functions.





1. Setting up the Boids Particle Emitter

1_1. The Object Settings

We'll be using the default cube as the boids particle emitter, so add a particle system to it.

To access the Particle options, switch to the Object buttons by pressing the [F7] key.
Then to get to the Particles sub-context, press [F7] twice; or just press the little orange/yellow particle icon.
In the 'Particle System' panel, click the 'Add New' button to create a particle system.

Make the following adjustments to the Particle button settings in the Particle System tab.
Set 'Amount:' to 100 , since 1000 is a bit high for the number of boids that we want to create.
'Start' time of 1.0 is fine; and an End time of 150 was used to match how long the birds continue to appear in Jahka's boid animation.
If you were going for a more realistic animation you would probably want to use an End: setting of 1.0, so that all the boids appear at once.
Since we don't want our boids to disappear before the end of the animation, set Life to 600. (For a 600 frame animation).
(Also, in the Scene Buttons Window [F10] > 'Anim' panel, set the 'End:' frame value to 600).

To keep the boid creation fairly random, set the first button below the 'Emit From' heading to Random.
Also, set the particle distribution to Random.



Figure 1_1. Particle System Settings.

1_2. The Physics Settings

Switch the Particle Physics type from the default 'Newtonian' to 'Boids' via the selector in the Physics panel - See Figure 1_2.
This brings up a whole raft of new buttons. The function of each button is fairly obvious from the name and the tool tip, but I'll describe the ones that we'll be using in just a minute.



Figure 1_2. Boids Physics.


In the Physics panel, you'll notice that the boids options are arranged into two columns: 'Behaviour' and 'Physics'.
The Behavious options controls how the boid particles will react to one another as well as various obstacles.
The Physics options control the velocity, acceleration, etc of the boid particles.


You'll notice that the Behaviour options are preceded by an up/down arrow, which allows you to move the controlled parameter up or down in the column/stack.

***VERIFY***
This can affect how a boid particle will react given a certain set of circumstances since the parameters are evaluated from top to bottom for each frame. For example, imagine your boid particle is flying around and encounters a deflection object to the left and a predator object to its right. If the 'Collision' parameter is higher in the column/(stack) than the 'Avoid' parameter, the boid will fly into the predator and vice versa if the order were reversed.
***VERIFY***


2.Adding a Boids Object


It's a good idea to add your boid object right away because it will give you a better idea of any clearance issues between
the boids and other objects that may occur, rather than finding out later that this is an issue.

We'll add a mesh "arrow" object at the origin. You can add something more closely resembling a bird if you wish. As long as it has wings that we can animate.
Ensure that the cursor is at the origin by pressing [Shift] + [c].
Add a mesh Plane, scale it down by a factor of 0.1, and then edit it to look like an arrow.

You may want to switch to Local view mode (NumPad [ / ] key), so that your view isn't obstructed by the Cube. Press the same key to return to Global view mode.
Another option would be to edit the mesh in 'Wire Frame' view mode by pressing [z]. (Same key to return to 'Solid' view mode).

Extrude out a couple of "wings" from the middle of the arrow mesh.
We will animate the wings later, giving them a "flapping" motion.
[Tab] into Object mode and then press [Ctrl] + [a] (Apply Object) > 'Scale and Rotation to ObData', to apply any scale/rotation transformations.

Note that the new version of Blender adds objects aligned to the Global co-ordinate system and also remains in Object mode when the object is added.
To return to the previous behaviour, you need to activate the buttons 'Switch to Edit Mode' and 'Aligned to View' beneath the 'Add new objects:' header located in the Information Window, Edit Methods options.


Figure 2_1. Arrow Boid.

Ensure that your arrow is pointing in the + Y axis direction as this corresponds to the default Tracking axis.
You can change the Track axis, if required, by accessing the track axis buttons in the Object Buttons Window > 'Anim settings' panel.


Figure 2_2. Track Buttons.

Rename the Plane "arrow" in the OB: button located in the Edit Buttons Window [F9] > 'Link and Materials' panel.

Next, add an Armature. [Tab] into Edit mode and select the tip of the bone and move it down ( [g], [z] ) to match the height of the arrow object more closely.
Select the entire bone, and then rename it "arrow" in the Edit Buttons Window > 'Armature Bones' panel.
Select the root node of the "arrow" bone and then [e] extrude out a bone for the right wing. Select the extruded bone and move it so that the root of the
bone is positioned over the center edge loop at the base of the wing. Then position the tip of the bone at the end of the wing. Name the bone "wing.R".
Also, make the "wing.R" bone a 'child of' the "arrow" bone.
Repeat the above steps to create the Left wing bone and name it "wing.L". Also, make the "wing.L" bone a 'child of' the "arrow" bone.


Figure 2_3. Adding the Bones.

In Object mode, select the arrow object, then [Shift] select the Armature and press [Ctrl] + [p] 'Make Parent To' > Armature.
In the next popup box, select 'Don't create Groups'.


Figure 2_4. Parenting the arrow Object to the Armature.

Now we need to create three Vertex Groups and assign the appropriate vertices to those Vertex Groups.
Select the "arrow" Object and [Tab] into Edit mode.
In the Edit Buttons Window > 'Link and Materials' panel, click the 'New' button located in the 'Vertex Groups' section of the panel.
Name the Vertex Group "arrow". Select the vertices shown below in Figure 2_5, and then click the 'Assign' button.
Following the same procedure, create Vertex Groups for the "wing.R" and "wing.L" vertices.
For the "wing.R" and "wing.L" Vertex Groups also include the center loop at the base of the wings that were also included in the "arrow" Vertex Group.
This will define those vertices as being shared between the main "arrow" group and the "wing.L/R" Vertex Groups, which should help to reduce the mesh deformation
at the base of the wings.


Figure 2_5. Creating Vertex Groups for the arrow.

[Tab] into Object mode and then select the Armature. Press [Ctrl] + [Tab] to enter Pose mode.
If you grab the arrow bone and move it around, the entire arrow object should move. Likewise, if you select one of the wing bones and move it, only
the corresponding wing portion should move. If that's not the case, you'll need to go back and make sure the Object Mesh was properly parented to
the Armature and that the Vertex Groups were also setup correctly.

Next, animate the wings flapping up and down motion by inserting rotation keys, ([i] > 'Rot') for the wing.R/L bones.
The Rotation Keys that I used are as follows:
Key 1: Frame 1: wings in neutral position,
Key 2: Frame 5: wings Up (Rotated 30 Degrees),
Key 3: Frame 13: wings Down (Rotated -60 Degrees),
Key 4: Frame 18: wings in neutral position.

Once you've set up one cycle, [Tab] out of Edit mode for the Ipo Curves, select all [a] IPO curves, and in the Curve menu, select 'Extend Mode' > 'Cyclic'.
Repeat for the other wing's IPO Curves.


Figure 2_6. Animating the arrow wing Bones.

Select the "arrow" Object and in the Edit Buttons Window > Modifiers panel, add a Particle Instance modifier.
In the Ob: button, enter the name of the Object with the particle system: 'Cube'.
Below the Ob: button, you can select the particle system, if the Object contains multiple particle systems.
The last group of buttons, allows you to set the particle properties that will create an instance of the object. Select 'Normal' and 'Alive'.


Figure 2_7. Adding a ParticleInstance Modifier for arrow.

Re-select the Cube object and switch to the Object > Particles and change the visualization type to 'None'.


Figure 2_8. Visualization Settings.

If you play the animation now ( [Alt] + [a] ), you should see the arrows wandering around aimlessly. Let's give them something to chase.


3. Adding a Target to Chase



As in Jahka's example boids2.avi animation, we're going to add a green UVSphere to serve as a chase/target for the boid particles.
So add an UVSphere using 16 Segments and 16 Rings and assign a green material to it. Finally, enable set smooth for it.


To obtain a smooth flowing animation, we will add a Curve > Path.
Select all control points and subdivide the path. Give it a shape similiar to that shown below in Figure 3_1.
To obtain the closed form, select the two end points and press [c] to close the path.
Be sure not to give the curve any extremely sharp turns as this may cause some issues later on (depending on other various settings).
[TAB] into Object mode and shift the Path up (+Z) about 5 BUs and about 6 BU to the left (-X). This helps to place some inital space
between the boids and the green sphere at the beginning.

You can also move some of the curve points vertically to make the flight path truly 3D.
Another option would be to add some Shape IPO keys to the Path, so that the green sphere doesn't travel a static path throughout the two
circuits of the path that it completes during the animation. This could also help to create a more dramatic "swooping" type effect.

Tip: With regards to the general size of the path; I've found that if you keep the path to within the 6 by 6 BU grid perimeter,
(ie. the grid you see when you rotate the view), it will usually yield a good starting off point, and you won't have to go to extremes
in setting the boid parameters later. Though feel free to experiment.

Parent ([Ctrl] + [p] > path constraint) the green UVSphere to the path.
Select the UVSphere and clear its location - [Alt] + [g] to snap it to the start of the Path.


Figure 3_1. The Flight Path.

Select the path and then open up an IPO Curve Window.
Switch the IPO Curve type in the header from 'Object' to 'Path'.
Select the speed curve and Tab into edit mode, select the curve handles and convert them to vector handles by pressing [v].
Since we want the green sphere to make two circuits of the Path, edit the path to look like the "saw-tooth" type curve in Figure 3_2 below.

Tip: To get the second "saw-tooth" wave form, select the right-most 2 curve handles, press [Shift] + [d] to duplicate them, Middle Mouse click while
dragging your mouse horizontally to lock the translation to the horizontal axis, then press [Ctrl] to move in coarser increments, and move the selection
300 frames to the right.

Ensure that the back side of the "saw-tooth" part of the curve is 1 Frame after the peak, ie. frame 300 -> 301 and frame 600 -> 601 for the second peak.
Note: The final Path IPO curve might look quite a bit different from the one shown below, because you may need to extend it if you find that
your particle boids are lagging behind the green sphere during the animation. Also, you can add additional control points to speed up or slow down the Sphere.
For example, I've added a Yellow Auto - handle control point [Shift] + [h] at about Frame 110 to slow the Sphere down slightly at the start of the animation.


Figure 3_2. The Path IPO Curve.

3_2. Setting the UVSphere as the Prey (Attractor)

With the UVSphere selected, click the 'Physics buttons' icon (just left of the Particles icon in the header).
In the 'Fields' panel, set the 'Field Type' to Spherical and increase the 'Strength' parameter to somewhere in the 5 to 10 range.
The 'Strength' parameter is a setting that you may need to tweak to get the right effect.


Figure 3_3. The Prey / "Attractor" Object.


4. Adding an Obstacle


Add another UVSphere and give it a red material.
Move it to just outside the left loop of the path.
Later on, once you have made some adjustments to the boid particles behaviour settings, you can more accurately position the red sphere in the middle of the boids flight path.


Figure 4_1. Deflection/Collision Obstacle.

Set the Deflection button for the Red Sphere, so that the boids will try to avoid it.
Note that this is tied in to the 'collision' parameter for the boids.


Figure 4_2. Deflection.


5.Adjusting the Behaviour Parameters

Now the fun begins.
This is the part that requires alot of tweaking and finesse to obtain the optimum solution to how you want the final result to appear.

An important note first though.
Blender uses a Point Cache system to save the Particle animation to disk. This allows the data to load faster.
However, if you were to play back the particle animation without first saving the blend file, you may get some strange results when you play back the particle animation
(especially if you try to play the boid animation in reverse by dragging your mouse backwards on the timeline.)
You need to save the blend file first, so that the system can properly name the directory for the cache files.
Once you've done this, play the particle animation once through right to the end, and then you shouldn't have any troubles playing the the particle system correctly.

*** Delete?***
To "synchronize" the Particle System with the rest of the Physics systems, an "unified" solution was necessary.
The purpose of this was to make it easier for the user, so that you don't have to wrestle with a number of different systems when you use/combine the various Physically based animation systems in Blender.
*** Delete?***

First, we'll switch to the animation Screen, by pressing [Ctrl] + [Left Arrow] key, since it is set up alot better with the appropriate windows that we'll be using for the following work.
Select the particle emitter Object. (Cube).

The following procedure is going to be hard to describe, because it involves alot of "trial and error" adjustments to get it right.
The goal is to get the boids moving as close as possible to the desired solution and then do fine adjustments to keep improving until we obtain the final result.

If you scrub through the time line now, you will likely see the boids still just wandering around aimlessly, and barely reacting to the Prey/Attractor object.
The first thing to do is maximize the 'Goal' parameter to 2, so the boids will follow the UVSphere, and also move it up in the stack to give it precedence over the other parameters.

Our initial goal is to have the boids closely chasing the green sphere without over-taking it or catching up to it (in the latter case, the particles will tend to circle around the green sphere).

The next adjustment to try is the MaxVelocity and AvVelocity settings.
If MaxVelocity is too low, the boids will never catch up to the green sphere, too high and the boids will tend to overshoot the target.
AvVelocity controls how close the boids will get to the set MaxVelocity value.

The LatAcc and TanAcc parameters control how rapidly the boids can change their speed in the lateral (side to side) and tangential (forward) directions.


Figure 5_1. .

Tips: You may find that no combination of settings generate the desired final outcome.
In that case, you may need to tweak some other parameters of your overall scene.
Here'a a few other things to tweak:



Well that's all there is to it.

Until next time, Happy Blendering.