Git Product home page Git Product logo

fabian-csg's Introduction

Fabian CSG

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.

Boolean Subtraction
Boolean Intersection
Boolean Difference

Features

  • 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)

Usage

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);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.