Created
January 18, 2017 09:39
-
-
Save JuliusVerne/09a7bf38c6098dc21f2db9386a37d1a4 to your computer and use it in GitHub Desktop.
Simple Processing 3 example patch for controlling Z Vector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This is a simple example for controlling Z Vector (https://z-vector.com) from Processing */ | |
/* Built in Processing 3*/ | |
import oscP5.*; // import the oscP5 libraries by Andreas Schlegel, available for download at http://www.sojamo.de/libraries/oscp5/ | |
import netP5.*; | |
OscP5 oscP5; | |
NetAddress myBroadcastLocation; | |
void setup() { | |
size(640, 360); | |
noStroke(); | |
oscP5 = new OscP5(this,12000); // set the address of the OSC server sending the messages (this program) | |
myBroadcastLocation = new NetAddress("127.0.0.1",7000); // set the target OSC server receiving the messages (Z Vector on default port) | |
} | |
void draw() { | |
background(255); | |
if (mouseX < height) { // make a square box for the X/Y controller on the left side of the UI | |
if (mousePressed == true) { | |
fill(63); | |
ellipse(mouseX, mouseY, 20, 20); | |
float xValue = (float) mouseX/height; | |
float yValue = (float) mouseY/height; | |
OscMessage xOscMessage = new OscMessage("/Z Vector/trail_wind"); // define the OSC path for the message | |
xOscMessage.add(xValue); // add mouse X position to the message, for this path Z Vector is expecting a float | |
oscP5.send(xOscMessage, myBroadcastLocation); // send the OSC message to the target server | |
OscMessage yOscMessage = new OscMessage("/Z Vector/trail_gravity"); // define the OSC path for the message | |
yOscMessage.add(yValue); // add mouse Y position to the message, for this path Z Vector is expecting a float | |
oscP5.send(yOscMessage, myBroadcastLocation); // send the OSC message to the target server | |
} else { | |
fill(127); | |
ellipse(mouseX, mouseY, 20, 20); | |
} | |
} | |
fill(127); | |
rect(height, 0, height, height); // draw a simple rectangle (button) on the right side of the UI | |
if ((mouseX > height) && (mousePressed == true)) { // when the mouse is on the right side of the UI and the button is pressed | |
fill(63); | |
rect(height, 0, height, height); // draw over the existing rectangle (button) on the right side of the UI | |
OscMessage xOscMessage = new OscMessage("/Z Vector/profile_revert_and_randomize_10"); // define the OSC path for the message | |
xOscMessage.add(1); // add a value to the message, for this path Z Vector is expecting boolean | |
oscP5.send(xOscMessage, myBroadcastLocation); // send the OSC message to the target server | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment