Skip to content

Instantly share code, notes, and snippets.

@studioijeoma
Created July 9, 2013 20:00
Show Gist options
  • Select an option

  • Save studioijeoma/5960737 to your computer and use it in GitHub Desktop.

Select an option

Save studioijeoma/5960737 to your computer and use it in GitHub Desktop.

Revisions

  1. Ekene Ijeoma created this gist Jul 9, 2013.
    84 changes: 84 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,84 @@
    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;
    }