Revision Difference
Jiggle_Bones#548656
<cat>Model.Physics</cat> ⤶
<title>Jiggle Bones</title>⤶
⤶
# Introduction⤶
Jiggle bones are a simple way to give physical, dangly attributes to your models. They have various usages including simulating hair and rope, solid hinge-based objects, and organic applications such as simulating breasts and fat.⤶
This page covers how to set up your bones in **Maya** and implement them as jiggle bones in-game. The fundamental and theoretical approach to bones and rigs are quite consistent across modelling packages. ⤶
⤶
**This page does not cover rigging or skin binding nor implementation.**⤶
⤶
<warning>Because of the organic nature of this page, it is marked NSFW. </warning>⤶
⤶
###The assumption is that:⤶
1. You have set up the skeleton for your model and it is rigged, whether that is a creature, simple prop, or a clothing item for Terry. The character rig from Terry’s model **(citizen.fbx)** is what we will be using throughout this page, so if you are simulating bones on Terry’s clothes (zippers, frilly parts, etc), you’re in luck.⤶
⤶
2. It is a piece of clothing for Terry, and you have properly bound it to Terry’s skin and it is somewhat functional.⤶
⤶
3. Your model is also unwrapped and textured properly and a proper .vmat has been assigned (although not strictly required).⤶
⤶
#Contents⤶
This tutorial will cover applying two jiggle bones to two different things: a zipper on a boot, and a pair of fake breasts. This is not the most complex nor is it the most simple jiggle bone setup. **This should cover you for most other applications of jiggle bones.** This article gives you a foundation for you to go and experiment. Jiggle bones can give some very interesting and dynamic results.⤶
⤶
One thing to remember is this: **jiggle bones take a long time to tweak.** You will likely not achieve the desired effect for your jiggle bones immediately. Additionally, **you are at the mercy of a physics engine.** ⤶
This means it can be hard to control your jiggle bones, and clipping is often present. However, thanks to the proactive nature of Source 2, we can edit the jiggle bones using ModelDoc’s GUI to see the effect immediately after recompiling your model.⤶
<warning>**Make frequent backups.** This is universal advice for an engine that permits such rapid changes to your content such as Source 2. </warning>⤶
⤶
⤶
#Terminology refresher⤶
###Vertex weights⤶
Every model is made up of vertices (the corner points of a mesh.) Source 2 needs to know which vertices will be affected by which bone so it can accurately simulate the physics effects upon each vertex. The process to mark these vertices is called **vertex weight painting**. In Maya, the whiter the vertex, the more that vertex will be **influenced** by that bone.⤶
###Influences⤶
**Bones and joints** must **influence** vertices. By selecting a joint in the **hierarchy list** during painting, we can see how it affects surrounding vertices (the white and black paint on the model). (GIF OF HIERARCHY PAINTING LIST)⤶
###Bone⤶
This is the longer shaped object that sits between two joints.⤶
###Joint⤶
This is the round object that sits between your bones.⤶
<upload src="b33fe/8daf981bca18ae8.png" size="16223" name="image.png" />⤶
###Hierarchy⤶
In Maya, skeletons are organised into hierarchies, with parent bones and child bones. For example, lower arm > wrist > fingers. Your jiggle bones will need to be placed into the most suitable (usually the nearest) hierarchical section for them to behave closest to what you want. ⤶
<upload src="b33fe/8daf8e868ec8a42.gif" size="259814" name="HierarchyMaya01.gif" />⤶
###Deformation⤶
How the vertices are pulled, stretched, and warped due to their surrounding influences. Deformation is good for organic parts, but not great for solid parts (such as zippers, metal, etc).⤶
###Skinning⤶
This is the process of binding the mesh to the nearest bone on the skeletal rig.⤶
⤶
#Important advice before you start⤶
###1. Regularly export your vertex weight maps from your model. ⤶
Click on your mesh and export the weight map. This is so that, if you ever go back and forth between the engine and Maya to tweak your vertex weight painting, you have a version to go back to if it turned out horribly. Vertex painting can get burdensome if you have a clothing mesh that won’t play nice with Terry’s rig (citizen.fbx) for example, because you may have to clear up a lot of clipping issues. ⤶
<upload src="b33fe/8daf8e875667b10.gif" size="273895" name="ExportSkinMaya01.gif" />⤶
###2. Watch Danduw’s video on how to create clothes for Terry in s&box. ⤶
This is so you can familiarise yourself with clothing in general, if your jiggle bone is attached to a garment. The video introduces you to creation and implementation, but more importantly, weight painting for your clothing.⤶
[Dandew's Video](https://www.youtube.com/watch?v=W7AoTMVv3QQ)⤶
⤶
###3. Jiggle bones must follow the x-axis (the red axis). ⤶
This means your joints, when set up in Maya, must point toward their proper direction according to the x-axis.⤶
<upload src="b33fe/8daf981e21c7fc7.gif" size="439884" name="JointBoneXAxisAlign.gif" />⤶
###4. If any of your rigging options are missing, switch to the rigging workspace within Maya. ⤶
Maya changes a lot depending on the selected workspace. For any geometry or UV tweaking, simply go back to a modelling workspace. ⤶
<upload src="b33fe/8daf8e8ae504765.gif" size="167872" name="RigSwitchMaya01.gif" />⤶
###5. Make backups. ⤶
Jiggle bones require a lot of tweaking. This is universal advice for an engine that permits such rapid changes to your content such as Source 2.⤶
⤶
###6. Ensure x-ray joints are enabled in the shading menu.⤶
<upload src="b33fe/8daf8e87f86f3aa.gif" size="205984" name="XrayJointsShading01.gif" />⤶
###7. Keep your model combined and as one mesh. ⤶
Remember that the vertices are what will be physically simulated by the engine. In the case of the zipper, it is a part of the entire boot model - you don’t need to separate the zip as a separate mesh.⤶
⤶
###8. Source 2 works with a maximum of 4 joint influences when skin binding. ⤶
Keep this in mind when binding and unbinding skin.⤶
⤶
⤶
#Zipper⤶
The first section will cover a basic dangling zipper from a pair of leather boots. We will start in Maya, move into ModelDoc, and then test out our zipper in-game. ⤶
⤶
These boots are already bound to the skeleton and follow Terry’s leg movements. Some weights have been painted to prevent clipping. The zip in question remains solid and keeps its shape. Remember - you should watch Danduw’s resource on the basics of vertex weight painting to ensure your model fits and moves cleanly before playing with jiggle bones.⤶
<upload src="b33fe/8daf9824821afba.gif" size="6268778" name="JiggleBonesTerryLegMovements.gif" />⤶
##1. Creating your Bones ⤶
⤶
###1.1 Export your weight maps. ⤶
We are adding new joints, and so the model must be unbound from the skin and then rebound before any changes in the hierarchy are detected. Export your weight maps so you can reimport them onto the mesh when we rebind the skin later.⤶
<upload src="b33fe/8daf98205b424a2.gif" size="218825" name="ExportWeightMapsNew.gif" />⤶
###1.2 Unbind your skin from the skeleton rig.⤶
This is so we can freely work with the skeleton to add bones. The skeleton turns dark blue to indicate that a mesh is not skinned to it.⤶
<upload src="b33fe/8daf982572a42d5.gif" size="285679" name="UnbindSkin.gif" />⤶
⤶
###1.3 Choose the nearest and most applicable joint for your use case. ⤶
For the zipper, joint leg_lower_R appears most suitable and thus choose this as the starting joint.⤶
<upload src="b33fe/8daf98266382ed6.gif" size="191584" name="NearestBoneJoint.gif" />⤶
###1.4 Turn on Snap to points so the bone you’re about to create snaps close to the desired point.⤶
<upload src="b33fe/8daf8e89e6a6587.gif" size="62519" name="SnaptoPointsMaya01.gif" />⤶
###1.5 Using Skeleton > Create Joints, firstly click on the joint leg_lower_R and click out two bones. ⤶
You can keep clicking until you’re done.⤶
<upload src="b33fe/8daf982720f0f77.gif" size="358161" name="CreateJoints.gif" />⤶
###1.6 You’ve just added a new bone to the rig. **Wow!**⤶
⤶
###1.7 Rename them appropriately. In this case, it’d be zipper_upper_L and zipper_lower_L.⤶
<upload src="b33fe/8daf9827b664d35.gif" size="249911" name="RenamingJoints.gif" />⤶
###1.8 Rotate the joints so that the x-axis follows the zipper.⤶
What we’ve created is essentially a small armature for the zip to follow.⤶
⤶
###1.9 Confirm that your hierarchy is correct. ⤶
⤶
###1.10 Repeat the above for the opposite boot. ⤶
Remember to keep good naming conventions (e.g., zipper_upper_L and zipper_upper_R).⤶
⤶
##2. Rebinding your skin & reimporting your weights⤶
⤶
###2.1 Select your mesh in the outliner, hold CTRL, and then select your rig (in this case, it is the pelvis). This selection order creates the hierarchy. ⤶
You don’t want to select the two things the other way around. Then, click the Bind Skin settings box. Ensure your settings are as follows, then click apply. ⤶
⤶
<upload src="b33fe/8daf9829e456dc5.gif" size="592348" name="RebindingMesh.gif" />⤶
⤶
###2.3 With the mesh selected (not the skeleton), reimport your weight maps. ⤶
This should restore your hard work from earlier.⤶
⤶
<upload src="b33fe/8daf982d2b3b2dd.gif" size="269693" name="ReimportWeightMaps.gif" />⤶
⤶
##3. Painting your weights⤶
⤶
###3.1 Welcome to the tricky part. ⤶
Because the zip is a solid part of the mesh, **this means the deformation has to remain minimal or non-existent.** We don’t want the zipper to bend or warp. In the case of this boot, the zipper sits in a location that has barely any deformation. Lucky.⤶
⤶
However, sometimes you may find your solid part bends and warps uncontrollably. For example, look at the zipper on this leotard garment for Terry. The neck can be a challenging area to paint.⤶
To fix this, we have to ensure the solid part is not influenced by any other joint than the one that is placed directly upon it. If the zipper’s vertices are influenced by other joints in the hierarchy, it’ll get pulled into those directions. **We want to make sure it keeps its shape, so that the jiggle bone effect is more realistic.**⤶
⤶
Use your discretion as to which influences will have the best looking effect. Keep the number of bones low if it is something like a hinge - a bit like this zip - and painting will become a lot easier. In this case, we only want the zip to be influenced by one bone. The preceding joints help position it, but it’ll be the latter joint that modulates the physics.⤶
⤶
###3.2 Anything that is influenced (painted white) by the zipper bone we have created will jiggle.⤶
If you don’t want a certain part of your mesh to be affected by physics, paint it black. As a general rule of thumb, the more solid an object, **the more solid the paint should be (white).** Naturally, paint gradients are better for fleshier or organic parts.⤶
⤶
###3.3 You can also go into vertex selection, and copy individual vertex weights to paste onto other vertices if you want them to deform similarly (or not at all).⤶
⤶
###3.4 Test the jiggle bone and surrounding joints.⤶
Manipulate the bones and make sure the area behaves as you want it to. If everything looks good, we can move onto importation.⤶
###3.5 Select the mesh, hold CTRL, and then select the skeleton (the pelvis, in this case). ⤶
⤶
###3.6 Export as .fbx into its corresponding addon folder. ⤶
Keep Maya open in case you need to adjust your weight painting later.⤶
⤶
##4. Importing into ModelDoc⤶
⤶
###4.1 Search in the asset browser for your model. Load it into ModelDoc. ⤶
You should see that your extra jiggle bones were imported.⤶
⤶
###4.2 Click + Add and choose JiggleBone. Rename it appropriately (ZipperBoneRight). Then, choose the corresponding bone (zipper_upper_R).⤶
⤶
###4.3 Shape the capsule to the shape of your jiggling mesh. ⤶
It should ideally start on the first joint and end on the last.⤶
⤶
###4.4 Hit compile. ⤶
If your mesh is a garment, you won’t be able to test it until you get in game. If it’s a basic physics prop - once the variables are set up - you can hit the play button in the top left to test it out.⤶
⤶
##5. Settings and variables⤶
⤶
###5.1 Valve uses jiggle bones in many of their games. ⤶
The below features example settings for different types of props from Valve games. This is how they set their bones up and so are a good guide to use if you’re lost or nothing is happening.⤶
⤶
###5.2 The below variables were used for the zipper. ⤶
These may not be perfect - and you may spend hours, days, weeks, or years perfecting your jiggle bones - but they do the job. They might be a good place to start if you want to experiment.⤶
⤶
###5.3 Use the jiggle bone helpers in ModelDoc to predict the effect of your variables.⤶
For example, turning on the yaw, pitch, and angle constraints creates a couple of cones and planes for you to visualise the maximum and minimum effects of the physical forces. Changing the Min Yaw and Max Yaw values, for example, will change the angle of the folded plane.⤶
⤶
##6. Test, test, and test again⤶
⤶
###6.1 When in game, press F2 to use the free camera. ⤶
You can witness your jiggly bits react to any animations supplied to the skeleton by s&box.⤶
⤶
###6.2 Adjust your variables (try to only do one at a time) and keep an eye on your in-game model. ⤶
It is crucial that you keep ModelDoc open and your game running so you can see any changes you make and if they benefit your project.⤶
⤶
#Creating jiggle bones for the fake breasts⤶