12/23/11

collision event-growing plants

  Doing particle dynamics in Maya is little bit complex compared to other 3d packages.Once you get the right track you can make stunning effects with particles inside Maya.Here I am showing a cool and easy way to create rain dynamics but instead of pruning water drops I am creating growing plants. I tried to avoid expressions and scripting as long as possible.
The repeating animation cycle of instanced particle according to the lifespan is the base of most of dynamic effects.
 
Topics covered
  • Particle dynamics(creation,field and collision)
  • Animating a growing plant with paint fx
  • Converting the paint effects to mesh
  • Instancing the animated mesh to particles
  • Adjusting the different attributes of instances to get desired effects.


Here we go

Rain Dynamics

  • Create a new scene in Maya.
  • Create a default plane with 10x10 spans and 25x25 width x height.(It can be any shape, ground,mud etc.…For the tutorial purpose I am using a simple plane.)
plane
  • Delete the history.
  • Go to dynamics menu and create an emitter with default settings.Translate in Y axis by 20 units.
  • Change the emitter type to volume and particle rate to 25.Scale the emitter volume to 12 x 12 in X and Z axis.
emitter
  • Select the particlehape1 and change its name to rainparticles.Add a gravity field with default value to the rainparticles.Now change the rainparticleshape from points to streaks.
rain parrticle
We have created our rain effect. Now we need some collision so that the plants can grow from out of the surface.
  • Select the rainparticles + shift select the surface and go to particles tab under dynamics menu and  select make collide.
  • Now we are going to generate some secondary particles.
  • Select the particle collision event editor.
collision
  • You can see a tab with your rainparticles selected.Simply tick the all collision tab and select the emit option under event tab.Make the spread value to zero and tick the original particle dies under event action.And press create event.(Note that number of particles should be one for this effect.If you want to create water splash or spawning increase the number of particles and adjust the spread value.But I am not showing that effect in this tutorial so simply kept the number to one.)
collision event editor
Now play the dynamics from beginning.You can see the as soon as rain particles hit the ground it disappears and new particles(points) are created and slides over the plane.
secondary particles
  • Select the secondary particles (particleshape1) and change its name to pruneparticles.Change its conserve value to zero.( To avoid unwanted motion of particles.)
conserve particles
Now play the animation from beginning.The pruneparticles remains on the ground.
  • Save the scene.
  • Select all the particles and add it to new display layer and hide it.
Now we are going to create a growing plant with Maya paintFX.

Growing plant animation with paint effects.

  • Change the menu to rendering and select get brush from paint effects tab.
get brush
I have selected fernstextured brush under plants category.
fernstextured
  • Now create a single stroke on the grid/plane.
May be your plant is created under the plane.Simply turn off the use normals in strokeshape.See the picture below.
strokeshape
  • And change the brush global size to 2.5.
global scale
Now we have a fully grown plant.But we need a growing plant animation according to time.It is very simple.Follow these steps.
  • Go to the flow animation tab under the fernstextured1,
  • Turn on the time clip and change the flow speed to one.
Play the animation.
brush animation
  • Now you can see our plant is growing according to the time.Don’t worry about the wired view.Note the final frame at which the plant is fully grown.Here it is at 70.But we need it at frame 25.It is very easy.Divide the actual final frame with desired final frame number,i.e., 70/25= 2.8    enter this amount in the flow speed value. 2.8
Play the animation. Now the animation completes at frame 25.In this way you can create plant growing animation very easily.Adjust the flow speed value for slow/speed growth rates.
Now we need to convert the paint effects to real mesh.This step is necessary for this tutorial.
  • Select the texturedfern paint stroke and do modify>convert>paint effects to polygon>options
convert painteffects to polygon
  • Turn on the quad output from the option menu,leave the rest as it is.
convert option
  • Click convert.Now you get a polygon plant with animation.The paint effect is automatically get hidden.
