Skip to content

Instantly share code, notes, and snippets.

@studioijeoma
Created July 9, 2013 20:00
Show Gist options
  • Save studioijeoma/5960737 to your computer and use it in GitHub Desktop.
Save studioijeoma/5960737 to your computer and use it in GitHub Desktop.
cubeMap.pde
import processing.video.*;
Movie tex;
// PImage tex;
float rotx = PI/4;
float roty = PI/4;
void setup() {
size(640, 640, P3D);
tex = new Movie(this, "testMovie.mov");
tex.loop();
// tex = loadImage("testImage.jpg");
textureMode(NORMAL);
fill(255);
stroke(color(44,48,32));
}
void draw() {
background(0);
noStroke();
translate(width/2.0, height/2.0, -100);
rotateX(rotx);
rotateY(roty);
scale(90);
TexturedCube(tex);
}
void movieEvent(Movie m) {
m.read();
}
void TexturedCube(PImage tex) {
// fill(255);
beginShape(QUADS);
texture(tex);
// +Z "front" face
vertex(-1, -1, 1, 0, 0);
vertex( 1, -1, 1, 1, 0);
vertex( 1, 1, 1, 1, 1);
vertex(-1, 1, 1, 0, 1);
// -Z "back" face
vertex( 1, -1, -1, 0, 0);
vertex(-1, -1, -1, 1, 0);
vertex(-1, 1, -1, 1, 1);
vertex( 1, 1, -1, 0, 1);
// +Y "bottom" face
vertex(-1, 1, 1, 0, 0);
vertex( 1, 1, 1, 1, 0);
vertex( 1, 1, -1, 1, 1);
vertex(-1, 1, -1, 0, 1);
// -Y "top" face
vertex(-1, -1, -1, 0, 0);
vertex( 1, -1, -1, 1, 0);
vertex( 1, -1, 1, 1, 1);
vertex(-1, -1, 1, 0, 1);
// +X "right" face
vertex( 1, -1, 1, 0, 0);
vertex( 1, -1, -1, 1, 0);
vertex( 1, 1, -1, 1, 1);
vertex( 1, 1, 1, 0, 1);
// -X "left" face
vertex(-1, -1, -1, 0, 0);
vertex(-1, -1, 1, 1, 0);
vertex(-1, 1, 1, 1, 1);
vertex(-1, 1, -1, 0, 1);
endShape();
}
void mouseDragged() {
float rate = 0.01;
rotx += (pmouseY-mouseY) * rate;
roty += (mouseX-pmouseX) * rate;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment