Skip to content

Instantly share code, notes, and snippets.

@mrichardson23
Created February 10, 2012 18:07
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 mrichardson23/1791336 to your computer and use it in GitHub Desktop.
Save mrichardson23/1791336 to your computer and use it in GitHub Desktop.
FaceOSC and Processing for Faux 3D Effects
import oscP5.*; OscP5 oscP5;
float posePositionX;
float posePositionY;
float poseScale;
PImage interior;
PImage exterior;
void setup() {
size(1000,667);
oscP5 = new OscP5(this, 8338);
oscP5.plug(this, "posePosition", "/pose/position");
oscP5.plug(this, "poseScale", "/pose/scale");
interior = loadImage("interior.png");
exterior = loadImage("exterior.jpg");
imageMode(CENTER);
}
void draw() {
float exteriorScale = map(poseScale, 6, 2, 1, 1.1);
float interiorScale = map(poseScale, 6, 2, 1.5, 1);
float exteriorImagePosX = map(posePositionX, 60, 586, 50, -50) + width/2;
float exteriorImagePosY = 30 - map(posePositionY, 60, 370, 50,-50) + height/2;
image(exterior, exteriorImagePosX, exteriorImagePosY, exterior.width * exteriorScale, exterior.height * exteriorScale);
image(interior, width/2, height/2, interior.width * interiorScale, interior.height * interiorScale);
}
public void posePosition(float x, float y) {
println("pose position\tX: " + x + " Y: " + y );
posePositionX = x;
posePositionY = y;
}
public void poseScale(float s) {
println("scale: " + s);
poseScale = s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment