5/21/12

Adding dynamics to Mograph cubes in Maya

Using procedural animation method we can mimic the Mograph module of Cinema 4D in Maya easily. I already covered that part in tutorial ‘abstract dancing cubes’. If you don’t have clear idea about procedural animations please watch the above mentioned tutorial first and continue this. Anyway I am covering the procedural part in this tutorial also. But I skip some steps.

Difficulty Intermediate

Tools Maya 2012 and above you can use Maya 2010 and 2011; all the steps will work fine except some advanced shading parts.

Topics covered

· Preparing the scene using clear hierarchy for procedural animation
· Animating the cubes using procedural animation
· Applying the animated shaders
· Applying the dynamics
Watch the Demo video,
dynamic cubes
You can see two modules in this video.
1 with dynamics
2 without dynamics
I created the entire animation using procedural animation tools and the end result is shown in video without dynamics. In the second module of the video you can see there is no collision, randomness etc. they are simple animation key frames. After some frame the animation stops. But in the first module with dynamics the cubes are behaving dynamically i.e.. They have collision, randomness etc. they perfectly collides with ground and never pass through the base and have sufficient self-collision also. In both video you can see the colours of the cubes are changing gradually according to the time.
Here are the steps,

Preparing the scene

1. Create a new project in Maya and set the default folders.
2. Create a new scene and set the play back speed to 24 FPS. Set the frame range to 400.
3. Go to top view and create a new polycube with width, height and depth set to 1.make sure that all the subdivision parameters are set to 1. (yes you can increase if you really want to slow down your system! It is completely personal choice because some people like to stress their system to maximum level. )
4. Set the transformation of the polycube to
5. Translate X= 1.5 Translate Y=0.5 Translate Z = 0 Rotation values should be 0 and scale values should be 1.
6. Delete the history by selecting the polycube1 and go to edit> delete by type> history. We are going to make copies of this cube, so keeping the history will slow down.
7. Select polycube1 and go to edit> duplicate special> option (select the small rectangle). Select edit>reset setting.
Now change the following value,
8. Translate X= 1.5 Number of copies=14 and click Duplicate special.
Duplicate special
Now we have something like this,
Duplicate special
9. We need to create a hierarchy for these cubes. Now they are not connected to each other. Select all the cubes and go to window>hypergraph: hierarchy. Press ‘f’ to focus the all the cubes.
heirarchy
10. Now deselect all the cubes by clicking the empty area in hierarchy window. Using middle mouse drag polycube15 to polycube14. Polucube14 to polycube13 and so on. The final output should like this
heirarchy
You can achieve the same by doing the same procedure in Outline or LMB dragging in viewport.
Now we created the hierarchy node. Select each cube and see how they are connected.
11. Select the polycube1 and create a group by edit>Group or by pressing CTRL+g. the group1 have the pivot resting on the centre of the grid.
parent
12. Go to edit>duplicate special>options. Reset the values. Change the values,
13. Rotate Y= 30 Number of copies= 11 and press duplicate special.
Duplicate special
Now the resulting cubes are overlapping at the base level.
14. Go to outliner and select groups 1 to 12 and translate in X axis so that they are not overlapping each other.( make sure that you are using local translation by holding the key ‘w’+ LMB and select ‘object’.
local transform
local transform
15. Check the outliner and expand it and study how they are arranged.
 

Animating the cubes

16. Go to frame 25 and select all the groups. Go to edit select hierarchy and press‘s’ for setting a key. It will take a while depending on your computer speed.
heirarchy in maya
17. Turn on the auto key frame toggle by clicking the key icon found at the bottom right side in playback area. Deselect the cubes by clicking an empty area in viewport.
18. Go to frame 1 and select all the cubes by dragging in view port and type in translate in X =0 so the cubes rest under their parent cube and forming a ring. See the figure.
group
19. Select all the groups in Outliner and go to modify>centre pivot and change the values of Translate to 0. Leave the Rotate attribute intact.
group
Now play the animation. You will get a nice array of cubes forming animation.
20. Go to frame 60 and select all the cubes (not the group) by drag selecting in view port and rotate them Rotate X = 0, Rotate Y = 12 Rotate Z = 12. (Make sure that you are rotating on local axis by holding ‘r’ + LMB and selecting local). You will get a nice figure like this.
mograph in maya
21. You can manually add rotation. Experiment with rotation, translation and add periodic key frames up to 200.
Watch the tutorial named abstract dancing cubes’.
22. Go to frame 230 and make the appearance of the cubes like in figure. You can have your own figure but it must be above the grid and should be well apart from each other.
mograph in maya
23. Play the animation. You can add key frames for each groups and cubes to get different animations.
24. Save the scene as different version.
 

Applying the Shaders

1. Select all the groups in outliner and go to polygon mode and select Mesh> combine. It will take a while depending on your computer speed. If your computer is really old go for a break and have some Coffee.
2. Now we have a single mesh named polysurface1. Rename it to ‘Cubes’. Don’t delete the history.
3. Save the scene. Play the animation. You can see the animation is there. if you open the Outliner and check there is all the hierarchy, but a transform node is assigned under each polycube. If you want to experiment select the ‘Cubes’ and delete the history. You will lose the animation and all the hierarchy groups will disappear. Undo the scene.
4. Select the ‘Cubes’ and go to frame 25 and apply a new Phong material.
5. Select the Phong1 and apply a ramp to the colour slot. The final effect will look like this.
ramp in maya
6. All the cubes have same texture. We need to randomize it gradually. This unity is because of the same UV. Select the ‘Cubes’ and go to window> UV texture editor. You will get something like this.
UV in Maya
7. We have to match the UV according to the current mesh position. Go to viewport and select the ‘Cubes’ and press ‘SHIFT’+RMB and select mapping> planar map Y. See the picture.
planar mapping
Now the cubes have a gradually changing ramp texture.
ramp texture
8. Select the Ramp 1 (use Hypershade for selecting) and change the type to UV ramp.
ramp texture
9. We need to randomize the colour. Change the U wave and V wave as U wave= 0.166 V wave= 0.73
ramp texture
10. Select the HSV Colour Noise and change the values. (If you are using Maya 2011 and older this option won’t be available.)
11. Hue noise= 0.695 Saturation noise =0.133 Value noise = 0.378
noise in ramp
12. Select the Placed 2d texture 1 and add an expression in Rotate Frame by selecting and typing “=frame/2” without “ ” and press Enter.
You can play with different values and expressions.
Play the animation. See how the colour changes according to time. Save the scene to a different version.
 

Applying the Dynamics

1. Select nDynamics mode. Go to Frame 1
2. Select the ‘Cubes’ and go to nmesh>create nCloth. This will create a nucleus1 and nCloth1 node in Outliner.
3. Select the nucleus1 and go to attribute editor and find the node named Time Attributes, expand it and change the start frame to 25. This will help in stimulation because at frame 25 the cubes are well separated.
nucleus
4. Right click on play back control and select playback speed>Play every Frame-max real time
playback control
Play the stimulation. You can see the cubes are gradually falling down and not following the key frames. This is right.
5. Select the nucleus1ndfind attribute called Ground Plane and turn on the Use Plane.
nucleus
6. Play the stimulation again. Now the cubes remain in the grid. If you want to check the real dynamics change the Start time in nucleus1 to 60 and play the stimulation. After frame 60 the cubes begin to fall down with respect to gravity and collide with the grid, bounces and collide with each other. Happy now. Change the start frame back to 25 and save the scene. If you feel the stimulation is slow change the scene scale to 0.05. These settings will nearly real stimulation. But I used the default value 1 because I need the slower stimulation. Better you also use value 1 for this tutorial.
7. Ok we need to link the animation to the dynamics. Select ncloth1 go to attribute editor, expand Dynamic attributes and find the attribute called Input mesh attract and change these value
Input mesh attract value = 0.20
Input attract damp = 0.002
Input motion drag = 0.001
Save the scene.
Experiment with different value and find the difference.
8. Now the cubes have animation and dynamics. But after the animation completes the stimulation is not good. So go to frame 225 and select nCloth1 and set a key frame in Input mesh attract value.
ncloth
9. Go to frame 230 and change the input mesh attract value to 0 and set a key frame.
ncloth
10. Save the scene and play the stimulation. If you are having slow fall down of the cubes after the animation increase the mass to 10.
Cache the simulation. Set lighting and render in Mental Ray.

3 comments:

Cathi Wenger-Oehn said...

I have a problem, I always geht the warning message:

"warning: nucleus evaluation skipped, frame change too large".

Do yu know what I can do? thank you

3D Motion Pictures Limited said...

Set your Time settings to "play every frame"

Joseph Cross said...

Question...I have a building exploding and when I try to cache I get the "warning: nucleus evaluation skipped, frame change too large"...I do have Playback speed set at "Play every frame". Help