# Mesh kisses

Why donâ€™t they touch to begin with? What are they and how are they made? There is not going to be any automatic solution for that unless you can define and predict a rule in the logic of the design.

Or do you mean to just collide one into the other?

1 Like

I want that based on the distance it z-directs towards each other. It are meshes.

The part in the yellow marking I am trying to collide so it will be â€˜partly stitchedâ€™ as sheets.

You could use snap in kangaroo or some collision option,

for now this can do the trick:
meshkiss_help_01.gh (73.9 KB)

It uses a point to create an attraction between the two meshes closest to it and moves vertices of corresponding faces along the face normal - you can extend the logic to curves or other attractors

1 Like

Weird Valentineâ€™s day here, but heyâ€¦

5 Likes

I tried something similar before wherein I let the points move by the z-axis. I tried kangaroo snapping but was not able to get right.

Hmmâ€¦

I now tried to get them hugging like sheets. But, as I tried before, it also did not work.

Do you might know how to let the meshes hug within a range?

meshkiss_help_02.gh (91.3 KB)

hugging is different from kissing

Donâ€™t have time to look into it right this minute but you could â€˜sandwichâ€™ the meshes to a curve passing in between them to account for such range along the curve versus the search radius of the single point.

maybe you can borrow from this other solution if youâ€™re staying away from kangaroo:

1 Like

I am trying to avoid kangaroo because it takes a lot of calculation time.

I looked at my own work again, but still doing something wrong. I now use crvs to get intersecting points and limit the range of moving points by the distances of the intersecting crvs.

Do you might know what I am doing wrong?

I was could not understand the sculted_tower_update.ghx

meshkiss_help_03.gh (96.3 KB)

okay, hugging is different from kissing, but sandwinching it to muchâ€¦
for what I want to achieve in my design

I apologize, I was being funny - stupid word choice, sandwich or hugging or kissing - I simply meant pulling them towards each other.

I havenâ€™t come back to see your script yet but as Michael pointed out in his earlier response with more clarity in your screenshot or explained logic perhaps it makes it easier for one to grasp what youâ€™re after.

Can you show a more accurate picture/sketch of what you mean by â€˜making the meshes kiss/hugâ€™?

Best

1 Like

No, I found it funny. I made a joke back, and jokes mean nothing and are only made because they are funny.

This is what I want. I want the neighboring meshes [blue] come to each other [as in red]. The rest of the mesh stays in position.

Based on how close the mesh vertices are to the other mesh, I want it magnetize to the other. I divided the vector by 2, so they will not cross each other. And moved only along the z-axis.

meshkiss_help_03.gh (70.1 KB)

I tried something like this before, but I cannot get it smooth. I am just a student, so I have to study how to do it, but I tried it for some couple of months in between other stuff. I cannot find a way.

It just looks like happy (close, but not what I want to achieve). I want to let it transition smoothly.

20190216 problem mesh kiss 04.gh (71.4 KB)

ForestOwl,

Transition smoothly and not touch or do you want the objects to touch?

Pull them less?

Though if they must touch or be super close then find the SmoothMesh component and smooth the resulting meshes with it, or smooth with weaverbird.

Also, thanks for the sketch you provided - your geometries in it are depicted a lot smoother than the meshes youâ€™re using in the file - so the question is do you have to use those meshes only?

Transition smoothly and not touch or do you want the objects to touch?

I want the objects touch one another.

Pull them less?

Pull them less does not work either because the â€˜z-moving pointsâ€™ neighborsâ€™ does not go with them while moving.

Though if they must touch or be super close then find the SmoothMesh component and smooth the resulting meshes with it, or smooth with weaverbird.

When smoothing it smooths everything, so other â€˜connectionsâ€™ with itself will disappear.

â€¦so the question is do you have to use those meshes only?

No, I am going to use several meshes.

I want to let â€˜close neighboring parts of meshesâ€™ attract to each other so they touch each other and form a one transitional â€˜surface-form.â€™ Doing this depending on the distance between the â€˜close neighboring parts of meshes.â€™

Did I explain it good enough?

Trying to do it with the component â€˜pull pointsâ€™ instead of â€˜project pointsâ€™ will give also a happy

20190216 problem mesh kiss 05.gh (154.9 KB)

1 Like

