rand() help

   4478   5   0
User Avatar
Member
4 posts
Joined: Dec. 2009
Offline
Hi, this should be easy for most of you out there. I am using geometry to scatter popcorn kernels (I have 3) around a model of a “pile.” Anyway, I figured out how to use the scatter SOP and copy SOP to aid me in this, and also Im aware of the “switch” SOP to switch between the 3 kernels. Where I need help is: I am assuming I need to throw in the rand() expression into the input of the Switch node to vary the popcorn kernels all over the model. rand($F) will not work because this is just going to be a stationary pile of popcorn. What do I put inside of the parentheses to get that randomization? Or am I needing to throw in another node somewhere? I feel like this should be really easy. Thanks!
Joel
User Avatar
Member
862 posts
Joined: Oct. 2008
Offline
create a stamp variable, for example rrand, and give it the value rand($PT). then in the switch type

if(stamp(“../”,“rrand”,0) < 0.3, 0, (if(stamp(“../”,“rrand”,0) < 0.6, 1, 2) ))
--
Jobless
User Avatar
Member
8602 posts
Joined: July 2007
Offline
or you can simplify that expression to
floor(stamp(“../copy1”, “rrand”, 0)*3)

supposing that the name of the copy SOP is “copy1” and that you have copy stamping enabled on it with rrand variable set to rand($PT) according to Soothsayer's post

but maybe this video can help you understand what copy stamping is and how it can be used http://www.sidefx.com/index.php?option=com_content&task=view&id=881&Itemid=132 [sidefx.com]
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
2624 posts
Joined: Aug. 2006
Offline
Maybe an expression like stamp(“../copy1' , ”myrand“ , 3) into my switch sop , then in the copy sop I would add a stamp expression using floor. So for the variable I would use something like floor( rand($PT) * opninputs(”../switch") ) . This should assign a random popcorm kernal to each point as you have 0 , 1 , 2 inputs into the switch SOP.

rob
Gone fishing
User Avatar
Member
862 posts
Joined: Oct. 2008
Offline
or

trunc(rand($PT)*3)
--
Jobless
User Avatar
Member
4 posts
Joined: Dec. 2009
Offline
I watched the video of copy stamping…super helpful…running into a few more problems but I think Ill be able to handle it now. Thanks everyone.
Joel
  • Quick Links