12 March 2011

Particle Example 7 : Particle Instancing Pt.2

In the Particle Instancing Pt.1, we made a bunch of flies. It moved in the same fashion and looked robotic. This time we will make Instance cycling to randomly animate a flock of flies.


1.  Create new scene and make the fly same as Pt.1. or you can use the same fly from Pt.1.
     Select the fly group in the outliner. Duplicate the group 8 times. Arrange them on the Y axis.
     Make sure you do not mess the flies geometry while moving them. It will cause offsetting
     from the particles during instancing.

2.  Hide the original fly. Rotate the wings of each duplicated flies as below.




















3.  Select Particles - Particle Tool - Option box. Setting as following and create.

     Particle name : flyParticles
     Number of particles : 20
     Maximum radius : 40

4.  Select fly1 through fly 8 in order in Outliner. The order will determine the cycling
     order used by the instancer.

5.  Select Particles - Instancer (Replacement) - Option box. Set as the following and Create.

     Particle Instancer Name : flyInstancer
     Cycle : Sequential
     Cycle Step Size : 1




















  •  A cycle setting of Sequential causes the instancer to cycle through the object indices in sequence rather than not using any cycling at all. A Cycle Step Size of 1 causes the instancer to display each object index for 1 frame before changing to the next item in the list.

6.  Hide fly1 through fly8. Playback the animation. All flies move in the same fashion.

7.  Select flyParticles and open the Attribute Editor. Go to Add Dynamic Attribute - General.
     Under the new tab, set the following options.

     Attribute Name : customAge
     Data Type : Float
     Attribute Type : Per Particle (Array)
     Add Initial State Attribute : ON

8.  Right mouse click on customAge Attribute and select Runtime Expression Before Dynamics.
 
     if (particleId ==0)
          customAge = age;
     else if (particleId ==1)
          customAge = age * 0.5;
     else if ((particleId % 2 == 0) && (particleId % 3 == 0))
          customAge = age * 0.25 * particleId / 4;
     else if (particleId % 2 == 0)
          customAge = age* 0.4 * particleId / 4;
     else if (particleId % 3 == 0)
          customAge = age * 0.35 * particleId / 4;
     else
          customAge = age * 0.2 * particleId / 4;

  • Each particle has unique particleId. By using the particleId, it controls this duration on a per particle basis. This is accomplished by multiplying the particleId by the age and saving the result in Age control we made above.

9.  Select flyParticles, set Particle Render Type to Numeric. You can see which particle
     will be affected by which portion of the expression.

10. Go to flyParticles' Attribute Editor - Instancer (Geometry Replacement) - Cycle Option
      - Age pull down menu, select customAge.

11. At the flyParticles Attribute Editor - Add Dynamic Attribute - General. Under the
      new tab, set the following options.

      Attribute Name : startPick
      Data Type : Float
      Attribute Type : Per Particle (Array)
      Add Initial State Attribute : ON

12.  Add creation expression to startPick attribute.

      if ( particleId == 0 )
          startPick = 0;
      else if ( particleId ==1 )
          startPick = 1;
      else if ( ( particleId % 2 == 0 ) && ( particleId % 3 == 0 ))
          startPick = 2;
      else if ( particleId % 2 == 0 )
          startPick = 3;
      else if ( particleId % 3 == 0 )
          startPick = 4;
      else
          startPick = 5;

  • After step 11, all flies begin their sequence at their fly1 position. You can change the object index the sequence starts on by setting the CycleStartObject attribute in the instancer. To do this, you will create another custom attribute (above). It controls CycleStartObject on a per particle basis.
13. Go to flyParticles' Attribute Editor - Instancer (Geometry Replacement) - Cycle Option      - CycleStartObject pull down menu, select startPick.

14. Playback the animation. 















Reference
  • Autodesk Maya 2011, 2010. Autodesk Maya Online Help : Introduction. [online] Available at : < file:///Applications/Autodesk/maya2011/docs/Maya2011/en_US/index.html?url=./files/GS_Introduction.htm,topicNumber=d0e1838 > [Accessed 25 February 2011].
  • Marc-André Guindon., 2005. Learning Maya 7 : The Special Effects Handbook. Unknown: Sybex

    No comments:

    Post a Comment