egl Posted September 11, 2014 Share Posted September 11, 2014 Hi smart people : ) Switching from XSI to HOU... Simple theoretical question: why some of expression variables and functions cant be used in some of values fields, example: polygonal sphere -> peak sop -> distance parameter. why expression rand($PT) does not work? I tested similar construction with polygonal sphere -> attribute create 'disp' ( rand($PT) for the value ) -> point ( position: $TX + $NX*point("../ac1",$PT,"disp",0), $TY....,$TZ....) works great. My guess: Peak SOP attribute Distance is not related to object`s points... but at first look it does. Thank you Quote Link to comment Share on other sites More sharing options...
Robert Posted September 11, 2014 Share Posted September 11, 2014 It is probably because $PT is a local variable. Many nodes support this local variable but it seems the peak SOP does not. To see which local variables the node supports you can always look at the help file for the node. You can also see which variables are OK to use by typing $ in the parameter field and going through the little drop-down list that appears. Quote Link to comment Share on other sites More sharing options...
egl Posted September 11, 2014 Author Share Posted September 11, 2014 local node variables, good. thank you. but what about just rand() in peak sop -> distance parameter. rand is global function? Quote Link to comment Share on other sites More sharing options...
Robert Posted September 11, 2014 Share Posted September 11, 2014 rand() is a hscript expression that you can use in pretty much any parameter field. The trick in this case is the seed you feed it. Often you would use the point number $PT as a seed because its unique for every point. In this case the peak SOP doesn't support the local variable $PT so you can't use it as a seed. The peak SOP is easy to use but if you want per point control I suggest you take a look at VOPSOPs or even better, pointwrangles. Inside a pointwrangle I can do the same operation as the peak SOP in 2 lines (or just 1 but this reads better): f@distance = rand(@ptnum)*.5; @P += @N*@distance; With the point wrangle you are not relying on some prebuilt functionality so anything goes, in this case offsetting the position by an amount you specifiy yourself ( rand(@ptnum)*.5 in this example). Quote Link to comment Share on other sites More sharing options...
fathom Posted September 11, 2014 Share Posted September 11, 2014 fwiw, you don't need @ on globals (ptnum, N, P) and you should prolly normalize N. i also like "hscript_rand()" over "rand()" because it uses a float seed rather than an int, but that's personal preference i suppose. Quote Link to comment Share on other sites More sharing options...
Robert Posted September 12, 2014 Share Posted September 12, 2014 I didn't know about the rand() function difference in VEX so I looked it up. It seems that rand() takes a float seed and random() takes an integer seed or converts the seed to one. It is true though that hscript_rand() would give more consistency when you are also using rand() outside of vex. And thanks for the tip about the globals, learned something new Quote Link to comment Share on other sites More sharing options...
fathom Posted September 13, 2014 Share Posted September 13, 2014 yeah, i guess i was thinking about random()... old habits, i guess. seems "rand()" was an h13 addition. looks like i can do a bit less typing. woot! thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.