Translating points procedurally

Recommended Posts

Hello---

I'm relatively new to Houdini.

I have a task where I have points which I have extracted from geometry

and I would like to translate those points to a location determined by a mathematical function. Let's assume that

I can access the points I need by using the "add" node and I have the points from my geometric structure.  What is the best way to

"loop" through that array of points and translate them to a new location.  For example, ignoring Z for the moment, say I just want to translate them in a parabolic

shape in 2D using the function y = X^2.  (ignore "z" coordinate).

What is the easiest way to do this ?  I would need to "loop" through various ranges of points in this list and perhaps move them differently, so the function may

apply to the first 100 points, but I may want to use a different function for the next 100 etc.  so I do need a way to parse through the list.

Would you use a point VOB for this ?  - or perhaps wrangle it directly in VEX ?  - or is there a way to do this in an expression within the node ?

Please point me in the right direction,  Cheers,

Edited by 964racer

Share on other sites

A point wrangle sounds the best way to do this.

`@P.y = @P.x * @P.x;`

or

`@P.y = pow(@P.x, 2);`

re splitting, each point gets an id, @ptnum, so you could do something like

```if (@ptnum < 100) {
@P.y = pow(@P.x, 2);
} else {
@P.y = @P.x * 32 + @P.z + sin(@Time + @ptnum);
}```

etc.

Share on other sites

Thanks, I will try that with a simple example to see if I can learn how to do that and then apply it to my larger geometry network..thanks

Share on other sites

This is working for me.. Thank you.. but how do I find out what built-in attributes are available from within a pointwrangle node that I can use within the vex expression ?

For example, I know from the code  examples (shown in the arrow menu) in the code editor box, that certain attributes like @ptnum exist but how do I find out what others are available ?

The docs for VEX have a table of some of them, but suppose for example, I would like to know if there is an attribute/variable that contains  the total number of points in the group , so in my calculation

for the current point, I may want to know how many other points are in the group ?

Also, it seems there is a vex function for "ch()", so I would assume that I could get information form other nodes from within a vex script ?  That would seem costly in terms of computation for certain operations,

but if a @nPoints doesn't exist, I know what the dimensions of the grid is feeding the pointwrangle, so I could derive nPoints from the dimension of the grid (doesn't sound elegant though.)

Thanks !!

Share on other sites

Check out the VEX functions page in the Help, it lists all the functions available to you.

It sounds like the function you need is npointsgroup()

Share on other sites

Thanks you ! ...the function, npoints(int) looks like it does it and will help for this value I need , but still looking for where I can find the list of internal attributes I can use like @ptnum etc...

Share on other sites

Laziest way is to put down a point vop, dive inside, and look at the global inputs node. That gives you a list of the more common attributes you'll use.

• 1

Share on other sites
15 hours ago, mestela said:

Laziest way is to put down a point vop, dive inside, and look at the global inputs node. That gives you a list of the more common attributes you'll use.

Thanks and "hovering" over the labels in the input node, shows the variable name and type.  perfect....

I was able to complete my project using some vex code in a point wrangle.   Are there any others ways to enter VEX code in Houdini other than in a "wrangle" node or graphically using a VOP node ?   Is there a way to use your own editor and create a VEX source file to be referenced by a node ?  I watched a recent tutorial on VEX given by the SideFX folks, but it seem to mainly focus on wrangle type nodes for VEX.

Edited by 964racer

Share on other sites

Hi

You can use the VEX SOP and point "Script" to a .vfl or precompiled .vex file on disk.
You can also put down an empty Attribute VOP (or any of the vop's) and point "VEX Source" to a file on disk.
It's also possible to set an external editor for the Expressions Editor.

Personally i tend to edit in my code in Sublime and just copy/paste into a wrangle.

-b