Jump to content

Understanding VEXpression


Recommended Posts

Can any VEXpression experts help me understand the following used in an Attribute Create node. Its from a .hip that demos light instancing. What exactly does the following return?      





Link to comment
Share on other sites


Start reading it from the center of the brackets:

(rand($PT+1541) // A random value between 0.0 and 1.0 is created based on the point number ($PT) + an additional seed value (1541)
*2 // The random value gets multiplied 2, so now it´s between 0.0 and 2.0
fit01( XXX ,1,2)) // This get fitted from 0.0 - 1.0 to 1.0 - 2.0 (so multiplying it by 2 has not made much sense imho)
int( XXX ) // The whole thing is casted to an integer, so in this case either 1 or 2
` XXX ` // The back ticks probably turn this into a string, so you can combine it with:

So I guess it would switch between two light sources named light1 and light 2.

Edited by konstantin magnus
Link to comment
Share on other sites

methinks be careful with int()

It's TRUNCATING....not just casting to type int.

So just randomly....round(1.8) = 2

but int(1.8) = 1

To me the original method is a bit 'convoluted'.....where you'd need to digest this bit of info:

fit01(num, newmin, newmax)

Returns a number between newmin and newmax that is relative to num in the range between 0 and 1. If the value is outside the 0 to 1 it will be clamped to the new range.

...the 'outside' range bit...


So I've fooled around with other methods...personally, I prefer the last....where you know it's one or the other..so simply add 1..assuming object names are obj1 and obj2...


Edited by Noobini
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.

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...