964racer Posted August 10, 2016 Share Posted August 10, 2016 (edited) 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 August 10, 2016 by 964racer Quote Link to comment Share on other sites More sharing options...
mestela Posted August 10, 2016 Share Posted August 10, 2016 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. Quote Link to comment Share on other sites More sharing options...
964racer Posted August 10, 2016 Author Share Posted August 10, 2016 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 Quote Link to comment Share on other sites More sharing options...
964racer Posted August 11, 2016 Author Share Posted August 11, 2016 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 !! Quote Link to comment Share on other sites More sharing options...
Sean-R Posted August 11, 2016 Share Posted August 11, 2016 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() Quote Link to comment Share on other sites More sharing options...
964racer Posted August 11, 2016 Author Share Posted August 11, 2016 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... Quote Link to comment Share on other sites More sharing options...
mestela Posted August 11, 2016 Share Posted August 11, 2016 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 Quote Link to comment Share on other sites More sharing options...
964racer Posted August 12, 2016 Author Share Posted August 12, 2016 (edited) 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 August 12, 2016 by 964racer Quote Link to comment Share on other sites More sharing options...
bonsak Posted August 13, 2016 Share Posted August 13, 2016 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.