Now we need copies of the plant mesh at each frame.Here is 25 frames so we need 25 still copies of plant sequentially.I think there are some MEL scripts/plugins named instancecopier or something to automate this process.But here I am doing it manually, hm…wait I am going to use some basic scripts also…so semi automatic.

  • Go to frame 1 and select fernsTextured1MeshGroup from outliner and press CTRL+d. Now you get a copy of the animated mesh at frame 1.Rename it to proxy.
  • Now go to frame 2 and select the fernsTextured1MeshGroup and press CTRL+d.Now we get the second copy.Repeat the process till the 25th frame.
  • Ok here is the semiautomatic method.Go to frame 3 and select fernsTextured1MeshGroup and press CTRL+d .You will get the third copy.Now open the script editor and find below lines and copy it to the mel tab
select -r fernsTextured1MeshGroup ;
duplicate -rr;
duplicate command
  • Now simply go to frame 4 and press the blue double arrow button(execute all) at the top of the script editor.And go to next frame and press the blue double arrow button.Repeat the process till frame 25.( If anyone know the script to do this fully automatic please give it as comments under this post).
  • Now we get 25 sequential copies of our growing plant.We already renamed the first group to proxy.So we need to rename rest of in same order.Select the fernsTextured1MeshGroup1 to fernsTextured1MeshGroup24 from outliner and  go to menu input line operations switch at the right top corner and select rename.See the image below.
rename
  • Now type proxy in the input area.Maya automatically renumbers the mesh groups sequentially.
image
Now select the animated mesh named fernsTextured1MeshGroup and hide it. We no longer need it visible.
Ok=K we have 25 mesh groups with sequential patterns of a a growing plant. Now we are going to fix its transformations to the root of grid.Select all the groups named proxy from outliner and press insert and move the pivot to the base of the plant mesh.See the picture below.
image
Press w and snap the meshes in to the root of the grid by pressing x and middle mouse and moving the mouse.Rotate the meshes accordingly so that they are standing vertically.
image
Now go to modify>freeze transformations and apply.
image
Save the scene again.
Now we are going to create the particle instances of these meshes with the pruneparticles.

Instancing the animated mesh with particles.

Unhide all the particles.
  • Select all the proxy mesh group from 0 to 24 from outliner and go to dynamics menu particles>instancer(Replacement) options.
  • Select the proxy groups from 0 to 24 under instanced objects window.Select the pruneparticleshape from particle object to instance.Select the allow all data type option.
image
Press create.
Play the scene from beginning.
Surprisingly you wont get any growing plant upon collision.Don't panic.
Simply select the instancer1 from outliner and change the cycle option to sequential.Play the animation.
image
Hooray….You haven’t done it right.I meant you get the animation but it is not right because after 24 th frame the pant disappears and grow again.That is not right.Then how could we fix it.
Change the cycle option to none.
Select the pruneparticles and go to add dynamic attribute tab and hit general. We are going to create a custom attribute for our instancer to work correctly.
 image
  • Name the new attribute to sequential and select the float and perparticle option and press OK.
image
  • Now right click on sequence attribute under perparticle array attribute and select add new ramp and go to option.
image
  • Press OK
image
  • Again right click on the sequence attribute and select edit array mapper.
image
  • Change the max value to 24 i.e. our last proxy group number.
image
  • Now go to instancer(geometry replacement) tab under pruneparticleshape tab and select allow all data type if it is not selected, then select the sequence option under object index tab.
image
  • Play the animation.Now the plant animation is inverted. Right click on the sequence tab under perparticle array attribute and select edit ramp.Change the black color to white and white color to black.
image
  • Play the animation.Now it plays correctly but after 25 frame the plant disappears and growing again.It is because of the lifespan of the particle.Change the life span of particles slightly above the desired animation range in seconds.Here I changed it to 17. ( my frame rate is 24 fps and total desired animation is 400 frames.So I need my particle should be visible above 400 frames.We need to convert 400 frames to sec i.e. 400/24=16.667.  So I chose 17.)
image
  • Now play the animation.The plants grow very slowly.It grow fully only at frame 400. We can change the animation speed by controlling the ramp connected to the sequence attribute.So right click the sequence attribute and select edit ramp.Delete the middle grey color and change the position of the white color to 0.041 (1/24).
Play the animation.
Now hide all the proxy groups.
You can add more attributes to scale,rotation etc.…so the plants look different each other.
If you think the plants appears after 2/3 frames later change the min value of arraymapper1 from zero to 2 or 3.

No comments: