Constructive Solid Geometry Code for JMonkey (Give Away)

Hi everyone,

Anybody interested in doing Constructive Solid Geometry with JME 3 ?

i just “quicly” modified a part of this code : UnBBoolean download | SourceForge.net
and, so far, it is working (at least for my humble needs)
the only issue is normals, but i dont care about normals (so far) cos results are not displayed in the game

so with this, one can compute union/intersection/difference between meshes as a resulting mesh
and create exploding walls or anything that comes to your mind
[ i use it as a test to implement a dynamic navmesh (still in progress) ]

  • download :

here it is : http://robot.isp.imath.be/wp-content/uploads/2013/05/csg.zip

  • an example of usage :
...
BooleanModeller booleanModeller = new BooleanModeller(someGeometry.getMesh(),someOtherGeometry.getMesh());
Mesh me = booleanModeller.getDifference();
Mesh me = booleanModeller.getUnion();
Mesh me = booleanModeller.getIntersection();
...
  • credits to the author of this code :

Danilo Balby Silva Castanheira (danbalby@yahoo.com)

  • credits to the book that explains the theory of this :

“Constructive Mesh Geometry for Polyhedral Objects”
D. H. Laidlaw, W. B. Trumbore, and J. F. Hughes.
SIGGRAPH Proceedings, 1986, p.161.

  • in the future (?)

if i modify it for further improvements, i’ll update the archive on my site
and if anybody wants to use it , you’re free to go
maybe adding this to jme would be great, or maybe jme already does this, and in that case , well f@#k it :stuck_out_tongue:
i found it on source forge so i guess it is open source (lol)

enjoy !

6 Likes

As the original code is GPL we sadly cannot add it to the engine, thanks nonetheless.

<cite>@normen said:</cite> As the original code is GPL we sadly cannot add it to the engine, thanks nonetheless.

well for educational purpouses i guess :slight_smile:

@curtisnewton said: well for educational purpouses i guess :-)

The engine is not for educational purposes but can be used for commercial projects, any GPL code can only reside inside the SDK and not the core engine.

<cite>@normen said:</cite> The engine is not for educational purposes but can be used for commercial projects, any GPL code can only reside inside the SDK and not the core engine.

yes, i meant i would leave it here for educational purpouses

anyway there is not a thousand different ways to do csg, i realized it while i was fighting with the code

Sorry to (sort of) grave dig.

Could this not be ported? I believe that license to be MIT, which pretty much allows anything so long as the license is included.
Also, I don’t know for certain but I’m pretty sure if you ported the code to java, it doesn’t have the terms that some ridiculous licenses have which basically give them exclusive ownership of the section of your brain storing the knowledge, so I don’t even think including the license is in order.

The MIT License is similar to the 3-clause “modified” BSD license, except that the BSD license contains a notice prohibiting the use of the name of the copyright holder in promotion. This is sometimes present in versions of the MIT License, as noted above.

So i would say yes, as jme is the more restrictive one this should work fine. Now only someone needs to verify it works and then port it.

@Empire Phoenix said: The MIT License is similar to the 3-clause "modified" BSD license, except that the BSD license contains a notice prohibiting the use of the name of the copyright holder in promotion. This is sometimes present in versions of the MIT License, as noted above.

So i would say yes, as jme is the more restrictive one this should work fine. Now only someone needs to verify it works and then port it.

I’ve pretty much ported it. All that’s left are all of the shapes (Ironically, Cube looks like it’s going to be the hardest one to port! Might just rewrite entirely). I’ve already done all of the other classes.
There are some pretty neat demonstrations on their website here: http://evanw.github.io/csg.js/

Edit 2: Oh my god, this has huge potential!

1 Like

OK.
I’ve ported everything. Now comes something slightly trickier: Triangulation!
I’m probably going to write my own (using somebody else’s algorithm) due to licensing issues with some of the open source options.
Edit: Oh, how much simpler life would be with lwjgl’s GLUtessellatorImpl.

@fabsterpal
wow that’s an old one
glad people found it interesting in the end
yes it has great potential
but it was already writen in java so what do you mean “ported everything” ?

@curtisnewton said: @fabsterpal wow that's an old one glad people found it interesting in the end yes it has great potential but it was already writen in java so what do you mean "ported everything" ?

The code you posted was licensed under a fairly restrictive license, it couldn’t be used in the JME core. I found one under an equally restrictive license. The one I ported was MIT licensed and written in JS.

GLUtessellatorImpl ? I thought it can only do on demand rendering, or can it also return the triangulated mesh?

@Empire Phoenix said: GLUtessellatorImpl ? I thought it can only do on demand rendering, or can it also return the triangulated mesh?

I believe it creates a buffer, not sure though.

OK, I’ve done it:
http://puu.sh/9ZeYG/577edb15ba.png
Now I just need to add the other shapes (so far, only Cube and Sphere are done).

Update: Ported CylinderBrush, and created a custom one: MeshBrush.

Now going to make a new thread for this, now I’m working on integrating it into the engine.

5 Likes

pretty cool