34
edits
m (→Example: Make an object jump on clapping: formatting) |
m (→Processing: formatting) |
||
Line 20: | Line 20: | ||
== Processing == | == Processing == | ||
In Processing you need to install a library. Click on ''Tools'' – ''Add Tools'' – Choose ''Libraries'' – Search for oscP5 and install it.<br><br> | In Processing you need to install a library. Click on ''Tools'' – ''Add Tools'' – Choose ''Libraries'' – Search for oscP5 and install it.<br><br> | ||
This is the basic processing script for sending Osc data (it just sets up the connection, actions can be added): <br>< | This is the basic processing script for sending Osc data (it just sets up the connection, actions can be added): <br> | ||
//load libraries | <source lang="javascript"> | ||
import netP5.*; | //load libraries | ||
import oscP5.*; | import netP5.*; | ||
OscP5 oscP5; | import oscP5.*; | ||
NetAddress myRemoteLovation; | |||
//make a connection | OscP5 oscP5; | ||
void setup () { | NetAddress myRemoteLovation; | ||
osP5 = new OscP5 (this, 9000); | |||
myRemoteLocation = new NetAddress("127.0.0.1", 9000); | //make a connection | ||
} | void setup () { | ||
// this is where you can make things happen and send values to Unity | osP5 = new OscP5 (this, 9000); | ||
void draw () { | myRemoteLocation = new NetAddress("127.0.0.1", 9000); | ||
OscMessage myMessage = new OscMessage ("/"); | } | ||
// add a value to the message (optional) | |||
myMessage.add(somevalue); | // this is where you can make things happen and send values to Unity | ||
// add a bool to the message (optional) | void draw () { | ||
myMessage.add(true); | OscMessage myMessage = new OscMessage ("/"); | ||
oscP5.send(myMessage, myRemoteLocation); | // add a value to the message (optional) | ||
} | myMessage.add(somevalue); | ||
// this is where you get feedback in Processing | // add a bool to the message (optional) | ||
void oscEvent (OscMessage theOscMessage) { | myMessage.add(true); | ||
print("### received an osc message."); | oscP5.send(myMessage, myRemoteLocation); | ||
print(" addrpattern: "+theOscMessage.addrPattern()); | } | ||
println(" typetag: "+theOscMessage.typetag()); | |||
println("### received an osc message. with address pattern"+theOscMessage.addrPattern()+" typetag | // this is where you get feedback in Processing | ||
}</ | void oscEvent (OscMessage theOscMessage) { | ||
print("### received an osc message."); | |||
print(" addrpattern: "+theOscMessage.addrPattern()); | |||
println(" typetag: "+theOscMessage.typetag()); | |||
println("### received an osc message. with address | |||
pattern"+theOscMessage.addrPattern()+" typetag | |||
+theOscMessage.typetag()); | |||
} | |||
</source> | |||
== Unity == | == Unity == | ||
With just a little help from Google (or bing if you’re one of those people) you can find one of these Osc Receiver Scripts. You will also need scripts for [https://github.com/heaversm/unity-osc-receiver/tree/master/Assets/Plugins Osc and Udp]. | With just a little help from Google (or bing if you’re one of those people) you can find one of these Osc Receiver Scripts. You will also need scripts for [https://github.com/heaversm/unity-osc-receiver/tree/master/Assets/Plugins Osc and Udp]. |
edits