You are on page 1of 12

Maya 104: Dynamics

During this tutorial we’ll explore a number of features of Maya’s dynamics toolset.

In part I - the ‘membrane pore tutorial’ - we’ll create a scene with a turbulent membrane that also
has a ‘pore’ dynamically floating in it. Next we’ll create a swarm of molecules that collide with the
membrane (and can otherwise only traverse it via the pore opening). We’ll gain finer control over
the behavior of individual molecules in the swarm through the use of expressions. Finally, we’ll
add goals to the entire swarm and control the degree to which these goals affect the swarm’s
movement.

In part II – the ‘blastocyst tutorial’ - we’ll look at how a piece of geometry can serve as a goal for
particles. Specifically, we’ll create a blastocyst-stage embryo made up of blobby particles
attracted to a sphere. We’ll control the behavior of these particles relative to the surface of the
sphere. For the finale, we’ll squeeze the blastocyst out of the zona pellucida surrounding it by
using a lattice deformer applied to the sphere.

Part I – “Membrane Pore”

Turbulent membrane: Soft Bodies

Create a NURBS plane that is 10 units in width,


with a length ratio of 1 and with 10 patches in U
and V. This will be the membrane – select it in
the Outliner and rename it ‘membrane.’

Switch to the Dynamics menu set and, with the


plane selected, go to Soft/Rigid Bodies ->
Create Soft Body | Options and use the
following settings:

Creation Options > Duplicate, make original soft Turning the NURBS plane membrane into a soft body
Check ‘Hide non-soft object’
Check ‘Make non-soft a goal’
Weight to 0.5 (default)

Now look in the Outliner: your original


‘membrane’ layer now has a particle object
(‘membraneParticle’) under it... This is the soft
body, where a single particle was created at the
location of every CV in your original NURBS
geometry. Notice also a hidden layer (in blue
text) called copyOfmembrane – this is a copy of
the original NURBS place you created, and
because of the creation settings, its CVs now The Outliner after soft body creation
serve as the goals for each corresponding
particle in the soft body.

For the time being, if you play the animation (set


your timeline to ~500 frames), nothing will

Maya 104: Dynamics


1
happen. To affect the position of the particles in
the soft body (and thereby get the membrane to
undulate) we need to apply a field.

With membraneParticle selected, go to Fields ->


Turbulence | Options – call your field
‘membraneTurbulence,’ and set the Magnitude
to 10 and the Attenuation to 0. Click Create,
and now play the animation. The membrane
briefly moves and then rigidifies – to get more
undulation, we need to do 2 things: lower the
goal weight of the particles to the NURBS plane
(which serves as its goal) and animate the
phase of the turbulence field so it constantly
changing.

Select membraneParticle and, in the Channel


Box find the attribute named ‘Goal Weight[0]’ –
set it to 0.4. If you play the animation, the
membrane moves a little more but still rigidifies
pretty quickly. Now select the turbulence field
and, in the Channel Box, LMB-select and then
RMB-click on the ‘Phase X’ attribute – from the
drop-down menu that appears, select Adding expressions to the phase X, Y, and Z of the turbulence field
Expressions. The Expression Editor opens – in
the blank space at the bottom, type in the
following:

membraneTurbulence1.phaseX = time;
membraneTurbulence1.phaseY = time;
membraneTurbulence1.phaseZ = time;

Click Create, close the Expression Editor, and


now play the animation!... You have an
undulating membrane.

Experiment with the ‘Goal Weight[0]’ value of


‘membraneParticle’ – as you might expect, the
higher the goal weight, the less undulation: this
is because the particles want to be ‘closer’ to the
CVs on the NURBS plane (which serves as their
goal). In doing so, they are less affected by the
Turbulence field that is trying to displace them.
Conversely, if you set the goal weight to 0, it’s
as if the particles of the soft body are not
‘seeing’ the NURBS plane goal at all, and the
turbulence field quickly scatters the soft body’s
particles in every direction.

