We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all, I'm trying to set threshold values for individual hotpoints using the code from Making things see as a base for an interactive video installation. I understand some of the code, and I understand I should be able to set individual threshold values for each hotpoint when I create and declare the hotpoint object, but I am confused at how to do this correctly. I will post the main code tabr first, then I will post the hotpoint object tab (which is pretty much line for line from 'Making things see' by Greg Borenstein. TL:DR where do set threshold values for individual hotpoints in this code? and how should it be called, using the void threshold(); function??
//Core hotpoint functionality taken from 'Making Things See' Book
//by Greg Borenstein. Code by Tim Buchanan with help from rob mac.
// NOTES
// Need to figure out a threshhold function for each hotpoint-
//this will allow for an object to be inside a hotpoint without-
//triggering.
//If I have time I would like to implement a GUI, with slider -
// bars for intuative hotpoint sizing.
import processing.opengl.*;
import SimpleOpenNI.*;
import processing.video.*;
//import ddf.minim.*;
SimpleOpenNI kinect;
float rotation = 0;
String nowPlaying = "";
// declare movie objects
Movie ExGF_Video;
Movie FirstMemory_Video;
Movie Loop_Video;
Movie Housemates_Video;
Movie ParentsDivorce_Video;
Movie Scotland_Video;
Movie Sequence11_Video;
Movie Teacher_Video;
Movie Tom_Video;
Movie VandA_Video;
// declare hotpoint objects -
Hotpoint ExGF_Trigger;
Hotpoint FirstMemory_Trigger;
Hotpoint Housemates_Trigger;
Hotpoint ParentsDivorce_Trigger;
Hotpoint Scotland_Trigger;
Hotpoint Sequence11_Trigger;
Hotpoint Teacher_Trigger;
Hotpoint Tom_Trigger;
Hotpoint VandA_Trigger;
float s = 1;
void setup() {
size(1280, 720, OPENGL);
background (0);
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
//setup video file
ExGF_Video = new Movie(this, "ExGF720.mp4");
FirstMemory_Video = new Movie(this, "FirstMemory720.mp4");
Loop_Video = new Movie(this, "loop720.mp4");
Housemates_Video = new Movie(this, "Housemates720.mp4");
ParentsDivorce_Video = new Movie(this, "parentsdivorce720.mp4");
Scotland_Video = new Movie(this, "Scotland720.mp4");
Sequence11_Video = new Movie(this, "Sequence11720.mp4");
Teacher_Video = new Movie(this, "Teacher720.mp4");
Tom_Video = new Movie(this, "Tom720.mp4");
VandA_Video = new Movie(this, "V&A720.mp4");
//---------------------------------------------------------
// initialize hotpoints with their origins (x,y,z) and their size
// This is where changes to cube position is to be made.
ExGF_Trigger = new Hotpoint(300, 0, 600, 50);
FirstMemory_Trigger = new Hotpoint(230, 0, 600, 50);
Housemates_Trigger = new Hotpoint(160, 0, 600, 50);
ParentsDivorce_Trigger = new Hotpoint(90, 0, 600, 50);
Scotland_Trigger = new Hotpoint(20, 0, 600, 50);
Sequence11_Trigger = new Hotpoint(-50, 0, 600, 50);
Teacher_Trigger = new Hotpoint(-120, 0, 600, 50);
Tom_Trigger = new Hotpoint(-190, 0, 600, 50);
VandA_Trigger = new Hotpoint(-260, 0, 600, 50);
//-----------------------------------------------------------
}
void draw() {
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//begining of mass if statments
if (nowPlaying =="pointCloud") {
background(0);
// println("c is pressed");
translate(width/2, height/2, -1000);
rotateX(radians(180));
translate(0, 0, 1400);
rotateY(radians(map(mouseX, 0, width, -180, 180)));
translate(0, 0, s*-1000);
scale(s);
stroke (255);
}
if (nowPlaying == "ExGF") {
image(ExGF_Video, 0, 0);
} else if (nowPlaying == "FirstMemory") {
image(FirstMemory_Video, 0, 0);
} else if (nowPlaying == "Housemates") {
image(Housemates_Video, 0, 0);
} else if (nowPlaying == "ParentsDivorce") {
image(ParentsDivorce_Video, 0, 0);
} else if (nowPlaying == "Scotland") {
image(Scotland_Video, 0, 0);
} else if (nowPlaying == "Sequence11") {
image(Sequence11_Video, 0, 0);
} else if (nowPlaying == "Teacher") {
image(Teacher_Video, 0, 0);
} else if (nowPlaying == "Tom") {
image(Tom_Video, 0, 0);
} else if (nowPlaying == "V&A") {
image(VandA_Video, 0, 0);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
kinect.update();
// here is where I need to implement a hotpoint viewing mode
stroke(255);
PVector[] depthPoints = kinect.depthMapRealWorld();
for (int i = 0; i < depthPoints.length; i+=5) {
PVector currentPoint = depthPoints[i];
// have each hotpoint check to see if it includes the currentPoint
ExGF_Trigger.check(currentPoint);
FirstMemory_Trigger.check(currentPoint);
Housemates_Trigger.check(currentPoint);
ParentsDivorce_Trigger.check(currentPoint);
Scotland_Trigger.check(currentPoint);
Sequence11_Trigger.check(currentPoint);
Teacher_Trigger.check(currentPoint);
Tom_Trigger.check(currentPoint);
VandA_Trigger.check(currentPoint);
point(currentPoint.x, currentPoint.y, currentPoint.z);
}
//println(ExGF_Trigger.pointsIncluded);
// Defining what happens when each hotpoint is hit
if (ExGF_Trigger.isHit()) {
nowPlaying = "ExGF";
stopVids();
ExGF_Video.play();
}
if (FirstMemory_Trigger.isHit()) {
nowPlaying = "FirstMemory";
stopVids();
FirstMemory_Video.play();
}
if (Housemates_Trigger.isHit()) {
nowPlaying = "Housemates";
stopVids();
Housemates_Video.play();
}
if (ParentsDivorce_Trigger.isHit()) {
nowPlaying = "ParentsDivorce";
stopVids();
ParentsDivorce_Video.play();
}
if (Scotland_Trigger.isHit()) {
nowPlaying = "Scotland";
stopVids();
Scotland_Video.play();
}
if (Sequence11_Trigger.isHit()) {
nowPlaying = "Sequence11";
stopVids();
Sequence11_Video.play();
}
if (Teacher_Trigger.isHit()) {
nowPlaying = "Teacher";
stopVids();
Teacher_Video.play();
}
if (Tom_Trigger.isHit()) {
nowPlaying = "Tom";
stopVids();
Tom_Video.play();
}
if (VandA_Trigger.isHit()) {
nowPlaying = "VA&";
stopVids();
VandA_Video.play();
}
// display each hotpoint and clear its points
ExGF_Trigger.draw();
ExGF_Trigger.clear();
FirstMemory_Trigger.draw();
FirstMemory_Trigger.clear();
Housemates_Trigger.draw();
Housemates_Trigger.clear();
ParentsDivorce_Trigger.draw();
ParentsDivorce_Trigger.clear();
Scotland_Trigger.draw();
Scotland_Trigger.clear();
Sequence11_Trigger.draw();
Sequence11_Trigger.clear();
Teacher_Trigger.draw();
Teacher_Trigger.clear();
Tom_Trigger.draw();
Tom_Trigger.clear();
VandA_Trigger.draw();
VandA_Trigger.clear();
}
void keyPressed() {
if (keyCode == 38) {
s = s + 0.01;
}
if (keyCode == 40) {
s = s - 0.01;
}
if (key == 'c' || key == 'C') {
FirstMemory_Video.stop();
ExGF_Video.stop();
Housemates_Video.stop();
ParentsDivorce_Video.stop();
Scotland_Video.stop();
Sequence11_Video.stop();
Teacher_Video.stop();
Tom_Video.stop();
VandA_Video.stop();
Loop_Video.stop();
nowPlaying = "pointCloud";
}
}
void movieEvent(Movie m) {
if (nowPlaying == "ExGF") {
ExGF_Video.read();
} else if (nowPlaying == "FirstMemory") {
FirstMemory_Video.read();
} else if (nowPlaying == "Housemates") {
Housemates_Video.read();
} else if (nowPlaying == "ParentsDivorce") {
ParentsDivorce_Video.read();
} else if (nowPlaying == "Scotland") {
Scotland_Video.read();
} else if (nowPlaying == "Sequence11") {
Sequence11_Video.read();
} else if (nowPlaying == "Teacher") {
Teacher_Video.read();
} else if (nowPlaying == "Tom") {
Tom_Video.read();
} else if (nowPlaying == "V&A") {
VandA_Video.read();
} else if (nowPlaying == "Loop") {
Loop_Video.read();
}
}
void stopVids() {
if (nowPlaying == "ExGF") {
FirstMemory_Video.stop();
Housemates_Video.stop();
ParentsDivorce_Video.stop();
Scotland_Video.stop();
Sequence11_Video.stop();
Teacher_Video.stop();
Tom_Video.stop();
VandA_Video.stop();
Loop_Video.stop();
} else if (nowPlaying == "FirstMemory") {
ExGF_Video.stop();
Housemates_Video.stop();
ParentsDivorce_Video.stop();
Scotland_Video.stop();
Sequence11_Video.stop();
Teacher_Video.stop();
Tom_Video.stop();
VandA_Video.stop();
Loop_Video.stop();
} else if (nowPlaying == "Housemates") {
ExGF_Video.stop();
FirstMemory_Video.stop();
ParentsDivorce_Video.stop();
Scotland_Video.stop();
Sequence11_Video.stop();
Teacher_Video.stop();
Tom_Video.stop();
VandA_Video.stop();
Loop_Video.stop();
} else if (nowPlaying == "ParentsDivorce") {
ExGF_Video.stop();
Housemates_Video.stop();
FirstMemory_Video.stop();
Scotland_Video.stop();
Sequence11_Video.stop();
Teacher_Video.stop();
Tom_Video.stop();
VandA_Video.stop();
Loop_Video.stop();
} else if (nowPlaying == "Scotland") {
ExGF_Video.stop();
Housemates_Video.stop();
ParentsDivorce_Video.stop();
FirstMemory_Video.stop();
Sequence11_Video.stop();
Teacher_Video.stop();
Tom_Video.stop();
VandA_Video.stop();
Loop_Video.stop();
} else if (nowPlaying == "Sequence11") {
ExGF_Video.stop();
Housemates_Video.stop();
ParentsDivorce_Video.stop();
Scotland_Video.stop();
FirstMemory_Video.stop();
Teacher_Video.stop();
Tom_Video.stop();
VandA_Video.stop();
Loop_Video.stop();
} else if (nowPlaying == "Teacher") {
ExGF_Video.stop();
Housemates_Video.stop();
ParentsDivorce_Video.stop();
Scotland_Video.stop();
Sequence11_Video.stop();
FirstMemory_Video.stop();
Tom_Video.stop();
VandA_Video.stop();
Loop_Video.stop();
} else if (nowPlaying == "Tom") {
ExGF_Video.stop();
Housemates_Video.stop();
ParentsDivorce_Video.stop();
Scotland_Video.stop();
Sequence11_Video.stop();
Teacher_Video.stop();
FirstMemory_Video.stop();
VandA_Video.stop();
Loop_Video.stop();
} else if (nowPlaying == "V&A") {
ExGF_Video.stop();
Housemates_Video.stop();
ParentsDivorce_Video.stop();
Scotland_Video.stop();
Sequence11_Video.stop();
Teacher_Video.stop();
Tom_Video.stop();
FirstMemory_Video.stop();
Loop_Video.stop();
} else if (nowPlaying == "Loop") {
FirstMemory_Video.stop();
ExGF_Video.stop();
Housemates_Video.stop();
ParentsDivorce_Video.stop();
Scotland_Video.stop();
Sequence11_Video.stop();
Teacher_Video.stop();
Tom_Video.stop();
VandA_Video.stop();
}
}
Answers
HOTPOINT TAB