Vex Bounding box ?

   13418   8   3
User Avatar
Member
2624 posts
Joined: Aug. 2006
Offline
Hi brains trust,

In the past I would use the bounding box expression ($BBY*2-1) * sin a lot in a point sop. what's the equivalent of the expression in vex , for use in vexpressions.

Rob
Gone fishing
User Avatar
Member
8592 posts
Joined: July 2007
Offline
you can use relbbox() function
for example:
float bby = relbbox(0, @P).y;
@P.x += sin(bby*10);
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
2624 posts
Joined: Aug. 2006
Offline
Thanks, I will have to have a play with that, just to make sure I understand it ! , While I am at it if I wanted $NX = $TX2 - $TX what should I look at in vex. I must say its not easy switching over after relying for so long on hscript expressions @!

Rob
Gone fishing
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
You could do like this:
@N=point(@OpInput2, “P”, @ptnum)-@P;
Assuming you're in an Attribute or Point Wrangle node.

-b
http://www.racecar.no [www.racecar.no]
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
@P = (relbbox(1,@P)*2-1) * sin(@Frame);
or for a more long winded version:

vector pos2 = @opinput1_P; // fetch second input position to variable pos2
@P = (relbbox(1,pos2)*2-1) * sin(@Frame);

Modern method to reference second input is documented in the last paragraph for the help on the Attribute Wrangle VOP.

@opinput0_P fetches first input or just us @P
@opinput1_P fetches second input P

There should be no need to use the point() function to fetch second, third and fourth input attributes.

relbbox(0,@P) fetches bbox position from first input
relbbox(1,@P) fetches bbox position from second input

All the vex functions that take a file as an argument, you can use the direct integer index to the input of the current SOP.
There's at least one school like the old school!
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
I find point(@OpInput2, “P”, @ptnum) to be a useful shortcut if the other objects have more points than the first one. Then it's easy to offset @ptnum to access points outside the range of the number of points in the first object.

-b
http://www.racecar.no [www.racecar.no]
User Avatar
Member
4528 posts
Joined: Feb. 2012
Offline
jeff
@P = (relbbox(1,@P)*2-1) * sin(@Frame);
or for a more long winded version:

vector pos2 = @opinput1_P; // fetch second input position to variable pos2
@P = (relbbox(1,pos2)*2-1) * sin(@Frame);

Modern method to reference second input is documented in the last paragraph for the help on the Attribute Wrangle VOP.

@opinput0_P fetches first input or just us @P
@opinput1_P fetches second input P

There should be no need to use the point() function to fetch second, third and fourth input attributes.

relbbox(0,@P) fetches bbox position from first input
relbbox(1,@P) fetches bbox position from second input

All the vex functions that take a file as an argument, you can use the direct integer index to the input of the current SOP.

I was expecting the opinput_attrib binding to be much faster than using point/prim functions but unfortunately it's the other way around . Using point/prim functions to get attributes from other inputs is faster. So I wouldn't use the opinput syntax if the performance is critical. Otherwise they would be nicer to use.
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 | pragmaticvfx.gumroad.com
User Avatar
Member
8592 posts
Joined: July 2007
Offline
pusat

I was expecting the opinput_attrib binding to be much faster than using point/prim functions but unfortunately it's the other way around . Using point/prim functions to get attributes from other inputs is faster. So I wouldn't use the opinput syntax if the performance is critical. Otherwise they would be nicer to use.

- in my tests @opinput_ binding is the same or maybe a bit faster than point() for matching by ptnum
- but be careful since if you have id attribute present on your geo, it's binding by id by default, which you can control in Bindings Tab/ Attribute To Match in which case it's speedwise comparable to findattribvalue() workflow
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
4528 posts
Joined: Feb. 2012
Offline
tamte
pusat

I was expecting the opinput_attrib binding to be much faster than using point/prim functions but unfortunately it's the other way around . Using point/prim functions to get attributes from other inputs is faster. So I wouldn't use the opinput syntax if the performance is critical. Otherwise they would be nicer to use.

- in my tests @opinput_ binding is the same or maybe a bit faster than point() for matching by ptnum
- but be careful since if you have id attribute present on your geo, it's binding by id by default, which you can control in Bindings Tab/ Attribute To Match in which case it's speedwise comparable to findattribvalue() workflow

Thanks I will check the file I sent to SESI. They also saw the same behaviour. Otherwise I was anxious to update all of my VEX code to use opinput.

Though the recent addition of auto type recognition for the known attributes also prevents me from doing this as I don't want to type prefixes for known types as we don't use the latest Houdini 15 build here.

For H16 hopefully all will be well.
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 | pragmaticvfx.gumroad.com
  • Quick Links