Set the goal weight back to 0.4 before


proceeding with the rest of the tutorial.

The soft body membrane with a goal weight of 0

Maya 104: Dynamics


2
Creating a membrane pore

Next, we'll need to cut a hole in the membrane


for our pore. We'll do this by projecting a circle
onto the plane and trimming the surface. (note
that if we made a polygon plane, we could
simply select a face and delete it). First, make
sure you go back to frame 1 of the timeline.
Create a NURBS circle with a Radius of 1 and
make sure it is positioned at the origin. Select
Projecting the circle onto the NURBS plane
the circle, then the plane, and in the 'Surfaces'
menuset, select Edit NURBS > Project Curve
on Surface

To trim the surface, select the plane, and go to:


Edit NURBS > Trim Tool. The plane should
become transparent with white lines indicating
the two sections. Click on the square shape (not
the circular shape) and hit Enter. You should
see that the shape you clicked on was retained,
and you should have a square with a little Using the Trim Tool. Click on the outer square shape to keep it
circular hole in it. You can play the animation
and see that the trimming did not affect the
undulation of the membrane. Return to frame 1.

For reasons that will become clear later, repeat


the process you just did (i.e. ‘project-on-surface’
and ‘trimming’) using the same circle but this
time with the copyOfmembrane NURBS (which
is currently hidden). After finishing this you can
hide or delete the circle.

Now create a NURBS torus of radius = 1 and


height ratio of 0.3 (you can enter these values Our very simple membrane pore
in the Channel Box after creating the torus).
Position the torus at the origin so it sits
exactly over the membrane hole. Not
surprisingly, if you play the animation again, the
membrane undulates but the pore doesn’t move
– not a very convincing integral membrane
protein! It would be nice to have the pore be
influenced by the local movement of the
membrane it is supposedly sitting in. To
accomplish this effect, we’ll convert the pore to a
soft body and then link the soft body particles to
those of the surrounding membrane via springs.

Select the torus and go to Soft/Rigid Bodies ->


Create Soft Body. No need to go the options
panel this time – it should use the last settings
you used for the membrane (i.e. duplicate the
geometry, make the original geometry soft,
make non-soft duplicate a goal, and hide the
non-soft duplicate). Now switch to component
mode (F8), go to the Top orthographic viewport, Selecting the CVs on the torus and the membrane’s CVs
immediately surrounding them

Maya 104: Dynamics


3
and switch to Shading -> X-Ray. Click-drag
select all the CVs on your torus, then click the
plane and shift-select only the CVs surrounding
the torus (see image on the right).
With these CVs selected, go to Soft/Rigid
Bodies -> Create Springs | Options. Change
the Creation method to ‘All’ and the Wire walk
length to 3. In the viewport you’ll notice a mess
of dotted lines have appeared – each dotted line
is a spring connecting CVs. In the Outliner,
select spring1 and hide it… will make it easier to
view the moving geometry underneath. Now
play the animation – the torus should be moving
slightly with the membrane. You can increase
this effect by increasing the stiffness value on
the springs: select ‘spring1’ in the Outliner and
find its Stiffness attribute in the Channel Box –
set it to 20.

A general note on particles and fields in a Maya


scene… if you select a particle object and then
create a field, Maya automatically connects that
field to the particle object. But what if you have
an existing field in your scene and you want to
connect a new particle object to it? These types
of relationships are controlled via the ‘Dynamic Spring creation settings
Relationships’ editor…

For example, let’s say we want to connect our


torus soft body to the existing turbulence field…
remember that right now, it is only moving
because it is connected to some of the
membrane’s CVs via springs. To have the torus
soft body directly influenced by the existing
turbulence field, go to Window -> Relationship
Editors -> Dynamic Relationships. The
window shows an Outliner-like listing on the left
column. Select nurbsTorus1 and to the right
should appear ‘membraneTurbulence1’ – but it
is not selected. Click ‘membraneTurbulence1’
(will now be highlighted in blue) and play the
animation. The torus is now being deformed
much more dramatically because its particles
are being pulled directly by the field – however it
is still anchored to the membrane via the The Dynamic Relationships window lets you control which particle
springs! A little too drastic an effect for this objects ‘see’ which fields in your scene
scene – so, in the Dynamic Relationships
window, click on ‘membraneTurbulence1’ again
to deselect it.

