
If anyone is interested in working with 3D content in processing, SketchUp is a free, easy to use program for creating 3D content. You will need to download the .obj exporter to get your SketchUp model into processing. You will also need the .obj library for Processing. I added a couple lines of code to the sample file to make the the “t” and “s” keys into zoom in and zoom out keys. I also changed the code so the model follows the mouse. Here is a link to a quick test I made. You may need to hit the “s” key a few times to zoom out before you can really see the model. If you are interested, the modified sample code is below.
//import processing.opengl.*;
// .OBJ Loader
// by SAITO
// Placing a virtual structure represented as mathematically
// three-dimensional object.
// SModel.load() reads structure data of the object stored
// as numerical data.
// SModel.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.*;
OBJModel model;
float rotX;
float rotY;
float changeSize = 30;
void setup()
{
size(800, 600, P3D);
frameRate(30);
model = new OBJModel(this);
model.debugMode();
model.load(”DMI.obj”);
}
void draw()
{
background(255);
lights();
pushMatrix();
translate(mouseX, mouseY);
rotateX(rotY);
rotateY(rotX);
scale(changeSize);
model.draw();
popMatrix();
}
boolean bTexture = true;
boolean bStroke = true;
void keyPressed(){
if(key == ‘t’){
changeSize++;
}
if(key == ’s’){
changeSize–;
}
else if(key==’1′)
model.drawMode(POINTS);
else if(key==’2′)
model.drawMode(TRIANGLES);
else if(key==’4′)
model.drawMode(POLYGON);
}
void mouseDragged()
{
rotX += (mouseX - pmouseX) * 0.01;
rotY -= (mouseY - pmouseY) * 0.01;
}