Jump to content

Expressions in parameter fields


egl

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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). 
Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...