How to create spline from points
1725 9 2- Beka
- Member
- 40 posts
- Joined: March 2018
- Offline
- Lucca
- Member
- 42 posts
- Joined: March 2019
- Offline
- Beka
- Member
- 40 posts
- Joined: March 2018
- Offline
LuccaThanks Lucca!
if they happen to be in right point order just use "add" sop enabling by group under polygons tab. Or otherwise if they somehow have fitting attributes you can also use 'add' to connect them via the attribute
Problem is that I don't know the right point order. I have not any information, only this.
- animatrix_
- Member
- 4530 posts
- Joined: Feb. 2012
- Offline
You can look up points in the direction of the previously found point by making an exception in the first point and limit your search to a cone angle using pcopen:
https://www.sidefx.com/docs/houdini/vex/functions/pcopen.html [www.sidefx.com]
Alternatively you can implement the same cone angle yourself and use the newer pcfind VEX functions.
https://www.sidefx.com/docs/houdini/vex/functions/pcopen.html [www.sidefx.com]
Alternatively you can implement the same cone angle yourself and use the newer pcfind VEX functions.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
- Beka
- Member
- 40 posts
- Joined: March 2018
- Offline
animatrix_Thank you!
You can look up points in the direction of the previously found point by making an exception in the first point and limit your search to a cone angle using pcopen:
https://www.sidefx.com/docs/houdini/vex/functions/pcopen.html [www.sidefx.com]
Alternatively you can implement the same cone angle yourself and use the newer pcfind VEX functions.
I thought something similar and probably it is the only way. I can not see how can I transfer cone information into pcopen(), but now I've found function of pccone() which can get direction and cone angle, (Wow I don't know that function). I think it will be difficult in the corner area, but yeah it will be good starting point
- cncverkstad
- Member
- 120 posts
- Joined: Aug. 2017
- Offline
- Beka
- Member
- 40 posts
- Joined: March 2018
- Offline
cncverkstadThank you so much!sort by index and Add.float pos_arr[] = {}; for(int i=0;i<@numpt;i++) { vector p = point(0, "P", i); push(pos_arr, p.z); } int ordering[] = argsort(pos_arr); ordering = reverse(ordering); for(int i=0;i<@numpt;i++) { setpointattrib(0, "sort_index", ordering[i], i); }
It has problem when curve turns around
- cncverkstad
- Member
- 120 posts
- Joined: Aug. 2017
- Offline
For that you can use
Euclidean Minimum Spanning Tree by Satoru Yonekura that I got those codes from.
Clean
Convertline
detail wrangle
blast not newedge
Have Fun
Euclidean Minimum Spanning Tree by Satoru Yonekura that I got those codes from.
foreach(int pt; nearpoints(0, @P, 1.0, 10)) { if(pt == @ptnum) continue; vector p = point(0, 'P', pt); float dist = distance(p, @P); int ptsA[] = nearpoints(0, @P, dist); int ptsB[] = nearpoints(0, p, dist); int chk = 0; foreach(int cpt; ptsB) { if(cpt == @ptnum || cpt == pt) continue; chk = removevalue(ptsA, cpt); if(chk) break; } if(!chk) { int pr = addprim(0, 'polyline'); addvertex(0, pr, @ptnum); addvertex(0, pr, pt); } }
Convertline
detail wrangle
int ptlist[]; for(int pt=0; pt<@numpt; pt++) push(ptlist, pt); int newlist[]; push(newlist, 0); removevalue(ptlist, 0); while(len(ptlist) > 0) { float mindist = 10000; int newpt = -1; int newedge = -1; foreach(int pt; newlist) { foreach(int prim; pointprims(0, pt)) { int targetpt = primpoint(0, prim, 0); if(targetpt == pt) targetpt = primpoint(0, prim, 1); if(find(newlist, targetpt) > -1) continue; float dist = prim(0, 'restlength', prim); if(dist <= mindist) { mindist = dist; newpt = targetpt; newedge = prim; } } } if(newpt == -1) break; push(newlist, newpt); removevalue(ptlist, newpt); setprimgroup(0, 'newedge', newedge, 1); }
blast not newedge
Have Fun
Edited by cncverkstad - Sept. 5, 2023 12:09:31
Conservation of Momentum
- Beka
- Member
- 40 posts
- Joined: March 2018
- Offline
cncverkstadWow it works! amazing!
For that you can use
Euclidean Minimum Spanning Tree by Satoru Yonekura that I got those codes from.Cleanforeach(int pt; nearpoints(0, @P, 1.0, 10)) { if(pt == @ptnum) continue; vector p = point(0, 'P', pt); float dist = distance(p, @P); int ptsA[] = nearpoints(0, @P, dist); int ptsB[] = nearpoints(0, p, dist); int chk = 0; foreach(int cpt; ptsB) { if(cpt == @ptnum || cpt == pt) continue; chk = removevalue(ptsA, cpt); if(chk) break; } if(!chk) { int pr = addprim(0, 'polyline'); addvertex(0, pr, @ptnum); addvertex(0, pr, pt); } }
Convertline
detail wrangleint ptlist[]; for(int pt=0; pt<@numpt; pt++) push(ptlist, pt); int newlist[]; push(newlist, 0); removevalue(ptlist, 0); while(len(ptlist) > 0) { float mindist = 10000; int newpt = -1; int newedge = -1; foreach(int pt; newlist) { foreach(int prim; pointprims(0, pt)) { int targetpt = primpoint(0, prim, 0); if(targetpt == pt) targetpt = primpoint(0, prim, 1); if(find(newlist, targetpt) > -1) continue; float dist = prim(0, 'restlength', prim); if(dist <= mindist) { mindist = dist; newpt = targetpt; newedge = prim; } } } if(newpt == -1) break; push(newlist, newpt); removevalue(ptlist, newpt); setprimgroup(0, 'newedge', newedge, 1); }
blast not newedge
Have Fun
Only the areas where I have harsh edges have a problem, but the rest is great!
Thank you!
- cncverkstad
- Member
- 120 posts
- Joined: Aug. 2017
- Offline
-
- Quick Links