Copy objects with bias/counting up a value

   1150   5   0
User Avatar
Member
11 posts
Joined: July 2014
Offline
I'm making a .hda for Maya and I'd like to procedurally copy a user-specified number of pieces of geometry from a set of an unknown number of objects at random, biased to the inverse of the objects' volume. For example, say the user asks for 100 copies and plugs in two objects, A and B. A has 0.3 times the volume of B. I'd like the system to return 100 objects which can each randomly be A or B, but with A being 3.3333 times as likely as B. Since the geometry is coming in from Maya, I know I can separate individual objects by name. I've gotten as far as measuring the volume of all objects together, then going through a loop of each named piece and giving its points an attribute equal to (The total volume of all objects)/(The object's individual weight), which gives all of the objects a total bias amount. Any advice on where to go from there?
Edited by EllyFish - April 24, 2018 18:17:31
User Avatar
Member
2536 posts
Joined: June 2008
Offline
What if you setup some wrangle to make a decision based upon all the input?

Attachments:
untitled-1.jpg (184.5 KB)
ap_weighted_scatter_042418.hiplc (137.7 KB)

Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
11 posts
Joined: July 2014
Offline
Enivob, thanks for the reply, but the 2-item example was just an example. As I said, I won't know how many items there will be beforehand. For all I know, there could be 1000 unique objects.
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
As I said, I won't know how many items there will be beforehand.

Then on your hda establish a user input parameter that establishes however many copies they want, and parameters for which objects the user wants to use.

And in the wrangle use those valuse to create the number of items of the desired objects.
Edited by BabaJ - April 24, 2018 21:55:14
User Avatar
Member
2536 posts
Joined: June 2008
Offline
I was thinking Python based weighted list with most likely candidate bubble sorted to the top..? Then you just fetch element ZERO from the list.
Edited by Enivob - April 25, 2018 09:43:09
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
11 posts
Joined: July 2014
Offline
Nevermind, I figured it out. I go through a list of the objects by name, and just give them an ID number, a piece_weight attribute of 0, and measure their volume. The I attribute promote the sum of their volumes to get the total volume. After that I go through a loop with feedback. I find the maximum piece_weight attribute of all objects, as well as the bias for the current object (total volume/object volume), add them together, and assign that as the piece_weight for the current object. At the end I divide all of their piece_weights by the maximum piece_weight to normalize them to a 0-1 scale, and my copy stamp node picks a random 0-1 float, and I take the object with the lowest piece_weight that is higher than that number.
  • Quick Links