A fork of this project exists here: https://sourceforge.net/projects/jmonkeycsg/
Fabian CSG (Constructive Shape Geometry) is a library for jMonkeyEngine that allows creating dynamic models with boolean operations.
- Fully ported csg.js library (MIT license) to Java, using JMonkeyEngine’s Vector3f.
- Added function to produce a Mesh from the CSG object.
- Made CSG.shapeName( static functions into classes that extend CSG.
- Created CSGNode class, which is used to sequentially add CSG brushes and output 1 geometry (Soon to be node)
- Created a MeshBrush, which reads the TexCoord, Normal, Position and Index buffers of a Mesh to product a shape which can be used for CSG.
- Add Material support on a per-brush level.
- Add UV calculations to standard shapes (Cube, Sphere, Cylinder)
- LOD support? (Or polygon reduction)
Material mat_csg = assetManager.loadMaterial(“Materials/WallCover/BrownBricks.j3m”);
mat_csg.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
CSGNode csg = new CSGNode();
csg.setMaterial(mat_csg);
CubeBrush base = new CubeBrush(new Vector3f(0f, 0f, 0f), new Vector3f(1f, 1f, 1f));
csg.addBrush(base);
SphereBrush hole = new SphereBrush(new Vector3f(0f, 0f, 0f), 1.3f, 16, 8);
hole.setType(BrushType.SUBTRACTIVE);
csg.addBrush(hole);
csg.regenerate();
csg.move(0f, 1f, 0f);
this.app.getRootNode().attachChild(csg);
Material mat_csg = assetManager.loadMaterial(“Materials/WallCover/BrownBricks.j3m”);
mat_csg.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
CSGNode csg = new CSGNode();
csg.setMaterial(mat_csg);
Spatial s = assetManager.loadModel(“Models/Characters/Goblin.j3o”);
ArrayList<Geometry> g = new ArrayList<>();
GeometryBatchFactory.gatherGeoms(s, g);
Mesh m = new Mesh();
GeometryBatchFactory.mergeGeometries(g, m);
MeshBrush mb = new MeshBrush(m);
csg.addBrush(mb);
CubeBrush base = new CubeBrush(new Vector3f(0f, 0.5f, 0f), new Vector3f(1f, 0.1f, 1f));
base.setType(BrushType.SUBTRACTIVE);
csg.addBrush(base);
csg.regenerate();
csg.move(0f, 1f, 0f);
this.app.getRootNode().attachChild(csg);