FLEX TUTORIAL
…soft body interaction of plants…

 

In order to achieve a lush environment containing plants it is not enough just to have "pretty" models. To give a scene that look of life you must have realistic motion…and secondary motion. There are two ways this is most commonly seen, through direct interaction of objects with the plants and through the interaction of natural effects such as wind.

I have found that the easiest way to achieve this look is to take advantage of the Flex modifier. The Flex modifier simulates soft-body dynamics. This spring-based system causes vertices to lag behind an object as it moves. Flex works with NURBS, patches, meshes, shapes and FFD space warps. You can also combine Flex with space warps such as Gravity, Wind, PBomb, Push, and Motor to add realistic surface animation to an object. Once set-up this modifier takes care of all motion and secondary motion itself…giving you a very automated scene!

 

Lets take a look at the basics of the Flex modifier itself.

 

Parameters rollout

 

Flex (highlighted in magenta): Sets the amount of flex and bend. Larger values increase the effect. Range=0 to 1000; Default=1.

This value represents the maximum number of frames that a vertex will lag behind.

Strength (highlighted in yellow): Sets the spring strength.

A value of 100 is rigid. Range=0 to 100; Default=3.

Sway (highlighted in cyan): Sets the time for the object to come to rest.

Lower values increase the time for the object to come to rest. Range=0 to 100; Default=7.

 

If at any time you really run into problems you can reset everything with the Reset button.

The reason I am only going through these settings is because this is really all you will need to understand for the direct interaction of objects method. 

If you wish to get into more finesse and control then you can hit the  "F1" key while in Max and check the online reference for details on the other settings.

 

When we go over the second part of this tutorial we will then take a look at the Advanced Parameters, because this is where you will bind the Flex Modifier to your  Wind space-warp.

 

 

Well, on to part 1...objects interacting directly with your plants!

Flex Modifier.jpg (57683 bytes)

 

...Direct Interaction of Objects...
 

Stack.jpg (24873 bytes)

As you can see to the left here is a snapshot of the finished plants modifier stack.  I have split the stack into sections by highlighting it.  In each section you will be controlling/setting up a specific movement of the plant.

The yellow area will control the initial and the gross amount of movement, while the cyan section helps to smooth out the motion across more of the plants surface (this is very important to achieve the look of a plant).  Finally the magenta section sets the model up for the assignment of Flex.

You see for Flex to work properly there must first be some sort of motion for it to react to.  The first question is how to apply that motion...the second is how to get that motion to be localized to the area of contact between the interacting objects.

 

The Volume Selection Modifier is the answer to the question...

 

The volume select modifier allows a person to select vertices based on an interactive and changing volume.  This volume can be controlled by various methods such as the sub-object gizmo, which can take the form of various shapes.  But it can also be dependant upon another object in your scene!  This is great news for us because now we can have the object we want to interact with this plant actually control the selection.  Which in turn will control motion.

Now in your scene you will find an elongated sphere that is animated along a straight path.  During the course of its motion it passes through the plant.  This is obviously the interacting object.  Now the scene in which you have objects interacting may involve a much more complicated model that will be interacting with the plant. 

I suggest however that you just create a simple object such as the sphere that follows the basic form of your interacting object.  Then simply link this simple object to your complex one and use it for the Volume Selection Controller.  I say this because it really will simplify the whole process and allow for faster updates and set-up.

Now lets look at the picture to the right.  This is a how you will want your Volume Select modifier set-up.  The highlighted area are the area that will differ from the default settings. 

Please note that in the yellow section where it says sphere...it would say "Pick Object", you would then pick whatever object you have set-up for interaction.

**Also this will be exactly the same set-up to this point for both of the Volume Selection modifiers in the final plants stack...see previous image.**

 

Finally, in Max R3, Discreet added a great new function called soft selection.  What is allows you to do is to have whatever effect you are going to apply, whether it just be a selection or another modifier, to gradually have its effect falloff.   If it were not for that feature this would be extremely difficult to set-up.  You can see this rollout for this section of Volume Select at the bottom of the picture. 

This is where the two Volume Select modifiers that are in the stack will differ!

VolSel Mod 1-2.jpg (62494 bytes)

Stack.jpg (24873 bytes)

As mentioned before the first volume select modifier is being used to control the main or initial motion.  That is to control the area just around the interaction.  This obviously is the area that needs to be moved by the interacting object the most.

