Jump to content
Sign in to follow this  
Jimbo55

For Each Loop to effect size

Recommended Posts

Hello I am trying to effect the size of each piece of geo in the following image.  I want each piece to be a random size, I feel like I'm almost there but am missing a bit of Hscript to do it.  Any input would be great.

 

Thanks in advance.

 

 

post-8450-0-96202800-1459197357_thumb.pn

For_each_Size.hip

Share this post


Link to post
Share on other sites

An alternative approach to something like this would be driving your fracture points with a Scatter SOP using a noise-based density attribute. If this isn't clear I'll see if I can prepare an example HIP for you later tonight. 

Share this post


Link to post
Share on other sites

I've attached a HIP file demonstrating the noise density technique. It's a very controllable and visual way of getting variation in your fracture, which is very important for voronoi-based fracturing given it's distinctive look. You might try something similar with the inside points if you want more variation there as well. 

 

Here's what I came up with for the ForEach solution:

fit01(rand(opdigits(stamps("..", "FORVALUE",""))), 0.5, 1)

Paste into Uniform Scale. This is basically retrieving the numerical suffix of each piece group and using it as the random seed. 

 

Hope that helped!

fracture_density_noise.hiplc

Edited by jrockstad

Share this post


Link to post
Share on other sites

Thanks Jrockstad
   This helps alot!  Where did you pick this up?  I've found plenty of info on how to use the copy sop with stamp functions but not doing this within a Foreach loop.

 

Thanks again.

Share this post


Link to post
Share on other sites

Glad it helped!

 

I discovered the opdigits() method in one of the ForEach example files. Launch the help browser from within Houdini, scroll down and for most nodes you'll find an Examples section where you can automatically load some small scenes demonstrating the functionality of that node into your current Houdini session. 

 

I should mention that in this case you could pare down that expression a bit and retrieve the exact same value just using

stamp("..", "FORIDXVALUE", 0)

but I thought the opdigits() trick was pretty neat so I figured I'd bring that to your attention as well. 

 

One more little note, just to clarify when I said you could perform something similar to the density-based scatter with your points inside the volume, the procedure is a little different. You would need to convert your geometry into a fog volume with an IsoOffset, then inside a Volume VOP multiply it by a noise. You can then feed the volume into a Scatter SOP with similar results - areas inside the volume with greater density will be populated with more points. Just make sure to leave the Density Attribute itself off though, as this is a point attribute that is not applicable to volumes and will cause the Scatter SOP to error out - in this case all the density information you need is in the volume itself.

 

Share this post


Link to post
Share on other sites

There is one more (for some scenarios) preferable way. By scatter node define relatively small number of points let say up to 5, then set those points represents places on your object where an other imaginary objects would hit. Those will be impact points. Then use VoronoiFracturePoints node for calculation of other points (which would be around those impact places and you can setup behavior of those impact places on surface, "under" surface, which radius will be affected,  etc and all those will result in different size of pieces ) to feed VoronoiFracture.  And you can use ExplodedView node to visualize separated pieces. 

 

Scene:

http://wikisend.com/download/558338/VoronoiFracturePoints.hip

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×