This will need a bit of tweaking to suit your purposes. It's very old and probably a bit mouldy, but I've just modified it to run under Beta for you:
Code:
import processing.video.*;
Capture cam;
float cubeScale=40;
float xmag, ymag = 0;
float newXmag, newYmag = 0;
int nNode = 1;
Node[] node = new Node[nNode];
float rotY, rotX;
int vDimX= 200;
int vDimY= 200;
void setup()
{
size(600,600, P3D);
noStroke();
// beginVideo(vDimX, vDimY, 25);
cam = new Capture (this, vDimX, vDimY, 25);
float j= 0; //-1;
float k= 0; //-1;
float l= 0; //-1;
for (int i=0;i<nNode;i++)
{
node[i] = new Node(j, k, l);
if(j++>= 1) {j=-1; if(k++>=1) {k=-1; l++;}}
}
}
void mouseDragged()
{
newXmag = mouseX/float(width) * TWO_PI;
newYmag = mouseY/float(height) * TWO_PI;
}
void draw()
{
background(255);
translate(width/2,height/2, 0);
float diff = xmag-newXmag;
if (abs(diff) > 0.01) { xmag -= diff/4.0; }
diff = ymag-newYmag;
if (abs(diff) > 0.01) { ymag -= diff/4.0; }
rotateX(-ymag);
rotateY(-xmag);
int i= (int)random(0, nNode);
int j= (int)random(0, 6);
node[i].updateFacet(node[i].facets[j]);
for (int k= 0; k< nNode; k++) {
node[k].draw();
}
if(cubeScale <100) {cubeScale+=0.25;}
}
class Node {
float xpos= 0;
float ypos= 0;
float zpos= 0;
PImage[] facets;
Node(float x, float y, float z) {
xpos = x*100;
ypos = y*100;
zpos = z*100;
facets = new PImage[6];
for(int i=0; i<6; i++) {
facets[i] = new PImage(vDimX, vDimY);
}
}
void updateFacet(PImage facet) {
if (cam.available()) {
cam.read();
}
for(int i=0; i<facet.width*facet.height; i++) {
facet.pixels[i]= cam.pixels[i];
}
}
void draw() {
pushMatrix();
translate(xpos,ypos,zpos);
scale(cubeScale);
fill(128, 230);
beginShape(QUADS);
texture(facets[0]);
vertex(-1, 1, 1, -vDimX, vDimY);
vertex( 1, 1, 1, vDimX, vDimY);
vertex( 1, -1, 1, vDimX, -vDimY);
vertex(-1, -1, 1, -vDimX, -vDimY);
endShape();
fill(128, 210);
beginShape(QUADS);
texture(facets[1]);
vertex( 1, 1, 1, -vDimX, vDimY);
vertex( 1, 1, -1, vDimX, vDimY);
vertex( 1, -1, -1, vDimX, -vDimY);
vertex( 1, -1, 1, -vDimX, -vDimY);
endShape();
beginShape(QUADS);
texture(facets[2]);
vertex( 1, 1, -1, -vDimX, vDimY);
vertex(-1, 1, -1, vDimX, vDimY);
vertex(-1, -1, -1, vDimX, -vDimY);
vertex( 1, -1, -1, -vDimX, -vDimY);
endShape();
beginShape(QUADS);
texture(facets[3]);
vertex(-1, 1, -1, -vDimX, vDimY);
vertex(-1, 1, 1, vDimX, vDimY);
vertex(-1, -1, 1, vDimX, -vDimY);
vertex(-1, -1, -1, -vDimX, -vDimY);
endShape();
beginShape(QUADS);
texture(facets[4]);
vertex(-1, 1, -1, -vDimX, vDimY);
vertex( 1, 1, -1, vDimX, vDimY);
vertex( 1, 1, 1, vDimX, -vDimY);
vertex(-1, 1, 1, -vDimX, -vDimY);
endShape();
beginShape(QUADS);
texture(facets[5]);
vertex(-1, -1, -1, -vDimX, vDimY);
vertex( 1, -1, -1, vDimX, vDimY);
vertex( 1, -1, 1, vDimX, -vDimY);
vertex(-1, -1, 1, -vDimX, -vDimY);
endShape();
popMatrix();
}
}