.. include:: .. # define a hard line break for HTML .. |br| raw:: html
.. _sec-tutorial: Tutorials ********* Important note: Unless otherwise stated, we'll assume all steps in the tutorials below happen with the timeline set to the solver start frame. That will be frame 1 in these examples. Let's make sure the Ziva VFX for Maya Plugin is loaded. We do that by opening the Maya Plug-in Manager; which can be found in the following menu: **Windows** |rarr| **Setting/Preferences** |rarr| **Plug-in Manager** If our plugin has been installed correctly, it should be visible in the Plug-in Manager. If it's not there, please revisit the :ref:`installation instructions`. After the plugin has been loaded, you should notice that **"Ziva"**, **"Ziva Tools"** and **"Ziva Transfer"** menus have been added to the Maya interface. (These menus are covered in more detail in the :ref:`Ziva Menus` section of the documentation). |br| Bodies ====== .. note:: This tutorial will show examples built on geometry from the Mr. Ink asset. If you'd like to use the same geometry presented here, you can find a ready-made file for this in the demo directory located in the Ziva install path. If you did a default install on Windows you would find the file here: C:/Program Files/Ziva/VFX/Ziva-VFX-Maya-Module/ZivaVFX-Maya-/demos/armFlex.ma. The complete Mr. Ink can be downloaded for free from: https://zivadynamics.com/promos/free. You'll notice in the file that there are two copies of the skeleton geometry. One is an alembic of the skeleton motion. The second one has a blendshape connection to the first. This effectivley creates a buffer between the two and is in line with our recommendations on how users should drive tissue rigs. We tend to discourage driving a Ziva simulation on directly with a live Maya rig with joints/constraints/controls etc. Following this guidance has several advantages for users: 1. Scenes are lighter, and faster to interact with. 2. Even standard Maya nodes can create cycles in the scenes which frequently cause issues with Ziva simulations at the subframe level. 3. The animator can work without requiring a Ziva license to generate bone motion. 4. It becomes straight forward to drive a simulation with a different animation. Simply import an Alembic of the bones into the muscle rig and create blendshapes between the corresponding bones. Here is an image of a typical Ziva character pipeline: .. image:: images/pipeline_white.png :width: 100% :alt: ziva character pipeline Creating a Tissue +++++++++++++++++ "Tissue" is the word we use to describe elastic solids in our system. These are simulated *soft body* objects. Our tools work exclusively with polygonal geometry. You can make almost any mesh into a Tissue (see below for exceptions). .. image:: images/quick_start1b.png :alt: bicep tissue Here are the steps for converting a mesh into a Tissue: 1. Select the mesh and convert to Tissue: **Ziva** |rarr| **Tissue** 2. Right click on the timeline and make sure one of the "Play every frame" options is selected, under Playback Speed. 3. Click play forward. .. image:: images/quick_start29.png :alt: play forward You will see the Tissue drop under gravity. .. note:: 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 with three axes (shown below). In addition to holding all of the global solver parameters, it is also responsible for visualizing all of our custom drawing.* By default, our solver node will be scaled to match the current Maya units. One of the axes has a "1m" at the end, showing what Ziva VFX considers to be 1 meter. In the example below, the character is something like 1.5 meters tall. This 'real world scale' should be considered with your own characters. You can simply scale the solver to adjust 'how big' Ziva VFX considers your Tissues to be. .. image:: images/quick_start2b.png :alt: solver node **Advanced** Requirements for geometry being converted to Tissue: 1. Must be manifold. 2. Must not have extremely thin triangles. 3. Must have positive volume. If the mesh is contiguous (i.e. is water tight), all normals should be pointing outward for collisions to work correctly. You can test a mesh before converting it to Tissue by selecting it and running the following MEL command: :ref:`zMeshCheck`. .. image:: images/visit_online_resource.png :width: 300px :alt: visit online resource :target: https://zivadynamics.com/resources/ziva-tissues |br| Creating a Bone +++++++++++++++ Bones are modelled using a geometric mesh. As opposed to Tissues, Bones are *kinematic* objects. Generally speaking, Tissues are attached to Bones. As the Bones move, the Tissues respond. .. image:: images/quick_start3.png :alt: bone Here are the steps for converting a mesh into a Bone: 1. Select a polygonal mesh that is not already a Tissue or Cloth 2. Convert the selected mesh into a bone: **Ziva** |rarr| **Bone** From here you are free to manipulate the bone as you like. You can make deformers, key the transforms, etc. You can do these manipulations before or after you have converted the mesh to a bone. .. note:: Best practice is to animate your bones in a separate file (called the bone rig or puppet), bake out the bone animation, and import as an alembic into your muscles setup. This has some advantages: * Many of Maya's nodes create unpredictable behaviour on subframes. Ziva VFX needs to know where bones are on subframes in order to compute bones correctly. * No Ziva VFX license is required for creating the animation puppet. * The resultant scenes are lighter. **Advanced** Requirements for geometry being converted to a Bone: 1. Must be manifold. 2. Must not have extremely thin triangles. 3. Must have positive volume. If the mesh is contiguous (i.e. is water tight), all normals should be pointing outward for collisions to work correctly. You can test a mesh before converting it to a Bone by selecting it and running the following MEL command: :ref:`zMeshCheck`. .. image:: images/visit_online_resource.png :width: 300px :alt: visit online resource :target: https://zivadynamics.com/resources/ziva-bones |br| Creating a Cloth ++++++++++++++++ Ziva Cloth is primarily designed to provide high level, realistic wrinkling detail at the skin level. To create a Cloth, select the mesh you want to convert into a Cloth, and run: **Ziva** |rarr| **Cloth** .. image:: images/quick_start4.png :alt: cloth **Advanced** Requirements for geometry being converted to Cloth: 1. Must be manifold. 2. Must not have extremely thin triangles. You can test a mesh before converting it to Cloth by selecting it and running the following MEL command: :ref:`zMeshCheck`. .. image:: images/visit_online_resource.png :width: 300px :alt: visit online resource :target: https://zivadynamics.com/resources/fat-skin-workflow |br| Deleting a Body +++++++++++++++ Select the Tissue, cloth or bone you wish to remove completely from your scene and run: **Ziva** |rarr| **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, choose: **Ziva** |rarr| **Remove** |rarr| **Tissue, Cloth or Bone** |br| Attachments =========== Fixed Attachments +++++++++++++++++ Attachments can be made between two soft bodies, or between a soft body and a bone. In this tutorial we'll do a typical Tissue to Bone attachment. Here are the steps for creating an Attachment: 1. Select some vertices on the Tissue. 2. Select a Bone. 3. Choose: **Ziva** |rarr| **Attachment**. .. image:: images/quick_start5.png :width: 100% :alt: vertex selection attachment image .. note:: You should now see some of the vertices of the Tissue connected to their closest points on the Bone with red dotted lines. This indicates that those Tissue points now have a fixed (red) attachment to the Bone. 4. To modify which vertices are part of the attachment, select the Tissue mesh and right-click to bring up the context menu for that object. In the right-click menu, navigate to: **Paint** |rarr| **zAttachment** |rarr| **zAttachment1-weights**. Paint as you normally would with a typical Maya deformer. .. image:: images/quick_start5b.png :width: 100% :alt: quick_start5 image .. image:: images/attachment_1.gif :alt: fixed attachment gif .. 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. There is no limit to the number of Attachments you can have on a body. A vertex on a body can also have any number of Attachment points. .. image:: images/visit_online_resource.png :width: 300px :alt: visit online resource :target: https://zivadynamics.com/resources/fixed-attachments |br| Sliding Attachments +++++++++++++++++++ Sliding attachments are useful when you want to have two bodies slide on each other, and also preserve the initial distance from each other. The process for making a sliding attachment is exactly the same as for a fixed attachment, except we change its mode. Here, we'll use Ziva's proximity selection tool to do the selection for us, and we'll tune the stiffness to direct the simulation. You can still select the vertices manually if you wish. 1. Select the Tissue object first, then then select the Bone object. 2. Choose **Ziva Tools** |rarr| **Proximity Tools** |rarr| **Select Vertices[] (option box)**. 3. Adjust the value to something that makes sense for your scene. Here I've used a radius of 1.5. 4. Choose **Select**. 5. Select the target object again (in this case the Bone). 6. Choose **Ziva** |rarr| **Attachment**. 7. Change your new attachment's type to **sliding** in the channel box. Notice the color changes from red to purple. 8. Select the source of the attachment; in this case the Tissue. Right click somewhere near the mesh (not on the mesh) and choose **Paint** |rarr| **zAttachment** |rarr| **zAttachment2-weights**. Here, we adjust the map to just have sliding on the belly of the muscle. .. image:: images/quick_start5e.png :alt: sliding painted 9. Adjust the **stiffnessExp** of the attachment to 10^6 in the channel box. This will make the attachment 1/100th of it's original stiffness. .. note:: All the associated Ziva nodes are listed in the channel box when you have a Tissue selected. So make sure you have the Tissue selected in order to see zAttachment2 in the channel box. .. image:: images/quick_start5f.png :width: 100% :alt: sliding stiffness | If one follows all the steps as outlined above, the result will be: .. image:: images/attachment_2.gif :alt: sliding stiffness .. image:: images/visit_online_resource.png :width: 300px :alt: visit online resource :target: https://zivadynamics.com/resources/sliding-attachments |br| Attaching Cloth ++++++++++++++++++++ Another useful thing you can do in Ziva VFX is to simulate fat and skin at the same time. When two soft bodies are simulated at the same time, they are considered 'coupled'. That is, they both affect each other during the course of the simulation. Typically, Cloth is used as an 'epidermis' and is attached to the fat. The coupled nature of this simulation produces realistic wrinkling as areas of the soft objects squash and stretch. Here is how to attach a Cloth: 1. Select your Cloth mesh, then add the fat to the selection. .. note:: Fat is usually solved as a single Tissue, as seen here. 2. Choose **Ziva** |rarr| **Attachment**. Because we did not do a vertex selection first, an attachment is made for every vertex on the source object; in this case, the Cloth. 3. By default, Cloth is a little bit more sensitive than Tissue to attachment stiffnesses. So change the **stiffnessExp** to 10^5. .. image:: images/quick_start6.png :width: 100% :alt: cloth to fat attachment |br| Fibers ====== Adding a Fiber ++++++++++++++ Fibers in Ziva VFX replicate the functionality of muscle fibers in the real world. A Fiber can contract a Tissue in a specified direction. To add a Fiber to a Tissue, select the Tissue and choose **Ziva** |rarr| **Muscle Fiber** .. image:: images/quick_start10a.png :alt: fiber defaults Ziva VFX will guess the default fiber direction when the Fiber is created. If you wish to alter it afterward, you'll need to edit the End Points Map: 1. Right click somewhere near the Tissue whose Fiber you wish to edit. 2. Choose **Paint** |rarr| **zFiber** |rarr| **zFiber1-endPoints**. 3. Add new end point vertices as you wish, and the Fiber Field will update. .. image:: images/quick_start9b.png :width: 100% :alt: fiber end point painting .. note:: Typically, the End Points map is mostly set to a value of 0.5, with one end of the Tissue painted to 0.0, and the other end to 1.0. The field is interpolated between the end point vertices and propogated through the Tet Mesh. You must have at least one vertex painted to 0.0 and one painted to 1.0, with the remainder being 0.5. Otherwise the Fiber will fail and the simulation will not solve. To actually fire (or excite) the Fiber, we look to the Excitation attribute on the zFiber node: 1. Select the Tissue whose Fiber you want to excite. 2. In the channel box, set a keyframe with an Excitation value of 0 on frame 15. 3. Set a keyframe to an Excitation value of 1 on frame 25. 4. Click on Play Forward. .. image:: images/fiber_1.gif :alt: fiber excitation .. note:: The simulation above has new bones added, and also the brachialis Tissue as well. There are sliding attachments between the humerus and the brachialis, as well as the brachialis and the bicep. **Advanced** If you want the Fiber to only affect a certain part of the Tissue, you can paint the weight map to 0 in the areas that are to remain unaffected by the Fiber. To do this: 1. Select the Tissue whose Fiber weight map you wish to alter. 2. Right click somewhere near the Tissue and choose **Paint** |rarr| **zFiber** |rarr| **zFiber1-weights**. 3. Paint the areas you wish to remain unaffected by the Fiber using Maya's paint tool. .. note:: There is no limit to the number of Fibers you can have on a Tissue. |br| Adding Line of Action to a Fiber ++++++++++++++++++++++++++++++++ In most cases it would be tedious to manually key the excitation for shot work. Line of Action will excite the muscle automatically based on the changing length of a nurbs curve. To set up Line of Action for a given Fiber, first we must attach a curve to some Bones. To do this: 1. Select the Tissue whose Fiber you want to create a Line of Action for. 2. Choose **Ziva Tools** |rarr| **Meshing** |rarr| **Create Line of Action Curve** .. note:: Ziva automatically builds a nurbs curve for you. This is just a standard 2-point nurbs curve. You are free to move the endpoints of this curve around, or create your own using the standard Maya tools. .. note:: In this example, the lower control vertex (CV) of the curve is moved further down the radialis to exaggerate the effect. 3. Select the curve, right click somewhere near the curve and choose **Control Vertex**. 4. Select the lower CV, and then select the closest bone mesh. 5. Choose **Ziva** |rarr| **Add Tissue Property** |rarr| **Rivet to Bone**. 6. Repeat steps 3 through 5 for the other CV. .. note:: You'll see two dotted red lines running from each CV to the bone you riveted to. 7. Then we will connect the curve to the Fiber. First select the curve. 8. Select the Tissue whose Fiber you wish to create the Line of Action for. 9. Choose **Ziva** |rarr| **Add Tissue Property** |rarr| **Muscle Line of Action**. .. image:: images/visit_online_resource.png :width: 300px :alt: visit online resource :target: https://zivadynamics.com/resources/automatic-muscle-firing **Advanced** You can amplify the effect of Line of Action. To do this: 1. Select the Tissue whose Fiber has the Line of Action. 2. Launch the Ziva Scene Panel by choosing **Ziva** |rarr| **Launch Scene Panel**. If the panel was already open refresh it using the green refresh button. 3. Roll out zFiber1 and then curve1. 4. Select zLineOfAction1. .. image:: images/quick_start11.png :alt: line of action scene panel :width: 100% 5. In the channel box, set Pos Sensitivity to 4. This will increase the senstitivy to changes in curve length by a factor of 4. .. image:: images/line_of_action_1.gif :alt: line of action example |br| Materials ========= Adding an Additional Material +++++++++++++++++++++++++++++ It can be helpful to have some areas of a Tissue behave differently to other areas of the same Tissue. To do this, Ziva VFX uses a layering approach to varying materials. The tet mesh in this example is set up with a spatially varying tet resolution (see `Local zTet Resolution`_). To add a new Material: 1. Select the Tissue for which you would like to add Material. 2. Choose **Ziva** |rarr| **Add Tissue Property** |rarr| **Material Layer**. 3. In the channel box, select **zMaterial2** and change **youngsModulusExp** to 10^5. This makes it 100 times more rigid. You'll notice that zMaterial2 is above zMaterial1 in the channel box. The Tissue will inherit the properties of the Tissue highest up in the stack. In order to 'reveal' the properties of zMaterial1 which is underneath, we need to paint the weight map of zMaterial2. This is similar to how layers function in photoshop. In our case, the weight map is like an alpha channel. 4. Right click somewhere near the Tissue that has the Material you'd like to paint. 5. Paint the weight map of zMaterial2 to black in the areas in which you'd like to reveal zMaterial1. .. image:: images/quick_start12.png :alt: zMaterial map .. image:: images/material_1.gif :alt: zMaterial simulation .. image:: images/visit_online_resource.png :width: 300px :alt: visit online resource :target: https://zivadynamics.com/resources/ziva-materials |br| Rest Shapes =========== Adding a Rest Shape ++++++++++++++++++++ .. note:: This section uses the Jellyphant asset which can be downloaded for free from: https://zivadynamics.com/promos/free. If you want to have more precise control over the direction of the simulation, you can change the shape of any or all of Tet Meshes during the simulation. You can specify one or more target shapes, and Ziva will fit the current Tet Mesh to those targets. For this example, we will work on the Jellyphant. 1. Duplicate the Jellyphant Tissue mesh and call it back_spikes. 2. Sculpt your changes on the sculpt mesh, which in this case is back_spikes. Do not change any topology. .. image:: images/quick_start15.png :width: 100% :alt: sculpt basic 3. Select your original Tissue mesh, which in this case is jellyphant_tissue. 4. Shift select the scuplted target, which in this case is back_spikes. 5. Choose **Ziva** |rarr| **Add Tissue Property** |rarr| **Rest Shape**. .. note:: If you play the simulation now, you'll see that by default, the Rest Shape is activated to full effect on the first frame of simulation. Notice that all the functionality of the simulation (fibers, attachments, secondary motion, etc) is preserved. .. image:: images/rest_shape_1.gif :alt: simple rest shape animation |br| Extracting a Rest Shape from the World ++++++++++++++++++++++++++++++++++++++ If you are creating rest shapes for a rig, you'll want to extract the correct mesh to feed in as a Rest Shape target. In this example we'll be working on the arm from the Mr. Ink character. 1. On the solver start frame, duplicate the Tissue you'd like to extract a rest shape from. In this example we will call it bicep_tissue_neutral. 2. Simulate the character into a pose that you wish to create a Rest Shape for. In this example, simulate to frame 20. 3. Duplicate the Tissue you wish to create a Rest Shape for at the current frame. In this example we will call it bicep_tissue_sculpt. 4. Sculpt this duplicated mesh into the shape you would like to see at this pose. .. image:: images/quick_start16.png :width: 100% :alt: sculpt for extraction 5. Be sure that your timeline is still on the frame where you duplicated the Tissue to do the sculpting. In this case, frame 20. 6. Select all of the following in the specified order: * The neutral shape (bicep_tissue_neutral). |br| * The Tissue after simulation (bicep_tissue). |br| * The sculpted shape (bicep_tissue_sculpt). |br| 7. Type the following into the MEL command box and run: ``zRestShape -pullBackGeo`` 8. You will get a new mesh with the suffix "_restShapeCorrective". Select your Tissue (in this example bicep_tissue), then select your newly generated corrective. .. image:: images/quick_start18.png :alt: sculpt for extraction 9. Choose **Ziva** |rarr| **Add Tissue Property** |rarr| **Rest Shape**. 10. Select your Tissue mesh and roll out the node **zRestShape1** in the channel box. 11. You can keyframe or connect other nodes to the target weight in the **zRestShape1** node. In this example, the curve from the line of action is used in conjunction with some standard Maya nodes to drive the target weight. An example node setup to drive the Rest Shape target: .. image:: images/quick_start17.png :width: 100% :alt: node setup Below is an example of a Rest Shape target being triggered over time: .. image:: images/rest_shapes_2.gif :alt: rest shapes sim Below is an example of toggling between the sim results with and without the Rest Shape applied: .. image:: images/quick_start14.gif :alt: restshape bicep switch |br| Adding Additional Targets to zRestShape Node ++++++++++++++++++++++++++++++++++++++++++++ To add an additional target to the **zRestShape** node: 1. Select a Tissue with a pre-existing Rest Shape node. 2. Shift select the target mesh that you wish to add. 3. Choose **Ziva** |rarr| **Add Tissue Property** |rarr| **Rest Shape**. Advanced Topics =============== Global zTet Resolution ++++++++++++++++++++++ The tetrahedral lattice that is drawn over your Tissues is called a *Tet Mesh*. This is the mesh that is actually being simulated, and your original geometry is embedded within the Tet Mesh. Its properties are located on the zTet node. Every Tissue has a single zTet node. Often you will need to increase the resolution of the Tet Mesh, because you need to represent more complex curvatures or wave propogations in your simulations. To change the resolution of your Tet Mesh globally for a Tissue: 1. Select the Tissue whose Tet Mesh you would like to alter. 2. In the channel box, change the value of the Tet Size attribute. In this example we change the Tet Size from 6.7 to 3. Notice the difference: .. image:: images/quick_start7.png :width: 100% :alt: cloth to fat attachment |br| Local zTet Resolution +++++++++++++++++++++ The drawback to adding more resolution to your Tet Meshes is that computation times go up. To optimize, we can paint the resolution of the Tet Mesh spatially. In this example, we have a mesh that represents armoured plates, and we want the areas between the plates to deform, but the plates to preserve their shape. To paint zTet resolution: 1. Select the Tissue whose Tet Mesh you would like to alter. 2. Right click somewhere near the Tissue and choose: **Paint** |rarr| **zTet** |rarr| **zTet1-weights**. Then paint as you normally would with a typical Maya deformer. .. image:: images/quick_start8.png :width: 100% :alt: zTet resolution simple **Advanced** The map being painted is multiplying against the surface refinement attribute on the zTet node. You can amplify the effect by increasing the value of surface refinement. Here we change it to 2: .. image:: images/quick_start8b.png :width: 100% :alt: zTet resolution advanced .. image:: images/visit_online_resource.png :width: 300px :alt: visit online resource :target: https://zivadynamics.com/resources/ziva-tet-mesh |br| Creating a Subtissue ++++++++++++++++++++ Subtissues are Tissues within Tissues. They can be helpful when you want very precise control over a region of a Tissue. Some advantages of Subtissues are the ability to make Attachments to the Subtissues, create Fibers on the Subtissues, and have a different Material in one area. The mesh of the parent Tissue should completely envelop the mesh of the Subtissue. Then, to create a Subtissue: 1. Make sure the parent Tissue and the Subtissues are already Tissues. (See `Creating a Tissue`_ above). 2. Select the mesh you wish to be the parent Tissue first. Then shift select the mesh of the Subtissue. 3. Choose **Ziva** |rarr| **Add Tissue Property** |rarr| **Subtissue** In this example we show the Jellyphant has a Subtissue for the trunk. We can still add a Fiber on the Subtissue. When the mesh of the Subtissue is selected, Ziva VFX will draw the Tet Mesh for the parent Tissue. .. image:: images/quick_start13.png :alt: subtissue jellyphant .. 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. |br|