// .OBJ Loader // by SAITO // Placing a virtual structure represented as mathematically // three-dimensional object. // OBJModel.load() reads structure data of the object stored // as numerical data. // OBJModel.draw() gives a visual form to the structure data. // processing standard drawing functions can be used to manipulate // the visual form to create deep visual experiences. // Created 20 April 2005 import saito.objloader.*; //import processing.opengl.*; OBJModel model; float rotX = 4.5; float rotY = -0.6; int zoom = 4; void setup() { size(440, 320, P3D); model = new OBJModel(this, "wateringcan.obj"); } void draw() { background(51); noStroke(); lights(); pushMatrix(); translate(width/2, 3*height/4); rotateX(rotY); rotateY(rotX); scale(zoom); model.drawMode(POLYGON); model.draw(); popMatrix(); } void keyPressed() { if(key == 'a') model.enableTexture(); else if(key=='b') model.disableTexture(); else if (keyCode == UP) zoom = abs(zoom) + 1; else if (keyCode == DOWN) zoom = abs(zoom) - 1; } void mouseDragged() { rotX += (mouseX - pmouseX) * 0.01; rotY -= (mouseY - pmouseY) * 0.01; }