Water particles with collisions

We’ll begin by creating an emitter - go to


Particles > Create Emitter | Options. In the

Maya 104: Dynamics


4
window that appears go to Edit -> Reset
Settings and use those defaults. You should
see a small circular object appear. Move (w) the
emitter down so that it is underneath the pore
and play the animation.

You should see that some very small gray


objects are being emitted in all directions. To
see the particles a little better, we'll change the
particle type. Select ‘particle1’ in the outliner,
rename it ‘waterParticle’, and open its
attributes ('ctrl + a'). Under the tab entitled
'waterParticleShape', scroll down to the The particle emitter, emitting particles.
Render Attributes tab and select 'Spheres.'
Click on the button 'Current Render Type' and
change the radius to 0.1. You should see that
your particles are now small spheres.

To have the particles collide with the membrane,


we’ll need to have it collide with the hidden
NURBS copy of the membrane. This is because
particles can’t collide with particles, and the
undulating soft body membrane is made of
particles! Select ‘waterParticle’ and
‘copyOfmembrane’ and go to Particles > Make Changing the particles to spheres
Collide. Repeat this for the Torus – select
‘waterParticle’ and ‘copyOfnurbsTorus’ and
Make Collide.

Now open the Dynamic Relationships window,


select ‘waterParticle’ on the left, click on the
‘collisions’ radio button at the top. In the left-
hand column click on ‘membraneShape’ to
select it and deselect ‘copyOfmembraneShape.’

Now go back to the beginning of the timeline


and hit play. You should see that the particles
don't go through the membrane anymore
(though some may peek through while they
bounce off). A lot of the particles are floating off Getting waterParticle to collide with the non-soft
the sides, though. We can keep them contained membrane as a proxy for the soft body membrane
by making a big sphere and using that as a
collision object just as we did for the membrane.

Create a NURBS sphere of a radius of 5,


located at the origin. Select the particles in the
outliner, then the sphere, and select Particles >
Make Collide. To be able to see through the
sphere, with the sphere selected, go to Display
> Object Display > Template. Go back to the
beginning of the timeline and press play.

We can put an upper limit on the total number of


particles. To do this, select the particle, and in
the channel box, input '200' into the 'max
count' field. By default, the max count is -1 The particles collide with the large sphere object, which has been
made into a template object.

Maya 104: Dynamics


5
(infinite). Now if you play, you can see that the
emitter stops emitting after it reaches 200
particles.

Next, we'll change the particles to sprites. Open


the waterParticleShape attributes (select Changing the maximum number of particles emitted (Channel Box)
particles and hit ctrl+A) and change the particle
Render Type to 'Sprites.' The particles should
change into gray squares.

We'll need to adjust the color of the sprites.


Under the 'Add Dynamic Attributes' tab, click
on the 'Color' button and select 'Add per
object' attribute – click on ‘Add Attribute.’ Now,
under the Render Attributes tab, if you click on
'Current Render Type,' you can change the
color of the sprites by changing the RGB values.
Change them so that Color Red, Blue and
Green are all 1. This should change the sprite
color to white. Change the Sprite Scale X and
Y to 0.2 to make the sprites smaller.

To get our sprites to look like molecules, we'll


Changing the RGB value for the Sprites
create a shader for the sprites. Open the
Hypershade and create a new lambert. Under
the color channel, select the checkered box and
select 'file' for the texture type. For the image
name of the file, select 'smallMol1.iff.'

Now apply the new shader to the sprites. The


image used for the shader had an alpha, or
transparency layer, so now the sprite doesn't
look like a square anymore.

