- // Test v0.01 interactive kinect installation
- import processing.opengl.*;
- import SimpleOpenNI.*;
- import ddf.minim.*;
- SimpleOpenNI kinect;
- float rotation = 0;
- // two AudioPlayer objects this time (need array for number of tracks)
- Minim minim;
- AudioPlayer kick;
- AudioPlayer snare;
- AudioPlayer punch;
- // declare hotpoint objects (need to create a grid for hotpoints and array for declaring them)
- Hotpoint snareTrigger;
- Hotpoint kickTrigger;
- Hotpoint punchTrigger;
- float s = 1;
- void setup() {
- size(1440, 1050, OPENGL);
- kinect = new SimpleOpenNI(this);
- kinect.enableDepth();
- minim = new Minim(this);
- // load both audio files
- snare = minim.loadFile("hat.wav");
- kick = minim.loadFile("kick.wav");
- punch = minim.loadFile("punch.wav");
-
- // initialize hotpoints with their origins (x,y,z) and their size
- snareTrigger = new Hotpoint(200, 0, 600, 150);
- kickTrigger = new Hotpoint(-200, 0, 600, 150);
- punchTrigger = new Hotpoint(-400, 0, 600, 150);
-
- }
- void draw() {
- background(0);
- kinect.update();
- translate(width/2, height/2, -1000);
- rotateX(radians(180));
- translate(0, 0, 1400);
- rotateY(radians(map(0, 0, width, 0, 0)));
- translate(0, 0, s*-1000);
- scale(s);
- stroke(255);
- PVector[] depthPoints = kinect.depthMapRealWorld();
- for (int i = 0; i < depthPoints.length; i+=10) {
- PVector currentPoint = depthPoints[i];
- // have each hotpoint check to see
- // if it includes the currentPoint
- snareTrigger.check(currentPoint);
- kickTrigger.check(currentPoint);
- punchTrigger.check(currentPoint);
- point(currentPoint.x, currentPoint.y, currentPoint.z);
- }
- println(snareTrigger.pointsIncluded);
- if(snareTrigger.isHit()) {
- snare.play();
- }
-
- if(!snare.isPlaying()) {
- snare.rewind();
- snare.pause();
- }
- if (kickTrigger.isHit()) {
- kick.play();
- }
-
- if(!kick.isPlaying()) {
- kick.rewind();
- kick.pause();
- }
-
- if (punchTrigger.isHit()) {
- punch.play();
- }
- if(!punch.isPlaying()) {
- punch.rewind();
- punch.pause();
- }
-
- // display each hotpoint
- // and clear its points
- snareTrigger.draw();
- snareTrigger.clear();
-
- kickTrigger.draw();
- kickTrigger.clear();
-
- punchTrigger.draw();
- punchTrigger.clear();
- }
- void stop()
- {
- // make sure to close
- // both AudioPlayer objects
- kick.close();
- snare.close();
- punch.close();
- minim.stop();
- super.stop();
- }
- void keyPressed() {
- if (keyCode == 38) {
- s = s + 0.01;
- }
- if (keyCode == 40) {
- s = s - 0.01;
- }
- }
Right now what this does is if you hover over the squares (there are three of them which are spaced out in the screen, then you trigger different sounds. I was wondering if it is possible to trigger videos instead of sound. Will this be possible. So basically if you hover over the box then a particular video plays till the end of the video. And then stops until you hover over the box again. Im using "hotpoints" as described in the "making things see" book about kinect.
Any help will be appreciated. Thank you.