The naked vertices complicate this as youâ€™ve already seen - the point where the meshes â€˜kissâ€™ involves enough naked vertices in the vicinity, which then forces you to also grab those points, which defeats the purpose of keeping the rest of the mesh unaltered - then if you choose to leave the naked vertices in place you end up with a forced kiss ( ) - switching to surfaces (mesh them later) or to denser (subdivided) meshes might give you smoother results - that hoopsnake work-around starts to look interesting though

Hey @ForestOwl,

Earlier today I was dealing with a different-but-similar mesh problem

Hereâ€™s a modified approach to the kissing, now with surfaces rebuilt from your meshes:
different_kiss.gh (49.2 KB)

 for other interesting graph mappers maybe try Riched Graph Mapper

Best

1 Like

Hi @ForestOwl,

Hereâ€™s a pythonic approach, if youâ€™re interested:

The script first evaluates the meshes that arenâ€™t already touching.
Then it looks for pairs that need to be kissing and moves the vertices of closest regions of both meshes closer together. Feel free to check it out below!

meshkiss_help_07.gh (47.0 KB)

3 Likes

Great thank you! I know tried to use more points and more meshes. This script is very handy for me.

What I know tried is to let the vector movement depend on the z-axis towards the attractor points. However, I get some bumps by that and not everything is connecting well due to my implementation.

How could I make it more â€˜controleableâ€™ and let it made itself as fluent as in your example but then in the context of â€˜more points and meshes?â€™ I cannot find a different way of what I am doing now.

20190216 problem mesh kiss 06.gh (135.4 KB)

Wow, you did it in Python

I almost studied all of it and already learning much of it. I am very happy with it because I now learning of how to work with meshes in Python.

I tried it also with three separated meshes, and understand by that it is meant for â€˜two meshes.â€™
I am going to see how I can â€˜expand it.â€™ I was thinking of using â€˜anemoneâ€™ to loop, but first I am going to try to see if I can make it work with more than two meshes.

20190216 problem mesh kiss 07.gh (51.5 KB)

1 Like

I havenâ€™t tested it beyond your example, but it might already work for more than two meshes. It just evaluates the kissing for mesh pairs, but it loops every mesh. You might have to play with the sliders for it to work though.

A mesh is created for every neighbor close by the â€˜target meshâ€™ within the loop.

As a student I am already very impressed by what you helped me with giving me something to learn from So, again, thank you.

I am now trying collecting all new_miâ€™s vectors and new_mjâ€™s vectors together and take then the average of every â€˜groupâ€™ vectors per point per mesh to deform them.

the mesh loops resulting in four meshes

I am going to try to change this part

The nested for loop that you posted above, loops each mesh, like we would chose team mates from a pool of players at a sports game. Nobody, can be chosen twice!
If you have four Meshes, at the first iteration, the first mesh (i = 0) is compared to the 2nd (j = i+1 = 1), 3rd (j = 2), and 4th (j= 3) mesh. At the 2nd iteration, the 2nd mesh (i = 1) is compared to the 3rd (j = i+1 = 2), and 4th mesh (j=3). At the 3rd iteration, the 3rd mesh (i = 2) is compared to only the 3rd mesh (j = i+1 = 3). At the fourth and last iteration (i=3), there are no meshes left to chose from, since j = i + 1 = 4 and there is no item beyond index 3.

Now, the problem with the duplicate 2nd mesh (from the top) is caused, because - at the first iteration - itâ€™s closest neighbouring mesh is the 2nd one directly below. So the script attracts both meshes to each other and stores the new meshes in `pulled_meshes`.
At the 2nd iteration, however, the unchanged 2nd Mesh from Meshes (that has already been attracted and saved in the previous iteration) is evaluated with the 3rd mesh, as its closest neighbour. It performs the kissing action and both meshes are saved into `pulled_meshes`. Unfortunately, the 2nd mesh gets stored twice, and thatâ€™s where the duplicates come from. Thanks for pointing that out!

You want to calculate all the vertex movements, save them per mesh vertex and average them later, in order to find its average movement and avoid duplicates? Seems to be a great work around!
Iâ€™ll also look into it tonight.

Instead of performing the vertex movement in the `pull_mesh()` method, you could try to refractor the code.
A new method could for instance only return the movement vectors between two compared meshes. You would call it in the lower nested loop portion and save all the movement vectors in some kind of structured nested list. You should also take count of how many times a given mesh has been evaluated, since you will probably need that later for averaging the movement vectors.
Another method, can then do the averaging and perform the vertex moving.

1 Like