Attaching Geometry to Particles
syllabus | schedule | projects | class notes | resources | students | Digital Arts website
Attaching Geometry to Particles

To attach geometry to particles:

Create particles and a piece of geometry (or it can be a group) and the geometry can be animated or not

Select the geometry then the Particles menu - Instancer (Replacement)

1. Select the geometry then the particles last then Particles menu - Instancer (Replacement)

The Particles menu - Instancer (Replacement) Options look like this:

instancer

Name the instancer

Make surethe correct particles are selected in the Particle object to instance:

We will change any other settings in the AttributeEditor later

click CREATE

To apply rotation and other attributes to the geometry dynamically:

You must first write expressions to tell the geometry what to do:

First we need to add a Dynamic Attribute

add dynamic attribute

Click General

Go to the New tab

add new dyanic

Enter a variable name InitialRandomSettings in Attribute Name
select Vector
select Per Particle (Array)
click Add button

Make another Dynamic attribute:

Name it RotateObject
select Vector
select Per Particle (Array)
click Add button

In the Particle's Attribute Editor -Per Particle (Array) you will see your new attributes (note it is smart enough to make words out of your variable name

Per Particle Array

Right mouse button over the Initial Random Settings and select Creation Expression

creation exp

Type:

InitialRandomSettings = <<rand(10),rand(10),rand(10)>>;
select CREATE

init settings exp

Click Runtime before dynamics

Type: RotateObject = InitialRandomSettings * age;
select EDIT or CREATE

init dyn

Now we need to set up the Instancer to realize those settings are out there and to use them:

Open the Instancer tab from the Particles Attribute Editor

instancerTab

Change Rotation Angle Units to Radians (easier to do the math on)

Change back to the ParticleShape tab and open the Instancer (Replacement)

In Rotation pull down and select RotationObject


You can instance more than one piece of geometry to the same particles.

Create 4-5 pieces of geometry and then the particles.

Select Particles menu - Instancer (Replacement)

Add a Dynamic Attribute: New - Data Type = float
select Per Particle (Array)

Name it GeometryIndex

OK

In the Per Particle Array of the Particle Attribute Editor, RMB and add a Creation expression

Type: GeometryIndex = id%4;

CREATE

In the Instancer section have Object Index select GeometryIndex


EXAMPLE:

Create a simple fly using primitives. Remember to set the pivot points of the wings in the body of the fly. Use a sphere and two cubes.

Select leftWing and shift click rightWing in the Outliner

Use Shift E to keyframe only the rotation of the wings at the following frames:
Use Middle Mouse button to go to a new frame with out updating the animation

    Frame 1 and 5 - rotate wings down
    Frame 2 and 4 - wings straight
    Frame 3 - wings up


Go into the Graph Editor and View menu Frame All

Curves - Post Infinity - Cycle with Offset

Make a grid of particles

    Number of particles = 1
    Particle spacing = 12
    Create Particle Grid -> Placement with textfield
    Min corner = -25, 0, -25
    Max corner = 25, 0, 25


Cursor in Window - Enter

Add Creation Expression to Position of the particles

    float $randY = rand(-3,3);
    float $randXZ = rand(-1,1);
    vector $offset = <<$randXZ, $randY, $randXZ>>;
    position = position + $offset;


Create (rewind till you get enough dispersion)

Solvers - Initial State - Set for Selected
Middle Mouse button drag the script to the shelf and delete it in the Expression window & press Edit

Select the dragonfly in the Outliner
Particles - Instancer(replacer) Options

Particle Instancer Name = flyInstanced
Create

Select the dragonfly and Display - Hide - Hide Selection

Resizing the dragonfly:

In the attribute for the Particles:
Add Dynamic Attribute - General

    New: Attribute Name: bugScaler
    Data Type: Vector
    Attribute Type: Array
    Add Initial State Attribute: ON


OK

Make a Creation Expression for this new bugScaler attribute

    if (frame==1)
    {
        $randSize = rand (0.4, 1.5);
        bugScaler = <<$randSize, $randSize, $randSize >>;
    }


Create

Open the Particle Instancer section of the Attribute Editor
General Options: Scale = bugScaler

Rewind till you like the sizes then :

Solvers - Initial State - Set for Selected

Comment out the code by putting a // in front of the lines

Apply some fields to the particles

Playblast the animation