Tutorial ******** Let’s start by creating a simple scene that demonstrates some basic principles. First load the Ziva Maya Plugin. We do that by opening the Maya Plug-in Manager; which can be found in the following menu: **Windows➞ Setting/Preferences➞ Plug-in Manager** If our plugin has already been installed in your plug-in path, it should already be visible in the Plug-in Manager. If it’s not there, you’ll have to browse your file structure for the **.mll** on Windows or the **.so** on Linux. After the plugin has been loaded, you should notice that **“Ziva”** and **“Ziva Tools”** menus have been added to the Maya interface. (These menus are covered in more detail in the **“Ziva Menus”** section of the documentation). .. image:: images/quick_start1.png :width: 400px :alt: quick_start1 image Bodies ====== Creating a Tissue +++++++++++++++++ (A "tissue" is the word we use to describe elastic solids in our system) 1. Set your current frame to the first frame of the simulation (for a new scene, this will default to frame 1). 2. Create a Maya polysphere (our tools work exclusively with polygonal geometry): **Create➞Polygon Primitives➞Sphere** 3. Select the sphere 4. Convert the selected sphere into a tissue: **Ziva➞Tissue** 5. Extend your timeline to 5000 frames (so we have lots of simulation time to play with) 6. Watch the sphere fall under gravity: **Ziva Tools➞Interactive Playback** 7. Adjust the solver scale to simulate a larger, more dynamic ball. The first time you create a tissue, bone or cloth in an empty Maya session, a solver node will automatically be created. The solver node appears in the scene as a custom locator node, and in addition to holding all of the global solver parameters, is also responsible for visualizing all of our custom drawing. By default, our solver node will be scaled to match the current Maya units. If you would like your tissues to behave as if they are larger objects, you can simply scale down the size of our solver node. .. image:: images/quick_start2.png :width: 400px :alt: quick_start2 image .. image:: images/quick_start3.png :width: 400px :alt: quick_start3 image Creating a Bone +++++++++++++++ (A "bone" is a user controlled or deformed input to our system - typically a geometric bone in a skeleton) .. image:: images/quick_start22.png :width: 200px :align: right :alt: quick_start22 image 1. Set your current frame back to the first frame of the simulation. 2. Create a Maya polysphere (our tools work exclusively with polygonal geometry): **Create➞ Polygon Primitives➞ Sphere** 3. Transform your new sphere by 3.0 units in ‘Y’ (This is so the new Sphere is no longer overlapping the tissue sphere). 4. Freeze transformations on the new Sphere: **Modify➞ Freeze Transformations** (This is so we will be able to easily “zero” out our bone’s position after multiple simulations) 5. Convert the selected sphere into a bone: **Ziva➞Bone** Creating a Cloth ++++++++++++++++ (A "cloth" is a 2D elastic element.) 1. Set your current frame to the first frame of the simulation (for a new scene, this will default to frame 1). 2. Create a Maya polyplane (our tools work exclusively with polygonal geometry): **Create➞Polygon Primitives➞Plane** 3. Translate the Plane by -4 units in 'X' 4. Uniformly scale the plane to a value of 3. 5. Set the polyplane's subdivisionWith and subdivisionHeight to a value of 10. 6. Select the plane 7. Convert the selected plane into a cloth: **Ziva➞Cloth** Creating a Subtissue ++++++++++++++++++++ (A "subtissue" defines material properties, muscle fibers, and attachments within another tissue.) 1. Set your current frame to the first frame of the simulation (for a new scene, this will default to frame 1). 2. Create a Maya polysphere (our tools work exclusively with polygonal geometry): **Create➞ Polygon Primitives➞ Sphere** 3. Transform your new sphere by 0.7 units in ‘X’ (This is so the new Sphere is no longer overlapping the tissue sphere). 4. Uniformly scale the new sphere to a value of 0.25. 5. Convert the new sphere into a 'tissue'. 6. Select the large tissue sphere we created in the previous `Creating a Tissue`_ section. 7. Shift select the new, smaller tissue. 8. execute: **Ziva➞Subtissue** .. image:: images/quick_start27.png :width: 400px :alt: quick_start27 image *Note: Now when you vary the material properties (including muscle fiber fields) of the 'Subtissue', this will be applied as a discontinious material change to the parent 'tissue'.* Deleting a Body +++++++++++++++ 1. Set your current frame to the first frame of the simulation (for a new scene, this will default to frame 1). 2. Create a Maya polysphere (our tools work exclusively with polygonal geometry): **Create➞ Polygon Primitives➞ Sphere** 3. Transform your new sphere by -3.0 units in ‘Y’ (This is so the new Sphere is no longer overlapping the tissue sphere). 4. Convert the selected sphere into a tissue: **Ziva➞Tissue** 5. Delete the selected sphere: **Ziva➞Delete selection** *Note: All bodies should be deleted in this way. Deleting a tissue, cloth or bone without using this menu item will leave your scene in a broken state. To remove the body from the simulation, but keep the geometry in the scene, execute: **Ziva➞Remove➞ Tissue, Cloth or Bone*** Attachments =========== Attaching the tissue ++++++++++++++++++++ 1. Right-click over the tissue sphere and choose “Vertex” from the marking menu. 2. Drag out a marquee selection over some of the vertices at the top of our tissue. 3. Shift-select our bone sphere and then choose: **Ziva➞Attachment** .. image:: images/quick_start4.png :width: 200px :align: right :alt: quick_start4 image *Note: You should now see some of the vertices of the tissue sphere connected to their closest points on the bone sphere with red dotted lines - this indicates that those tissue points now have a soft(dotted lines) fixed(red) attachment to the bone sphere* 4. To modify which vertices are part of the attachment; select the tissue sphere, then right-click to bring up the context menu for that object. In the right-click menu, navigate to: **Paint➞ zAttachment➞ zAttachment1-weights** - and then paint as you normally would with a typical Maya deformer. .. image:: images/quick_start5.png :width: 200px :align: right :alt: quick_start5 image *Note: If the attachment map on the “source” object is a grey-scale value, the stiffness of the attachment will be attenuated at those attachment proxies. Also, attachment paint on the “target” object will limit where closest-point lookups and/or sliding can occur.* .. image:: images/quick_start6.png :width: 200px :align: right :alt: quick_start6 image 5. Scale down the Solver node to a value of 1 in X, Y and Z (This will make the sphere appear to be much larger object to the solver). 11. Select the bone object, then run an interactive simulation: **Ziva Tools➞Interactive Playback** - and during playback, move the bone around (you should see the non-attached vertices of the tissue dynamically jiggle - this will be more obvious if you first scale the solver to a value of 1 in all axes, as this effectively make the sphere appear to be larger to the solver). Attaching the cloth ++++++++++++++++++++ 1. Right-click over the cloth plane and choose “Vertex” from the marking menu. 2. Drag out a marquee selection over some of the vertices at the edge of our cloth. 3. Shift-select our bone sphere and then choose: **Ziva➞Attachment** .. image:: images/quick_start26.png :width: 400px :alt: quick_start26 image *Note: Attaching cloth(es) is the same as attaching tissue(s)* Exploring Attachments +++++++++++++++++++++ .. image:: images/quick_start7.png :width: 400px :alt: quick_start7 image 1. Set your current frame back to the first frame of the simulation. 2. Select the tissue in order to make the attachment visible and then select the attachment. You will then be presented with the following attachment options * **Envelope** - attenuates the attachment stiffness * **Attachment Mode** - lets you choose between NONE, FIXED and SLIDING * **Stiffness** - determines how much the attachment will be allowed to stretch * **Stiffness Exp** - Is the power to which the value of the stiffness is to be raised * **Is Hard** - make the attachment formulation technically more stable (useful when extremely stiff) at the cost of some speed * **Maintain Offset** - when switched off, will cause the ends of the attachment to snap together * **Correspondence** - defines how the attachment mapping is generated * **Show** - will toggle the attachment visibility *The following images demonstrate the behavioral differences between fixed and sliding attachments.* .. image:: images/quick_start8.png :width: 300px :alt: quick_start8 image .. image:: images/quick_start9.png :width: 300px :alt: quick_start9 image Attaching Tissues Together ++++++++++++++++++++++++++ 1. Delete the cloth to simplify our scene, select the cloth and execute: **Ziva➞Delete selection** 2. Create an additional tissue sphere in your scene, offset from the first one. 3. Right-click over the new tissue sphere and choose “Vertex” from the marking menu. 4. Drag out a marquee selection over some of the vertices at the top of our tissue. 5. Shift-select the first tissue sphere and then choose: **Ziva➞Attachment** .. image:: images/quick_start21.png :width: 400px :alt: quick_start21 image *Attachments can be created between tissues and cloths as well as from bones to either tissues or cloths* Exploring Attachment Source / Target Behavior +++++++++++++++++++++++++++++++++++++++++++++ 1. Create a new scene. 2. Create a Maya polyplane (our tools work exclusively with polygonal geometry): **Create➞Polygon Primitives➞Plane** 3. Set the polyPlane's subdivisionWidth and subdivisionHeight to a value of 20. 4. Duplicate the plane. 5. Transform your new plane by 1.0 units in ‘Y’ (This is so the new Plane is no longer overlapping the first one). 6. Uniformly scale the new plane to a value of 3. 7. Select both planes and then 'group' them **Edit➞Group** 8. Rotate the new group to a value of -20.0 in 'X' 9. Convert the first plane into a bone: **Ziva➞Bone** 10. Convert the second plane into a tissue: **Ziva➞Tissue** 11. First select the 'bone' plane. 12. Shift-select our tissue plane and then choose: **Ziva➞Attachment** 13. Select the attachment and change its mode from 'fixed' to 'sliding'. 14. Run the simulation and observe the result. .. image:: images/quick_start23.png :width: 400px :alt: quick_start23 image *When making sliding attachments, the vertices of the 'source' of the attachment (the first object selected) are sliding on the faces of the 'target' mesh. Those vertex positions are what is being considered when looking for the closest points on the faces of the 'target' mesh.* 1. On frame 1, swap the attachment direction **Ziva➞Swap Attachment Direction** 2. Run the simulation and observe the result. .. image:: images/quick_start24.png :width: 400px :alt: quick_start24 image *You'll now see that the 'source' of the attachment is now the 'tissue' mesh. In this case, it has the effect of limiting the motion of the 'tissue', as all of it's vertices effectively have no place to slide.* .. image:: images/quick_start25.png :width: 400px :alt: quick_start25 image *By removing some of the source points from the attachment, the 'tissue' is now free to slide on the 'bone'.* Using Bones as the Source of Attachments ++++++++++++++++++++++++++++++++++++++++ **Embedding bones inside a tissue** (This approach can be used to good effect for creating soft characters.) 1. Create a new scene. 2. Set your current frame to the first frame of the simulation (for a new scene, this will default to frame 1). 3. Create a Maya polysphere (our tools work exclusively with polygonal geometry): **Create➞Polygon Primitives➞Sphere** 4. Select the sphere. 5. Scale the sphere to a value of 3 in X, Y and Z. 6. Convert the selected sphere into a tissue: **Ziva➞Tissue** 7. Create a cube: **Create➞Polygon Primitives➞Cube** 8. Convert the selected cube into a bone: **Ziva➞Bone** 9. Select the bone and then the tissue and create an attachment: **Ziva➞Attachment** 10. Increase the attachment **“stiffnessExp”** to **10^7**. 11. Decrease the material **“youngsModulusExp”** to **10^2**. 12. Start the interactive simulation: **Ziva Tools➞Interactive Playback** - then move the bone around and the tissue will follow. .. image:: images/quick_start20.png :width: 400px :alt: quick_start20 image Changing the zTet Resolution ============================ For many muscles, it is preferable to actually keep your grid spacing set to a high number, as the resolution of the tet mesh is an indicator of the required deformation frequency and doesn’t actually need to conform to the embedded surface. If you require local features of the tissue to have a higher resolution tet mesh; you can paint this increase in resolution. .. image:: images/quick_start10.png :width: 300px :alt: quick_start10 image .. image:: images/quick_start11.png :width: 300px :alt: quick_start11 image Right-click on the selected tissue and choose to paint: **Paint➞zTet➞zTet1-weights** - and then paint as you normally would with a typical Maya deformer. Adding a Muscle Fiber Field =========================== .. image:: images/quick_start12.png :width: 200px :align: right :alt: quick_start12 image 1. Set your current frame back to the first frame of the simulation. 2. To make your tissue lighter relative to the solver, scale the solver node to a value of 10 in X, Y and Z. 3. Select the tissue sphere and then choose the **Ziva➞Muscle Fiber** menu item. *Note: You will be presented with a default fiber field. The field gradient (which is authored using the .endPoints map on the zFiber node) is initialized with a uniform value of 0.5 everywhere except for the two farthest points, which are initialized with values of 0 and 1 respectively. You can re-paint this map as you see fit. (Uninitialized fibers are oriented along the tissue’s normals.)* 4. To adjust the flow of the fiber field, navigate to: **Paint➞zFiber➞zFiber1-endPoints**. 5. You will now have to specify the **“in-points”** by selectively painting surface vertices with a value of **0.0**, and **“out-points”** by selectively painting additional vertices with a value of **1.1**. - Some value leeway is allowed, in order to make things a little easier for users using pressure sensitive drawing tablets. .. image:: images/quick_start13.png :width: 200px :align: right :alt: quick_start13 image *Note: Once the “in” and “out” points have been specified, you will be presented with a fiber field that conforms to the tangency of the embedded tissue surface mesh. (Right example: **in** and **out** points have been painted at the poles of the tissue sphere)* 6. To interactively fire the muscle while the simulation is running; let’s connect a polyCube to the zFiber excitation. First let’s create a polyCube. This can be found in the following menu: **Create➞Polygon Primitives➞Cube**. 7. Now connect the cube’s **“translateY”** attribute to the zFiber1 node’s **“excitation”** attribute using either the connection editor, or by executing the following line of MEL: **connectAttr -f pCube1.translateY zFiber1.excitation;** .. image:: images/quick_start14.png :width: 400px :alt: quick_start14 image *Note: the weights attribute on the zFiber node will allow you to remove the effect of the fiber field from parts of your tissue. If you have vertices selected when the zFiber node is created, the weights will be set to a value of 1.0 for only those vertices.* Adding an Additional Material ============================= 1. Set your current frame back to the first frame of the simulation. 2. Let’s soften the current material. Find the zMaterial node in the current tissue’s history. 3. Reduce the value of the value of the **“youngsModulusExp”** to a value of **10^1**. 4. Then on the tissue’s zTet node; flood the weights to a value of 1.0 and set the **“tetSize”** to 0.4. .. image:: images/quick_start15.png :width: 400px :alt: quick_start15 image *Note: If you run the simulation without firing the muscle, the material should noticeably sag under gravity.* 5. At the start frame, select the vertices on the left side of the tissue sphere and then choose the **Ziva➞Material Layer** menu item (this will “layer” a new material node on top of the pre-existing material and flood it’s weight to a value of 1.0 for the selected vertices). *Note: If you run the simulation without firing the muscle, the material should sag under gravity.* .. image:: images/quick_start17.png :width: 400px :alt: quick_start17 image 6. If you want to adjust how the zMaterial2 occludes the underlying zMaterial1 node’s properties, in the right-click context menu from over the tissue, navigate to: **Paint➞zMaterial➞zMaterial2-weights** - and then modify the painted map. 7. When you start your simulation (**Ziva Tools➞Interactive Playback**), you will now see one half of the tissue sphere is now noticeably softer and sags under gravity .. image:: images/quick_start16.png :width: 400px :alt: quick_start16 image Using Delaunay Tet Mesher instead of Adaptive Tetrahedralization ================================================================ 1. Set your current frame back to the first frame of the simulation. 2. Select the tissue sphere and then choose the **Ziva Tools➞Create Delaunay Tet Mesh** menu item. 3. Run the simulation to view the results. .. image:: images/quick_start18.png :width: 300px :alt: quick_start18 image .. image:: images/quick_start19.png :width: 300px :alt: quick_start19 image Delaunay tet meshes are more difficult to create and use, but can offer benefits in some cases. We only recommend using them if you’re sure you need them.