Randomly choose between mutliple source objects for Greeble

   2045   5   1
User Avatar
Member
4 posts
Joined: Sept. 2019
Offline
Hi!

I'm trying to make a greeble tool, but I can't proceed on because I can't instantiate the different source objects to the subdivided grid that I have. I have created six variations of a grid, which I have called GreebleObjects, which I want to be placed randomly on the grid. The problem is in the delete under the object merge, instead of obeying the expression inside the delete group to choose only one Greebleobject, they all appear at once. Could someone tell me what's going wrong?

I attached the .hip file

Thanks!

Attachments:
greeble.hipnc (521.5 KB)

User Avatar
Member
2529 posts
Joined: June 2008
Offline
What about something like this….
Construct a string attribute that randomly programs the ObjectMerge.
Construct a random part for each primitive using VEX.
int index = int(fit01(rand(@primnum+ch("seed")),1,7));
s@obj_path = sprintf("/obj/GreebleObjects/grid%d",index);

Reference the attribute using the hScript prims function.
`prims("../foreach_begin1/",0,"obj_path")`

Attachments:
Untitled-1.jpg (167.5 KB)
ap_greeble.hipnc (536.7 KB)

Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
4 posts
Joined: Sept. 2019
Offline
It works, thank you very much! It's a smart way to fix it.

Btw I still don't understand why the expression in the group inside the delete doesn't choose only one random piece of the GreebleObjects.

Thanks again!!!
User Avatar
Member
1737 posts
Joined: May 2006
Online
An alternative way is to make use of copytopoints and its new ability to support variants; if the incoming points have a @variant attribute, it looks for the matching @variant on the shapes to copy, and only copies that geometry onto the point.

I've attached 2 setups, one which inserts a variant workflow onto your existing setup which is a little hacky, and another one using copytopoints and some labs tools to make setup a little easier. Added a few things into that second setup to add random rotation and stuff, and it support 3d shapes (try swapping the grid for the sphere or box at the top of the network).

Attachments:
greeble_me.hipnc (475.8 KB)
greeble_me2.hipnc (574.7 KB)

http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
4 posts
Joined: Sept. 2019
Offline
Thank u Mestela! I like it because it seems simpler than using vex, but the @variant attribute doesn't work for me, it appears a warning on the attributecreate where you create the @variant that says “Unexpected integer precision”. Maybe this attribute can not be run in Houdini 17.5. Also I get some problems with the lab tools beacause of the version.I attach a screen capture of the error of the second set up (greeble_me2).

I would like to know how could I do the same thing but without having to use the @variant attribute?

Attachments:
variant_problem.png (1.7 MB)

User Avatar
Member
7737 posts
Joined: Sept. 2011
Offline
Damn_daniel
Thank u Mestela! I like it because it seems simpler than using vex, but the @variant attribute doesn't work for me, it appears a warning on the attributecreate where you create the @variant that says “Unexpected integer precision”. Maybe this attribute can not be run in Houdini 17.5. Also I get some problems with the lab tools beacause of the version.I attach a screen capture of the error of the second set up (greeble_me2).

I would like to know how could I do the same thing but without having to use the @variant attribute?

Copy to pieces only uses the variant attribute in 18.
  • Quick Links