GMU:Tutorials/Visual Interaction: Difference between revisions

From Medien Wiki
Line 170: Line 170:


Then, right click created game object and rename it "OSC Receiver".<br>
Then, right click created game object and rename it "OSC Receiver".<br>
In this tutorial, all scripts related OSC
In this tutorial, all scripts related to OSC will be attached on this game object.<br>
<br>
3.Right click on the "Project" tab on the bottom left of the window.<br>
Create 2 folders and name them "Scripts" and "Plugins".<br>
[[File:Unity 02_06.png|thumb|500px|left]]<br>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Then, drug and drop downloaded Unity plugins named '''"Osc.cs", "Udp.cs", "Perlin.cs" to "Plugins" folder.'''<br>
Also, you drug and drop Unity scripts called '''"OSCReceiver.js" to "Scripts" folder.'''<br>
In Unity, there are some special folder name for specific types of objects.<br>
You can find detailed information on [[Reference]] part.


== Prepare a noise animation script on Unity ==  
== Prepare a noise animation script on Unity ==  

Revision as of 07:22, 30 July 2016

How to control Unity with Max/Msp


In this tutorial, you will get the basic ideas of interactive connection between Unity and Max/Msp, using open sound control (OSC).
You will try to control noise deformation intensity of a mesh object as an example.

There are some materials you need to test this tutorial.
Please download and install following plugins before you start;

-OSC plugins for Unity
Media:OSC_Plugins_for_Unity.zip

-OSC plugins for Max/Msp
http://cnmat.berkeley.edu/patch/4029

-Perlin noise plugin for Unity
Media:PerlinNoise.zip

-Scripts for Unity
Media:UnityNoise_Scripts.zip

Make a OSC bridge on Max/Msp

In this section, you will make a OSC sender part on Max/Msp.

1.Open a new patcher from top menu bar. You can also make a new patcher with shortcuts "command" + "K".

2.Press "F" key to make a number box for float. This will be the input of the noise contoroller.

3.Press "M" key to make a message node and type "/test $1" and connect with the number box.
"/test" is an identifier of the osc message. You can rename whatever you want, but you should pay attention not to forget "/" before the name of identifier.
Also, "$1" is required to import external value.

4.Press "B" to make a bang node and press "N" and type "OpenSoundControl".

5.Press "N" and type "udpsend 127.0.0.1 2222".
"127.0.0.1" is a IP address, which is used to test this setup internally.
If you try this tutorial with multiple computers, check the IP address of a computer for Unity project.
"2222" is a name of port. You can define any integer, but make sure that you are using the same port number for Max patch and Unity.

6.Connect nodes together like the picture below;

MaxMsp 01 06.png
















7. Then, lock the patcher with "command"+ "E". Now you are ready to run the "sender" part.

Make a OSC bridge on Unity

In this section, you will make OSC receiver part on Unity.

1.Open Unity and make a new project folder.
You will see the window like this picture;

Unity 02 01.png













Click the "NEW" icon on the top right of the window to make a new project folder.
Then you can name the project folder and define the place you make.

Unity 02 02.png













Make sure that you are selecting "3D" mode. If you are selecting, its color is red.

2.Create "Empty" game object from the create button on the "Hierarchy" tab, which is top left on the window.

Unity 02 04.png













Then, right click created game object and rename it "OSC Receiver".
In this tutorial, all scripts related to OSC will be attached on this game object.

3.Right click on the "Project" tab on the bottom left of the window.
Create 2 folders and name them "Scripts" and "Plugins".

Unity 02 06.png













Then, drug and drop downloaded Unity plugins named "Osc.cs", "Udp.cs", "Perlin.cs" to "Plugins" folder.
Also, you drug and drop Unity scripts called "OSCReceiver.js" to "Scripts" folder.
In Unity, there are some special folder name for specific types of objects.
You can find detailed information on Reference part.

Prepare a noise animation script on Unity

In this section, you will develop the object which you animate with OSC signals.

References

You can downloaded finished sample project files from this link;

Max patch
Media:NoiseController.maxpat.zip

Unity Project
Media:PerlinNoiseDeformation.zip