├── Packages └── manifest.json ├── ProjectSettings ├── ProjectVersion.txt ├── TagManager.asset ├── AudioManager.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── TimeManager.asset ├── DynamicsManager.asset ├── EditorSettings.asset ├── NetworkManager.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── QualitySettings.asset ├── GraphicsSettings.asset ├── Physics2DSettings.asset ├── ClusterInputManager.asset ├── EditorBuildSettings.asset └── UnityConnectSettings.asset ├── UnityPackageManager └── manifest.json ├── media └── demo.gif ├── Assets ├── tidal-unity.unity ├── TidalUnity.sln.unity ├── Resources │ ├── CUTSOM PLANE.mat │ ├── thing.physicMaterial │ ├── CUTSOM PLANE.mat.meta │ ├── thing.physicMaterial.meta │ ├── Shaders.meta │ ├── Things.meta │ ├── ImageEffects │ │ ├── Shaders │ │ │ ├── VortexEffect.shader.meta │ │ │ └── VortexEffect.shader │ │ └── Scripts │ │ │ ├── ImageEffectBase.cs.meta │ │ │ ├── Vortex.cs.meta │ │ │ ├── Vortex.cs │ │ │ ├── ImageEffects.cs.meta │ │ │ ├── ImageEffectBase.cs │ │ │ └── ImageEffects.cs │ ├── Shaders │ │ ├── twist.shader.meta │ │ └── twist.shader │ ├── Scripts.meta │ ├── Skyboxes.meta │ ├── ImageEffects.meta │ └── Scripts │ │ ├── Move.cs.meta │ │ └── Move.cs ├── tidal-unity.unity.meta ├── TidalUnity.sln.unity.meta ├── OSC.meta ├── Editor.meta ├── Resources.meta ├── Thing.cs ├── GameEvent.cs.meta ├── Thing.cs.meta ├── OSC │ ├── OSCBundle.cs.meta │ ├── OSCClient.cs.meta │ ├── OSCMessage.cs.meta │ ├── OSCPacket.cs.meta │ ├── OSCServer.cs.meta │ ├── OSCClient.cs │ ├── OSCBundle.cs │ ├── OSCServer.cs │ ├── OSCMessage.cs │ └── OSCPacket.cs ├── OSCController.cs.meta ├── OSCHandler.cs.meta ├── SpringCamera.cs.meta ├── Editor │ ├── OSCHelper.cs.meta │ └── OSCHelper.cs ├── Ripple.cs.meta ├── OSCController.cs ├── Ripple.cs ├── SpringCamera.cs ├── GameEvent.cs └── OSCHandler.cs ├── .gitignore ├── .vscode └── settings.json ├── README.md ├── Module └── UnityOsc.hs └── LICENSE /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2017.3.0f3 2 | -------------------------------------------------------------------------------- /UnityPackageManager/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | } 4 | } 5 | -------------------------------------------------------------------------------- /media/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/media/demo.gif -------------------------------------------------------------------------------- /Assets/tidal-unity.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/Assets/tidal-unity.unity -------------------------------------------------------------------------------- /Assets/TidalUnity.sln.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/Assets/TidalUnity.sln.unity -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /Assets/Resources/CUTSOM PLANE.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/Assets/Resources/CUTSOM PLANE.mat -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /Assets/Resources/thing.physicMaterial: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/Assets/Resources/thing.physicMaterial -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/PresetManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moxuse/tidal-unity/HEAD/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /Assets/tidal-unity.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f46d4bdd47a2949939e0aeefdd6bcaf6 3 | timeCreated: 1497677861 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TidalUnity.sln.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be51aa80632c2422696684ea424b588f 3 | timeCreated: 1483592229 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/OSC.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bcb8056e08fe24e44a24da996ec27d3f 3 | folderAsset: yes 4 | timeCreated: 1483586166 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Resources/CUTSOM PLANE.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b914507b80f0a4124bd8c0f342b95848 3 | timeCreated: 1483674087 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4df1a5583bb2c4e859501976f7f6dddd 3 | folderAsset: yes 4 | timeCreated: 1483586166 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Resources/thing.physicMaterial.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 213a4d32e250349a4bbb96c99d91f5dd 3 | timeCreated: 1483689103 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 542820e6f73324cc7afa681f0b5fd6c1 3 | folderAsset: yes 4 | timeCreated: 1483601789 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Resources/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c1df963099c84c3590935d3ffccf6cc 3 | folderAsset: yes 4 | timeCreated: 1484100913 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Resources/Things.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 270a89a0d04cc4e0e82ee63fa92990a3 3 | folderAsset: yes 4 | timeCreated: 1497534692 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Resources/ImageEffects/Shaders/VortexEffect.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a316bb76d327411abadf3de2de48d13 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Resources/Shaders/twist.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41e4a76e7a1a747f8a719fcf3fb560fd 3 | timeCreated: 1484621746 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Resources/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4abbac53d6da42f3bd65904efe2c671 3 | folderAsset: yes 4 | timeCreated: 1525848140 5 | licenseType: Free 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Resources/Skyboxes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4cfde08efde8b444d9828124bb7c51b9 3 | folderAsset: yes 4 | timeCreated: 1525759742 5 | licenseType: Free 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Resources/ImageEffects.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8d5862fea5c74e49a1f3d9231987b34 3 | folderAsset: yes 4 | timeCreated: 1511947124 5 | licenseType: Free 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Thing.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class Thing : MonoBehaviour { 6 | 7 | // Use this for initialization 8 | void Start () { 9 | 10 | } 11 | 12 | // Update is called once per frame 13 | void Update () { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Assets/GameEvent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7482661034fc34c58b99fcce9e924d3b 3 | timeCreated: 1484116817 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Thing.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab078433223a94fb59b15b45cc7ab2b3 3 | timeCreated: 1484116835 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/OSC/OSCBundle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c98da95218d944e658fb86275ef4a37a 3 | timeCreated: 1483586166 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/OSC/OSCClient.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0b74727f619aa4b949c62cc9054992ab 3 | timeCreated: 1483586166 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/OSC/OSCMessage.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6172bd17f06e74f6b831efbff2da8dea 3 | timeCreated: 1483586166 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/OSC/OSCPacket.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6bac95caee724076a9a21444dd20f8a 3 | timeCreated: 1483586166 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/OSC/OSCServer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ce9f473d613d45a99f9998fff1228ab 3 | timeCreated: 1483586166 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/OSCController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd556b13bb0e940ffa9dea9961303dee 3 | timeCreated: 1483586355 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/OSCHandler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e364f9eeb6bc746e6ab27fca132a1069 3 | timeCreated: 1483586166 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SpringCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68710bed6e74b4aa2aacadac7f7b73c4 3 | timeCreated: 1491647241 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Editor/OSCHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da9552f82cb834b49b8f404c44400654 3 | timeCreated: 1483586166 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Resources/ImageEffects/Scripts/ImageEffectBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23d1f6ecd1efa4c0ca17a37c8f01f3e0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Resources/Scripts/Move.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 581af49e2a9d34fa4b7933f5744188f1 3 | timeCreated: 1525847709 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Resources/ImageEffects/Scripts/Vortex.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17ca1befaeb5d4cf8b7099c6ee56807e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - shader: {fileID: 4800000, guid: 708b781cad112c75d0008dfa8d76c639, type: 3} 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Ripple.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e360dcf0141034942b0865c8a6bed926 3 | timeCreated: 1517902459 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: 9 | - shader: {fileID: 4800000, guid: 790cb8f3b370949f4a851dcf16f8a94c, type: 3} 10 | executionOrder: 0 11 | icon: {instanceID: 0} 12 | userData: 13 | assetBundleName: 14 | assetBundleVariant: 15 | -------------------------------------------------------------------------------- /Assets/Resources/Scripts/Move.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class Move : MonoBehaviour { 6 | public Vector3 move = new Vector3(0, 0, 0); 7 | 8 | // Use this for initialization 9 | void Start () { 10 | 11 | } 12 | 13 | // Update is called once per frame 14 | void Update () { 15 | var pos = this.transform.position; 16 | // Debug.Log(pos); 17 | pos.x += move.x; 18 | pos.y += move.y; 19 | pos.z += move.z; 20 | this.transform.position = pos; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Assets/Resources/ImageEffects/Scripts/Vortex.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | [ExecuteInEditMode] 4 | [AddComponentMenu("Image Effects/Displacement/Vortex")] 5 | public class Vortex : ImageEffectBase { 6 | public Vector2 radius = new Vector2(0.4F,0.4F); 7 | public float angle = 50; 8 | public Vector2 center = new Vector2(0.5F, 0.5F); 9 | 10 | // Called by camera to apply image effect 11 | void OnRenderImage (RenderTexture source, RenderTexture destination) { 12 | ImageEffects.RenderDistortion (material, source, destination, angle, center, radius); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | /Assets/Resources/Things 8 | /Assets/Resources/SkyBoxes 9 | 10 | ExportedObj/ 11 | .consulo/ 12 | *.csproj 13 | *.unityproj 14 | *.sln 15 | *.suo 16 | *.tmp 17 | *.user 18 | *.userprefs 19 | *.pidb 20 | *.booproj 21 | *.svd 22 | 23 | 24 | # Unity3D generated meta files 25 | *.pidb.meta 26 | 27 | # Unity3D Generated File On Crash Reports 28 | sysinfo.txt 29 | 30 | # Builds 31 | *.apk 32 | *.unitypackage 33 | 34 | testOscTidal.app 35 | 36 | Assets/Air_Conditioner 37 | Assets/Air_Conditioner.meta 38 | Assets/Resources/ImageEffects/* 39 | Assets/Materials.meta 40 | Assets/Materials/defaultMat.mat 41 | Assets/Materials/defaultMat.mat.meta 42 | Assets/Resources/Shaders/* 43 | Assets/Resources/New\ Physic\ Material.physicMaterial 44 | Assets/Resources/New\ Physic\ Material.physicMaterial.meta 45 | 46 | 47 | *.app 48 | -------------------------------------------------------------------------------- /Assets/Resources/ImageEffects/Scripts/ImageEffects.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 791c0cd7314674bb89d09dc767330b80 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - blitCopyShader: {fileID: 4800000, guid: 3338b5ea2f3cb594698fae65cf060346, type: 3} 8 | - blitMultiplyShader: {fileID: 4800000, guid: 7034c801b78acab448cdcf845f7c352d, 9 | type: 3} 10 | - blitMultiply2XShader: {fileID: 4800000, guid: cde82987e0a884c4788c65f7b54390e8, 11 | type: 3} 12 | - blitAddShader: {fileID: 4800000, guid: c7515f214a63bdb42b6ae6335a00a8a4, type: 3} 13 | - blitAddSmoothShader: {fileID: 4800000, guid: 7741a77a7c455d0418bc429bd508dc87, 14 | type: 3} 15 | - blitBlendShader: {fileID: 4800000, guid: f1cf7e9c98754c4429ff0f7cc1d9dd7b, type: 3} 16 | executionOrder: 0 17 | icon: {instanceID: 0} 18 | userData: 19 | assetBundleName: 20 | assetBundleVariant: 21 | -------------------------------------------------------------------------------- /Assets/Resources/ImageEffects/Scripts/ImageEffectBase.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | [RequireComponent (typeof(Camera))] 4 | [AddComponentMenu("")] 5 | public class ImageEffectBase : MonoBehaviour { 6 | /// Provides a shader property that is set in the inspector 7 | /// and a material instantiated from the shader 8 | public Shader shader; 9 | private Material m_Material; 10 | 11 | protected virtual void Start () 12 | { 13 | // Disable if we don't support image effects 14 | if (!SystemInfo.supportsImageEffects) { 15 | enabled = false; 16 | return; 17 | } 18 | 19 | // Disable the image effect if the shader can't 20 | // run on the users graphics card 21 | if (!shader || !shader.isSupported) 22 | enabled = false; 23 | } 24 | 25 | protected Material material { 26 | get { 27 | if (m_Material == null) { 28 | m_Material = new Material (shader); 29 | m_Material.hideFlags = HideFlags.HideAndDontSave; 30 | } 31 | return m_Material; 32 | } 33 | } 34 | 35 | protected virtual void OnDisable() { 36 | if( m_Material ) { 37 | DestroyImmediate( m_Material ); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Assets/Resources/Shaders/twist.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/Twist" { 2 | Properties { 3 | _Freq ("Freq", Range(0,20)) = 0.0 4 | _Color ("Color", Color) = (1,1,1,1) 5 | _MainTex ("Base (RGB)", 2D) = "white" {} 6 | } 7 | SubShader { 8 | Tags { "RenderType"="Opaque" } 9 | 10 | 11 | CGPROGRAM 12 | // Physically based Standard lighting model, and enable shadows on all light types 13 | #pragma surface surf Lambert vertex:vert 14 | 15 | // Use shader model 3.0 target, to get nicer looking lighting 16 | //#pragma target 3.0 17 | 18 | sampler2D _MainTex; 19 | 20 | struct Input { 21 | float4 color : COLOR; 22 | float2 uv_MainTex; 23 | }; 24 | 25 | float _Freq = 0; 26 | 27 | void vert (inout appdata_full v) { 28 | v.vertex.x += 0.18 * sin(v.normal.y * _Freq); 29 | v.vertex.z += 0.18 * -cos(v.normal.y * _Freq) + 0.2; 30 | //v.vertex.y += 0.18 * sin(v.normal.x * _Freq); 31 | //v.vertex.z += 0.18 * -cos(v.normal.x * _Freq) + 0.2; 32 | } 33 | 34 | void surf (Input IN, inout SurfaceOutput o) { 35 | // Albedo comes from a texture tinted by color 36 | //o.Albedo = half3(1, 1, 1); 37 | // o.Albedo = _Color; 38 | half4 c = tex2D (_MainTex, IN.uv_MainTex); 39 | o.Albedo = c.rgb; 40 | o.Alpha = c.a; 41 | } 42 | ENDCG 43 | } 44 | FallBack "Diffuse" 45 | } 46 | -------------------------------------------------------------------------------- /Assets/Resources/ImageEffects/Scripts/ImageEffects.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | //using System; 3 | 4 | /// A Utility class for performing various image based rendering tasks. 5 | [AddComponentMenu("")] 6 | public class ImageEffects 7 | { 8 | public static void RenderDistortion(Material material, RenderTexture source, RenderTexture destination, float angle, Vector2 center, Vector2 radius) 9 | { 10 | bool invertY = source.texelSize.y < 0.0f; 11 | if (invertY) 12 | { 13 | center.y = 1.0f - center.y; 14 | angle = -angle; 15 | } 16 | 17 | Matrix4x4 rotationMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, angle), Vector3.one); 18 | 19 | material.SetMatrix("_RotationMatrix", rotationMatrix); 20 | material.SetVector("_CenterRadius", new Vector4(center.x, center.y, radius.x, radius.y)); 21 | material.SetFloat("_Angle", angle * Mathf.Deg2Rad); 22 | 23 | Graphics.Blit(source, destination, material); 24 | } 25 | 26 | [System.Obsolete("Use Graphics.Blit(source,dest) instead")] 27 | public static void Blit(RenderTexture source, RenderTexture dest) 28 | { 29 | Graphics.Blit(source, dest); 30 | } 31 | 32 | [System.Obsolete("Use Graphics.Blit(source, destination, material) instead")] 33 | public static void BlitWithMaterial(Material material, RenderTexture source, RenderTexture dest) 34 | { 35 | Graphics.Blit(source, dest, material); 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/Resources/ImageEffects/Shaders/VortexEffect.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Hidden/Twist Effect" { 4 | Properties { 5 | _MainTex ("Base (RGB)", 2D) = "white" {} 6 | } 7 | 8 | SubShader 9 | { 10 | Pass 11 | { 12 | ZTest Always Cull Off ZWrite Off 13 | 14 | CGPROGRAM 15 | #pragma vertex vert 16 | #pragma fragment frag 17 | 18 | #include "UnityCG.cginc" 19 | 20 | uniform sampler2D _MainTex; 21 | 22 | uniform float4 _MainTex_ST; 23 | 24 | uniform float4 _MainTex_TexelSize; 25 | uniform float _Angle; 26 | uniform float4 _CenterRadius; 27 | 28 | struct v2f { 29 | float4 pos : SV_POSITION; 30 | float2 uv : TEXCOORD0; 31 | float2 uvOrig : TEXCOORD1; 32 | }; 33 | 34 | v2f vert (appdata_img v) 35 | { 36 | v2f o; 37 | o.pos = UnityObjectToClipPos(v.vertex); 38 | float2 uv = v.texcoord.xy - _CenterRadius.xy; 39 | o.uv = TRANSFORM_TEX(uv, _MainTex); //MultiplyUV (UNITY_MATRIX_TEXTURE0, uv); 40 | o.uvOrig = uv; 41 | return o; 42 | } 43 | 44 | float4 frag (v2f i) : SV_Target 45 | { 46 | float2 offset = i.uvOrig; 47 | float angle = 1.0 - length(offset / _CenterRadius.zw); 48 | angle = max (0, angle); 49 | angle = angle * angle * _Angle; 50 | float cosLength, sinLength; 51 | sincos (angle, sinLength, cosLength); 52 | 53 | float2 uv; 54 | uv.x = cosLength * offset[0] - sinLength * offset[1]; 55 | uv.y = sinLength * offset[0] + cosLength * offset[1]; 56 | uv += _CenterRadius.xy; 57 | 58 | return tex2D(_MainTex, uv); 59 | } 60 | ENDCG 61 | 62 | } 63 | } 64 | 65 | Fallback off 66 | 67 | } 68 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": 3 | { 4 | "**/.DS_Store":true, 5 | "**/.git":true, 6 | "**/.gitignore":true, 7 | "**/.gitmodules":true, 8 | "**/*.booproj":true, 9 | "**/*.pidb":true, 10 | "**/*.suo":true, 11 | "**/*.user":true, 12 | "**/*.userprefs":true, 13 | "**/*.unityproj":true, 14 | "**/*.dll":true, 15 | "**/*.exe":true, 16 | "**/*.pdf":true, 17 | "**/*.mid":true, 18 | "**/*.midi":true, 19 | "**/*.wav":true, 20 | "**/*.gif":true, 21 | "**/*.ico":true, 22 | "**/*.jpg":true, 23 | "**/*.jpeg":true, 24 | "**/*.png":true, 25 | "**/*.psd":true, 26 | "**/*.tga":true, 27 | "**/*.tif":true, 28 | "**/*.tiff":true, 29 | "**/*.3ds":true, 30 | "**/*.3DS":true, 31 | "**/*.fbx":true, 32 | "**/*.FBX":true, 33 | "**/*.lxo":true, 34 | "**/*.LXO":true, 35 | "**/*.ma":true, 36 | "**/*.MA":true, 37 | "**/*.obj":true, 38 | "**/*.OBJ":true, 39 | "**/*.asset":true, 40 | "**/*.cubemap":true, 41 | "**/*.flare":true, 42 | "**/*.mat":true, 43 | "**/*.meta":true, 44 | "**/*.prefab":true, 45 | "**/*.unity":true, 46 | "build/":true, 47 | "Build/":true, 48 | "Library/":true, 49 | "library/":true, 50 | "obj/":true, 51 | "Obj/":true, 52 | "ProjectSettings/":true, 53 | "temp/":true, 54 | "Temp/":true 55 | } 56 | } -------------------------------------------------------------------------------- /Assets/OSCController.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | using UnityOSC; 8 | 9 | public class OSCController : MonoBehaviour { 10 | 11 | [SerializeField]string _TargetAddr = "127.0.0.0"; 12 | [SerializeField]int _OutGoingPort = 5001; 13 | [SerializeField]int _InComingPort = 5000; 14 | 15 | private Queue queue; 16 | 17 | public delegate void onMsgDelegate(OSCMessage msg); 18 | public event onMsgDelegate onMsg = null; 19 | 20 | void Start() { 21 | OSCHandler.Instance.Init(_TargetAddr, _OutGoingPort, _InComingPort); 22 | 23 | queue = new Queue(); 24 | queue = Queue.Synchronized(queue); 25 | 26 | var server = OSCHandler.Instance.Servers["TidalClient"].server; 27 | server.PacketReceivedEvent += OnPacketReceived; 28 | } 29 | 30 | void OnPacketReceived(OSCServer server, OSCPacket packet) { 31 | if (1 <= queue.Count) { 32 | return; 33 | } else { 34 | queue.Enqueue (packet); 35 | } 36 | } 37 | 38 | void Update() { 39 | if (queue == null) { 40 | return; 41 | } 42 | while (0 < queue.Count) { 43 | OSCPacket packet = queue.Dequeue () as OSCPacket; 44 | if (packet.IsBundle ()) { 45 | // if OSCBundl 46 | OSCBundle bundle = packet as OSCBundle; 47 | foreach (OSCMessage msg in bundle.Data) { 48 | 49 | } 50 | } else { 51 | OSCMessage msg = packet as OSCMessage; 52 | 53 | if ("/unity_osc" == msg.Address) { 54 | if (onMsg != null) { 55 | onMsg (msg); 56 | } 57 | } 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Assets/Ripple.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | [ExecuteInEditMode] 5 | public class Ripple : MonoBehaviour 6 | { 7 | public Shader shader; 8 | public float radius; 9 | public Texture2D mod_source; 10 | private Material m_Material; 11 | private int time; 12 | 13 | protected Material material { 14 | get { 15 | if (m_Material == null) { 16 | if (shader == null) { 17 | shader = Shader.Find ("ripple"); 18 | } 19 | m_Material = new Material (shader); 20 | m_Material.hideFlags = HideFlags.HideAndDontSave; 21 | } 22 | return m_Material; 23 | } 24 | } 25 | 26 | protected virtual void Start() { 27 | time = 0; 28 | radius = 0; 29 | if (shader == null) { 30 | shader = Shader.Find ("ripple"); 31 | } 32 | m_Material = new Material(shader); 33 | } 34 | 35 | void Update () { 36 | time++; 37 | } 38 | 39 | protected virtual void OnRenderImage(RenderTexture source, RenderTexture destination) 40 | { 41 | material.SetFloat("time", time); 42 | material.SetFloat("radius", radius); 43 | material.SetTexture ("ModTex", mod_source); 44 | Graphics.Blit(source, destination, m_Material); 45 | } 46 | 47 | 48 | protected virtual void OnDisable() { 49 | if( m_Material ) { 50 | DestroyImmediate( m_Material ); 51 | } 52 | } 53 | 54 | [System.Obsolete("Use Graphics.Blit(source,dest) instead")] 55 | public static void Blit(RenderTexture source, RenderTexture dest) 56 | { 57 | Graphics.Blit(source, dest); 58 | } 59 | 60 | [System.Obsolete("Use Graphics.Blit(source, destination, material) instead")] 61 | public static void BlitWithMaterial(Material material, RenderTexture source, RenderTexture dest) 62 | { 63 | Graphics.Blit(source, dest, material); 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | TidalUnity 2 | --- 3 | 4 | TidalUnity is the middle-ware of visual livecode tool. It bridges control patterns that was generated with [TidalCycles](https://tidalcycles.org) to visual renderer on Unity engine. 5 | 6 | 7 | ![demo.gif](media/demo.gif) 8 | 9 | ## demo 10 | 11 | [https://vimeo.com/198314806](https://vimeo.com/198314806) 12 | 13 | [https://vimeo.com/198320403](https://vimeo.com/198320403) 14 | 15 | ## Installation 16 | 17 | put```Module/UnityOsc.hs```file to your $HOME```~``` 18 | 19 | then, boot TidalCycles. 20 | 21 | excute below in your editor within TidalCycles context. 22 | 23 | ``` 24 | :load ~/UnityOsc 25 | 26 | v1 <- unityStream 27 | ``` 28 | 29 | livecode in Tidal. 30 | 31 | ``` 32 | v1 $ thing "apple" 33 | ``` 34 | 35 | ## Prepare Assets 36 | 37 | TidalUnity attempts to load all '.prefab' file in 38 | 39 | ``Assets/Resources/Things`` 40 | 41 | when it boot. 42 | 43 | Please make ``Assets/Resources/Things`` directory and put your game-objects. 44 | 45 | Tidal's parameter ```thing```will match prefab file's name(whithout extension). 46 | 47 | ## Parameters 48 | 49 | ``` 50 | x 51 | ``` 52 | 53 | - value : Float : x position in 3D space. (default 0) 54 | 55 | ``` 56 | y 57 | ``` 58 | 59 | - value : Float : y position in 3D space. (default 0) 60 | 61 | ``` 62 | z 63 | ``` 64 | 65 | - value : Float : z position in 3D space. (default 0) 66 | 67 | 68 | ``` 69 | duration 70 | ``` 71 | 72 | - value : Float : object's life time in second. 1 is 1 second. (default 0.5) 73 | 74 | 75 | ``` 76 | rigid 77 | ``` 78 | 79 | - value : Int : if 0 < rigid, object will be calicurated phisics. 80 | 81 | 82 | ``` 83 | randCam 84 | ``` 85 | 86 | - speed : Float : speed of random camera transition. 87 | 88 | 89 | ``` 90 | vortex 91 | ``` 92 | 93 | - x : Float : x scale of vortex distortion. (default 0.5) 94 | - y : Float : y scale of vortex distortion. (default 0.5) 95 | - angle : Float : angle of vortex distortion. (default 0) 96 | 97 | -------------------------------------------------------------------------------- /Module/UnityOsc.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TypeSynonymInstances, FlexibleInstances, OverloadedStrings #-} 2 | 3 | -- custom osc send 4 | 5 | module UnityOsc where 6 | import Sound.Tidal.Stream 7 | import Sound.Tidal.Pattern 8 | import Sound.Tidal.ParseBP 9 | import Sound.Tidal.Stream 10 | import Sound.Tidal.Context 11 | 12 | tidalUnityTarget :: OSCTarget 13 | tidalUnityTarget = OSCTarget {oName = "tidal-unity", 14 | oAddress = "127.0.0.1", 15 | oPort = 5000, 16 | oPath = "/unity_osc", 17 | oShape = Just [ 18 | ("thing", Just $ VS ""), 19 | ("x", Just $ VF 0), 20 | ("y", Just $ VF 0), 21 | ("z", Just $ VF 0), 22 | ("moveX", Just $ VF 0), 23 | ("moveY", Just $ VF 0), 24 | ("moveZ", Just $ VF 0), 25 | ("vscale", Just $ VF 1.0), 26 | ("duration", Just $ VF 0.5), 27 | ("twist", Just $ VF 0), 28 | ("rigid", Just $ VI 0), 29 | ("randCam", Just $ VF 0), 30 | ("vortexRadX", Just $ VF 0.5), 31 | ("vortexRadY", Just $ VF 0.5), 32 | ("vortexAngle", Just $ VF 0), 33 | ("ripple", Just $ VF 0), 34 | ("dlight", Just $ VS "r") 35 | ], 36 | oLatency = 0.1, 37 | oPreamble = [], 38 | oTimestamp = MessageStamp 39 | } 40 | 41 | thing = pS "thing" 42 | x = pF "x" 43 | y = pF "y" 44 | z = pF "z" 45 | moveX = pF "moveX" 46 | moveY = pF "moveY" 47 | moveZ = pF "moveZ" 48 | vscale = pF "vscale" 49 | duration = pF "duration" 50 | twist = pF "twist" 51 | rigid = pI "rigid" 52 | randCam = pF "randCam" 53 | vortexRadX = pF "vortexRadX" 54 | vortexRadY = pF "vortexRadY" 55 | vortexAngle = pF "vortexAngle" 56 | ripple = pF "ripple" 57 | dlight = pS "dlight" 58 | 59 | vortex x y angle = vortexRadX x |+| vortexRadY y |+| vortexAngle angle 60 | move x y z = moveX x |+| moveY y |+| moveZ z 61 | 62 | -- skybox = makeS unityShape "skybox" 63 | 64 | -------------------------------------------------------------------------------- /Assets/SpringCamera.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class SpringCamera : MonoBehaviour 5 | { 6 | private Camera mainCam; 7 | 8 | private float nextCamPosX = 0; 9 | private float nextCamPosY = 0; 10 | private float nextCamPosZ = 0; 11 | private float curCamPosX = 0; 12 | private float curCamPosY = 0; 13 | private float curCamPosZ = 0; 14 | private float speedX = 0; 15 | private float speedY = 0; 16 | private float speedZ = 0; 17 | private float friction = 0.4f; 18 | private float spring = 0.5f; 19 | 20 | // Use this for initialization 21 | void Start () 22 | { 23 | this.mainCam = GameObject.Find("Main Camera").GetComponent(); 24 | 25 | this.mainCam.transform.position = this.animateCamera(); 26 | this.BasePosition (1.0f); 27 | } 28 | 29 | // Update is called once per frame 30 | void Update () 31 | { 32 | Vector3 next = this.animateCamera (); 33 | this.mainCam.transform.position = next; 34 | this.mainCam.transform.LookAt(new Vector3 (0, 0.5f, 0)); 35 | } 36 | 37 | public void BasePosition (float speed) { 38 | this.nextCamPosX = -0.6f; 39 | this.nextCamPosY = 1.6f; 40 | this.nextCamPosZ = -1.38f; 41 | this.friction = Random.Range (0.4f, 0.8f); 42 | this.spring = Random.Range (0.1f, 0.2f) * speed; 43 | } 44 | 45 | public void NextPosition (float speed) { 46 | float rand_fact_x = Random.Range (0.0f, 1.3f) + 2.7f; 47 | float rand_fact_z = Random.Range (0.0f, 1.3f) + 2.7f; 48 | this.nextCamPosX = (Random.Range(-1.0f * rand_fact_x, rand_fact_x)); 49 | this.nextCamPosY = Random.Range (0.5f, 1.7f); 50 | this.nextCamPosZ = (Random.Range (-1.0f * rand_fact_z, rand_fact_z)); 51 | this.friction = Random.Range (0.4f, 0.8f); 52 | this.spring = Random.Range (0.1f, 0.2f) * speed; 53 | } 54 | 55 | Vector3 animateCamera () { 56 | float ax, ay, az; 57 | ax = (this.nextCamPosX - this.curCamPosX) * this.spring; 58 | this.speedX += ax; 59 | this.speedX *= this.friction; 60 | this.curCamPosX += this.speedX; 61 | 62 | ay = (this.nextCamPosY - this.curCamPosY) * this.spring; 63 | this.speedY += ay; 64 | this.speedY *= this.friction; 65 | this.curCamPosY += this.speedY; 66 | 67 | az = (this.nextCamPosZ - this.curCamPosZ) * this.spring; 68 | this.speedZ += az; 69 | this.speedZ *= this.friction; 70 | this.curCamPosZ += this.speedZ; 71 | 72 | return new Vector3( this.curCamPosX, this.curCamPosY, this.curCamPosZ ); 73 | } 74 | 75 | public void SetVortex (float radX, float radY, float angle) { 76 | var vortex = this.mainCam.GetComponent(); 77 | vortex.radius.x = radX; 78 | vortex.radius.y = radY; 79 | vortex.angle = angle; 80 | } 81 | 82 | public void SetRipple (float radius) { 83 | var ripple = this.mainCam.GetComponent(); 84 | ripple.radius = radius; 85 | } 86 | } 87 | 88 | -------------------------------------------------------------------------------- /Assets/OSC/OSCClient.cs: -------------------------------------------------------------------------------- 1 | // 2 | // UnityOSC - Open Sound Control interface for the Unity3d game engine 3 | // 4 | // Copyright (c) 2012 Jorge Garcia Martin 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 7 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation 8 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | // and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions 12 | // of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 15 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 17 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 18 | // IN THE SOFTWARE. 19 | // 20 | 21 | using System; 22 | using System.Net; 23 | using System.Net.Sockets; 24 | 25 | namespace UnityOSC 26 | { 27 | /// 28 | /// Dispatches OSC messages to the specified destination address and port. 29 | /// 30 | 31 | public class OSCClient 32 | { 33 | #region Constructors 34 | public OSCClient (IPAddress address, int port) 35 | { 36 | _ipAddress = address; 37 | _port = port; 38 | Connect(); 39 | } 40 | #endregion 41 | 42 | #region Member Variables 43 | private IPAddress _ipAddress; 44 | private int _port; 45 | private UdpClient _udpClient; 46 | #endregion 47 | 48 | #region Properties 49 | public IPAddress ClientIPAddress 50 | { 51 | get 52 | { 53 | return _ipAddress; 54 | } 55 | } 56 | 57 | public int Port 58 | { 59 | get 60 | { 61 | return _port; 62 | } 63 | } 64 | #endregion 65 | 66 | #region Methods 67 | /// 68 | /// Connects the client to a given remote address and port. 69 | /// 70 | public void Connect() 71 | { 72 | if(_udpClient != null) Close(); 73 | _udpClient = new UdpClient(); 74 | try 75 | { 76 | _udpClient.Connect(_ipAddress, _port); 77 | } 78 | catch 79 | { 80 | throw new Exception(String.Format("Can't create client at IP address {0} and port {1}.", _ipAddress,_port)); 81 | } 82 | } 83 | 84 | /// 85 | /// Closes the client. 86 | /// 87 | public void Close() 88 | { 89 | _udpClient.Close(); 90 | _udpClient = null; 91 | } 92 | 93 | /// 94 | /// Sends an OSC packet to the defined destination and address of the client. 95 | /// 96 | /// 97 | /// A 98 | /// 99 | public void Send(OSCPacket packet) 100 | { 101 | byte[] data = packet.BinaryData; 102 | try 103 | { 104 | _udpClient.Send(data, data.Length); 105 | } 106 | catch 107 | { 108 | throw new Exception(String.Format("Can't send OSC packet to client {0} : {1}", _ipAddress, _port)); 109 | } 110 | } 111 | #endregion 112 | } 113 | } 114 | 115 | -------------------------------------------------------------------------------- /Assets/OSC/OSCBundle.cs: -------------------------------------------------------------------------------- 1 | // 2 | // UnityOSC - Open Sound Control interface for the Unity3d game engine 3 | // 4 | // Copyright (c) 2012 Jorge Garcia Martin 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 7 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation 8 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | // and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions 12 | // of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 15 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 17 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 18 | // IN THE SOFTWARE. 19 | // 20 | 21 | using System; 22 | using System.Net; 23 | using System.Text; 24 | using System.Collections.Generic; 25 | using System.Diagnostics; 26 | 27 | namespace UnityOSC 28 | { 29 | /// 30 | /// Models a Bundle of the OSC protocol. 31 | /// Derived from a OSC Packet over a OSC Stream. 32 | /// 33 | public sealed class OSCBundle : OSCPacket 34 | { 35 | 36 | #region Constructors 37 | public OSCBundle() 38 | { 39 | _address = BUNDLE; 40 | } 41 | 42 | public OSCBundle(long timestamp) 43 | { 44 | _address = BUNDLE; 45 | _timeStamp = timestamp; 46 | } 47 | #endregion 48 | 49 | #region Member Variables 50 | private const string BUNDLE = "#bundle"; 51 | 52 | #endregion 53 | 54 | #region Properties 55 | #endregion 56 | 57 | #region Methods 58 | 59 | /// 60 | /// Specifies if the packet is an OSC bundle. 61 | /// 62 | override public bool IsBundle() { return true; } 63 | 64 | /// 65 | /// Packs a bundle to be transported over an OSC stream. 66 | /// 67 | override public void Pack() 68 | { 69 | // TODO: Pack bundle with timestamp in NTP format 70 | 71 | throw new NotImplementedException("OSCBundle.Pack() : Not implemented method."); 72 | } 73 | 74 | /// 75 | /// Unpacks an OSC bundle from a data stream. 76 | /// 77 | /// 78 | /// A 79 | /// 80 | /// 81 | /// A 82 | /// 83 | /// 84 | /// A 85 | /// 86 | /// 87 | /// A 88 | /// 89 | public new static OSCBundle Unpack(byte[] data, ref int start, int end) 90 | { 91 | string address = OSCPacket.UnpackValue(data, ref start); 92 | Trace.Assert(address == BUNDLE); 93 | 94 | long timeStamp = OSCPacket.UnpackValue(data, ref start); 95 | OSCBundle bundle = new OSCBundle(timeStamp); 96 | 97 | while(start < end) 98 | { 99 | int length = OSCPacket.UnpackValue(data, ref start); 100 | int packetEnd = start + length; 101 | bundle.Append(OSCPacket.Unpack(data, ref start, packetEnd)); 102 | } 103 | 104 | return bundle; 105 | } 106 | 107 | /// 108 | /// Appends an OSC message to a bundle. 109 | /// 110 | /// 111 | /// A 112 | /// 113 | public override void Append (T msgvalue) 114 | { 115 | Trace.Assert(msgvalue is OSCMessage); 116 | _data.Add(msgvalue); 117 | } 118 | #endregion 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /Assets/Editor/OSCHelper.cs: -------------------------------------------------------------------------------- 1 | // 2 | // UnityOSC - Open Sound Control interface for the Unity3d game engine 3 | // 4 | // Copyright (c) 2012 Jorge Garcia Martin 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 7 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation 8 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | // and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions 12 | // of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 15 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 17 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 18 | // IN THE SOFTWARE. 19 | // 20 | 21 | using UnityEngine; 22 | using UnityEditor; 23 | using UnityOSC; 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | 28 | /// 29 | /// Helper to monitor incoming at outgoing OSC messages from the Unity Editor. 30 | /// You should have this script placed at the /Editor folder. 31 | /// Show the panel helper by selecting "Window->OSC Helper" from the Unity menu. 32 | /// 33 | public class OSCHelper : EditorWindow 34 | { 35 | #region Member variables 36 | private string _status = ""; 37 | private string _selected = "none"; 38 | private List _output = new List(); 39 | private int _portselected = 0; 40 | 41 | private Dictionary _clients = new Dictionary(); 42 | private Dictionary _servers = new Dictionary(); 43 | #endregion 44 | 45 | /// 46 | /// Initializes the OSC Helper and creates an entry in the Unity menu. 47 | /// 48 | [MenuItem("Window/OSC Helper")] 49 | static void Init () 50 | { 51 | OSCHelper window = (OSCHelper)EditorWindow.GetWindow (typeof(OSCHelper)); 52 | window.Show(); 53 | } 54 | 55 | /// 56 | /// Executes OnGUI in the panel within the Unity Editor 57 | /// 58 | void OnGUI () 59 | { 60 | if(EditorApplication.isPlaying) 61 | { 62 | _status = ""; 63 | GUILayout.Label(_status, EditorStyles.boldLabel); 64 | GUILayout.Label(String.Concat("SELECTED: ", _selected)); 65 | 66 | _clients = OSCHandler.Instance.Clients;//Get the clients 67 | _servers = OSCHandler.Instance.Servers;//Get the servers 68 | 69 | foreach(KeyValuePair pair in _clients) 70 | { 71 | if(GUILayout.Button(String.Format("Client '{0}' port: {1}", pair.Key, pair.Value.client.Port))) 72 | { 73 | _selected = pair.Key; 74 | _portselected = pair.Value.client.Port; 75 | } 76 | } 77 | 78 | foreach(KeyValuePair pair in _servers) 79 | { 80 | if(GUILayout.Button(String.Format("Server '{0}' port: {1}", pair.Key, pair.Value.server.LocalPort))) 81 | { 82 | _selected = pair.Key; 83 | _portselected = pair.Value.server.LocalPort; 84 | } 85 | } 86 | 87 | GUILayout.TextArea(FromListToString(_output)); 88 | } 89 | else 90 | { 91 | _status = "\n Enter the play mode in the Editor to see \n running clients and servers"; 92 | GUILayout.Label(_status, EditorStyles.boldLabel); 93 | } 94 | } 95 | 96 | /// 97 | /// Updates the logs of the running clients and servers. 98 | /// 99 | void Update() 100 | { 101 | if(EditorApplication.isPlaying) 102 | { 103 | OSCHandler.Instance.UpdateLogs(); 104 | 105 | if(_clients.ContainsKey(_selected) && _clients[_selected].client.Port == _portselected) 106 | { 107 | _output = _clients[_selected].log; 108 | } 109 | else if(_servers.ContainsKey(_selected) && _servers[_selected].server.LocalPort == _portselected) 110 | { 111 | _output = _servers[_selected].log; 112 | } 113 | 114 | Repaint(); 115 | } 116 | } 117 | 118 | /// 119 | /// Formats a collection of strings to a single concatenated string. 120 | /// 121 | /// 122 | /// A 123 | /// 124 | /// 125 | /// A 126 | /// 127 | private string FromListToString(List input) 128 | { 129 | string output = ""; 130 | 131 | foreach(string value in input) 132 | { 133 | output += value; 134 | } 135 | 136 | return output; 137 | } 138 | } -------------------------------------------------------------------------------- /Assets/OSC/OSCServer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // UnityOSC - Open Sound Control interface for the Unity3d game engine 3 | // 4 | // Copyright (c) 2012 Jorge Garcia Martin 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 7 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation 8 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | // and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions 12 | // of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 15 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 17 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 18 | // IN THE SOFTWARE. 19 | // 20 | 21 | using System; 22 | using System.Net; 23 | using System.Net.Sockets; 24 | using System.Threading; 25 | using System.Collections.Generic; 26 | 27 | namespace UnityOSC 28 | { 29 | public delegate void PacketReceivedEventHandler(OSCServer sender, OSCPacket packet); 30 | 31 | /// 32 | /// Receives incoming OSC messages 33 | /// 34 | public class OSCServer 35 | { 36 | #region Delegates 37 | public event PacketReceivedEventHandler PacketReceivedEvent; 38 | #endregion 39 | 40 | #region Constructors 41 | public OSCServer (int localPort) 42 | { 43 | PacketReceivedEvent += delegate(OSCServer s, OSCPacket p) { }; 44 | 45 | _localPort = localPort; 46 | Connect(); 47 | } 48 | #endregion 49 | 50 | #region Member Variables 51 | private UdpClient _udpClient; 52 | private int _localPort; 53 | private Thread _receiverThread; 54 | private OSCPacket _lastReceivedPacket; 55 | private int _sleepMilliseconds = 10; 56 | #endregion 57 | 58 | #region Properties 59 | public UdpClient UDPClient 60 | { 61 | get 62 | { 63 | return _udpClient; 64 | } 65 | set 66 | { 67 | _udpClient = value; 68 | } 69 | } 70 | 71 | public int LocalPort 72 | { 73 | get 74 | { 75 | return _localPort; 76 | } 77 | set 78 | { 79 | _localPort = value; 80 | } 81 | } 82 | 83 | public OSCPacket LastReceivedPacket 84 | { 85 | get 86 | { 87 | return _lastReceivedPacket; 88 | } 89 | } 90 | 91 | /// 92 | /// "Osc Receive Loop" sleep duration per message. 93 | /// 94 | /// The sleep milliseconds. 95 | public int SleepMilliseconds 96 | { 97 | get 98 | { 99 | return _sleepMilliseconds; 100 | } 101 | set 102 | { 103 | _sleepMilliseconds = value; 104 | } 105 | } 106 | #endregion 107 | 108 | #region Methods 109 | 110 | /// 111 | /// Opens the server at the given port and starts the listener thread. 112 | /// 113 | public void Connect() 114 | { 115 | if(this._udpClient != null) Close(); 116 | 117 | try 118 | { 119 | _udpClient = new UdpClient(_localPort); 120 | _receiverThread = new Thread(new ThreadStart(this.ReceivePool)); 121 | _receiverThread.Start(); 122 | } 123 | catch(Exception e) 124 | { 125 | throw e; 126 | } 127 | } 128 | 129 | /// 130 | /// Closes the server and terminates its listener thread. 131 | /// 132 | public void Close() 133 | { 134 | if(_receiverThread !=null) _receiverThread.Abort(); 135 | _receiverThread = null; 136 | _udpClient.Close(); 137 | _udpClient = null; 138 | } 139 | 140 | 141 | /// 142 | /// Receives and unpacks an OSC packet. 143 | /// A 144 | /// 145 | private void Receive() 146 | { 147 | IPEndPoint ip = null; 148 | 149 | try 150 | { 151 | byte[] bytes = _udpClient.Receive(ref ip); 152 | 153 | if(bytes != null && bytes.Length > 0) 154 | { 155 | OSCPacket packet = OSCPacket.Unpack(bytes); 156 | 157 | _lastReceivedPacket = packet; 158 | 159 | PacketReceivedEvent(this, _lastReceivedPacket); 160 | } 161 | } 162 | catch{ 163 | throw new Exception(String.Format("Can't create server at port {0}", _localPort)); 164 | } 165 | } 166 | 167 | /// 168 | /// Thread pool that receives upcoming messages. 169 | /// 170 | private void ReceivePool() 171 | { 172 | while( true ) 173 | { 174 | Receive(); 175 | 176 | Thread.Sleep(_sleepMilliseconds); 177 | } 178 | } 179 | #endregion 180 | } 181 | } 182 | 183 | -------------------------------------------------------------------------------- /Assets/OSC/OSCMessage.cs: -------------------------------------------------------------------------------- 1 | // 2 | // UnityOSC - Open Sound Control interface for the Unity3d game engine 3 | // 4 | // Copyright (c) 2012 Jorge Garcia Martin 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 7 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation 8 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | // and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions 12 | // of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 15 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 17 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 18 | // IN THE SOFTWARE. 19 | // 20 | 21 | using System; 22 | using System.Collections.Generic; 23 | using System.Net; 24 | using System.Text; 25 | 26 | namespace UnityOSC 27 | { 28 | public sealed class OSCMessage : OSCPacket 29 | { 30 | #region Constructors 31 | public OSCMessage (string address) 32 | { 33 | _typeTag = DEFAULT.ToString(); 34 | this.Address = address; 35 | } 36 | 37 | public OSCMessage (string address, object msgvalue) 38 | { 39 | _typeTag = DEFAULT.ToString(); 40 | this.Address = address; 41 | Append(msgvalue); 42 | } 43 | #endregion 44 | 45 | #region Member Variables 46 | private const char INTEGER = 'i'; 47 | private const char FLOAT = 'f'; 48 | private const char LONG = 'h'; 49 | private const char DOUBLE = 'd'; 50 | private const char STRING = 's'; 51 | private const char BYTE = 'b'; 52 | private const char DEFAULT = ','; 53 | 54 | private string _typeTag; 55 | 56 | #endregion 57 | 58 | #region Properties 59 | #endregion 60 | 61 | #region Methods 62 | 63 | /// 64 | /// Specifies if the message is an OSC bundle. 65 | /// 66 | /// 67 | /// A 68 | /// 69 | override public bool IsBundle() { return false; } 70 | 71 | /// 72 | /// Packs the OSC message to binary data. 73 | /// 74 | override public void Pack() 75 | { 76 | List data = new List(); 77 | 78 | data.AddRange(OSCPacket.PackValue(_address)); 79 | OSCPacket.PadNull(data); 80 | 81 | data.AddRange(OSCPacket.PackValue(_typeTag)); 82 | OSCPacket.PadNull(data); 83 | 84 | foreach (object value in _data) 85 | { 86 | data.AddRange(OSCPacket.PackValue(value)); 87 | if (value is string || value is byte[]) 88 | { 89 | OSCPacket.PadNull(data); 90 | } 91 | } 92 | 93 | this._binaryData = data.ToArray(); 94 | } 95 | 96 | /// 97 | /// Unpacks an OSC message. 98 | /// 99 | /// 100 | /// A 101 | /// 102 | /// 103 | /// A 104 | /// 105 | /// 106 | /// A 107 | /// 108 | public static OSCMessage Unpack(byte[] data, ref int start) 109 | { 110 | string address = OSCPacket.UnpackValue(data, ref start); 111 | OSCMessage message = new OSCMessage(address); 112 | 113 | char[] tags = OSCPacket.UnpackValue(data, ref start).ToCharArray(); 114 | foreach (char tag in tags) 115 | { 116 | object value; 117 | switch (tag) 118 | { 119 | case DEFAULT: 120 | continue; 121 | 122 | case INTEGER: 123 | value = OSCPacket.UnpackValue(data, ref start); 124 | break; 125 | 126 | case LONG: 127 | value = OSCPacket.UnpackValue(data, ref start); 128 | break; 129 | 130 | case FLOAT: 131 | value = OSCPacket.UnpackValue(data, ref start); 132 | break; 133 | 134 | case DOUBLE: 135 | value = OSCPacket.UnpackValue(data, ref start); 136 | break; 137 | 138 | case STRING: 139 | value = OSCPacket.UnpackValue(data, ref start); 140 | break; 141 | 142 | case BYTE: 143 | value = OSCPacket.UnpackValue(data, ref start); 144 | break; 145 | 146 | default: 147 | Console.WriteLine("Unknown tag: " + tag); 148 | continue; 149 | } 150 | 151 | message.Append(value); 152 | } 153 | 154 | if(message.TimeStamp == 0) 155 | { 156 | message.TimeStamp = DateTime.Now.Ticks; 157 | } 158 | 159 | return message; 160 | } 161 | 162 | /// 163 | /// Appends a value to an OSC message. 164 | /// 165 | /// 166 | /// A 167 | /// 168 | public override void Append (T value) 169 | { 170 | Type type = value.GetType(); 171 | char typeTag = DEFAULT; 172 | 173 | switch (type.Name) 174 | { 175 | case "Int32": 176 | typeTag = INTEGER; 177 | break; 178 | 179 | case "Int64": 180 | typeTag = LONG; 181 | break; 182 | 183 | case "Single": 184 | typeTag = FLOAT; 185 | break; 186 | 187 | case "Double": 188 | typeTag = DOUBLE; 189 | break; 190 | 191 | case "String": 192 | typeTag = STRING; 193 | break; 194 | 195 | case "Byte[]": 196 | typeTag = BYTE; 197 | break; 198 | 199 | default: 200 | throw new Exception("Unsupported data type."); 201 | } 202 | 203 | _typeTag += typeTag; 204 | _data.Add(value); 205 | } 206 | #endregion 207 | } 208 | } -------------------------------------------------------------------------------- /Assets/GameEvent.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | public class GameEvent : MonoBehaviour { 7 | 8 | OSCController osc_controller; 9 | 10 | private Dictionary things; 11 | private Dictionary skyboxes; 12 | private GameObject plane; 13 | private GameObject dirLight; 14 | 15 | private float offsetScale; 16 | 17 | private string currentSkyboxName; 18 | 19 | void Start () { 20 | offsetScale = 1.0f; 21 | plane = GameObject.Find ("Plane"); 22 | dirLight = GameObject.Find ("Directional Light"); 23 | things = new Dictionary (); 24 | string thingsPath = "Assets/Resources/Things"; 25 | //string shaderPath = "Assets/Resources/Shader"; 26 | DirectoryInfo dir = new DirectoryInfo (thingsPath); 27 | FileInfo[] info = dir.GetFiles ("*.prefab"); 28 | 29 | foreach (FileInfo f in info) { 30 | 31 | string key = f.Name.Replace(".prefab", string.Empty); 32 | GameObject value = Resources.Load("Things/" + key, typeof(GameObject))as GameObject; 33 | 34 | if (value != null) { 35 | things.Add (key, value); 36 | //Debug.Log (key, value); 37 | } else { 38 | Debug.Log ("couldnt load object: " + key); 39 | } 40 | } 41 | 42 | skyboxes = new Dictionary (); 43 | string skyboxesPath = "Assets/Resources/Skyboxes"; 44 | DirectoryInfo s_dir = new DirectoryInfo (skyboxesPath); 45 | FileInfo[] s_info = s_dir.GetFiles ("*.mat"); 46 | 47 | foreach (FileInfo f in s_info) { 48 | string key = f.Name.Replace(".mat", string.Empty); 49 | Material value = Resources.Load("Skyboxes/" + key) as Material; 50 | // Debug.Log (value); 51 | if (value != null) { 52 | skyboxes.Add (key, value); 53 | } else { 54 | Debug.Log ("couldnt load skybox: " + key); 55 | } 56 | } 57 | currentSkyboxName = "studio"; 58 | 59 | osc_controller = GameObject.Find("OSCController").GetComponent(); 60 | 61 | osc_controller.onMsg += (msg) => { 62 | // print (msg.Data[0].ToString()); 63 | 64 | var thing_str = msg.Data[0].ToString(); 65 | var pos = new Vector3((float)msg.Data[1], (float)msg.Data[2], (float)msg.Data[3]); 66 | var move = new Vector3((float)msg.Data[4], (float)msg.Data[5], (float)msg.Data[6]); 67 | var scale = (float)msg.Data[7]; 68 | var dur = (float)msg.Data[8]; 69 | var twist = (float)msg.Data[9]; 70 | var rigid = (int)msg.Data[10]; 71 | var randCam = (float)msg.Data[11]; 72 | var vortexRadX = (float)msg.Data[12]; 73 | var vortexRadY = (float)msg.Data[13]; 74 | var vortexAngle = (float)msg.Data[14]; 75 | var ripple = (float)msg.Data[15]; 76 | // var skyboxName = (string)msg.Data[13]; 77 | var dLight = (string)msg.Data[16]; 78 | 79 | GameObject thing = things[thing_str]; 80 | 81 | if (0 < twist) { 82 | ApplyShader(thing, "Custom/Twist", twist); 83 | } else { 84 | Debug.Log("not apply"); 85 | } 86 | 87 | if (0 < randCam) { 88 | this.RandCamera(randCam); 89 | } 90 | 91 | //if (0 != vortexAngle) { 92 | this.Vortex(vortexRadX, vortexRadY, vortexAngle); 93 | //} 94 | 95 | this.Ripple(ripple); 96 | 97 | // if (skyboxName != null) { 98 | // ChangeSkyBox(skyboxName); 99 | // } 100 | 101 | if (dLight != null) { 102 | SetDLight(dLight); 103 | } 104 | 105 | //Debug.Log(scale); 106 | if (thing) { 107 | AppendItem(thing, pos, move, scale * offsetScale, dur, rigid); 108 | } 109 | }; 110 | 111 | osc_controller.onBang += (msg) => { 112 | offsetScale = 2.0f; 113 | }; 114 | } 115 | 116 | // Update is called once per a frame 117 | void Update () { 118 | if (1.0f < offsetScale) { 119 | offsetScale = offsetScale - 0.2f; 120 | } 121 | } 122 | 123 | void AppendItem (GameObject thing, Vector3 pos, Vector3 move, float scale, float dur, int rigid) { 124 | var clone = Instantiate (thing, pos, Quaternion.identity); 125 | if (0 < rigid) { 126 | clone.AddComponent (); // Add the rigidbody. 127 | clone.AddComponent (); // Add the rigidbody. 128 | MeshCollider collider = clone.GetComponent (); 129 | Rigidbody rigidbody = clone.GetComponent (); 130 | collider.convex = true; 131 | rigidbody.useGravity = true; 132 | } else { 133 | if ("NoMesh" == clone.tag) { 134 | SphereCollider collider = clone.GetComponent (); 135 | if (collider) { 136 | collider.enabled = false; 137 | } 138 | } 139 | } 140 | clone.transform.localScale = new Vector3(scale,scale,scale); 141 | 142 | clone.AddComponent ().move = move; 143 | 144 | Destroy(clone, dur * 1.0f); 145 | } 146 | 147 | void RandCamera (float speed) { 148 | SpringCamera cam = GameObject.Find("SpringCamera").GetComponent (); 149 | cam.NextPosition(speed); 150 | } 151 | 152 | void ApplyShader (GameObject thing, string shaderName, float val) { 153 | //Debug.Log("setShaderToGameobject started: " + thing.name + " / " + shaderName); 154 | var shader = Shader.Find(shaderName); 155 | 156 | //foreach (Transform t in thing.GetComponentsInChildren()) { 157 | 158 | foreach (var renderer in thing.GetComponents()) { 159 | //foreach (var material in renderer.material) { 160 | Material material = new Material(shader); 161 | material.CopyPropertiesFromMaterial(renderer.sharedMaterial); 162 | 163 | material.SetTexture("Base (RGB)", renderer.sharedMaterial.mainTexture); 164 | material.SetFloat ("_Freq", val); 165 | renderer.material = material; 166 | } 167 | //} 168 | } 169 | 170 | void Vortex(float radX, float raadY, float angle) { 171 | var sp_camera = GameObject.Find("SpringCamera").GetComponent(); 172 | if (sp_camera) { 173 | sp_camera.SetVortex(radX, raadY, angle); 174 | } 175 | } 176 | 177 | void Ripple(float radius) { 178 | var sp_camera = GameObject.Find("SpringCamera").GetComponent(); 179 | if (sp_camera) { 180 | sp_camera.SetRipple(radius); 181 | } 182 | } 183 | 184 | void SetDLight(string mode) { 185 | if ("d" == mode) { 186 | this.dirLight.transform.rotation = Quaternion.Euler(-50.0f, -180.0f, 0.0f); 187 | } else if ("r" == mode) { 188 | this.dirLight.transform.rotation = Quaternion.Euler(50.0f, -180.0f, 0.0f); 189 | } 190 | } 191 | 192 | 193 | void ChangeSkyBox(string name) { 194 | if (currentSkyboxName == name) { 195 | return; 196 | } 197 | if ("" == name) { 198 | if (this.plane != null) { 199 | MeshRenderer m =this.plane.GetComponent(); 200 | m.material.SetColor("_Albedo" ,new Color(1.0f,1.0f,1.0f,1.0f)); 201 | } 202 | RenderSettings.skybox = skyboxes["studio"]; 203 | return; 204 | } 205 | var mat = skyboxes [name]; 206 | 207 | if (mat != null) { 208 | RenderSettings.skybox = skyboxes [name]; 209 | 210 | if (this.plane != null) { 211 | MeshRenderer m =this.plane.GetComponent(); 212 | m.material.SetColor("_Albedo" ,new Color(1.0f,1.0f,1.0f,0.0f)); 213 | } 214 | } else { 215 | if (this.plane != null) { 216 | MeshRenderer m = this.plane.GetComponent(); 217 | m.material.SetColor("_Albedo" ,new Color(1.0f,1.0f,1.0f,1.0f)); 218 | } 219 | RenderSettings.skybox = skyboxes["studio"]; 220 | } 221 | 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /Assets/OSC/OSCPacket.cs: -------------------------------------------------------------------------------- 1 | // 2 | // UnityOSC - Open Sound Control interface for the Unity3d game engine 3 | // 4 | // Copyright (c) 2012 Jorge Garcia Martin 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 7 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation 8 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | // and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions 12 | // of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 15 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 17 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 18 | // IN THE SOFTWARE. 19 | // 20 | 21 | using System; 22 | using System.Diagnostics; 23 | using System.Collections.Generic; 24 | using System.Text; 25 | 26 | namespace UnityOSC 27 | { 28 | /// 29 | /// Models a OSC Packet over an OSC stream. 30 | /// 31 | abstract public class OSCPacket 32 | { 33 | #region Member Variables 34 | protected List _data; 35 | protected byte[] _binaryData; 36 | protected string _address; 37 | protected long _timeStamp; 38 | #endregion 39 | 40 | #region Properties 41 | public string Address 42 | { 43 | get 44 | { 45 | return _address; 46 | } 47 | set 48 | { 49 | Trace.Assert(string.IsNullOrEmpty(_address) == false); 50 | _address = value; 51 | } 52 | } 53 | 54 | public List Data 55 | { 56 | get 57 | { 58 | return _data; 59 | } 60 | } 61 | 62 | public byte[] BinaryData 63 | { 64 | get 65 | { 66 | Pack(); 67 | return _binaryData; 68 | } 69 | } 70 | 71 | public long TimeStamp 72 | { 73 | get 74 | { 75 | return _timeStamp; 76 | } 77 | set 78 | { 79 | _timeStamp = value; 80 | } 81 | } 82 | #endregion 83 | 84 | #region Methods 85 | abstract public bool IsBundle(); 86 | abstract public void Pack(); 87 | abstract public void Append(T msgvalue); 88 | 89 | /// 90 | /// OSC Packet initialization. 91 | /// 92 | public OSCPacket () 93 | { 94 | this._data = new List(); 95 | } 96 | 97 | /// 98 | /// Swap endianess given a data set. 99 | /// 100 | /// 101 | /// A 102 | /// 103 | /// 104 | /// A 105 | /// 106 | protected static byte[] SwapEndian(byte[] data) 107 | { 108 | byte[] swapped = new byte[data.Length]; 109 | for(int i = data.Length - 1, j = 0 ; i >= 0 ; i--, j++) 110 | { 111 | swapped[j] = data[i]; 112 | } 113 | return swapped; 114 | } 115 | 116 | /// 117 | /// Packs a value in a byte stream. Accepted types: Int32, Int64, Single, Double, String and Byte[]. 118 | /// 119 | /// 120 | /// A 121 | /// 122 | /// 123 | /// A 124 | /// 125 | protected static byte[] PackValue(T value) 126 | { 127 | object valueObject = value; 128 | Type type = value.GetType(); 129 | byte[] data = null; 130 | 131 | switch (type.Name) 132 | { 133 | case "Int32": 134 | data = BitConverter.GetBytes((int)valueObject); 135 | if (BitConverter.IsLittleEndian) data = SwapEndian(data); 136 | break; 137 | 138 | case "Int64": 139 | data = BitConverter.GetBytes((long)valueObject); 140 | if (BitConverter.IsLittleEndian) data = SwapEndian(data); 141 | break; 142 | 143 | case "Single": 144 | data = BitConverter.GetBytes((float)valueObject); 145 | if (BitConverter.IsLittleEndian) data = SwapEndian(data); 146 | break; 147 | 148 | case "Double": 149 | data = BitConverter.GetBytes((double)valueObject); 150 | if (BitConverter.IsLittleEndian) data = SwapEndian(data); 151 | break; 152 | 153 | case "String": 154 | data = Encoding.ASCII.GetBytes((string)valueObject); 155 | break; 156 | 157 | case "Byte[]": 158 | byte[] valueData = ((byte[])valueObject); 159 | List bytes = new List(); 160 | bytes.AddRange(PackValue(valueData.Length)); 161 | bytes.AddRange(valueData); 162 | data = bytes.ToArray(); 163 | break; 164 | 165 | default: 166 | throw new Exception("Unsupported data type."); 167 | } 168 | return data; 169 | } 170 | 171 | /// 172 | /// Unpacks a value from a byte stream. Accepted types: Int32, Int64, Single, Double, String and Byte[]. 173 | /// 174 | /// 175 | /// A 176 | /// 177 | /// 178 | /// A 179 | /// 180 | /// 181 | /// A 182 | /// 183 | protected static T UnpackValue(byte[] data, ref int start) 184 | { 185 | object msgvalue; //msgvalue is casted and returned by the function 186 | Type type = typeof(T); 187 | byte[] buffername; 188 | 189 | if (type.Name == "String") 190 | { 191 | int count = 0; 192 | for (int index = start; data[index] != 0; index++) count++; 193 | 194 | msgvalue = Encoding.ASCII.GetString(data, start, count); 195 | start += count + 1; 196 | start = ((start + 3) / 4) * 4; 197 | } 198 | else if (type.Name == "Byte[]") 199 | { 200 | int length = UnpackValue(data, ref start); 201 | byte[] buffer = new byte[length]; 202 | Array.Copy(data, start, buffer, 0, buffer.Length); 203 | start += buffer.Length; 204 | start = ((start + 3) / 4) * 4; 205 | 206 | msgvalue = buffer; 207 | } 208 | else 209 | { 210 | switch (type.Name) 211 | { 212 | case "Int32": 213 | case "Single"://this also serves for float numbers 214 | buffername = new byte[4]; 215 | break; 216 | 217 | case "Int64": 218 | case "Double": 219 | buffername = new byte[8]; 220 | break; 221 | 222 | default: 223 | throw new Exception("Unsupported data type."); 224 | } 225 | 226 | Array.Copy(data, start, buffername, 0, buffername.Length); 227 | start += buffername.Length; 228 | 229 | if (BitConverter.IsLittleEndian) 230 | { 231 | buffername = SwapEndian(buffername); 232 | } 233 | 234 | switch (type.Name) 235 | { 236 | case "Int32": 237 | msgvalue = BitConverter.ToInt32(buffername, 0); 238 | break; 239 | 240 | case "Int64": 241 | msgvalue = BitConverter.ToInt64(buffername, 0); 242 | break; 243 | 244 | case "Single": 245 | msgvalue = BitConverter.ToSingle(buffername, 0); 246 | break; 247 | 248 | case "Double": 249 | msgvalue = BitConverter.ToDouble(buffername, 0); 250 | break; 251 | 252 | default: 253 | throw new Exception("Unsupported data type."); 254 | } 255 | } 256 | 257 | return (T)msgvalue; 258 | } 259 | 260 | /// 261 | /// Unpacks an array of binary data. 262 | /// 263 | /// 264 | /// A 265 | /// 266 | /// 267 | /// A 268 | /// 269 | public static OSCPacket Unpack(byte[] data) 270 | { 271 | int start = 0; 272 | return Unpack(data, ref start, data.Length); 273 | } 274 | 275 | /// 276 | /// Unpacks an array of binary data given reference start and end pointers. 277 | /// 278 | /// 279 | /// A 280 | /// 281 | /// 282 | /// A 283 | /// 284 | /// 285 | /// A 286 | /// 287 | /// 288 | /// A 289 | /// 290 | public static OSCPacket Unpack(byte[] data, ref int start, int end) 291 | { 292 | if (data[start] == '#') 293 | { 294 | return OSCBundle.Unpack(data, ref start, end); 295 | } 296 | 297 | else return OSCMessage.Unpack(data, ref start); 298 | } 299 | 300 | /// 301 | /// Pads null a list of bytes. 302 | /// 303 | /// 304 | /// A 305 | /// 306 | protected static void PadNull(List data) 307 | { 308 | byte nullvalue = 0; 309 | int pad = 4 - (data.Count % 4); 310 | for(int i = 0; i < pad; i++) 311 | data.Add(nullvalue); 312 | } 313 | 314 | #endregion 315 | } 316 | } 317 | -------------------------------------------------------------------------------- /Assets/OSCHandler.cs: -------------------------------------------------------------------------------- 1 | // 2 | // UnityOSC - Open Sound Control interface for the Unity3d game engine 3 | // 4 | // Copyright (c) 2012 Jorge Garcia Martin 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 7 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation 8 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | // and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions 12 | // of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 15 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 17 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 18 | // IN THE SOFTWARE. 19 | // 20 | // Inspired by http://www.unifycommunity.com/wiki/index.php?title=AManagerClass 21 | 22 | using System; 23 | using System.Net; 24 | using System.Collections.Generic; 25 | 26 | using UnityEngine; 27 | using UnityOSC; 28 | 29 | /// 30 | /// Models a log of a server composed by an OSCServer, a List of OSCPacket and a List of 31 | /// strings that represent the current messages in the log. 32 | /// 33 | public struct ServerLog 34 | { 35 | public OSCServer server; 36 | public List packets; 37 | public List log; 38 | } 39 | 40 | /// 41 | /// Models a log of a client composed by an OSCClient, a List of OSCMessage and a List of 42 | /// strings that represent the current messages in the log. 43 | /// 44 | public struct ClientLog 45 | { 46 | public OSCClient client; 47 | public List messages; 48 | public List log; 49 | } 50 | 51 | /// 52 | /// Handles all the OSC servers and clients of the current Unity game/application. 53 | /// Tracks incoming and outgoing messages. 54 | /// 55 | public class OSCHandler : MonoBehaviour 56 | { 57 | #region Singleton Constructors 58 | static OSCHandler() 59 | { 60 | } 61 | 62 | OSCHandler() 63 | { 64 | } 65 | 66 | public static OSCHandler Instance 67 | { 68 | get 69 | { 70 | if (_instance == null) 71 | { 72 | _instance = new GameObject ("OSCHandler").AddComponent(); 73 | } 74 | 75 | return _instance; 76 | } 77 | } 78 | #endregion 79 | 80 | #region Member Variables 81 | private static OSCHandler _instance = null; 82 | private Dictionary _clients = new Dictionary(); 83 | private Dictionary _servers = new Dictionary(); 84 | 85 | private const int _loglength = 25; 86 | #endregion 87 | 88 | /// 89 | /// Initializes the OSC Handler. 90 | /// Here you can create the OSC servers and clientes. 91 | /// 92 | public void Init(string targetAddr, int outGoingPort, int inComingPort) 93 | { 94 | //Initialize OSC clients (transmitters) 95 | //Example: 96 | //CreateClient("SuperCollider", IPAddress.Parse(targetAddr), outGoingPort); 97 | 98 | //Initialize OSC servers (listeners) 99 | //Example: 100 | 101 | CreateServer("TidalClient", inComingPort); 102 | } 103 | 104 | #region Properties 105 | public Dictionary Clients 106 | { 107 | get 108 | { 109 | return _clients; 110 | } 111 | } 112 | 113 | public Dictionary Servers 114 | { 115 | get 116 | { 117 | return _servers; 118 | } 119 | } 120 | #endregion 121 | 122 | #region Methods 123 | 124 | /// 125 | /// Ensure that the instance is destroyed when the game is stopped in the Unity editor 126 | /// Close all the OSC clients and servers 127 | /// 128 | void OnApplicationQuit() 129 | { 130 | foreach(KeyValuePair pair in _clients) 131 | { 132 | pair.Value.client.Close(); 133 | } 134 | 135 | foreach(KeyValuePair pair in _servers) 136 | { 137 | pair.Value.server.Close(); 138 | } 139 | 140 | _instance = null; 141 | } 142 | 143 | /// 144 | /// Creates an OSC Client (sends OSC messages) given an outgoing port and address. 145 | /// 146 | /// 147 | /// A 148 | /// 149 | /// 150 | /// A 151 | /// 152 | /// 153 | /// A 154 | /// 155 | public void CreateClient(string clientId, IPAddress destination, int port) 156 | { 157 | ClientLog clientitem = new ClientLog(); 158 | clientitem.client = new OSCClient(destination, port); 159 | clientitem.log = new List(); 160 | clientitem.messages = new List(); 161 | 162 | _clients.Add(clientId, clientitem); 163 | 164 | // Send test message 165 | string testaddress = "/test/alive/"; 166 | OSCMessage message = new OSCMessage(testaddress, destination.ToString()); 167 | message.Append(port); message.Append("OK"); 168 | 169 | _clients[clientId].log.Add(String.Concat(DateTime.UtcNow.ToString(),".", 170 | FormatMilliseconds(DateTime.Now.Millisecond), " : ", 171 | testaddress," ", DataToString(message.Data))); 172 | _clients[clientId].messages.Add(message); 173 | 174 | _clients[clientId].client.Send(message); 175 | } 176 | 177 | /// 178 | /// Creates an OSC Server (listens to upcoming OSC messages) given an incoming port. 179 | /// 180 | /// 181 | /// A 182 | /// 183 | /// 184 | /// A 185 | /// 186 | public void CreateServer(string serverId, int port) 187 | { 188 | OSCServer server = new OSCServer(port); 189 | server.PacketReceivedEvent += OnPacketReceived; 190 | 191 | ServerLog serveritem = new ServerLog(); 192 | serveritem.server = server; 193 | serveritem.log = new List(); 194 | serveritem.packets = new List(); 195 | 196 | _servers.Add(serverId, serveritem); 197 | } 198 | 199 | void OnPacketReceived(OSCServer server, OSCPacket packet) 200 | { 201 | } 202 | 203 | /// 204 | /// Sends an OSC message to a specified client, given its clientId (defined at the OSC client construction), 205 | /// OSC address and a single value. Also updates the client log. 206 | /// 207 | /// 208 | /// A 209 | /// 210 | /// 211 | /// A 212 | /// 213 | /// 214 | /// A 215 | /// 216 | public void SendMessageToClient(string clientId, string address, T value) 217 | { 218 | List temp = new List(); 219 | temp.Add(value); 220 | 221 | SendMessageToClient(clientId, address, temp); 222 | } 223 | 224 | /// 225 | /// Sends an OSC message to a specified client, given its clientId (defined at the OSC client construction), 226 | /// OSC address and a list of values. Also updates the client log. 227 | /// 228 | /// 229 | /// A 230 | /// 231 | /// 232 | /// A 233 | /// 234 | /// 235 | /// A 236 | /// 237 | public void SendMessageToClient(string clientId, string address, List values) 238 | { 239 | if(_clients.ContainsKey(clientId)) 240 | { 241 | OSCMessage message = new OSCMessage(address); 242 | 243 | foreach(T msgvalue in values) 244 | { 245 | message.Append(msgvalue); 246 | } 247 | 248 | if(_clients[clientId].log.Count < _loglength) 249 | { 250 | _clients[clientId].log.Add(String.Concat(DateTime.UtcNow.ToString(),".", 251 | FormatMilliseconds(DateTime.Now.Millisecond), 252 | " : ", address, " ", DataToString(message.Data))); 253 | _clients[clientId].messages.Add(message); 254 | } 255 | else 256 | { 257 | _clients[clientId].log.RemoveAt(0); 258 | _clients[clientId].messages.RemoveAt(0); 259 | 260 | _clients[clientId].log.Add(String.Concat(DateTime.UtcNow.ToString(),".", 261 | FormatMilliseconds(DateTime.Now.Millisecond), 262 | " : ", address, " ", DataToString(message.Data))); 263 | _clients[clientId].messages.Add(message); 264 | } 265 | 266 | _clients[clientId].client.Send(message); 267 | } 268 | else 269 | { 270 | Debug.LogError(string.Format("Can't send OSC messages to {0}. Client doesn't exist.", clientId)); 271 | } 272 | } 273 | 274 | /// 275 | /// Updates clients and servers logs. 276 | /// 277 | public void UpdateLogs() 278 | { 279 | foreach(KeyValuePair pair in _servers) 280 | { 281 | if(_servers[pair.Key].server.LastReceivedPacket != null) 282 | { 283 | //Initialization for the first packet received 284 | if(_servers[pair.Key].log.Count == 0) 285 | { 286 | _servers[pair.Key].packets.Add(_servers[pair.Key].server.LastReceivedPacket); 287 | 288 | _servers[pair.Key].log.Add(String.Concat(DateTime.UtcNow.ToString(), ".", 289 | FormatMilliseconds(DateTime.Now.Millisecond)," : ", 290 | _servers[pair.Key].server.LastReceivedPacket.Address," ", 291 | DataToString(_servers[pair.Key].server.LastReceivedPacket.Data))); 292 | break; 293 | } 294 | 295 | if(_servers[pair.Key].server.LastReceivedPacket.TimeStamp 296 | != _servers[pair.Key].packets[_servers[pair.Key].packets.Count - 1].TimeStamp) 297 | { 298 | if(_servers[pair.Key].log.Count > _loglength - 1) 299 | { 300 | _servers[pair.Key].log.RemoveAt(0); 301 | _servers[pair.Key].packets.RemoveAt(0); 302 | } 303 | 304 | _servers[pair.Key].packets.Add(_servers[pair.Key].server.LastReceivedPacket); 305 | 306 | _servers[pair.Key].log.Add(String.Concat(DateTime.UtcNow.ToString(), ".", 307 | FormatMilliseconds(DateTime.Now.Millisecond)," : ", 308 | _servers[pair.Key].server.LastReceivedPacket.Address," ", 309 | DataToString(_servers[pair.Key].server.LastReceivedPacket.Data))); 310 | } 311 | } 312 | } 313 | } 314 | 315 | /// 316 | /// Converts a collection of object values to a concatenated string. 317 | /// 318 | /// 319 | /// A 320 | /// 321 | /// 322 | /// A 323 | /// 324 | private string DataToString(List data) 325 | { 326 | string buffer = ""; 327 | 328 | for(int i = 0; i < data.Count; i++) 329 | { 330 | buffer += data[i].ToString() + " "; 331 | } 332 | 333 | buffer += "\n"; 334 | 335 | return buffer; 336 | } 337 | 338 | /// 339 | /// Formats a milliseconds number to a 000 format. E.g. given 50, it outputs 050. Given 5, it outputs 005 340 | /// 341 | /// 342 | /// A 343 | /// 344 | /// 345 | /// A 346 | /// 347 | private string FormatMilliseconds(int milliseconds) 348 | { 349 | if(milliseconds < 100) 350 | { 351 | if(milliseconds < 10) 352 | return String.Concat("00",milliseconds.ToString()); 353 | 354 | return String.Concat("0",milliseconds.ToString()); 355 | } 356 | 357 | return milliseconds.ToString(); 358 | } 359 | 360 | #endregion 361 | } 362 | 363 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------