8
$\begingroup$

If I have two cubes (with the same vertices and indices) and they are animated to move on their own paths, can I calculate the distance between v0 of one cube and v0 of the other cube to drive something like vertex color of the original for v0? Ideally I'd like to do it for all 8 vertices by indexed pair (v0 to v0, v1 to v1, etc...).

The only thing I could think of was to capture the Position Attribute of two Object Info nodes and then do a Vector Math Distance on those. This seems to just result in the distance of the vertices from one cube to 0,0,0. I get the Position node is based on the geometry downstream, but I feel like that is limiting in this case as I want two uniques sets of geometry to be compared. Speadsheet and Node Group

It is super simple in Animation Nodes. Just use some mesh input nodes for each object, grab the Vertex locations and then calculate the list of distances. Would love to have that same simple functionality in Geometry Nodes.

UPDATED Example with Solution

Based on the selected answer from Robin Betts I'd like to share an example of how I was planning on using the feature. Here's a simple example of transferring the 'Distance' between vertices of two frame offset Alembics (should probably work on rigs and FBX files as well) over by an attribute to the Shader. Then I just ran the attribute through a ColorRamp to give shading based on the 'Speed' of the individual vertices. I left the offset copy of the Alembic in the scene in wireframe view if that helps to see where the colors are coming from. Example of using an Alembic to calculate the 'speed' of the vertices

$\endgroup$
2
  • $\begingroup$ Great stuff! I guess if that was a Vector Subtract instead of Distance , (in World Space,) you could encode direction, too, to get a vector velocity? You could always recover the float speed from that in the shader, if you wanted to dispense with some of the information. $\endgroup$
    – Robin Betts
    Dec 21, 2021 at 8:24
  • 1
    $\begingroup$ Good idea, the door is open now to explore other mesh compare operations. Next is to replicate mesh tension in GN (compare face area to an original static mesh) that has been available in AN and other scripts/addons. github.com/harisreedhar/an_bluefox_extension#mesh-nodes blenderartists.org/t/revised-mesh-tension-add-on/1239091 $\endgroup$ Dec 21, 2021 at 19:15

1 Answer 1

7
$\begingroup$

You can Transfer the vertex position, (in the modified object's space) from the target object to the modified object by Index, and subtract it in place, as an attribute of the modified object:

enter image description here

This shows the view of the attribute of the modified object (here, output as Vertex Distance,) against actual example measurements on vertex 1 and vertex 6:

enter image description here

$\endgroup$
5
  • 1
    $\begingroup$ I believe this is exactly what I was looking for, thank you. Not super intuitive like it is in Animation Nodes, but makes sense now that I see it. As long as the index order of the vertices remains the same then I can see how this could be applied to other geometry. I'm going to try it with an imported Alembic using the Mesh Sequence Cache modifier and a duplicate with a few frame offset. Basically looking to capture the 'speed' of each vertex of the Alembic. I'll report back if it works. $\endgroup$ Dec 21, 2021 at 3:07
  • $\begingroup$ Ooh nice. I can see it as a useful tool to compare standard deviation in the position of two meshes, but it does require the geometry to be ordered exactly the same way on both objects, right ? $\endgroup$
    – Gorgious
    Dec 21, 2021 at 10:13
  • $\begingroup$ @Gorgious This one does.. but I guess you could sample by proximity? It depends what is meant by 'position of 2 meshes' ? ... which distances are being considered.. could it be 'sampled closest point on B for each point on A'? $\endgroup$
    – Robin Betts
    Dec 21, 2021 at 10:23
  • $\begingroup$ I was thinking of this kind of application, danielgm.net/cc/forum/viewtopic.php?t=3718 but I think the algorithm in Cloudcompare is (a bit) more complicated in reality :) Anyways for two meshes coming from the same source this is a nice tool using GN. Cheers $\endgroup$
    – Gorgious
    Dec 21, 2021 at 10:27
  • $\begingroup$ @Gorgious that discussion suggests distance along +/- Normal.. which would be a Ray Cast ? I've been working with that quite a lot recently, trying to make a 'better shrinkwrap' which incrementally tucks itself into corners $\endgroup$
    – Robin Betts
    Dec 21, 2021 at 11:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .