コード
import controlP5.*;
import wblut.geom.*;
import wblut.hemesh.*;
import wblut.core.*;
import wblut.math.*;
import wblut.nurbs.*;
import wblut.processing.*;
WB_Render3D render;
HE_Mesh mesh;
int setTubeFacets;
int setTorusFacets;
int setRadius1;
int setRadius2;
int setTwist;
int setTubePhase;
int setTorusPhase;
ControlP5 cp5;
void setup() {
size(960, 540, P3D);
colorMode(HSB, 360, 100, 100);
render = new WB_Render3D(this);
cp5 = new ControlP5(this);
cp5.addSlider("setRadius1").setRange(0, 200).setValue(50).setPosition(20, 20);
cp5.addSlider("setRadius2").setRange(0, 200).setValue(100).setPosition(20, 40);
cp5.addSlider("setTubeFacets").setRange(0, 200).setValue(16).setPosition(20, 60);
cp5.addSlider("setTorusFacets").setRange(0, 200).setValue(32).setPosition(20, 80);
cp5.addSlider("setTwist").setRange(-100, 100).setValue(0).setPosition(20, 100);
cp5.addSlider("setTubePhase").setRange(-100, 100).setValue(0).setPosition(20, 120);
cp5.addSlider("setTorusPhase").setRange(-100, 100).setValue(0).setPosition(20, 140);
}
void create() {
HEC_Torus creator = new HEC_Torus().setTubeFacets(setTubeFacets).setTorusFacets(setTorusFacets);
creator.setRadius(setRadius1, setRadius2);
creator.setTwist(setTwist);
creator.setTubePhase(setTubePhase);
creator.setTorusPhase(setTorusPhase);
mesh = new HE_Mesh(creator);
}
void draw() {
create();
background(0, 0, 20);
directionalLight(0, 0, 100, 1, 1, -1);
directionalLight(0, 0, 50, -1, -1, 1);
pushMatrix();
translate(width/2, height/2, 0);
rotateY(map(mouseX, 0, width, -PI, PI));
rotateX(map(mouseY, 0, height, PI, -PI));
noStroke();
fill(0, 0, 100);
render.drawFaces(mesh);
stroke(0, 0, 0);
noFill();
render.drawEdges(mesh);
popMatrix();
}
リファレンス
www.wblut.com