If you want to avoid having the sprites peeking


through the membrane during collisions, you can
create another membrane collision plane and
move it lower than the original.

Next we'll add some rotation and jiggly, random Sprites with shader applied.
movement to the molecules using MEL scripting.

To change the rotation of the particles, open the


ParticleShape attributes. Under the 'Add
Dynamic Attributes' tab, click on the 'General'
button. This opens a new window where you
can either create a new dynamic attribute or
select from some ready-made ones. Switch to
the 'Particles' tab and scroll down until you find
"SpriteTwistPP." Select it and click the 'Add'
button.

Now if you look under the 'Per Particle (Array)


Attributes' tab, you should see that a
'spriteTwistPP' line has been added. Right
click in the box next to the spriteTwistPP,
Adding a 'spriteTwistPP' dynamic attribute.

Maya 104: Dynamics


6
and select 'Creation Expression..." This will
open the expression editor window.

The Creation Expression defines the particle's


attributes when it is first born. Here, we want to
create a script that will randomize the rotation
values of the sprite when it is first created. We'll
also be creating a runtime expression for the
particles. Runtime expressions (which can be
either before or after dynamics) are evaluated
while the animation is running.

In the Expression editor, write the following MEL


script:

spriteTwistPP = rand(0,360);

Click 'Create' when you are finished. Now if you


go to the beginning of the timeline and play, you
should see that all of the sprites have a random The expression editor
rotation at the beginning of the animation. This
rotation, however, does not change during the
course of the animation.

To have a change in rotation, create a runtime


expression for spriteTwistPP. You can do this
by either right clicking in the 'spriteTwistPP'
field in the ParticleShape attributes and
selecting 'Runtime Before Dynamics
Expression..." or, if your Expression Editor is still
open, by clicking on the 'Runtime before
Dynamics' radio button.

In the Expression editor, create the following


runtime expression:

spriteTwistPP += rand(-2,2);

This expression is shorthand for:

spriteTwistPP = spriteTwistPP + rand(-2,2);

This tells Maya to add some random number


between -2 and 2 to the old value for spriteTwist
Radio buttons (red circles) to switch between writing creation
for each particle from the previous frame. This expression and runtime before dynamics expressions.
results in a slow, random rotation for the particle.
Play the animation to see this. You can change
the values that are added to be larger for a more
dramatic difference (by using rand(-5,5), for
example).

To create a more jiggly movement, rather than


the rather straight linear movement we have
now, we'll write an expression for the velocity of
each particle. This time, the dynamic attribute is
available by default, so we don't have to add it.

Maya 104: Dynamics


7
Under the waterParticleShape attributes, go to
the 'Per Particle (Array) Attributes' tab and
right click next to 'velocity.' Select 'Creation
Expression...'

In the Expression Editor, type in this script,


either above or below the spriteTwistPP lines:

velocity = <<(rand(-2,2)), (rand(-2,2)), (rand(-2,2))>>;

Click on 'Edit.'

This tells Maya to start the particles off with


some random velocity between -2 and 2 for x, y
and z.

Now switch over to the runtime script by clicking


on the 'runtime before dynamics' radio button
in the Expression Editor. Add the same line:

velocity = <<(rand(-2,2)), (rand(-2,2)), (rand(-2,2))>>;

Click on 'Edit.'

Now if you play the animation, you can see that


the particles are jiggling around, but they're
jiggling so much that they aren't getting
anyplace. Let's change the runtime expression
so that the velocity only changes every 5th
frame.

Change the runtime expression for the velocity


to:

if (frame%5 == 0)
{
velocity = <<(rand(-2,2)), (rand(-2,2)), (rand(-2,2))>>;
}

These lines tell Maya to change the velocity to a


random value only when the frame number is
divisible by 5 (that is, when the remainder of the
frame number divided by 5 is equal to zero).

Make sure you press 'Edit' in the expression


editor and replay the animation.

Note: to render Sprites, you need to render them