With this in mind you do not need a large fall-off...only just enough so as the plant is still smooth when you apply the X-form modifier (or whatever modifier you deem useful) in the next step.

I used a fall-off of 200 in this scene. This number will vary depending on your objects scale Vs. your world scale.  To find a   setting that is appropriate I moved the time slider along until the interacting object was at it greatest moment of needed interaction with the plant (when it was half way through it).  The selection will show in you view port as red where the vertices are 100% selected,  fading off to yellow, green and finally blue which is not selected at all.  You must have the "use soft selection" box checked. 

Below is a series of screen shots of what the selection looks like at various frames.

**Remember the selection moves with the object because of volume select modifier!

VolSel 1.jpg (67868 bytes)

 

 

 

 

 

 

 

Now that you have the automatic selection set-up based on the interacting object you need to tell the vertices of the plant how to respond or move.  You can do this a number of ways...using pretty much any modifier (bend, twist, skew, etc..) I have chosen to use the x-form modifier.

Go to a middle frame again, one where the object and plant interaction needs to have the greatest effect and set your X-form modifier.  To set the X-form go into sub-object mode and select the Gizmo.  

This is seen in the screen shot to the right.

Now you simply move and rotate the gizmo until the vertices have been displaced enough so that there is no intersection between objects.

To the right shows my x-form modifier at frame 23.

**Keep in mind the direction of movement and aesthetics when doing this! 

Also remember that you do not need to animate this as the automatic selection takes care of this for you...just scrub the time slider to see how the plant now moves out of the way of your object.

Great now you have a plant that is moving out of the way of your object.  But it looks a little stiff.  Plants are generally very flexible and if you push on one part of it, often it can cause almost the whole plant to move slightly.

That's when the second Volume Select modifier comes in!

Xform Modifier.jpg (25064 bytes)

X-form View.jpg (41460 bytes)

Stack.jpg (24873 bytes)

Now, this will begin the second stage of set-up that is in the final plants modifier stack. (see previous stack image)  This will fall under the section highlighted in cyan, and will be used to smooth out the motion and to stop it from being too localized and stiff!

I will not run over the entire set-up of this Volume Select because you will set it up exactly the same as the first.  The only difference will come when you set the Falloff under the Soft Selection rollout (highlighted in yellow).

The reason the selection for this is at 700 is that you need a much higher setting to encompass more or all of the plant.  This is to give the whole plant that subtle motion that Flex needs to give you the smooth secondary animation you are looking for!

Below is a series of screen shots of what the 2nd selection looks like at various frames.

**Keep in mind that this shows the first Volume Selects X-form modifier being applied to the plant.

VolSel 2.jpg (68207 bytes)

 

 

 

 

 

 

 

 

Again, once you have the selection all set you need to apply some modifiers to deform the mesh.  I used another x-form modifier of which I applied basically the say move and rotation to but at a much smaller scale.  The deformations you will be applying at this level should be much more subtle than that of the previous set. 

