An intersect path of two meshes

Hey guys! Do you know the easiest way to find a path of intersect of two meshes (mesh with plane)? May I do this with babylon.js or do you know another js lib that can do this? Thank you :slight_smile:

This is an example screenshot from blender app.

May be I can do this with CSG? or not?

I’m not sure what you are trying to do but this might help.
https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh

1 Like

Hi guys.

Yeah, I was sort-of thinking in the same direction… or possibly with a shadowMap or stencilBuffer (like I know what a stencilBuffer can be used-for). hehe.

https://playground.babylonjs.com/#D25VJD#1

I used a highly-sub-divided ground as one of the CSG mesh, but the CSG system doesn’t like that very much, because it’s not a closed volume. It leaves “below-the-floor” slag… acting more like a plastics extruder than a boolean subtractor. Irrelevant.

Now, how does a person “process” the vertexData of finalMesh, “harvesting” ONLY “rim-of-the-bowl” points, and pushing them into a path2d array… IN SOME SEQUENCE/ORDER which path2d enjoys?

OUCH! Silhouette edge-harvesting 101. :smiley:

If I rem right, a user named Nesh, and @JohnK did some work on “MRI image slicing” and similar… in our old forum. How to add thickness to a 2D textured plane? - Questions & Answers - HTML5 Game Devs Forum Worth a look, likely. That might be the wrong thread… and maybe John can help steer us to something more apropos.

1 Like

thank you, than I’ll try to dig into CSG code to find answers :slight_smile:

My pleasure. hmm. In my opinion, NOW it’s time to TRY to gather all finalMesh.vertexData POSITION-KIND data (the positions of ALL the vertices of finalMesh). Gather those in a giant pile, then go thru them (iterate thru them)… and gather every position which has a Y-value that is a [range] below the floor height. (ie. only grab points that are slightly negative on y-axis. Perhaps, gather all vertices who have a Y value between -0.01 and -.1. Put all of THOSE into an array.

THAT… SHOULD BE… the “rim around the bowl”… or… a silhouette of the intersection… sort of like a “cross-section”. You could use that data… as path3d points. Path3d is a dataType laying around in BJS land… here and there.

BUT… even though this would “harvest” all the verts (positions) around the bowl’s rim… we don’t have them in sequence/order. If you were to feed that data… to a LinesMesh (to draw the path for us)… it would not look pretty at all… because the LinesMesh wants the array-of-positions (its path) to be in-sequence/order.

And I don’t know what “process” would be needed… to convert an out-of-order pile of positions… into a “connect the dots” logical path. We need “positional sorting” of the harvested data-pile… prior-to feeding that path… to a LinesMesh.

Really, let’s wait a bit and listen for better ideas. There’s got to be a better way to do intersect-edge gathering. hmm. I have one more REALLY RETARDED idea… involving a giant sheet of tiny SPS particles, pushing any mesh into that “sheet”, and using basic collision detect that CAN be activated on SPS particles… to “find the intersection edge”. Weird idea.

did like that :slight_smile: https://playground.babylonjs.com/#D25VJD#3

but without a valid sequence we’ve got invalid path :upside_down_face:

2 Likes

Ooooh, nice! You know what you are doing. I’m glad. I think you’re going to nail this. Good codin’!!! Real nice. Let’s ping-in @jerome and @JohnK … see if those path-masters have some advice.

seems like I can solve this problem with Use Facet Data - Babylon.js Documentation and getClosestFacetAtCoordinates. I can move in cut plane and collect points from the surface of the mesh into an array in correct order.

2 Likes