code on processing
import netP5.*;
import oscP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
NetAddress myRemoteLocation2;
NetAddress testmyRemoteLocation3;
void setup () {
size(600,600);
background(0);
oscP5 = new OscP5(this,8888); // <<<<<<<<<<<<Port number
/* you must find your UUID and match it below */
//oscP5.plug(this, "Controller1AccelGyro", "/Controller1AccelGyro");
oscP5.plug(this, "Controller1Btn", "/Controller1Btn");
oscP5.plug(this, "ControllerJoystickandAccelerometer", "/Controller1AccelGyroJoyStick");
oscP5.plug(this, "ControllerJoystick", "/Controller1Joystick");
oscP5.plug(this, "WekiJoystickRotateRight", "/wekiJoystickRotate-1_1");
oscP5.plug(this, "WekiJoystickRotateLeft", "/wekiJoystickRotate-1_2");
oscP5.plug(this, "SwitchBoard", "/SwitchController");
oscP5.plug(this, "SwitchBoard2", "/SwitchController2");
//Wekinator Port is 7777
//Unity Port is 9999
//This Port is 8888
myRemoteLocation = new NetAddress("192,168,236,159",9999);
myRemoteLocation2 = new NetAddress("192,168,236,159",7777);
testmyRemoteLocation3 = new NetAddress("192,168,236,118",5555);
}
void draw() {
}
// accepts controller button values and sends them to unity
void Controller1Btn (int x) {
OscMessage myMessage = new OscMessage("/UnityController1Btn");
int ButtonPressed = x;
//println(ButtonPressed);
myMessage.add(ButtonPressed);
oscP5.send(myMessage, myRemoteLocation);
}
//accepts joystick and Accelrometer values and sends them to wekinator
void ControllerJoystickandAccelerometer (float gForceX, float gForceY, float gForceZ, float rotX, float rotY, float rotZ, int Jx, int Jy, int Js) {
OscMessage myMessage3 = new OscMessage("/WekiControllerJoyStick");
float wekiJx = map(Jx, 0, 4095, 0, 1);
float wekiJy = map(Jy, 0, 4095, 0, 1);
float wekiJs = map(Js, 0, 4095, 0, 1);
myMessage3.add(wekiJx);
myMessage3.add(wekiJy);
myMessage3.add(wekiJs);
//println(wekiJx);
oscP5.send(myMessage3, myRemoteLocation2);
}
void ControllerJoystick (int x) {
OscMessage myMessage4 = new OscMessage("/WekiControllerJoyStick2");
float wekiJDirection = map(x, 0, 9, 0, 1);
myMessage4.add(wekiJDirection);
oscP5.send(myMessage4, myRemoteLocation2);
//println(wekiJDirection);
}
void WekiJoystickRotateRight () {
OscMessage myMessage5 = new OscMessage("/unity/PanRotateRight");
float x = 1.0f;
myMessage5.add(x);
oscP5.send(myMessage5, myRemoteLocation);
println("RotateRight");
}
void WekiJoystickRotateLeft () {
OscMessage myMessage5 = new OscMessage("/unity/PanRotateLeft");
float x = 2.0f;
myMessage5.add(x);
oscP5.send(myMessage5, myRemoteLocation);
println("RotateLeft");
}
// accepts switchboard values and sends them over to unity
void SwitchBoard (int x, int y) {
OscMessage myMessage2 = new OscMessage("/UnitySwitchBoard");
int SwitchPath = x;
int SwitchNumber = y;
println("SwitchPath" + SwitchPath);
myMessage2.add(SwitchPath);
myMessage2.add(SwitchNumber);
oscP5.send(myMessage2, myRemoteLocation);
}
// this is the function meant to send the osc messages back to the esp 32
void SwitchBoard2 (int x, int y) {
OscMessage myMessage2 = new OscMessage("/UnitySwitchBoard");
int SwitchPath = x;
int SwitchNumber = y;
println("SwitchPath" + SwitchPath);
myMessage2.add(SwitchPath);
myMessage2.add(SwitchNumber);
//oscP5.send(myMessage2, myRemoteLocation);
oscP5.send(myMessage2, testmyRemoteLocation3);
}