Jump to content

VEX Noob question: why is "v" needed ?


AstralZombie

Recommended Posts

This often comes down to a quirk of VEX (or at least I'd call it a quirk). The letter in front of the "@" symbol is meant to declare the data type of the attribute, v for vector, f for float, i for integer etc. If you don't specify then Houdini will try to "guess" for you, however, I find that it can very easily guess wrong when it comes to vectors, and instead of reading all the three values of the vector, treats it like a float and just reads the first value (and then possibly fills the last two values of the vector with the same value as the first field).

My general philosophy is that I always just add the datatype indicator in front of the "@" to be as safe as possible, but as a general rule of thumb (but not a completely bulletproof fact), if you've defined the attribute in the same wrangle then you often don't need to keep using the datatype letter, like in the example below:

v@v = {0,0,1};
v@up = {0,1,0};

v@N = cross(@side, @up);

However, if you would be to make the v and up attributes in another wrangle and just try to calculate the N in a new wrangle then you'd more than likely need to use the datatype defining letter in front of the "@" symbol again.

Hope that can answer some of your questions.

  • Like 1
Link to comment
Share on other sites

It doesnt guess. By default it binds @ as float. There are some predefined attributes that Houdini knows is a vector, like P/v/N and other default ones. You typically dont have to define those. But for any custom attributes you do have to declare what they are. Its a good habit to always do f@, v@ etc

  • Like 1
Link to comment
Share on other sites

VEX is exactly like C, variables are declared once only.
You only need "@" when importing or exporting attributes (in this case point attributes)
But if you call an attribute inside VEX, then you need to tell VEX how to interpret its type. hence the v@ or f@ in front


for example:

vector a,b,c;
a= {1,0,0};
b = {0,1,0};
c = a+b;

// export c as an attribute named d
v@d = c;


You should read this:
https://www.sidefx.com/docs/houdini/vex/lang.html

 

Edited by bunker
  • Like 1
Link to comment
Share on other sites

so, it turns out Underscoreus' post was the key: 

@side was made in a previous node, and so the need to explicitly add the type in a subsequent wrangle. 

I will just get in the habit of adding the type in front of all user defined attributes. 

 

thanks much!

 

 

  • Like 1
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...