GMU:Tutorials/Visual Interaction: Difference between revisions

From Medien Wiki
(Blanked the page)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''
== How to control Unity with Max/Msp ==
''' <br>
In this tutorial, you will get the basic ideas of interactive connection between Unity and Max/Msp, using open sound control (OSC).<br>
You will try to control noise deformation intensity of a mesh object as an example.
<br>
<br>
There are some materials you need to test this tutorial.
<br>
Please download and install following plugins before you start;
<br>
<br>
-OSC plugins for Unity<br>
[[Media:OSC_Plugins_for_Unity.zip|OSC_Plugins_for_Unity.zip]]<br>
<br>
-OSC plugins for Max/Msp<br>
http://cnmat.berkeley.edu/patch/4029<br>
<br>
-Perlin noise plugin for Unity<br>
[[Media:PerlinNoise.zip|PerlinNoise.zip]]<br>
<br>
-Scripts for Unity<br>
[[Media:UnityNoise_Scripts.zip|UnityNoise_Scripts.zip]]


== Make a OSC bridge on Max/Msp ==
In this section, you will make a OSC sender part on Max/Msp.
<br>
<br>
1.Open a new patcher from top menu bar. You can also make a new patcher with shortcuts "command" + "K".
<br>
<br>
2.Press "F" key to make a number box for float. This will be the input of the noise contoroller.
<br>
<br>
3.Press "M" key to make a message node and type '''"/test $1"''' and connect with the number box.<br>
'''"/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.<br>
Also, '''"$1"''' is required to import external value.
<br>
<br>
4.Press "B" to make a bang node and press "N" and type "OpenSoundControl".
<br>
<br>
5.Press "N" and type '''"udpsend 127.0.0.1 2222"'''.<br>
'''"127.0.0.1"''' is a IP address, which is used to test this setup '''internally'''.<br>
If you try this tutorial with multiple computers, '''check the IP address of a computer for Unity project.'''<br>
"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'''.
<br>
<br>
6.Connect nodes together like the picture below;<br>
[[File:MaxMsp 01_06.png|thumb|500px|left]]
<br>
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.
<br>
<br>
1.Open Unity and make a new project folder.<br>
You will see the window like this picture;<br>
[[File:Unity 02_01.png|thumb|500px|left]]
<br>
Click the "NEW" icon on the top right of the window to make a new project folder.<br>
Then you can name the project folder and define the place you make.<br>
[[File:Unity 02_02.png|thumb|500px|left]]
<br>
Make sure that you are selecting '''"3D"''' mode. If you are selecting, its color is red.
<br>
<br>
2.Create "Empty" game object from the create button on the "Hierarchy" tab, which is top left on the window.<br>
[[File:Unity 02_04.png|thumb|500px|left]]
<br>
Then, right click created game object and rename it "OSC Receiver".<br>
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  [[#References|References]] part.
<br>
<br>
4. Click "OSC Receiver" game object. The detailed information about this game object appears on the "Inspector" tab on the right side of the window. Drug and drop"Osc.cs", "Udp.cs" and "OSCReceiver.js" on it.<br>
[[File:Unity 02_11.png|thumb|500px|left]]
5. If you try this tutorial on your computer internally, make sure that "OSC Receiver" script uses '''the same IP address''' and '''port name on "Listener Port"'''.<br>
If you try it with multiple computers, modify parameters of "OSC Receiver" script on the Inspector tab.<br>
== Prepare a noise animation script on Unity ==
At last, you will make animated object.
<br>
<br>
1.Drag and drop '''"NoiseDeform.js"''' script, which is included in the [[Media:UnityNoise_Scripts.zip|UnityNoise_Scripts.zip]], on the '''"Scripts" folder''' on the "Project" tab.<br>
Also, drag and drop the perlin noise plugin '''"Perlin.cs"''' on the '''"Plugins" folder'''.
<br>
<br>
2.Create a sphere. Normally the default size of the sphere is too small when it's seen from the default camera position, so you can make it bigger by pressing "R" key and drag the center cube of the gizmo.
== References ==
You can downloaded finished sample project files from this link;
<br>
<br>
Max patch<br>
[[Media:NoiseController.maxpat.zip|NoiseController.maxpat.zip]]
<br>
<br>
Unity Project<br>
[[Media:PerlinNoiseDeformation.zip|PerlinNoiseDeformation.zip]]
<br>
<br>
There is detailed description about special folder name on Unity project.<br>
https://docs.unity3d.com/Manual/SpecialFolders.html

Latest revision as of 18:47, 30 July 2016