# Naughty Dog Muscle Recreation (Proof Of Concept)

So this is my attempt to recreate the effects of a tool made by Judd Simantov at Naughty Dog. It is a simply distance based muscle simulation.

**How it works**

There are two pairs of locators.

They drive the CV position of two linear curves.

The are lofted to create a nurbs surface (I do this with a node but don't actually have a shape node).

The point on the surface (that matches the position of the midpoints of the two curves) has it's position and normal vector queried by a pointOnSurfaceInfo node.

The normal vector is multiplied by the bulge effect output (explained below) and added to the position.

Then that new position (along with the two locators positions drive the position of the CV's of a quadratic (degree 2) curve.

Those two resulting curves are then lofted to create a nurbs surface.

**Calculating The Bulge Effect:**

The distance between them is measured

The distance is divided by the global scale of the rig (to compensate for double transforms)(I did not do this in the proof of concept(

The distance is then divided by the original distance between the two points

It is then raised to the power of the bulge factor (set to -1 by default) to calculate a volume preserving effect.

This value is then multiplied by the starting bulge.

**Attaching The Locator To The Surface:**

Get the normal and tangent-U vectors at a point on the surface and plug them into a four-by-four matrix node as the x-axis and y-axis.

Multiply that matrix by the parent inverse matrix of the locator (in order to cancel out the parent transforms and make the attachment work regardless of heirarchy)

That matrix is turned into translate and rotate attributes using a decompose matrix node.

Those attributes are plugged into the locator.

**Bringing It All Together:**

You gotta love it when a node network looks so nice in the node editor.

**Addendum:**

In the naughty dog demo some of the muscles have six attachment point instead of four. To make that work all you would need to do is set up the same curve system 3 times instead of a two, and make sure that the surface you query the normals off of is cubic rather than linear (so that it has continuous normals). If you do use six point then you should have 3 separate start bulge values for even more customization.

Tags: