maybe you can help me with one thing.
I haven’t found it in the documentation http://lifesine.eu/so/jcsg-0.5.8-SNAPSHOT-javadoc.zip
I try to rotate a cylinder. See the commented out line with lots of ???
Thank you.
Chrisir
// the PShape reference which will contain the converted
PShape csgResult;
void setup() {
//
size(900, 900, P3D);
noStroke();
// JCSG sample code:
// we use cube and sphere as base geometries
CSG cube = new Cube(12, 2, 2).toCSG();
CSG sphere = new Sphere(1.25).toCSG();
// cyl2 == horizontal
float cylRadius=.65;
CSG cyl2 = new Cylinder( cylRadius, cylRadius, 12, 43).toCSG();
cyl2 = cyl2.transformed(Transform.unity().translateX(2));
// cyl2 = cyl2.transformed(Transform.unity().rotate(1.0, 1.2, 2.0)); // ???????????????????????????????????
csgResult = CSGToPShape(cyl2, 45);
}
void draw() {
background(0);
lights();
translate(width * 0.5, height * 0.5, 0);
shape(csgResult);
}
//-----------------------------------------------------------------------------
// re-usable function to convert a CSG mesh to a Processing PShape
PShape CSGToPShape(CSG mesh, float scale) {
// allocate a PShape group
PShape csgResult = createShape(GROUP);
// for each CSG polygon (Note: these can have 3,4 or more vertices)
for (Polygon p : mesh.getPolygons()) {
// make a child PShape
PShape polyShape = createShape();
// begin setting vertices to it
polyShape.beginShape();
// for each vertex in the polygon
for (Vertex v : p.vertices) {
// add each (scaled) polygon vertex
polyShape.vertex((float)v.pos.getX() * scale, (float)v.pos.getY() * scale, (float)v.pos.getZ() * scale);
}
// finish this polygon
polyShape.endShape();
//append the child PShape to the parent
csgResult.addChild(polyShape);
}
return csgResult;
}
//