Tutorial "Houdini First Steps - MO6 - Attributes and Variables" by Ari Danesh

   3313   2   1
User Avatar
Member
2 posts
Joined: Jan. 2015
Offline
Hi folks, I hit a brick wall just after 6 first steps tutorial here

I'm using Houdini 15.5 Apprentice while trying to emulate the tutorial by Ari Danesh in Houdini 12.

In module 6 of the First Steps tutorial, Ari is showing us some examples of how we can read and use attributes and variables. In the third example, Ari is storing color information in a new custom attribute with 3 components and then recalling/reassign it from the next point node using the usual syntax e.g “$ARI1”, “$ARI2” and “$ARI3” to add color.

In my case this doesn't work. If, for example, I call $MYCOLOR1 to add color, my point node wont cook.
I tried using the VEX way to call attribute e.g. “@myColor.2” etc., it works, but no matter what the number after the dot notation is, it only refer to the first component of my newly created custom attribute.

I tried looking at the documentation of the point node and the attribute create node, but I got nothing from there.

So the question(s) is:
If I create an attribute named custColor in attribute create node, what is the syntax to call that attribute in point node?
It also will help a lot if someone could point a direction to informations regarding syntaxes to write these snippets of codes in parameters.

Thanks guys,
Dian
404 not found
User Avatar
Member
606 posts
Joined: July 2013
Offline
For example, to access the 1st component of a Vector, you can do @Vector.x, @Vector.u or @Vector.r, all 3 statements are resolved the same, as they reference the 1st component.

From the Docs regarding accessing VEX attribute components…
Dot operator

You can use the dot operator (.) to reference individual components of a vector, matrix or struct.

For vectors, the component names are fixed.

.x or .u to reference the first element of vector2.
.x or .r to reference the first element of vector and vector4.
.y or .v to reference the second element of vector2.
.y or .g to reference the second element of vector and vector4.
.z or .b to reference the third element. of vector and vector4
.w or .a to reference the fourth element of a vector4.
The choice of the letters u,v/x,y,z/r,g,b is arbitrary; the same letters apply even if the vector doesn’t hold a point or color.

For matrices, you can use a pair of letters:

.xx to reference the [0][0] element
.zz to reference the [2][2] element
.ax to reference the [3][0] element

So, for your scenario, you can do @myColor.b to access the 2nd component of the vector.
Edited by TwinSnakes007 - Aug. 16, 2016 12:58:57
Houdini Indie
Karma/Redshift 3D
User Avatar
Member
2 posts
Joined: Jan. 2015
Offline
Thanks Daryl, it works, and I understand a bit more.

But still, this following doc about attribute create still bothers me:

Local Variable

Name of the local variable that corresponds to the new attribute. If you leave this field blank, the local variable is the name of the attribute in all UPPERCASE.

To access individual components of a multi-component attribute, the user can append to this name:

X, Y, or Z for vector attributes.
1, 2, 3, etc. for float attributes. Note that the numbering starts at 1, not 0.
For example:

Attribute Type Local variables created
abc
Float, size = 1
$ABC = $ABC1
abc
Float, size = 2
$ABC1, $ABC2
abc
Vector
$ABCX, $ABCY, $ABCZ

That's from Houdini 15.5 documentation, so I can't find any reason I can't call my attribute using “$MYCOLOR1” syntax (but nevertheless, I can't).
Is there any explanation to this?

Thanks,
Dian
404 not found
  • Quick Links