page 1 2 3 - the shaker - MAYA TUTORAL 2 
  INTEGRATING THE INTENSITY AND FINE-TUNE CONTROLS
 
 
  
If you click on the above image (then return here) you will spot that the real final expression  for the shaker node is vastly more complex than what we have achieved so far.  
  
It is not as complex as it looks though. In essence it is what I have so far explained but incorporates all the controls and also has that 'if/else' statement to allow for conditions where the wander intesity has been set to zero and no cumulative movement is needed.  
  
Lets look again at those custom attributes that were set up on the shaker node on page 1.  
Firstly there was a main intensity setting for each animation property:  
  
Shake_intensity  
Destabilise_intensity  
Wander_intensity  
Jitter_intensity  
  
Then each function had a master intensity control for each translation and rotation channel. The exception was Wander which, as explained earlier, only acts on tx ty and tz:  
  
shake_xtrans_master;  
shake_ytrans_master;  
shake_ztrans_master;  
shake_xrot_master;  
shake_yrot_master;  
shake_zrot_master;  
  
destabilise_xtrans_scale;  
destabilise_ytrans_scale;  
destabilise_ztrans_scale;  
destabilise_xrot_scale;  
destabilise_yrot_scale;  
destabilise_zrot_scale;  
  
wander_xtrans_master;  
wander_ytrans_master;  
wander_ztrans_master;  
  
jitter_xtrans_master;  
jitter_ytrans_master;  
jitter_ztrans_master;  
jitter_xrot_master;  
jitter_yrot_master;  
jitter_zrot_master;  
  
  
NB.1.  all these custom attributes were added as floating point values in the arbitary range of 0-10.  

NB.2  You will note that the destabilise fine controls here read "destabilise_xxxxx_scale" - they are not fine tune intensities but fine tune scale adjustments. More on this later.  
  
  
By incorporating all these controls or variables into our main expression, the shaker node can be adjusted at a main level for each animation property and then at the channel level for fine control.  
  
Imagine a large aircraft cruising high in the air. It will need gentle, smooth movemet in the y axis (destabilisation) as it rides over the air flow and similar movement in the z rotation as it banks slightly left and right. Additionally, a patch of air turbulence may cause temporary violent x and y translation movement (shake with perhaps a little bit of jitter).  
     
Clearly, its useful to have all your parameters controllable to make for all sorts of animation combinations.  
  
  
  
The final expression really just involves integrating these variables into the expression and then adding some scale factors here and there to give usable ranges of shake, destabilisation etc...  
  
On page 1, we saw that the expression to create shake on the x axis was:  
  
the_shaker.tx = ( gauss ( ( rand ( 0 , 1 ) ) ) )   
  
all we do for the main control "shake_intensity" is to insert it where the fixed number 1 is:  
  
the_shaker.tx = ( gauss ( ( rand ( 0 ,    (the_shaker.shake_intensity)    ) ) ) )   
  
Now, the larger the shake_intensity, the greater the range of the first random number generated. Therefore the xtrans offset is bigger and we get larger shaking movements.  
  
The final step is to add in our fine control, shake_xtrans_master, by multiplying it with the main intensity:  
  
the_shaker.tx =  
(gauss (( rand  (0,    (the_shaker.shake_intensity  * the_shaker.shake_xtrans_master) ))))  
  
We can now fine tune the x axis shake, independently of the other channels. However, we need a scaling integer in there otherwise our values will be too high and inappropriate (remember that all our sliders go from 0 to 10):  
  
the_shaker.tx =  
(gauss(( rand(0,(the_shaker.shake_intensity  * (the_shaker.shake_xtrans_master*0.1)) ))))  
  
All the controls are integrated as this example shows for all the other channels and the 3 other animation techniques. Feel free to sift through the final expressions yourself.  
  
  
  

FINAL DETAILS
  
The one exception is the Destabilise fine channel controls which, you will remember, were named "destabilise_xxxxx_scale". This is because they do not increase the intensity or amount of desatbilistaion (only the main destabilise_intensity parameter does this). Rather, they scale the noise (time) function so that more destabilisation occurs per second.  
  
Remember that our skelton expression for destabilistaion was:  
  
the_shaker.tx = noise (time)  
  
this produced a smooth yet random change in movement. Well by multiplying the time variable the movement remains smooth but happens quicker. There is a greter rate of change of movement per unit of time:  
  
the_shaker.tx = noise (time * destabilise_xtrans_scale)  
  
  
  
The final trick to mention is the if/else statement or conditional statement as it is referred to.  
Remember that wander was created using the idea:  
  
x translation = xtranslation + random number  
  
Well if the user has set the wander to zero the random number part of the wander expression will also be zero (once it has all its variables incorporated) but the existing xtranslation will still be added to the other animation effects. In short, the node will still wander.  
  
To get around this the final expression first identifies if the wander_intensity = 0 or not. If it is then the_shaker.tx is given a value of shake + destabilisation + jitter. If it does not equal zero then a second statement (after "else") comes into play and the_shaker.tx is given the value of shake + destabilisation + jitter + the_shaker.tx (its current value) + wander.  
  
It may sound confusing but essentially, if no wander has been set the random offset values generated by the other 3 properties need to be applied directly to the channel in question as opposed to cumulatively. Trust me, it works !  
  
  
  
The final part of this piece of work involved me writing a simple mel script to create my own window with all the controls at hand - far neater than the attribute editor.  
  
Here you can download the_shaker.mb and the_shaker.mel and view the accompanying read_me file.  
  
Best bet is to import the shaker.mb and make it the parent of a camera or object. Then source the_shaker.mel from your script editor and if my custom "shakecontrol" window does not appear, type "shakecontrol" into the Maya command line. If you have problems you can always control the node from the channel box or attribute editor. Play around with the sliders and watch. You might be playing for longer than you think !  
  
NB you may have to right click on these links and choose "save file" in order to download or shift click
  

click here to download zip file of the_shaker.mel

(updated spet 2005 so it works, thanks to matt oursbourn)

 
click here to view the shaker read me notes