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?
2806 5 1-
- litote
- Member
- 274 posts
- Joined: 7月 2013
- オフライン
-
- tamte
- Member
- 9432 posts
- Joined: 7月 2007
- オンライン
-
- animatrix_
- Member
- 5135 posts
- Joined: 2月 2012
- オフライン
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] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
-
- ingauravbackliner
- Member
- 7 posts
- Joined: 4月 2023
- オフライン
-
- litote
- Member
- 274 posts
- Joined: 7月 2013
- オフライン
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
- 274 posts
- Joined: 7月 2013
- オフライン
-
- Quick Links


