IntroductionThis example takes the coordinates as you specify them ignoring the processing transformation matrix. This means that the results of transate() and rotate are ignored. Detailsimport eu.fluidforms.a3D.*;
import eu.fluidforms.parser.*;
import eu.fluidforms.processing.*;
import eu.fluidforms.a2D.*;
import eu.fluidforms.io.*;
import eu.fluidforms.geometry.*;
import eu.fluidforms.utils.*;
import eu.fluidforms.primitives.*;
import template.*;
void setup(){
size(500, 500, P3D);
String format = "stl";
FGraphics gExport = (FGraphics)beginRecord("eu.fluidforms.processing.FGraphics", "Box." + format);
gExport.setApplyTransformMatrix(false);
smooth();
translate(width/2, height/2);
rotateX(PI/2);
int scale = 170;
int resolution = 50;
float inc = (TWO_PI)/resolution;
for(float v=-PI/2; v<=PI/2; v+=inc){ // creates a half circle
beginShape(TRIANGLE_STRIP);
for(float u=0; u<=TWO_PI; u+=inc){ // rotates the half circle
float x1 = getX(u, v);
float y1 = getY(u, v);
float z1 = getZ(u, v);
float x2 = getX(u, v+inc);
float y2 = getY(u, v+inc);
float z2 = getZ(u, v+inc);
vertex(x1*scale,y1*scale,z1*scale);
vertex(x2*scale,y2*scale,z2*scale);
}
endShape();
}
endRecord();
}
float getX(float u, float v){
return cos(u) * cos(v);
}
float getY(float u, float v){
return sin(u) * cos(v);
}
float getZ(float u, float v){
return sin(v) + cos(u);
}
|