PDA

View Full Version : How to get the distance between parts nodally?



Hulk
05-09-2018, 04:12 AM
Hi guys,

I have an array of spheres (9x9) all in one piece and the spheres get displaced by a null object.
I want the spheres that come closer to other spheres to change the color/light up.
I don't know how to get the distance between parts.
Right now I am using the wpos and opos distance to drive a gradient but that's a diferent result.
Anyone know what nodes to use or how to do it right?

thx

Sensei
05-09-2018, 05:23 AM
Distance between two known parts should be possible to calculate using
Math > Vector > Distance,
and two item info/part info nodes which will output World Position.

But if you need to do it in array, 9x9 is 81 pieces, making connections between all would be tremendous job.. Is it the real problem (amount of connections).. ?
But you could try using Occlusion node instead. It's returning white when parts are far away and black when they're very close (and gray levels for intermediate distances).
So try getting occlusion color and plug it to Gradient (to cut larger distances=whiter results) to see how it works.

Hulk
05-09-2018, 06:25 AM
Thx Sensei,

I will try the occlusion approach.
the problem is not the amount of connections but getting the distance between the spheres.
I move them with part move so they are all in one layer as one single object.
If I use the wpos and opos to measure the distance I only get the info how far they moved from the position and not how close are they to other parts even parts that haven't moved

Hulk
05-09-2018, 06:28 AM
This is the animation I did. but I wanna adjust the glow so it lights up when Spheres are getting close to each other.


https://youtu.be/oPzDo8eIAhk

hypersuperduper
05-09-2018, 06:48 AM
You could also try the ray closest node. It works sort of like occlusion.

MonroePoteet
05-09-2018, 07:00 AM
If you're using LW2018, you can use the Mesh Part node Part Center output to get the Distance to the displacement Null and use that as input to Gradient(s) for the Color and / or Luminosity. I hadn't seen your animation before I made up the scene, so the displacement I used on the spheres is very different! The black grid shows the original sphere positions before displacement.

141609

141610

141608

Sample scene attached. Have fun!

mTp

P.S. Just saw the post about RayClosest - works great, here's the node setup:

141612

141611

Hulk
05-09-2018, 07:20 AM
Thx, that sounds about right. But I am using 2015.3