Get mesh intersection

Hi. What would be the easiest way to get the intersection of two meshes?
So I have 2 meshes and lets assume they intersect. I want to get the mesh which is the result of the intersection.
Is there any class or methods in JME which make this happen easy so I dont have to implement complicated algorithms? The meshes are all convex.

It is not simple thing. I don’t think there is anything in jme3 atm to facilitate that.
Magic keywords you have too look on the net for that is

or CSG.

There was a java3d project implementing that
http://unbboolean.sourceforge.net/
Should be reasonably easy to port to jme3, as general concepts are similar (like… both being in java and both being scenegraphs :wink:
Unbboolean is a library for runtime operations, not only gui frontend for modelling. I don’t think that porting gui makes too much sense - too much effort.

1 Like

This is very interesting.

The GUI is buggy with the Java3D library I installed, but the boolean algorithms themselves are clean and interesting.
Thank you for the link.

Edit: Apparently there’s a port already :
http://hub.jmonkeyengine.org/forum/topic/boolmesh-java-boolean-operations-on-mesh/

Blender supports boolean operations. Do you need to do this dynamically or could you just do it in blender ahead of time?

Hi zarch,
I tested the port of unbboolean but it didn’t work at all (the resulting objects were totally wrong). I tried to fix it without success.
I need it dynamical. But anyway, I’m just interested to merge 2D polygons, with holes… mainly for the NavMesh pathfinder.

I took the week-end to create my own Polygon2D object. You declare the edges, and it will triangulate automatically. You can also declare holes inside it.

The polygon’s edge are in Cyan. The holes are in Red, and the automatic triangulation in Green.
The final result can be seen in purple on the left side.

The code is certainly far from optimal mathematically, but it does the job. :slight_smile:
It’s very very hard to find anything similar in Java on the net. And the few algorithms I found didn’t do the holes.

In 2D, I’ve used Java’s Area class for something like this before: http://docs.oracle.com/javase/6/docs/api/java/awt/geom/Area.html

Quick and easy.

But how do you triangulate from an Aera ?

@ozonegrif said: But how do you triangulate from an Aera ?

Yeah, that’s a little less straight forward but I don’t remember it being too bad. It was a really long time ago, though.