Simple but not stupid scattering?

   656   4   1
User Avatar
Member
129 posts
Joined: March 2018
Offline
Been using and developing quite a few scattering modules over the years for specific purposes and Lately I have had a need for quite simple systems but that was not something solved by the built in modules.
For example: let’s say you want to distribute a selection of boxes(not cubes) on a surface but the boxes can not be scaled and should not overlap. Sounds super easy but not sure how to do this with built in modules. Should I have to make my own “check bounding box intersection thingy” in a loop? Misuse uv layout per entagmas old tut? I am curious if there is a quick and smart way to solve this and would be very happy to see solutions.
User Avatar
Member
897 posts
Joined: July 2018
Offline
These problems often branches of into very specific solutions depending on your requirements. Is it for 3d, do you have angle axis oriented boxed, do you have soft constraints like "prefered" solutions in cases when there's more than one solution?

Even breaking down to atomic nodes are difficult as Houdini isn't a great fit for custom data types like "box".

Without good information about your particular case, my guess
  1. For a perfect solution with perfect control it's best to just wrangle the whole thing. Implement custom box overlap functions and calculate good positions until you've filled the space.
  2. 3d For a more expensive, simpler but also a lot more readable setup I would loop-feedback it with intersection checks.
  3. 2d, guessing this is what Entagma does, use the uv layout to place squares on the mesh that you then replaces with boxes.
B.Henriksson, DICE
User Avatar
Member
129 posts
Joined: March 2018
Offline
Thanks for the feedback. Have made solutions in the 2 and 3 before genres but not 1. I like that you bring up writing it all yourself as an option since in the end this is not that hard conceptually .
As you saw from the first post, I am hoping for a genre “0” ? so I can lazily jump to other issues.
User Avatar
Member
897 posts
Joined: July 2018
Offline
filipw
As you saw from the first post, I am hoping for a genre “0” ? so I can lazily jump to other issues.
If I understand you correctly, you'd like ready nodes/functions to use- This is where one would need to understand your exact constraints to even begin tackling it. Just filling a single polygon with squares is a difficult problem. Would you instead say that you can accept working on a grid then the same challenge become trivial- just move the grid over the polygon and delete what's outside. But then again, say you also need it to work for multiple polygons in 3d and the distribution needs to be continuous across edges and the grid solution becomes very difficult.

Fundamentally it's about how packing problems is ambiguous and lack good universal methods. UV packing is the best there is.
B.Henriksson, DICE
User Avatar
Member
123 posts
Joined: March 2014
Offline
If you don't need the packing to be very tight you can use the point relax node, it takes pscale into account and gives pretty good results. The less cube-shaped your boxes are the bigger the gaps will become, because the point relax assumes spherical points.

A more accurate non-VEX solution would be to use Vellum. The idea being that you scatter them initially with 0.5x their size, ensuring that they don't overlap. Then on the Vellum configure (should probably use Vellum Configure Strut Softbody) you set their rest length scale to 2x, this way they'll scale themselves to their intended size on frame 2.
On the Vellum solver you would want to increase friction static threshold and wind drag a lot (maybe to 5 each or something) so that they don't separate too much when they get scaled up. Also set stretch and bend stiffness very high and increase constraint iterations if needed.

Setting the Vellum solver to quasistatic will output only a single frame instead of a simulation (although internally it does have to calculate frame by frame, so you may want to cache the resulting frame).

Just tested this, and the packing can be very tight when you do it like this.

Attachments:
boxes_01.jpg (239.2 KB)

  • Quick Links