How can I make the only top of a tube look at an object?

   2331   8   1
User Avatar
Member
15 posts
Joined: 6月 2019
Offline
Image Not Found

I'am learing houdini and trying to get this effect

I have a setup with a grid full of tubes, a ball is orbiting over it and I'am trying to make it look like
the top of the tubes are atracted to the ball as if the ball is some sort of magnet.

So far I'have cheated the effect by animating a bend modifier and rotation modifier to match the orbiting ball
but it looks a bit off. Also I was looking in to the “look at” constraint to make the tubes look at the cube
in combination with the bend modifier but it diddn't look nice as well.

I suppose there is a way to ditch the bend and rotation modifiers and simulate the setup without cheating.
The base of the tubes should be locked the the ground and not rotating, the rest should point to the ball and bend acordingly to its position.

I'am at a loss here, it would be great if somebody could help me figure this out.

Attachments:
Look at alternative.png (591.7 KB)

User Avatar
Member
13 posts
Joined: 3月 2019
Offline
This may or may not work but I would have thought in theory you could rig the tube with bones and make ik chain (or Houdini equivalent) use the top bone to aim constraint (or Houdini equivalent) the ball so the tube bends in any direction? talking from a max / maya background.

might be worth getting this working with a single tube to start with then look at have multiples this way it breaks down the problem into smaller tasks.
User Avatar
Member
15 posts
Joined: 6月 2019
Offline
Hmm, I had hoped to find a way without using bones. I'am also from a maya/max background
and was wondering if I could do this in houdini with a different approach.

But it makes sense, I will give it a try this way too.

Thanks
User Avatar
Member
37 posts
Joined: 8月 2015
Offline
You can set the Bend node to a direction. Here's a quick setup;
Edited by Nicolas Longchamps - 2019年10月4日 09:33:17

Attachments:
bend_to_dir.png (682.7 KB)

User Avatar
Member
15 posts
Joined: 6月 2019
Offline
Nicolas Longchamps
You can set the Bend node to a direction. Here's a quick setup;

This is probably exactly what i'm looking for! If I understand correctly I can animate the ‘Null’ to follow the orbiting object, and thus making it bend that way.

However I'm not comfortable with the code for wrangles jet.
could please explain me what's inside the one in your example?

Is the purple line a result of referencing the goaldirx atribute?

Many thanks!
User Avatar
Member
37 posts
Joined: 8月 2015
Offline
Ah sorry!

The wrangle node is for setting up the direction of the object. I like setting up the attributes i need once, in a centralized location, rather than doing math in a parameter channel. In this case the desired direction is a normalized vector from the cylinder base to the null. Something like v@dir = normalize(NullPos - CylPos);
So now that wrangle node has a detail attrib called “dir” which is a vector that points to the null.

The purple line is a spare input reference. Spare inputs are a cool feature that aren't documented much. There's documentation for spares in the compile block but they are usable everywhere. It simply lets you add an input to a node.
Here the bend node has a spare input, which points to the detail wrangle node. Then i can simply refer to it in the parameter using ‘-1’ rather than a path to an external node. Normal wire inputs have indexes from 0. So a VOP for instance has inputs 0-1-2-3. Spare inputs go the other way, so -1, -2, -3, etc.

Then the bend node's direction is:
detail(-1,'dir',<index>)

get detail attrib of input -1 (linked via first spare). attrib name is ‘dir’ and use component <index> (x=0,y=1,z=2).


Note also i have one cylinder per object. The setup is different if all your cylinders are in the same geometry; you will have to setup a for-loop to handle that.
Edited by Nicolas Longchamps - 2019年10月7日 10:10:51
User Avatar
Member
15 posts
Joined: 6月 2019
Offline
Thank you for your great and in depth post it really helps me understand this!
The spare input is connected to the wrangle.

Now I feel a bit embarrassed because its probably quite simple.
But I'm at a loss on how to reference the variables NullPos and CylPos in the wrangle node to there corresponding position.
User Avatar
Member
37 posts
Joined: 8月 2015
Offline
Here's a quick example using a for-loop to bend multiple tubes in a single geo. For every point, the cylinder is copied to the current point, a direction vector is calculated from the point to the null and the bend sop is configured using the current position, goal direction and tube length.

It also uses compile block to multithread the loop and speed it up quite a bit. You can see the speed difference by disabling the compile block. It complicates the example a bit but its a good use-case for compiling.

Attachments:
BendToLookAtObj.hip (195.3 KB)

User Avatar
Member
15 posts
Joined: 6月 2019
Offline
Thank you so much for all your help the patience and the example file! It really helps to switch things on and off/swap them with other nodes to see how they work The compiling block actually makes such a big difference in speed I'm amazed by it.. Again, I'm super grateful I wish you all the best!!
Edited by Mistah - 2019年10月10日 11:48:29
  • Quick Links