Skip to content

Instantly share code, notes, and snippets.

@daniah
Created November 17, 2014 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniah/b523da76ff2dad6b6600 to your computer and use it in GitHub Desktop.
Save daniah/b523da76ff2dad6b6600 to your computer and use it in GitHub Desktop.
Water Park_Daniah
//Processing:
import oscP5.*;
OscP5 oscP5;
import processing.video.*;
Movie myMovie;
import codeanticode.syphon.*;
SyphonServer server;
PVector posePosition = new PVector();
PVector poseOrientation = new PVector();
//PImage tree;
PImage circle;
float c;
float y1;
float mouthHeight;
float mouthWidth;
float eyeLeft;
float eyeRight;
float eyebrowLeft;
float eyebrowRight;
float jaw;
float nostrils;
float poseScale;
void setup() {
size(displayWidth, displayHeight, P2D);
// tree = loadImage("trees.jpg");
circle = loadImage("circle2.png");
myMovie = new Movie(this, "water.mp4");
myMovie.loop();
c = 1;
noCursor();
server = new SyphonServer(this, "Processing Syphon");
oscP5 = new OscP5(this, 8338);
oscP5.plug(this, "found", "/found");
oscP5.plug(this, "poseScale", "/pose/scale");
oscP5.plug(this, "posePosition", "/pose/position");
oscP5.plug(this, "poseOrientation", "/pose/orientation");
oscP5.plug(this, "mouthWidthReceived", "/gesture/mouth/width");
oscP5.plug(this, "mouthHeightReceived", "/gesture/mouth/height");
oscP5.plug(this, "eyeLeftReceived", "/gesture/eye/left");
oscP5.plug(this, "eyeRightReceived", "/gesture/eye/right");
oscP5.plug(this, "eyebrowLeftReceived", "/gesture/eyebrow/left");
oscP5.plug(this, "eyebrowRightReceived", "/gesture/eyebrow/right");
oscP5.plug(this, "jawReceived", "/gesture/jaw");
oscP5.plug(this, "nostrilsReceived", "/gesture/nostrils");
}
void draw() {
// image(tree, 0, 0);
image(myMovie, 0, 0);
if (keyPressed && key == '1') {
c+=0.008;
}
if (keyPressed && key =='2') {
c-=0.008;
}
scale(poseScale/1.5);
// rotate ( poseOrientation.z * -1 +.08);
image(circle, -700-posePosition.x*1.5, -1000+posePosition.y*1.5);
println(posePosition.x, posePosition.y);
server.sendScreen();
}
void movieEvent(Movie m) {
m.read();
}
public void poseScale(float s) {
println("scale: " + s);
poseScale = s;
}
public void posePosition(float x, float y) {
println("pose position\tX: " + x + " Y: " + y + " Y1: " + y1 );
posePosition.set(x, y, 0);
}
public void poseOrientation(float x, float y, float z) {
println("pose orientation\tX: " + x + " Y: " + y + " Z: " + z);
poseOrientation.set(x, y, z);
}
public void mouthWidthReceived(float w) {
println("mouth Width: " + w);
mouthWidth = w;
}
public void mouthHeightReceived(float h) {
println("mouth height: " + h);
mouthHeight = h;
}
public void eyeLeftReceived(float f) {
println("eye left: " + f);
eyeLeft = f;
}
public void eyeRightReceived(float f) {
println("eye right: " + f);
eyeRight = f;
}
public void eyebrowLeftReceived(float f) {
println("eyebrow left: " + f);
eyebrowLeft = f;
}
public void eyebrowRightReceived(float f) {
println("eyebrow right: " + f);
eyebrowRight = f;
}
public void jawReceived(float f) {
println("jaw: " + f);
jaw = f;
}
public void nostrilsReceived(float f) {
println("nostrils: " + f);
nostrils = f;
}
// all other OSC messages end up here
void oscEvent(OscMessage m) {
if (m.isPlugged() == false) {
println("UNPLUGGED: " + m);
}
}
//Arduino:
float brightness = 0;
void setup()
{
Serial.begin(9600);// open serial port, set the baud rate to 9600 bps
pinMode(9,OUTPUT);
}
void loop()
{
int sensorValue;
sensorValue = analogRead(A0); //connect Steam sensors to Analog 0
Serial.println(sensorValue); //print the value to serial
delay(50);
analogWrite(9,brightness);
if(sensorValue>200)
{
brightness = map(sensorValue,200,1000,0,255);}
Serial.println(brightness);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment