What does @P when run over Primitives mean?

   1285   5   1
User Avatar
Member
11 posts
Joined: 1月 2021
Offline
I am always confused about this and it is difficult to find an answer on the vex docs page.
When I run over Primitives in Vex, what does @P here mean?
for example, if I use the following on three connected lines with four points
int closept = nearpoint(1, @P);

I tried to printf the P attribute and saw three vectors which seems to mean that @P has nothing to do with the points but probably belongs to each line. It's not vertex otherwise 6 values will get print out.

But from middle mouse click there is no @P prim attribute but only the point attribute.
Is this @P prim attribute a hidden attribute?
And how is it calculated? Is it the middle point of the line and the centroid of a face?

Thanks
Edited by aaoc1 - 2022年12月2日 23:16:49
---------------------------------------------------
User Avatar
Member
4495 posts
Joined: 2月 2012
Offline
Hi,

It's the bounding box center of the primitive.
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
User Avatar
Member
11 posts
Joined: 1月 2021
Offline
animatrix_
Hi,

It's the bounding box center of the primitive.


Thanks. So I assume its some kind of hidden attribute then?
Do you might know in that case is there anyway to invoke access to this prim@P value easily if the wrangle is run over points?
---------------------------------------------------
User Avatar
Member
4495 posts
Joined: 2月 2012
Offline
lmnoc1
animatrix_
Hi,

It's the bounding box center of the primitive.


Thanks. So I assume its some kind of hidden attribute then?
Do you might know in that case is there anyway to invoke access to this prim@P value easily if the wrangle is run over points?

I would say it's a special attribute that Houdini recognizes and computes on the fly, just like how it recognizes N.

You can get the same value using the prim or primuv function. For primuv make sure to use a UVW value of 0.5:

primuv ( 0, "P", @primnum, 0.5 );
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
User Avatar
Member
900 posts
Joined: 2月 2016
Offline
it would be very practical in some cases if you could also set it from a primitive wrangle, instead of writing your own routine with primpoints().. that would save time and space in the wrangle code.
User Avatar
Member
7740 posts
Joined: 9月 2011
Offline
animatrix_
Hi,

It's the bounding box center of the primitive.

Not the bounding box center, but the average value of points of the primitive. For some primitives the two might be the same.

primuv of coord (0.5, 0.5, 0.5) is not always the same as average of P. For polygons of 5+ sides, (0.5, 1) is the center, and for tetrahedrons, (0.25, 0.25, 0.25) is the center.

Attachments:
primcenters.hip (260.7 KB)

  • Quick Links