Jump to content

Recommended Posts

Hello,

I am stuck on this. I have been trying to sort points from left to right and follow the sequence. I used the sort node but it is not sorting as I want it. How can do it?

Please find the image attached below

 

SortProblem.PNG

Share this post


Link to post
Share on other sites

Can you post the scene file? I am able to sort random points on a grid like that using the sort sop on my side, so I would be interested in taking a look at your file to see why it's not working.

But using a sort sop and Point Sorting by Z should work

Share this post


Link to post
Share on other sites

Maybe this Helps!
 

float pos_arr[] = {}; // y
for(int i=0;i<@numpt;i++) {
    vector p = point(0, "P", i);
    push(pos_arr, p.y);
}
int ordering[] = argsort(pos_arr); 
ordering = reverse(ordering); 

// visualize
//(ordering
for(int i=0;i<@numpt;i++) {
    setpointattrib(0, "sort_index", ordering[i], i);
}

 

SortOD.hiplc

Share this post


Link to post
Share on other sites

Hi,

I don't think, that there is a general solution, which works in every case, but here are some ideas (in VEX):

  • if your points are quite sorted in one direction like x or z you can use relbbox() to get the relative values in the bounding box
  • take the point with lowest z-value for example (as starting point)
  • try to find find all neighbours, which similar z value (this should be the first row) -> this can be done growing the selection with some restrictions (half edge count = 1) until there are only two neighbours left for next point (end of the row)
  • once you have the first row you can grow this to get the second, third and so on
  • now you can use each row (number) and the relbbox() value to define a sort attribute

This is not a very straightforward solution and probably there are much easier ones (but it should work)

SortProblem_mod.hipnc

  • Thanks 2

Share this post


Link to post
Share on other sites

Wow. That's amazing. It's a good way to learn VEX too. It seems very advance. Thanks a lot. A lot of learning to do today.

 

  • Like 1

Share this post


Link to post
Share on other sites

If I speak for myself, I've started VEX doing really simple things again and again. I've haven't watched many tutorial, so I can't give you advices here, but you will probably find some interesting ones on the sidefx.com homepage. Here some ideas I would recommend and all of these are from my personal experience

  • how are point/prim/vertex/detail wrangles working
  • what are point/prim/vertex/detail attributes and how are they working
  • what are the different functions good for
  • the relationships between points/prims/vertices etc...
  • (at least some basic) math like vectors and matrices (linear algebra) -> if you don't know everything from start it might be not a problem, but as soon as you learn more you can do alot of more (but houdini also offers alot inbuild)
  • other areas of math can be usefull aswell (depending on your needs) like (graph theory, differential geometry, analysis, stochastic, etc...) -> houdini already offers alot of tools/functions which can help you there
  • if you have a problem, try to divide it into smaller parts, which can be easier solve (this should be possible in many cases)
  • if you want to solve a problem, try to describe the problem aswell (like if you are trying to explain it to someone else)
  • don't get desperated, if you can't solve a problem -> this will happen alot (sometimes sleeping one or few nights can have positive effects)

I've never regretted learning VEX and I'm still learning, there is so much to you can do with VEX (even if not everything is that easy as with other languages). You will find many good example from this forum and from sidefx.com, which can give you good inspirations to do new things or think in different ways. But at the beginning I would do some basic stuff (by using the VEX language reference) and maybe looking into some basic tutorials.

Edited by Aizatulin
  • Thanks 3

Share this post


Link to post
Share on other sites

@Aizatulin This is great advice. Thank you for taking the time and writing this out. It really helps. After many years of trying with Houdini and going back and forth, I have finally found time to learn Houdini completely. I am really amazed by how wonderful and powerful this software is. And thanks to this forum and people who are ever helpful, it's making my journey to learning very easy.

Thanks a ton.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×