I saw a tutorial where the position of scattered copies using Copy to Points node are raised in the Y axis with this expression:
v@scale = rand(@ptnum);
v@P.y += v@scale.y/2;
It uses a randomised scale on an object copied to points on a flat Grid and then moves them up by half their height so they sit flush on the grid. What I don't understand is why the second line uses += rather than =
Can someone explain? The Houdini documentation mentions "Variable assignment" operators:
= += -= *= /= %= &= |= ^=
What does +- mean in VEX?
1028 5 1- litote
- Member
- 209 posts
- Joined: 7月 2013
- Offline
- tamte
- Member
- 8449 posts
- Joined: 7月 2007
- Offline
- animatrix_
- Member
- 4458 posts
- Joined: 2月 2012
- Offline
It's a common syntax in C style languages, now even languages like Python have the same syntax.
+= can be translated as "add whatever is to the right of the += to the variable on the left of the +=".
+= can be translated as "add whatever is to the right of the += to the variable on the left of the +=".
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
- ingauravbackliner
- Member
- 7 posts
- Joined: 4月 2023
- Offline
- litote
- Member
- 209 posts
- Joined: 7月 2013
- Offline
Thanks for your answers.
After experimenting I found that if you just use: v@P.y = v@scale.y/2;
...then the geometry will flatten out on the Y axis like a plane rather than retain its shape. So, presumably this is working on all points of the geo as VEX tends to do, telling Houdini to place them all at the same Y position, whereas += moves each point up by the same amount, thus retaining the shape of the geo.
After experimenting I found that if you just use: v@P.y = v@scale.y/2;
...then the geometry will flatten out on the Y axis like a plane rather than retain its shape. So, presumably this is working on all points of the geo as VEX tends to do, telling Houdini to place them all at the same Y position, whereas += moves each point up by the same amount, thus retaining the shape of the geo.
- litote
- Member
- 209 posts
- Joined: 7月 2013
- Offline
-
- Quick Links