vex instead of local variables

   6709   8   1
User Avatar
Member
25 posts
Joined: 1月 2014
Offline
Hey there guys.

Now what Houdini is starting to move away from using local variables, I am lost in how to achieve certain results.

So back in the old days( I still do it due to the old point node being available ), I would use the old point node, plug a point into input 1 and then another point into input 2. Then I would add a normal, and set the X to $TX2 - $TX, the Y to $TY2 - $TY, and $TZ2 - $TZ.

Now that Sidefx is pushing for vex ( which is a good idea to keep Houdini more focused and allow us to have faster executing networks), the old point node would now set the normal to @N.x, @N.y, @N.z instead of $NX, $NY and $NZ

So my question is….

How would I convert $TX2 - $TX into vex to set the normal direction like I used to?
Edited by Martin Krol - 2017年4月28日 09:54:18
User Avatar
Member
23 posts
Joined: 2月 2014
Offline
You can simply initialize Normals in attrib wrangle using

@N;
User Avatar
スタッフ
107 posts
Joined: 2月 2009
Offline
Martin Krol
Hey there guys.

Now what Houdini is starting to move away from using local variables, I am lost in how to achieve certain results.

So back in the old days( I still do it due to the old point node being available ), I would use the old point node, plug a point into input 1 and then another point into input 2. Then I would add a normal, and set the X to $TX2 - $TX, the Y to $TY2 - $TY, and $TZ2 - $TZ.

Now that Sidefx is pushing for vex ( which is a good idea to keep Houdini more focused and allow us to have faster executing networks), the old point node would now set the normal to @N.x, @N.y, @N.z instead of $NX, $NY and $NZ

So my question is….

How would I convert $TX2 - $TX into vex to set the normal direction like I used to?


In the new Point Sop ( Attribute expression sop ), set the ‘attribute’ parameter to N and then in the VEXpression field enter :

v@opinput1_P - v@P

You can use the “opinput_” to fetch attributes from other inputs. This works in wrangles, etc.
—————-
Scott Keating
Product Designer
SideFX Software
—————-
User Avatar
Member
45 posts
Joined: 8月 2012
Offline
sakeating
In the new Point Sop ( Attribute expression sop ), set the ‘attribute’ parameter to N and then in the VEXpression field enter :

v@opinput1_P - v@P

You can use the “opinput_” to fetch attributes from other inputs. This works in wrangles, etc.
Hello, this is great, but can we see it all in help docs? Example: before/after.
Edited by Felix6699 - 2017年4月28日 10:36:02
User Avatar
Member
25 posts
Joined: 1月 2014
Offline
sakeating
v@opinput1_P - v@P

Thank you for the answer.

Just so I try to understand what this all means. Would you mind if I ask what it all means? or how I should interpret it logically?

v@opinput1_P - v@P

so how I am reading it is: vector attribute of operator input 1s position - vector attribute position?

So you don't have to specify the second input directly?

The local variables seemed logical $TX2 - $TX

kinda like using ch(“../node2/tx”) - ch(“../node1/tx”)

Originally I was expecting to use (@N2.x or @N.x2) - @N.x but this didnt get me anything.

( I apologize ahead of time, I am not a programmer and I am trying to make sense of all of this )
User Avatar
Member
1798 posts
Joined: 5月 2006
Online
Yep. More a a breakdown, might help or hinder, apologies in advance.

@ is prefix for attribute
@P is the position attribute of a point
@N is the normal attribute of a point

Because attributes can have different types (vector, float, int etc), there are prefixes to denote what you're talking about:

v@foo; // means @foo is a vector
i@bar; // means @bar is a integer
f@grep; // means @grep is a float

The 4 inputs of a wrangle are numbered 0,1,2,3. If you wanted to refer to the @P from input 1, you put opinput1_ between the @ and P, like this:
@opinput1_P

So if you wanted to be super canonical, to get position from the 0 input, you'd specify its a vector, the 0 input, and the P attribute:

v@opinput0_P

In practice there's a few shortcuts you can take. Vex knows about frequently used attributes like P, N, Cd, so they don't need the type prefix. Also, if you don't specify the ‘opinput_n’ bit, it pulls from the 0 input. This is why can you just write

@P

So in your case, you want to set N based on the input-0 point minus the input-1 point. In a wrangle, you write that pretty much as that sentence flows, first being all super canonical and smug coder:

v@opinput0_N = v@opinput0_P - v@opinput1_P;

and again being lazy coder; we don't need the type prefix (tho its a good habit to get into), and we don't need to specify opinput0_, as that'll be assumed. So that shortens to

@N = @P - @opinput1_P;

Hope that helps!

-matt
Edited by mestela - 2017年4月28日 11:18:53
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
25 posts
Joined: 1月 2014
Offline
mestela
o if you wanted to be super canonical, to get position from the 0 input, you'd specify its a vector, the 0 input, and the P attribute:

Awesome!. That is sooooo super helpful

Thank you soo much!
User Avatar
Member
45 posts
Joined: 8月 2012
Offline
mestela, You should write Help Doc for SideFx
User Avatar
スタッフ
503 posts
Joined: 7月 2005
Offline
The page you want is https://www.sidefx.com/docs/houdini/vex/snippets. [sidefx.com] I will try to make the links to that page from the nodes more prominent.
  • Quick Links