Jump to content
midicon

Find the center of a deforming tube with Vex

Recommended Posts

This is probably not as hard as I think but I'm trying to find a way to draw a line down the center of an animated object using vex. I have a tube that is a cache and it is deforming. The points and polys don't change. I want to create a curve that goes directly down the center of the tube. I was successful by manually deleting some poly loops, and using a divide node with remove shared edges and then packing the shared faces then using an add to connect the center points, this is a quick and DIRTY way that worked. But I would like a more robust procedural way of doing this, if I had a lot of objects this way would be a pain. I have attached a .hip for if someone would like to help me out with this it would be much appreciated thanks in advance.    

Rob

FindthecenterTest.hip

Share this post


Link to post
Share on other sites

Hey Thanks for taking a stab at this! That is a really interesting solution. and it works for this example. But if I changed the geo it wouldn't work. I was wondering if there is a way that I could do it with a vol. My idea is (I just don't know the proper vex function), scatter points in the vol of the object and find the center line of the vol and push the points to the center line. Is there a function for this?? or I was thinking maybe find the center of the edge rings and then addpoint to the center of the edge ring. But Then I don't know the vex function to get the center of each edge ring. Let me know if these Ideas can help find the solution! thanks for your help Aragatory.

 

Rob 

Share this post


Link to post
Share on other sites

Is the idea that it will always be a tube with a set number of rows and columns? Or do you want a solution that will work with more complex geometry that might not be consistent down the whole length?

Share this post


Link to post
Share on other sites

I have an imperfect solution, but it's very close, and should at least be workable. This is using a tool from the Qlib toolset called group_edge_loop.

First group an edge ring of the tube (Select first edge then hold A and middle mouse click to select the whole ring). This part could use proceduralizing, I'm not sure the best way to do this though.

Then use group_edge_loop_ql SOP to create groups of every loop. Promote to point group and then use pack SOP to get a centroid point for each loop.

The group_edge_loop_ql SOP doesn't seem to resolve the loops on the caps correctly, so I'm removing the end points from the line.

FindthecenterTest_v02.hipnc

Edit: In regards to Aragatory's question above, this will only work with a tube.

Edited by coltonmil

Share this post


Link to post
Share on other sites

If it’s only ever running over a tube you could easily make my solution fully procedural by linking the group by range and vex to the number of divisions. 

For some thing more complex a volume and attribute from volume might be the way to go. 

Share this post


Link to post
Share on other sites

I deliberately mangled the tube up to make things harder...got so close...

(refrained from calling it testtube centre)

ok, DQ due to being non-VEX.

TubeCentre.jpg

vu_tubecentre.hipnc

Edited by Noobini

Share this post


Link to post
Share on other sites

Not that it solves your problem, but here is a clarification of the problem you're trying to solve:

https://doc.cgal.org/latest/Surface_mesh_skeletonization/index.html

At least you have the name of the problem, and one implementation in C++ / CGAL. I'm working on something related, (CGAL + Houdini) maybe it's not that hard to offload some work to CGAL..

Share this post


Link to post
Share on other sites
4 hours ago, Noobini said:

I deliberately mangled the tube up to make things harder...got so close...

(refrained from calling it testtube centre)

ok, DQ due to being non-VEX.

TubeCentre.jpg

vu_tubecentre.hipnc

clooose, just one step away.. Sort pts by gradient that you can get in resample (curveu)

Share this post


Link to post
Share on other sites
12 hours ago, ItsMeM said:

if you need to stay with a tube, maybe this will work?

FindthecenterTest_vex.hip

Hey thanks for these two great solutions!! Both ideas work. This is pretty much what I had in mind! The only thing that is a cheat per-say is that imagine this is a cache so there isn't a curve to resample so get the curveu attr as easily as you did... but it looks like the only reason you did that was to get the correct order of the points and I think you can come up with this after the wrangle.

The  whole idea is that there is a human body 4 limbs and a torso and I find the center points of each limb and torso(basicallt creating center curves through the model) without splitting the model. I wanted to get this to work on a tube as a human character is basically cylinders. with this solution I would still have some work to do in splitting the mesh and find the rows and colls. This is a great step in the right direction, thank you for this! 

Rob  

Share this post


Link to post
Share on other sites

 

On 2/2/2018 at 10:32 PM, Noobini said:

I deliberately mangled the tube up to make things harder...got so close...

(refrained from calling it testtube centre)

ok, DQ due to being non-VEX.

TubeCentre.jpg

vu_tubecentre.hipnc

 

On 2/3/2018 at 3:04 AM, ItsMeM said:

clooose, just one step away.. Sort pts by gradient that you can get in resample (curveu)

 

If you don't have the original geometry and therefore no access to that initial resample. This should work.

 

 

vu_tubecentre_end_bit.hipnc

  • Like 1

Share this post


Link to post
Share on other sites
On 10/1/2018 at 6:00 PM, lloydwood said:

 

 

 

If you don't have the original geometry and therefore no access to that initial resample. This should work.

 

 

vu_tubecentre_end_bit.hipnc

..well that was simple...why didn't I think of it ???

Edited by Noobini

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

×