After the X-form I applied a a nice bend to the plant.   You need this if you want to get the swaying that comes when you brush against a plant, both from physical contact and from the air turbulence you generate.  (Flex can't do anything unless the object first moves...it is only for secondary motion)

To the right is a screen shot of  what the plant looks like with the bend modifier applied to it in the viewport.

The settings used for the Bend Modifier were an angle amount of 12 and a direction of 0, in the Z axis.

Bend ViewPort.jpg (29697 bytes)
 

Finally we get to the last stage of the process before Flex is added  In the stack illustration this would be the magenta highlighted section...preparing the mesh for the Flex Modifier.  This is a very simple stage.  You will notice if you look at the stack all of the modifiers have an asterix by there name...this is because so far everything has been affecting the mesh at a sub-object level, determined by the Volume Select Modifiers.  However we want Flex to affect the mesh as a whole.  To ensure this just add another Volume Select Modifier...and leave everything at default.  That means:

  • Stack Selection Level  =  Object
  • Selection Method  =  Replace
  • Selection Type  =  Window
  • Select By  =  Volume: Box
  • And soft selections is not used

Thats it...now on to the Flex Modifier itself!

 

Now, I have already run though the basics of the Flex Modifier with you.  So really all you need is to experiment with the values until you get something you are happy with.

The only ones I used Flex, Strength, and Sway.   And there setting were 1, 3, and 10 respectively. 

You can see this in the first image (Flex Modifier) in the tutorial where they are highlighted!

The last step and this one is fairly important is to go into the sub-object mode of the Flex Modifier called "Edge Vertices".  Here you will select a few of the vertices at the base of your plant (see image right). 

This is to simply anchor the base...by selecting those vertices you have indicated that you do not want them to move.  This of course makes sense because while you want your plant to sway nicely you don't want it to shift in the ground!

 

Bend ViewPort.jpg (29697 bytes)

 

Well, thats it, you should now have an object interacting automatically with your plant!  It may take a few test previews to get the motion pegged down but thats about it.  You can apply this procedure to as many plants in your scene as you wish, and if the object that is interacting with them is always the same you need only one Volume Selection Controller....just use it for all of them.  Or if you need the precision, make multiple controllers. 

Next up...how to make you plants sway in the Wind!

 

...Interaction through Nature (WIND)...
 

 

The procedure for setting up your scene to have plants interacting with a Wind Spacewarp is actually much easier than direct object interaction...but it may take more fiddling!  And since you already have a good understanding of Flex from the last tutorial I will make this one much more brief.

 

First you will want to set you Flex Modifier to be effecting the plant in such a way as to have the ends of the leaves much more flimsy and loose than the base, which should be solid.  How do you do this...thats right Soft Selection!

To achieve this you will first enter the Vertex Sub-Object mode of your editable mesh (the plant).  Then using soft selections, select a falloff from the leaves to the base.  Leaves being the most selected and the base the least (or preferably not at all)

**You can see a screen shot of what my selections looked like to the right.

Excellent, now without exiting the sub-object mode apply the Flex modifier.  This is very important you must not exit sub-object mode for the the flex modifier to recognize your selection.  Another way you could do this is to apply a Mesh Select Modifier prior to the Flex and do your selections there.

 

Anyway, now that you have your flex modifier applied below are the examples of the settings I used.

 

Edit Mesh Soft Selections.jpg (57031 bytes)

Flex Wind Modifier.jpg (60011 bytes)

 

The first thing I should mention is that the setting under Parameters (cyan highlight) are going to have to be played with for you to get the look you want, but these are a good starting point.

Next, you will notice that under Advanced Properties there are to listings (highlighted in magenta), Wind01 and Wind02.  These are the wind spacewarps in the scene. To select the once you have created them you simply click "Add Force" (highlighted in yellow) and then select them.  You will have to repeat the procedure for each of them.

That takes care of the plant and the Flex Modifier...until later if you you want to play with your parameter settings!

 

Now you need to set-up your wind modifiers. (the creation and placement of these modifiers should be done prior to adding them as forces to the flex modifier).

I have included two wind modifiers in my scene for the simple reason of randomizing the plant movement.  There are other ways of doing this (you can actually add any particle Spacewarp as a force, but I chose to do it this way). 

You can see below the way I situated them in the scene so as they would "play off" each other.

Wind Placement.jpg (31499 bytes)

 

 

 

 

 

 

 

 

 

 

 

One of the things one will notice in the example scene file is that the wind objects are animated side to side.  This is another way to randomize the wind...please understand that there is no set way to animate them and that it is purely up to you to find a motion that suits your needs.

Didn't I say there would be a lot of tweaking! 

The method I used was to go along and rotate them a bit at varying intervals without a whole lot of thought (it shouldn't take more than 30 seconds to do this) then I looked at the plant motion and began to tweak.

Of course I also animated the Wind Parameters!   To the right is a the wind modifier and you will see two highlighted areas.   These are the area I animated.  Again the settings you see may not be the setting you need to use, they may be too strong or too weak...also the animation method is the same as the one described above for there rotation. 

**However, you may need to be a little more careful with these and the flex modifier can be quite sensitive.

One thing to note is that if rendering a scene you should give a few frames as a buffer (say 20 or so) prior to the beginning of the render.   The reason for this buffer is to allow the Flex modifier time to settle into a nice soft motion. At the beginning there is usually a sudden swaying back and forth due to the sudden movement)...this will calm down after a few frames.

 

Wind Modifier.jpg (45163 bytes)

Well that should be about it, now that you have your wind modifiers set-up and picked as your forces in the Flex Modifier all that is left is for you to tweak.

I hope this has been a help to you and have fun creating!