/** Newell's Teapot rendered using my BezierPatch class.
The BezierPatch class significantly extends Processings ability
to draw interesting shapes in 3D. The class is designed to mimic
Processings own behaviour as much as possible.
Feel free to implement it in your sketches as well. */ import com.processinghacks.arcball.*; Teapot teapot; PFont font; PImage skin; final int GRID=0, SURFACE=1, TEXTURE=2; int mode=SURFACE; //-------------- void setup() { size(300,300,P3D); font = loadFont("Silkscreen-8.vlw"); textFont(font); textMode(SCREEN); ArcBall ab = new ArcBall(this); skin = loadImage("tartan.png"); teapot = new Teapot(); teapot.setDetail(6); } //-------------- void drawTexture() { fill(0); noStroke(); teapot.visualize(skin); } //-------------- void drawGrid() { noFill(); stroke(0,64); teapot.visualize(); } //-------------- void drawSurface() { fill(160); noStroke(); teapot.visualize(); } //-------------- void draw() { background(192); translate(width/2,height/2,-250); scale(60); lights(); if(mode==SURFACE) drawSurface(); else if(mode==GRID) drawGrid(); else drawTexture(); fill(0); text("[1-9] to set resolution",5,10); text("[SPACE] to cycle rendering mode",5,20); text("[mouse drag] to rotate",5,30); text("resolution: "+teapot.detail+"^2",5,height-5); } //------------------------- void keyPressed(){ if(key==' ') mode = (mode+1)%3; if(key>='1' && key<='8') teapot.setDetail(1+key-'1'); if(key=='9') teapot.setDetail(16); } //------------------------- void keyReleased(){ } //-------------- void mousePressed(){ } //-------------- void mouseReleased() { } //--------------