Jump to content
Haya8810

Copy geometry along created curve by findshortestpath-Help.

Recommended Posts

Hello guys. I'm a newbie of Houdini.  I'm trying to make a procedural random cable node.

Currently, I'm struggling to distribute geometry along curves that I created by findshortestpath.
Roughly speaking, I have two problems.

1) I can't get proper normal direction on the curve. So It would be great If I get  the same normal direction as my base geometry somehow and copy my geometry along the curve.

2) would it be possible to control the number of distributing quantities?

I attached my screenshot in this post. Thank you!

model.JPG

キャプチャ.JPG

キャプチャ2.JPG

キャプチャ.JPG

Share this post


Link to post
Share on other sites

Hey Haya,
I've made a quick hipfile below demonstrating a few concepts that hopefully will help answer some of your questions. I was alittle unsure about what you were after in terms of wanting to copy the normals from your original geometry. Are you trying to have the geometry align to the original geometries surface? Almost like small cars driving on a piece of geometry? Or are you referring to something else?
I've marked the nodes of interest in yellow with a spikey shape. Hopefully, it can be helpful!

Also, in the future, don't be afraid of uploading your actual hipfile itself as an attachment. More often than not it is actually easier to just download the hipfile itself and have a look rather than having a picture of the node network and having to imagine how it works.

instancing_along_path.hiplc

  • Like 2

Share this post


Link to post
Share on other sites

Hi Peon. Thank you for your warm reply! 

I see, I have attached the hipfile here. Also, sorry that I couldn't attach my original file since I started the base geo with my obj file. So I created the same node with just a sphere.

I've been trying to build a simple cable generator for my personal work. So in my node, I created a random cable from findshortestpath and added connection geos that looks like rivets with copy node. However, the normal direction is currently messed up. Therefore, my current goal is to line the rivets up with a red face facing up along the base geo normal and randomize the rivets count somehow. 

I hope this reply helps and please take a look. 

Thank you. 

pipe.hipnc

Share this post


Link to post
Share on other sites

Hey Haya,
I've had a look at your hipfile and made two different setups that I think do what you want. They are almost identical except for one that lets you choose how many rivets you want and will place them in an orderly fashion using a "resample" node and the other setup will give you a more random layout of rivets using a "scatter" node.

The main differences/nodes of note have been marked in yellow, but I'll give a quick overview here over the thought process/what they do.

One of the most important things is to give your shortest path splines propper normals, to do this I simply added a "facet" node with "post compute normals" turned on before the "findshortestpath" node when it was still a sphere geometry. This gives us propper/correct surface normals, if you try to apply the facet after the shortest path then it gives kind of wonky results. One issue is that the "findshortestpath" node eliminates the normal attribute so I assed an "attribute transfer" node to transfer the normals from the sphere to the newly created paths.
After that, I set a simple "up" attribute. This is because when working with the "copytopoints" node there are certain attributes the node inherently understands, N and up being some of the most commonly used. To have "full" (or at least very nearly full) control of the orientation of your instanced geometry you'll need at least two directional vectors, one to tell your geometry where to point, the N attribute, and one to tell it how it should be oriented around that vector, the up attribute.
After that, I simply add either the "resample" or "scatter" nodes which work to give you control of how many points you have. The "resample" node works like a subdivide but for lines and the "scatter" just spreads points randomly onto the lines.
Lastly, I changed out the "copy stamp" node with the "copy to points" node. The stamp node is not really used as much anymore and it a fair bit slower than the "copy to points" node. It might still have its uses somewhere but in most cases, you'll probably be fine to just use the "copy to points" node.
The only other thing worth mentioning is that I added another transform node to your rivet geometry. When you are going to instance a piece of geometry using the normal and up attributes your geometry needs to be aligned/pointing/rotated along the Z-axis since this is seen as the "forward" axis in Houdini. I always like to think of it as the blue arrow of the Z-axis in the gnomon symbolizes the normal direction from the points you are going to copy on to since the normal visualizer is also dark blue.

Anyways, enough rambling. Hope that was helpful, good luck!

pipe_mnb.hipnc

Share this post


Link to post
Share on other sites

Hi Peon, That is awesome! That is exactly what I wanted to do.
Also, thank you for describing the node very clearly.  Now I can go further step.  

Could I ask you one more thing as extra, if you don't mind? I'm just curious if I can set a different direction of copied geometry depends on the curve directions. Currently, all the geos are facing goes up. For example, if the curve direction is vertical, copied geo faces horizontal direction, on the other hand, if curve direction is horizontal, copied geo faces vertical direction.

I attached a screengrab with my poor annotation.

Anyway, thank you so much Peon, you are my lifesaver!  

キャプチャ.JPG

Share this post


Link to post
Share on other sites

Hey Haya,
Here is a hipfile with those modifications. To change these kinds of orientations you'll need to fiddle around with either the normal attribute or the up attribute. In this case, it was the up attribute. I made this work by rotating the up vector 90 degrees if the line was going up or down. I rotated the up vector by using a matrix and the rotate function which might be very heavy-handed and overcomplicated here so if anyone else has a better, simpler solution that might be easier to implement/understand. To be able to figure out which pieces of the path goes up or down I simply added a polyframe node that outputs a tangentu attribute. This is basically just a vector pointing from one point to the next point on the path. So if the y component of that vector is too far from 0, meaning its horizontal, it's pointing up or down, hence meaning that that points up vector should be rotated 90 degrees.

Good luck!
Underscoreus / Martin

pipe_02_electric_boogaloo_mnb.hipnc

  • Like 1

Share this post


Link to post
Share on other sites

Hi Peon. 

Wow That is awesome!  thank you for helping me a lot! I learned a lot from your nodes. Actually, this thread was my first post but I'm really happy to have all of your kind and cooperative comments. 

Thank you very very much Peon you are the best! 

Haya

  • Like 1
  • Thanks 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

×