using Maya's hardware renderer. Generally,
sprites and other particle types that can't be
rendered using Maya's software renderer need
to be composited with other scene elements in
post-production.

Maya 104: Dynamics


8
Swarming goals

Finally, we’ll add another level of control to the


water sprites in the scene by adding a transform
node ‘goal.’ Go to Create -> Locator and
position it above the membrane and a bit to the
left (it should be inside the large NURBS sphere,
but not directly above the pore opening). Now
select the particles, shift-select the locator
and go to Particles -> Goal.

If you play the animation, you’ll see the particles


are now immediately attracted towards the
locator but are stuck under the membrane. In
order to get some of those particles to reach the Getting the sprites to swarm towards a locator goal
locator, we need to lessen the goal weight a bit.
In the Channel Box for waterParticle find Goal
Weight[0] and reduce it from the default 0.5 to
0.15. If you wanted to start with rather ‘aimless’
particles for a time and then have them
progressively swarm towards the locator goal,
you would simply key the goal weight value over
time (i.e. low value or 0 in the beginning followed
by a higher value).

Now lets create another locator and add it as a


goal to our waterParticle. Create -> Locator and
position it above the membrane but this time on
the right side of the pore. Select the particles,
shift-select the locator and again go to
Particles -> Goal. If you go the waterParticle
Channel Box, you’ll see that there are now 2
sets of Goal Weight attributes: Goal Weight [0]
and Goal Weight [1]. If you set both of these to
0.5 and play the animation, you’ll notice that all
the particles swarm to an intermediate position
between the two Locator goals (which happens
to be directly over the pore, so they all traverse
it). You can control the speed with which they
get to this position by increasing the Goal
Weight values… in fact, if you set both to 1, they A particle object has 2 goal weight values
will instantly go to that position. Again, this does when 2 locator goals have been applied to it.
not affect where they swarm, but how fast they
get there… this is true as long as the goal
weight values are identical.

You can end by making a simple animation…

Frame1:
Goal Weight [0] = 0.15 & Goal Weight [0] = 0

Frame180: key same values as frame 1

Frame360: The particles have 2 Locator goals applied – because these have
Goal Weight [0] = 0 & Goal Weight [0] = 0.3 identical goal weight values, the particles swarm to an
intermediate position

Maya 104: Dynamics


9
Part II – Blastocyst

Creating the blobby blastocyst

Set your timeline to 500 frames and create an


emitter (reset settings). By default this will
create an Omni-type emitter at the center of your
scene. Press play to see point particles
emanating from it in all directions. Select the
particles and open their attributes – go down to
the ‘Render Attribute’ section and select The Blobby surfaces particle render type as seen in the viewport
‘Blobby Surface’ for the particle Render Type –
click on the ‘Current Render Type.’

Run the animation until ~frame 150 and then


play with the setting for the blobby surface
Radius and Threshold. I would recommend
leaving the Radius between 1 and 1.5 in the
beginning and testing the Threshold value
between 0.5 and 0.8. As you do test renders
after each change, notice that some settings
allow the spheres to ‘meld together (this effect is
very similar to what we saw for Cinema4D’s
metaballs system). Set the Radius to 1 and
Threshold to 0.08 before proceeding.
Blobby surfaces rendered (radius of 1.6 and threshold of 0.7)
Now create a NURBS sphere with a radius of 5
and center it at the origin of your scene.
Select the sphere and, in the Surfaces menu
set, go to Edit NURBS -> Rebuild Surface |
Options. Reset Settings and then select Keep
NumSpans – make sure the Parameter range is
‘0 to 1’ (this is the reason we are rebuilding the
surface). When you click Rebuild, the sphere
will not appear to change in the viewport, but its
parameterization will have been set from 0 to 1
(and this will be important for the expressions
we will be writing later on).

In the same way that we set a Locator to be a


