Hey, so I took the 2d pixelator program I wrote yesterday and threw in the 3rd dimension. I picked brightness for the box height... click on the link below to see a screen capture movie of what I was able to produce. This was running on a 17" powerbook g4 with an external iSight camera.
http://www.youtube.com/v/SjvuyzBkLcc
Code is below... change the camera name to yours, and that should do it. If you're using an external old school iSight, you might be able to just leave it alone:
Quote:
/* webcam 3d pixelator!!
// steve cooley
// http://somejunkwelike.com/wordpress
// http://stevecooley.etsy.com
// 2006-05-07
*/
import processing.video.*;
Capture myCapture;
// split the screen by:
int gridsizex = 40;
int gridsizey = 40;
// space between boxes
int spacer = 0;
void setup()
{
background(0);
framerate(20);
size(640, 480, P3D);
println(Capture.list()); // to output which cam is connected, then copy that text into the string below
// "IIDC FireWire Video" is what my external iSight is called.
String s = "IIDC FireWire Video";
myCapture = new Capture(this, s, width, height, 10);
noStroke();
rectMode(CORNER);
}
void captureEvent(Capture myCapture) {
myCapture.read();
}
//
// get the size of the window
// divide the window by x across and y down
// for every time in the x and y divisions, get the pixel color at that location
// draw a box (or ellipse) on that spot with that color
//
void draw() {
lights();
background(204);
float cameraY = height/8.0;
float fov = 1.5;
float cameraZ = cameraY / tan(fov / 2.0);
float aspect = float(width)/float(height);
perspective(fov, aspect, cameraZ/10.0, cameraZ*10.0);
float mousex = mouseX;
float mousey = mouseY;
camera(width/2, mouseY, mouseX,width/2,height/2,0,0.0,1.0,1.0); // help... this camera control is hard to understand
if(myCapture.available()) {
// Reads the new frame
myCapture.read();
}
for(int y = 0; y<height; y=y+(height/gridsizey))
{
// println(y);
for(int x = 0; x<width; x=x+(width/gridsizex))
{
// this took me a while to understand.
// it was trying to get() the canvas at first, but then I learned about
// myCapture.get();
// I learned so much doing this program!
color cp = myCapture.get(x, y);
fill(cp);
pushMatrix(); // OH, that's what that does. COOL.
translate(x, y,0);
box(width/gridsizex-spacer, height/gridsizey-spacer, int(brightness(cp)));
popMatrix();
}
}
}