Saturday, July 19, 2014

Climbing Rope Simulation

Problem: Similar to the cord on the blinds in the final scene in Owned, Ram's Horn needed to have a rope simulation added to it. However, unlike Owned, this rope simulation would have to be adaptable enough to be placed in any scene, because the main character is a mountain climber and as such relies heavily on his climbing rope despite all the antics he participates in.

After looking over the many scenes that require this tool, we determined that this tool would have to have the following requirements

1.  It must be able to be constrained on both sides to two different points of separate geometry
2.  The wire must have adjustable length
3.  The wire segments must have adjustable length
4.  We must be able to define collision geometry
5.  The wire must have a renderable geometry that has adjustable thickness

Solution: The node network that I came up with was relatively simple, but effective in solving these problems. It consisted of three nodes, as most dynamics simulations do in Houdini. First, a Geometry node to establish the static rope [static_rope]. Second, the DOP network to simulate the necessary forces [wire_sim_network]. Third, a Geometry node to import the simulation data and generate a renderable geometry off of it [render_rope].

Overall Node Network
The static rope node needed to solve some of the problems with the initial rope right away. First, we generate the initial rope with a line node [rope_geo]. This doesn't allow free adjustment of the length of the line segments, but it does allow for adjustment of the overall line length and the origin of the line. The initial direction of the line turns out to be important as well to ensure a smooth pre-roll and this line node is the place that it can be adjusted.

To allow for adjusting the line segment length, we add a resample node [adjust_segment_length]. This allows us to freely adjust the length of each line segment without having to worry about the overall length of the line changing.

Finally, for the DOP simulation, we will need to isolate the first and last points on the line so we can properly set up the constraints. That's what the two group nodes are for [isolate_origin_point] and [isolate_dest_point].

Static Rope Network
The DOP network then imports this line as well as the geometry for collision. 

First, we import the line into a wire object [climbing_rope] and pass it through a wire solver [wiresolver1]. Then, using the points we isolated earlier, we add two SBD pin constraints to constrain this wire object to the points on the objects we need to [constrain_to_origin] and [constrain_to_dest]. Then, to simulate air resistance, we add a drag force to help the momentum of the simulation die down naturally [air_resist].

Right beside that, we import the collision geometry as a static object [collision_object] and pass it through a static solver [staticsolver1].

Merging them together [merge_all], we add a main gravity force to the simulation [main_gravity_force].

DOP Network


Once the simulation is done, we can retrieve the simulation data [import_rope], but at this point it is still a non-renderable line. To solve this, we use a poly wire node to skin some geometry evenly around the line [polywire1]. This poly wire node allows us to freely adjust the thickness of the line for rendering purposes.
Render Rope Network
So, for the artist using the tools, I exposed a lot of the parameters necessary to apply this network to any situation.

First, in the Rope tab, I applied everything that has to do with the rope itself. They can adjust the overall length of the rope through the initial line node and the segment length through the resample node. The Thickness attribute carries over to the poly wire node and the initial direction is set on the initial line node for optimum preroll.

The origin Geometry and point are normally passed to the initial line node and the origin of the line is set to the position of that point in space. However, in the cases where this is not important, it can be left undefined and the origin with be set to (0, 0, 0)

The destination Geometry and point are normally used to set up the second pin constraint, but in the event that it's not needed, the constraint is deactivated and the rope hangs limply behind its origin.

Rope Tab
The collision tab then simply points out which geometry needs to be collided with. The containing object and the geometry are needed by the static object.

Collision Tab
Running this network through a simple test proves that it is effective at accomplishing these tasks.




Thus with little adjustment, we were able to incorporate this Rope Simulation tool into our film and here's a peek at what the simulator looks like in action.