particle goal in Part I of the tutorial, this time
we’ll have the NURBS sphere be a goal for the
particles… the big difference is that we will not
have the pivot of the sphere be the goal but
rather each of its CVs. Select the particles and Rebuilding your sphere such that the min and max
shift-select the sphere – go to Particles -> range for the UVs is 0 to 1.
Goal | Options. Reset Settings (the important
thing is that ‘Use transform as goal’ is NOT
checked). Set the goal value to 1 and click
Create. If you play the animation, you’ll see that
the blobbies immediately go to several positions
around the sphere… these are the CVs!
Remember that on a NURBS sphere (as well as
any other curved NURBS surface), the CVs do Setting the NURBS geometry of the sphere as a goal

Maya 104: Dynamics


10
not actually lie on the surface. This is problem
for what we are trying to do (i.e. to ‘coat’ the
sphere with particles).

We need to instruct the particles to go sit on the


NURBS surface of the sphere – and to do this,
we’ll need to write some expressions (as with
most things in Maya dynamics!).

Select the particles and, in the Attribute


Editor, scroll down to the Add Dynamic
Attributes tab – click on General, and under the
Particle tab, select both goalU and goalV – and Blobby particles instantly migrate to the CVs of the sphere
click Add and then close. Now we’ll set a when the goal value is set to 1
creation expression on these:

In the Per Particle (Array) Attributes, RMB-


click next to goalU and select Creation
Expression… in the window that appears,
enter the following expression:

particleShape1.goalU = rand(1);
particleShape1.goalV = rand(1); Adding goalU and goal V attributes to the particle object

Click on Create. Now play the animation and


you’ll notice that the particles now populate the
surface of the sphere randomly. Stop the
animation around frame 400 and take a render –
getting to be pretty embryo-like already! You
can populate the sphere surface with particles
more rapidly if you increase the emitter’s rate -
select the emitter and set the rate to 500 in the
Channel Box.

We can also add expressions to achieve other NURBS sphere populated with particles on its surface after
effects on our particles – for one, it might be nice adding an expression to the goalU and goalV attributes
(if creepy) to animate the movement of the
particles by offsetting them slightly from the
surface. For this we can create a runtime
expression (instead of a creation expression)…
for each frame of the animation, the expression
will ‘pick’ a random value to offset each
individual particle from the sphere surface.

Go back to the particle Attribute Editor and


under Add Dynamic Attributes tab – click on
General again. This time select ‘goalOffset’
from the list and click Add. Now that this
attributes is showing in the Per Particle (Array)
Attributes, RMB-click to the right of it and
Blobby surface render of previous image
select Runtime Expression Before Dynamics.
Enter the following expression:

particleShape1.goalOffset = rand(0.2);

Maya 104: Dynamics


11
Click on Create and play your animation –
particles are now jiggling on the surface.

Squeezing the blastocyst-stage


embryo out of the zona pellucida
As seen on the reference image on the right, the
blastocyst can leave its protective coating – the
zona pellucida. This is a perfect excuse to pass
our blobby sphere through a lattice deformer!
For now you can hide the particles – select the
sphere and, in the animation menu set, go to
Create Deformers -> Lattice | Options. Reset
Settings and then enter the following values for
the ‘Divisions’: 10 2 2.

In the Outliner, select both the ffd1Lattice and


ffd1Base layers and then activate the scale tool
(r) and scale along the x axis (such that the
overall length of the lattice is roughly twice that
of the sphere’s diameter). Now select the
sphere and move to one side of the lattice.
(Refer to the images on the right for these
steps).

RMB-click over the lattice and select Lattice


Point – now select the purple dots towards the
center of the lattice and scale them down. Refer
to the image below:
Lattice created around the sphere

Finally, on frame 200, set a key on the position


Lattice (and its base) scaled along the x
of the sphere – go to frame 300, move the
sphere to the other side of the lattice (should get
squeezed) and set a key on the new position.
Turn the particles back on and render!

Sphere moved to the side of the lattice

Maya 104: Dynamics


12

You might also like