VEX intrinsic bounds

   8146   7   1
User Avatar
Member
11 posts
Joined: Oct. 2013
Offline
Hi, I want to quickly and efficiently get the centre of a polygon in an attribWrangle node. Rather than get the positions for the linear vertices for the vertices for the primitive and manually get the average, I though i could use the primitive intrinsic “bounds”.

Using :
primintrinsic(0, “bounds”, @primnum );

I find that i can get the values in a vector4 or vector(3), but that means I can only get the first four values out of the six-value attribute.
Trying to return into a 6-float array doesnt work, returning to a matrix3 ( nine floats ) doesnt work. returning to a string doesnt work.

Is there any way to actually get at the data in the intrinsic or shall i resign myself to “maybe in Houdini 14 …” and do the slow vertex-averaging ?
User Avatar
Member
2 posts
Joined: July 2012
Offline
This should create the correct float array in a wrangle:

f@intrinsic_bounds = primintrinsic(0, “bounds”, @primnum);
User Avatar
Member
8514 posts
Joined: July 2007
Online
or if you are in primitive mode you can just do
@P
to get center of current prim
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
1 posts
Joined: Oct. 2013
Offline
Thanks, both methods worked for me perfectly!
But there's a little notice:
seems like @P gives averaged point positions (geometric center, which value differs from the centroid value) of points, attached to current polygon. If precise prim centroid value is needed, the method with intrinsic bounds is preferable.
User Avatar
Member
8514 posts
Joined: July 2007
Online
Novosed Dmitry
…If precise prim centroid value is needed, the method with intrinsic bounds is preferable.

it's arguable which one is more precise as that really depends on your needs, but valid point

one more thing worth noting though is that center of bounding box will most probably vary when you apply transform to the prim, while point average will still produce the same relative center to the prim
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
2036 posts
Joined: Sept. 2015
Offline
Found this post because I was having trouble accessing a specific primitive bounds intrinsic value of which it had 6 of them.

tbeven above suggests using the syntax:

f@intrinsic_bounds = primintrinsic(0, “bounds”, @primnum);

Novosed Dmitry says it works, but for me it didn't.

Maybe it was a typo on tbevens part, or in previous Houdini versions it may have worked?

Because I'm using H16 and after playing around for a while and thinking about it, when I changed it to:

f[]@intrinsic_bounds = primintrinsic(0, “bounds”, @primnum);

It then worked that I could access any of the individual values with say something like:

f@intrinsic_bounds[n]

n being a typical value that might be used for accessing any array member.

Just thought I would post a comment on this in case other beginners come accross this post and have similar issues.
Edited by BabaJ - Sept. 21, 2017 10:40:41
User Avatar
Member
7737 posts
Joined: Sept. 2011
Online
you forgot the []when accessing the array element. 'f@'refers only to float attributes, while the intrinsic_bounds is an array. Either use 'f[]@intrinsic_bounds'every time, or use it only the first time while using '@intrinsic_bounds'for all subsequent references.

example:

i[]@pts = primpoints(0,@primnum);
vector pos = point(0,"P",@pts[-1]);

or

i[]@pts = primpoints(0,@primnum);
vector pos = point(0,"P",i[]@pts[-1]);

I'm not sure if you need to store the bounds as a separate float array attribute, since the bounds are always available, so for the case where you don't have to store it, use a regular variable "float bounds[] = ..."
Edited by jsmack - Sept. 21, 2017 22:48:25
User Avatar
Member
2036 posts
Joined: Sept. 2015
Offline
Not sure what you mean about

...you forgot the [] when accessing the array element...

you mean tbevan forgot? This was an old post I bumped up to point out the omission, in case someone else like me was trying to figure out how to access the bounds intrinisic

Because it worked the way I did it.
Edited by BabaJ - Sept. 22, 2017 01:09:58
  • Quick Links