Skip to main content

Cone Twist Constraints

Cone Twist Constraints


Recently I was trying to recreate a wooden fence breaking apart, I found that the look with normal glue constraints was not at all accurate to that of actual wood. The constraints were either ON or OFF, not allowing the pieces to bend before the constraints break, which seems to be one of the defining looks in wood breaking. The best option for replicating this effect is the Cone Twist Constraint, which according to the docs "Constrains an object to remain a certain distance from the constraint, and limits the object's rotation." Pretty quickly I found that cone twist constraints aren't quite as simple to set up as a typical glue constraints but after a lot of digging around, I was able to the right way to do it. But I didn't find a simple guide to setting them up, so I wanted to share what I had found.

A Flipbook from when I was still tweaking, and testing the values.  The cone twist effect on the planks is pretty evident.

Typically when setting up some simple glue constraints, you'd use a Connect Adjacent Pieces node to create the primitives for the glue constraints, and afterwards create "constraint_name" and "constraint_type" attribs. 


Primitive lines created from the Connect Adjacent Points SOP  in a simple glue setup.

These are easy to bring into DOPS with a "Glue Constraint Relationship" and "Constraint Network" nodes. But when I tried to switch out the "Glue Constraint Relationship" node with a "Cone Twist Constraint Relationship"node, the sim went wild, and was not producing the desired effect.
After my research I found a few key differences to remember when setting up Cone Twist Constraints.


1.) COLLAPSE THE PRIMITIVES

So instead of having two points connecting the surface points to represent the glue bonds, for the cone twist you actually want to have two sets of points directly on top of each other. Otherwise the constrained pieces will violate their initial position and break their bonds on the frame. To achieve this you can append a Primitive SOP, turn on "Do Transformations", set the Pivot Translate to each primitive's centroid with $CE_ function, and then set the scale in each axis to 0. Now each primitive's two points have been put in the exact same position in the center of  itself.

The Primitive SOP, set to collapse the primitive's points on it's center.

Although they look like single points, the collapsed primitives are what you feed into your simulation to setup the Cone Twist Constraints.


2.) SETTING TORQUE LIMIT

Much like setting the initial strength attribute for a typical glue constraint, you need to set an initial attribute to set the limits for the constraints. With Cone Twist Constraints f@torquelimit is the attribute to create that will be used to break the bonds. There isn't an intuitive way I found to change this in DOPS, so you'll end up coming back to this and tweaking as you look dev your sim.

Setting the torque limit inside a Prim Wrangle. I found the expression fit(rand((float)@primnum), 0, 1, ch("torque_min"), ch("torque_min") ) helpful to get some randomization.

3.) SOP SOLVER BOND BREAKING

From what I found, the best break the cone twist bonds is to setup a sop solver to do it manually in DOPS. To do this append a Enable Solver to the 3rd input of the Constraint Network, then a plug a SOP Solver into the Enable Solver Node.

The Node Graph of a working Cone Twist Constraint

Inside the SOP Solver, turn on the Solve Objects on Creation Frame toggle and double click on the node to dive inside. Connect a Primitive Wrangle to the relationship_geometry, here we'll put a bit of code to break the glue bonds according to the torque limit set to each primitive for the pin constraints. 

if (f@torque > f@torquelimit) {
removeprim(0, @primnum, 0);
}

Now if you run the simulation any piece that breaks the torque limit will break it's glue bonds.

Setup inside the SOP Solver


Now you've got a working Cone Twist Constraint! Adjusting the parameters in the Cone Twist Constraint Relationship node (especially the first 4 parameters) will change how much the pieces move and rotate before breaking their bond. Using the parameters in the Cone Twist Node, and the torque limit attribute, you can get a lot of different looks!



Changing the Torque Limit and Twist Attribs




Popular posts from this blog

Fern Generator HDA

The Fern Generator Digital Asset A fun Digital Asset I recently put together, generates random ferns on any geometry you feed it.  It also has options for masking by geometry, custom spawn pts. input, custom leaf input, color and tons of other randomization. I plan to update this page w/an overview of how I created this HDA, to help give any people wondering some direction.  Fern Generator - A Houdini Digital Asset from Gabriel Fernandez on Vimeo . Below is a link to download the Non-Commercial version of the HDA Any feedback or comments are appreciated! Happy Ferning! Non-Commercial HDA Download Here!! **Current Build has a bit of a render issue I'm working on**

The Donutizer HDA

The Donutizer Digital Asset While taking on the Daily Render Alphabet Challenge, I created a donut that I was rather proud of. Although it might not be the most used HDA in your library, I thought it'd be fun to create a Digital Asset out of it, & make it available. It's called the Donutizer, and it will turn any poly-mesh into a donut, complete with sprinkles & frosting.  An example of the Donutizer in action The Digital Asset includes parameters for, adding custom noise and surface based color to the donut surface, adjusting frosting coverage and shaping, and tuning the sprinkle's density, size, & shape. Below is a link to download the Non-Commercial version of the HDA Any feedback or comments are appreciated! Happy Donuting! Non-Commercial HDA Download Here!!