// GeometryFactoryDemo // Dave Bollinger // http://www.davebollinger.com /** mouse X controls radius mouse Y controls height */ GeometryFactory gf; float halfwidth, halfheight; float quarterwidth, quarterheight; float rotx = 0f, roty = 0f; void setup() { size(300,300,P3D); halfwidth = width * 0.5f; halfheight = height * 0.5f; quarterwidth = width * 0.25f; quarterheight = height * 0.25f; stroke(0); fill(224,192); gf = new GeometryFactory(); gf.setDetail(16); // just to demo how its called, default detail of 12 would have been fine // could have also just constructed it as: gf = new GeometryFactory(16); } void draw() { background(255); translate(halfwidth, halfheight, 0f); rotateX(rotx+=0.01); rotateY(roty+=0.01); lights(); float mx = (mouseX - halfwidth) * 0.5f; float my = (mouseY - halfheight) * 0.5f; //pushMatrix(); gf.disc(0f, mx); //popMatrix(); pushMatrix(); translate(-quarterwidth, -quarterheight, 0f); gf.cylinder(my, mx); popMatrix(); pushMatrix(); translate(-quarterwidth, quarterheight, 0f); gf.cone(my, mx); popMatrix(); pushMatrix(); translate(quarterwidth, -quarterheight, 0f); gf.capped_cylinder(my, mx, mx/2); popMatrix(); pushMatrix(); translate(quarterwidth, quarterheight, 0f); gf.capped_cone(my, mx); popMatrix(); }