VEX and local variables

   5217   6   1
User Avatar
Member
86 posts
Joined: Sept. 2008
Offline
hi all..

I wrote a SOP to rotate a primitive about an axis defined by its first and last points. Since it isn't modifying geometry i used VEX for its portability and speed, but there doesn't seem to be a way to define or use local variables in the parameters. Looked about and, judging by a post at http://forums.odforce.net/index.php?/topic/8200-vex-sop-and-local-variables/, [forums.odforce.net] this feature may not be supported.

Maybe i'm missing something or there is an easier/better way to do this task?

I could use Python or C++, but the operation in question is performed frequently. Is there a convenient way to add parallelism to HDK SOPs running on the CPU?

thanks!
I installed a skylight in my apartment… the people who live above me are furious!
- Steven Wright
User Avatar
Member
4271 posts
Joined: July 2005
Offline
Usually local variables map to attributes on the geometry which means you don't have to do much work as bound attributes are available within VEX as long as you have a VEX parameter of the same name.

Attachments:
pointSOP_vs_VEXSOP.hip (445.2 KB)

if(coffees<2,round(float),float)
User Avatar
Member
86 posts
Joined: Sept. 2008
Offline
ah.. i see. Thanks - that will work fine for my purposes. Now i just have to figure out how to access the positions of the first and last points in the primitive to put the vector between them into an attribute. I don't see a way to do this using the Primitive or AttribCreate SOPs.. perhaps i miss something. Is there a way to do this using existing components?
I installed a skylight in my apartment… the people who live above me are furious!
- Steven Wright
User Avatar
Member
192 posts
Joined: Nov. 2008
Offline
david_aiken
Now i just have to figure out how to access the positions of the first and last points in the primitive to put the vector between them into an attribute.

This is very doable using ‘import attribute’ in a vopsop. Here's an example that stores that vector as colour and rotates about it.

Attachments:
rorate_prim_around_prim_axis.hip (109.0 KB)

User Avatar
Member
86 posts
Joined: Sept. 2008
Offline
the modulo VOP is rather interesting :>). Thanks! It's one of those things where you're wondering how best to do it.
I installed a skylight in my apartment… the people who live above me are furious!
- Steven Wright
User Avatar
Member
86 posts
Joined: Sept. 2008
Offline
Just a minor note, but i've added a rotate VOP to the example in case anyone else might want it.

Attachments:
rotate_prim_around_axis_def_by_first_last_points.hipnc (134.7 KB)

I installed a skylight in my apartment… the people who live above me are furious!
- Steven Wright
User Avatar
Member
192 posts
Joined: Nov. 2008
Offline
david_aiken
Just a minor note, but i've added a rotate VOP to the example in case anyone else might want it.

sweet
  • Quick Links