add TUIO in Unity-19050-05-BallPool

master
chwan1 6 years ago
parent ab6fdfb790
commit 28b3f3b09d
  1. 6
      .gitmodules
  2. 3379
      Unity-19050-05-BallPool/Assets/Frozen/Frozen.unity
  3. 9
      Unity-19050-05-BallPool/Assets/Frozen/Script/SceneController.cs
  4. 23
      Unity-19050-05-BallPool/Assets/UnityUtilityNativePlugin/Script/DebugInformation.cs
  5. 13
      Unity-19050-05-BallPool/Assets/UnityUtilityNativePlugin/Script/DebugInformation.cs.meta
  6. 21
      Unity-19050-05-BallPool/Assets/UnityUtilityNativePlugin/Script/DisplayConfig.cs
  7. 11
      Unity-19050-05-BallPool/Assets/UnityUtilityNativePlugin/Script/DisplayConfig.cs.meta
  8. 9
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.NET.meta
  9. 127
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.NET/OSCBundle.cs
  10. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.NET/OSCBundle.cs.meta
  11. 213
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.NET/OSCMessage.cs
  12. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.NET/OSCMessage.cs.meta
  13. 292
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.NET/OSCPacket.cs
  14. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.NET/OSCPacket.cs.meta
  15. 77
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.NET/OSCReceiver.cs
  16. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.NET/OSCReceiver.cs.meta
  17. 313
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.NET/OSCTimeTag.cs
  18. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.NET/OSCTimeTag.cs.meta
  19. 80
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.NET/OSCTransmitter.cs
  20. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.NET/OSCTransmitter.cs.meta
  21. 9
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC.meta
  22. 75
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC/QrCodeOSCReceiver.cs
  23. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC/QrCodeOSCReceiver.cs.meta
  24. 80
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC/UCOSCReceiver.cs
  25. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/OSC/UCOSCReceiver.cs.meta
  26. 9
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO.meta
  27. 440
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioBlob.cs
  28. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioBlob.cs.meta
  29. 868
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioClient.cs
  30. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioClient.cs.meta
  31. 454
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioContainer.cs
  32. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioContainer.cs.meta
  33. 109
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioCursor.cs
  34. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioCursor.cs.meta
  35. 131
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioListener.cs
  36. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioListener.cs.meta
  37. 336
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioObject.cs
  38. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioObject.cs.meta
  39. 353
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioPoint.cs
  40. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioPoint.cs.meta
  41. 315
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioTime.cs
  42. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/3rdParty/TUIO/TuioTime.cs.meta
  43. 9
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO.meta
  44. 9
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/Editor.meta
  45. 15
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/Editor/CreateUcEventSystem.cs
  46. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/Editor/CreateUcEventSystem.cs.meta
  47. 18
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/FilterInterfaces.cs
  48. 13
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/FilterInterfaces.cs.meta
  49. 503
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/GlobalMKHookInput.cs
  50. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/GlobalMKHookInput.cs.meta
  51. 29
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/GlobalMKHookInputModule.cs
  52. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/GlobalMKHookInputModule.cs.meta
  53. 89
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/InputVisualizer.cs
  54. 13
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/InputVisualizer.cs.meta
  55. 183
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/TUIOInputModule.cs
  56. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/TUIOInputModule.cs.meta
  57. 238
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/TUIOManager.cs
  58. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/TUIOManager.cs.meta
  59. 90
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/TuioBuffer.cs
  60. 13
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/TuioBuffer.cs.meta
  61. 38
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/TuioDefaultFilter.cs
  62. 13
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/TuioDefaultFilter.cs.meta
  63. 11
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/TuioFilter.cs
  64. 13
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/TuioFilter.cs.meta
  65. 127
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/TuioUpdater.cs
  66. 13
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/TuioUpdater.cs.meta
  67. 11
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/UCEventSystem.cs
  68. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/UCEventSystem.cs.meta
  69. 154
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/UCEventSystem.prefab
  70. 8
      Unity-19050-05-BallPool/Assets/UnityUtils/TUIO/UCEventSystem.prefab.meta
  71. 58
      Unity-19050-05-BallPool/Assets/UnityUtils/UI/UCInputField.cs
  72. 12
      Unity-19050-05-BallPool/Assets/UnityUtils/UI/UCInputField.cs.meta
  73. 2
      Unity-19050-05-BallPool/Packages/com.ultracombos.chwan1
  74. 2
      Unity-19050-05-BallPool/Packages/manifest.json
  75. 1
      _Package/com.ultracombos.osc
  76. 1
      _Package/com.ultracombos.tuio

6
.gitmodules vendored

@ -25,3 +25,9 @@
path = Unity-19050-01_ForstCoronation/Packages/KlakSpout path = Unity-19050-01_ForstCoronation/Packages/KlakSpout
url = https://github.com/UltraCombos/KlakSpout url = https://github.com/UltraCombos/KlakSpout
branch = upm branch = upm
[submodule "_Package/com.ultracombos.osc"]
path = _Package/com.ultracombos.osc
url = https://github.com/UltraCombos/com.ultracombos.osc
[submodule "_Package/com.ultracombos.tuio"]
path = _Package/com.ultracombos.tuio
url = https://github.com/UltraCombos/com.ultracombos.tuio

File diff suppressed because it is too large Load Diff

@ -15,8 +15,6 @@ namespace UltraCombos.Frozen
public class SceneController : Singleton<SceneController> public class SceneController : Singleton<SceneController>
{ {
[SerializeField]
GlobalMKHookInput inputModule;
public State state = State.Standby; public State state = State.Standby;
public float standbyTime = 10.0f; public float standbyTime = 10.0f;
@ -136,16 +134,9 @@ namespace UltraCombos.Frozen
private bool GetKeyDown(KeyCode key) private bool GetKeyDown(KeyCode key)
{
if (Application.isFocused)
{ {
return Input.GetKeyDown(key); return Input.GetKeyDown(key);
} }
else
{
return inputModule.GetButtonDown(key.ToString());
}
}
public void GoStandby() public void GoStandby()
{ {

@ -1,23 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DebugInformation : MonoBehaviour
{
[SerializeField] Text fpsText;
float fps = 30.0f;
float stamp = -0.1f;
private void Start()
{
}
private void Update()
{
fps = Mathf.Lerp(fps, 1.0f / (Time.time - stamp), 0.02f);
stamp = Time.time;
fpsText.text = string.Format("fps: {0}", fps);
}
}

@ -1,13 +0,0 @@
fileFormatVersion: 2
guid: 69c0f378d0dcf504980865e62df80079
timeCreated: 1523610448
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,21 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace UltraCombos.Utility
{
public class DisplayConfig : MonoBehaviour
{
public int width = 1280;
public int height = 720;
public int fps = 60;
public bool fullscreen = true;
private void Awake()
{
Screen.SetResolution(width, height, fullscreen, fps);
Application.targetFrameRate = fps;
}
}
}

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 400c2cde369742e4690d5216c5c3b3c3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: fa57c10b7d260f14097cfff344c082df
folderAsset: yes
timeCreated: 1482467657
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -1,127 +0,0 @@
#region licence/info
// OSC.NET - Open Sound Control for .NET
// http://luvtechno.net/
//
// Copyright (c) 2006, Yoshinori Kawasaki
// All rights reserved.
//
// Changes and improvements:
// Copyright (c) 2006-2014 Martin Kaltenbrunner <martin@tuio.org>
// As included with http://reactivision.sourceforge.net/
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// * Neither the name of "luvtechno.net" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
// WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion licence/info
using System;
using System.Collections;
/// <summary>
/// VVVV OSC Utilities
/// </summary>
namespace OSC.NET
{
/// <summary>
/// OSCBundle
/// </summary>
public class OSCBundle : OSCPacket
{
protected const string BUNDLE = "#bundle";
private DateTime timestamp = new DateTime();
public OSCBundle(DateTime ts, bool extendedMode = false) : base(extendedMode)
{
this.address = BUNDLE;
this.timestamp = ts;
}
public OSCBundle(long ts, bool extendedMode = false) : base (extendedMode)
{
DateTime start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
timestamp = start.AddMilliseconds(ts).ToLocalTime();
}
public OSCBundle(bool extendedMode = false) : base (extendedMode)
{
this.address = BUNDLE;
this.timestamp = DateTime.Now;
}
override protected void pack()
{
ArrayList data = new ArrayList();
addBytes(data, packString(this.Address));
padNull(data);
addBytes(data, packTimeTag(timestamp)); // fixed point, 8 bytes
foreach(OSCPacket oscPacket in this.Values)
{
if (oscPacket != null)
{
byte[] bs = oscPacket.BinaryData;
addBytes(data, packInt(bs.Length));
addBytes(data, bs);
}
else
{
// TODO
}
}
this.binaryData = (byte[])data.ToArray(typeof(byte));
}
public static new OSCBundle Unpack(byte[] bytes, ref int start, int end, bool extendedMode = false)
{
string address = unpackString(bytes, ref start);
//Console.WriteLine("bundle: " + address);
if(!address.Equals(BUNDLE)) return null; // TODO
DateTime timestamp = unpackTimeTag(bytes, ref start);
OSCBundle bundle = new OSCBundle(timestamp, extendedMode);
while(start < end)
{
int length = unpackInt(bytes, ref start);
int sub_end = start + length;
bundle.Append(OSCPacket.Unpack(bytes, ref start, sub_end, extendedMode));
}
return bundle;
}
public DateTime getTimeStamp() {
return timestamp;
}
override public void Append(object value)
{
if( value is OSCPacket)
{
values.Add(value);
}
else
{
// TODO: exception
}
}
override public bool IsBundle() { return true; }
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 9670623378c1d1344912298eb9dc0878
timeCreated: 1482467657
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,213 +0,0 @@
#region licence/info
// OSC.NET - Open Sound Control for .NET
// http://luvtechno.net/
//
// Copyright (c) 2006, Yoshinori Kawasaki
// All rights reserved.
//
// Changes and improvements:
// Copyright (c) 2006-2014 Martin Kaltenbrunner <martin@tuio.org>
// As included with http://reactivision.sourceforge.net/
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// * Neither the name of "luvtechno.net" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
// WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion licence/info
using System;
using System.Collections;
using System.IO;
using System.Text;
namespace OSC.NET
{
/// <summary>
/// OSCMessage
///
/// Contains an address, a comma followed by one or more type identifiers. then the data itself follows in binary encoding.
/// </summary>
public class OSCMessage : OSCPacket
{
// These Attributes adhere to the OSC Specs 1.0
protected const char INTEGER = 'i'; // int32 8byte
protected const char FLOAT = 'f'; //float32 8byte
protected const char LONG = 'h'; //int64 16byte
protected const char DOUBLE = 'd'; // float64 16byte
protected const char STRING = 's'; // padded by zeros
protected const char SYMBOL = 'S'; // same as STRING really
protected const char BLOB = 'b'; // bytestream, starts with an int that tells the total length of th stream
protected const char TIMETAG = 't'; // fixed point floating number with 32bytes (16bytes for totaldays after 1.1.1900 and 16bytes for fractionOfDay)
protected const char CHAR = 'c'; // bit
protected const char COLOR = 'r'; // 4x8bit -> rgba
//protected const char TRUE = 'T';
//protected const char FALSE = 'F';
protected const char NIL = 'N';
//protected const char INFINITUM = 'I';
//protected const char ALL = '*';
// These Attributes are added for convenience within vvvv. They are NOT part of the OSC Specs, but are VERY useful if you want to make vvvv talk to another instance of vvvv
// Using them requires to set the ExtendedVVVVMethod property to true (with the constructor or with the Unpack methods, depending if you want to send or receive)
protected const char VECTOR2D = 'v'; // synonym to dd
protected const char VECTOR3D = 'V'; // synonym to ddd
protected const char QUATERNION = 'q'; // synonym to dddd
protected const char MATRIX4 = 'M'; // for 4x4 Matrices with float, so synonym to ffffffffffffffff
public OSCMessage(string address, bool extendedMode = false) : base(extendedMode)
{
this.typeTag = ",";
this.Address = address;
}
public OSCMessage(string address, object value, bool extendedMode = false) : base(extendedMode)
{
this.typeTag = ",";
this.Address = address;
Append(value);
}
override protected void pack()
{
ArrayList data = new ArrayList();
addBytes(data, packString(this.address));
padNull(data);
addBytes(data, packString(this.typeTag));
padNull(data);
foreach(object value in this.Values)
{
if(value is int) addBytes(data, packInt((int)value));
else if(value is long) addBytes(data, packLong((long)value));
else if(value is float) addBytes(data, packFloat((float)value));
else if(value is double) addBytes(data, packDouble((double)value));
else if(value is string) {
addBytes(data, packString((string)value));
padNull(data);
}
else if (value is Stream) {
addBytes(data, packBlob((Stream)value));
padNull(data);
}
//else if (value is RGBAColor) addBytes(data, packColor((RGBAColor)value));
else if (value is char) addBytes(data, packChar((char)value));
else if (value is DateTime)
{
addBytes(data, packTimeTag((DateTime)value));
}
}
this.binaryData = (byte[])data.ToArray(typeof(byte));
}
public static OSCMessage Unpack(byte[] bytes, ref int start, bool extendedMode = false)
{
string address = unpackString(bytes, ref start);
//Console.WriteLine("address: " + address);
OSCMessage msg = new OSCMessage(address, extendedMode);
char[] tags = unpackString(bytes, ref start).ToCharArray();
//Console.WriteLine("tags: " + new string(tags));
foreach(char tag in tags)
{
//Console.WriteLine("tag: " + tag + " @ "+start);
if(tag == ',') continue;
else if(tag == INTEGER) msg.Append(unpackInt(bytes, ref start));
else if(tag == LONG) msg.Append(unpackLong(bytes, ref start));
else if(tag == DOUBLE) msg.Append(unpackDouble(bytes, ref start));
else if(tag == FLOAT) msg.Append(unpackFloat(bytes, ref start));
else if (tag == STRING || tag == SYMBOL) msg.Append(unpackString(bytes, ref start));
else if (tag == CHAR) msg.Append(unpackChar(bytes, ref start));
else if (tag == BLOB) msg.Append(unpackBlob(bytes, ref start));
//else if (tag == COLOR) msg.Append(unpackColor(bytes, ref start));
else if (tag == TIMETAG) msg.Append(unpackTimeTag(bytes, ref start));
else Console.WriteLine("unknown tag: " + tag);
}
return msg;
}
override public void Append(object value)
{
if(value is int)
{
AppendTag(INTEGER);
}
else if(value is long)
{
AppendTag(LONG);
}
else if(value is float)
{
AppendTag(FLOAT);
}
else if(value is double)
{
AppendTag(DOUBLE);
}
else if(value is string)
{
AppendTag(STRING);
}
else if (value is char)
{
AppendTag(CHAR);
}
else if (value is Stream)
{
AppendTag(BLOB);
}
else if (value is DateTime)
{
AppendTag(TIMETAG);
}
/*else if (value is RGBAColor)
{
AppendTag(COLOR);
}*/
else
{
Fallback();
return;
}
values.Add(value);
}
private void Fallback()
{
AppendTag(NIL);
// values.Add("undefined");
}
protected string typeTag;
protected void AppendTag(char type)
{
typeTag += type;
}
override public bool IsBundle() { return false; }
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append(this.Address + " ");
for(int i = 0; i < values.Count; i++)
sb.Append(values[i].ToString() + " ");
return sb.ToString();
}
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 2e5455a72772ac84a8d970fe4da47144
timeCreated: 1482467657
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,292 +0,0 @@
#region licence/info
// OSC.NET - Open Sound Control for .NET
// http://luvtechno.net/
//
// Copyright (c) 2006, Yoshinori Kawasaki
// All rights reserved.
//
// Changes and improvements:
// Copyright (c) 2006-2014 Martin Kaltenbrunner <martin@tuio.org>
// As included with http://reactivision.sourceforge.net/
//
// Further implementations and specifications:
// Copyright (c) 2013 Marko Ritter <marko@intolight.de>
// As included with https://github.com/vvvv/vvvv-sdk///
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// * Neither the name of "luvtechno.net" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
// WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion licence/info
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Drawing;
namespace OSC.NET
{
/// <summary>
/// OSCPacket
/// </summary>
abstract public class OSCPacket
{
public static readonly Encoding ASCIIEncoding8Bit;
public bool ExtendedVVVVMode { get; set; }
static OSCPacket()
{
ASCIIEncoding8Bit = Encoding.ASCII;//Encoding.GetEncoding(1252);
}
public OSCPacket(bool extendedMode = false)
{
this.ExtendedVVVVMode = extendedMode;
this.values = new ArrayList();
}
protected static void addBytes(ArrayList data, byte[] bytes)
{
foreach(byte b in bytes)
{
data.Add(b);
}
}
protected static void padNull(ArrayList data)
{
byte zero = 0;
int pad = 4 - (data.Count % 4);
for (int i = 0; i < pad; i++)
{
data.Add(zero);
}
}
internal static byte[] swapEndian(byte[] data)
{
byte[] swapped = new byte[data.Length];
for(int i = data.Length - 1, j = 0 ; i >= 0 ; i--, j++)
{
swapped[j] = data[i];
}
return swapped;
}
protected static byte[] packInt(int value)
{
byte[] data = BitConverter.GetBytes(value);
if(BitConverter.IsLittleEndian) data = swapEndian(data);
return data;
}
protected static byte[] packLong(long value)
{
byte[] data = BitConverter.GetBytes(value);
if(BitConverter.IsLittleEndian) data = swapEndian(data);
return data;
}
protected static byte[] packFloat(float value)
{
byte[] data = BitConverter.GetBytes(value);
if(BitConverter.IsLittleEndian) data = swapEndian(data);
return data;
}
protected static byte[] packDouble(double value)
{
byte[] data = BitConverter.GetBytes(value);
if(BitConverter.IsLittleEndian) data = swapEndian(data);
return data;
}
protected static byte[] packString(string value)
{
return ASCIIEncoding8Bit.GetBytes(value);
}
protected static byte[] packChar(char value)
{
byte[] data = BitConverter.GetBytes(value);
if (BitConverter.IsLittleEndian) data = swapEndian(data);
return data;
}
private static void Copy(Stream src, Stream dst, int bufferSize = 81920)
{
byte[] array = new byte[bufferSize];
int count;
while ((count = src.Read(array, 0, array.Length)) != 0)
{
dst.Write(array, 0, count);
}
}
protected static byte[] packBlob(Stream value)
{
var mem = new MemoryStream();
value.Seek(0, SeekOrigin.Begin);
//value.CopyTo(mem);
Copy(value, mem);
byte[] valueData = mem.ToArray();
var lData = new ArrayList();
var length = packInt(valueData.Length);
lData.AddRange(length);
lData.AddRange(valueData);
return (byte[])lData.ToArray(typeof(byte));
}
protected static byte[] packTimeTag(DateTime value)
{
var tag = new OscTimeTag();
tag.Set(value);
return tag.ToByteArray(); ;
}
protected static byte[] packColor(Color col)
{
byte[] data = {col.R, col.G, col.B, col.A};
if (BitConverter.IsLittleEndian) data = swapEndian(data);
return data;
}
abstract protected void pack();
protected byte[] binaryData;
public byte[] BinaryData
{
get
{
pack();
return binaryData;
}
}
protected static int unpackInt(byte[] bytes, ref int start)
{
byte[] data = new byte[4];
for(int i = 0 ; i < 4 ; i++, start++) data[i] = bytes[start];
if(BitConverter.IsLittleEndian) data = swapEndian(data);
return BitConverter.ToInt32(data, 0);
}
protected static long unpackLong(byte[] bytes, ref int start)
{
byte[] data = new byte[8];
for(int i = 0 ; i < 8 ; i++, start++) data[i] = bytes[start];
if(BitConverter.IsLittleEndian) data = swapEndian(data);
return BitConverter.ToInt64(data, 0);
}
protected static float unpackFloat(byte[] bytes, ref int start)
{
byte[] data = new byte[4];
for(int i = 0 ; i < 4 ; i++, start++) data[i] = bytes[start];
if(BitConverter.IsLittleEndian) data = swapEndian(data);
return BitConverter.ToSingle(data, 0);
}
protected static double unpackDouble(byte[] bytes, ref int start)
{
byte[] data = new byte[8];
for(int i = 0 ; i < 8 ; i++, start++) data[i] = bytes[start];
if(BitConverter.IsLittleEndian) data = swapEndian(data);
return BitConverter.ToDouble(data, 0);
}
protected static string unpackString(byte[] bytes, ref int start)
{
int count= 0;
for(int index = start ; bytes[index] != 0 ; index++, count++) ;
string s = ASCIIEncoding8Bit.GetString(bytes, start, count);
start += count+1;
start = (start + 3) / 4 * 4;
return s;
}
protected static char unpackChar(byte[] bytes, ref int start)
{
byte[] data = {bytes[start]};
return BitConverter.ToChar(data, 0);
}
protected static Stream unpackBlob(byte[] bytes, ref int start)
{
int length = unpackInt(bytes, ref start);
byte[] buffer = new byte[length];
Array.Copy(bytes, start, buffer, 0, length);
start += length;
start = (start + 3) / 4 * 4;
return new MemoryStream(buffer);
}
protected static Color unpackColor(byte[] bytes, ref int start)
{
byte[] data = new byte[4];
for (int i = 0; i < 4; i++, start++) data[i] = bytes[start];
if (BitConverter.IsLittleEndian) data = swapEndian(data);
return Color.FromArgb (data[3],data[0],data[1],data[2]);
}
protected static DateTime unpackTimeTag(byte[] bytes, ref int start)
{
byte[] data = new byte[8];
for (int i = 0; i < 8; i++, start++) data[i] = bytes[start];
var tag = new OscTimeTag(data);
return tag.DateTime;
}
public static OSCPacket Unpack(byte[] bytes, bool extendedMode = false)
{
int start = 0;
return Unpack(bytes, ref start, bytes.Length, extendedMode);
}
public static OSCPacket Unpack(byte[] bytes, ref int start, int end, bool extendedMode = false)
{
if(bytes[start] == '#') return OSCBundle.Unpack(bytes, ref start, end, extendedMode);
else return OSCMessage.Unpack(bytes, ref start, extendedMode);
}
protected string address;
public string Address
{
get { return address; }
set
{
// TODO: validate
address = value;
}
}
protected ArrayList values;
public ArrayList Values
{
get { return (ArrayList)values.Clone(); }
}
abstract public void Append(object value);
abstract public bool IsBundle();
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 1d5e22291a499ea4e9b4eb0aa812e8b0
timeCreated: 1482467657
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,77 +0,0 @@
#region licence/info
// OSC.NET - Open Sound Control for .NET
// http://luvtechno.net/
//
// Copyright (c) 2006, Yoshinori Kawasaki
// All rights reserved.
//
// Changes and improvements:
// Copyright (c) 2006-2014 Martin Kaltenbrunner <martin@tuio.org>
// As included with http://reactivision.sourceforge.net/
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// * Neither the name of "luvtechno.net" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
// WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion licence/info
using System;
using System.Net;
using System.Net.Sockets;
namespace OSC.NET
{
/// <summary>
/// OSCReceiver
/// </summary>
public class OSCReceiver
{
protected UdpClient udpClient;
protected int localPort;
public OSCReceiver(int localPort)
{
this.localPort = localPort;
Connect();
}
public void Connect()
{
if(this.udpClient != null) Close();
this.udpClient = new UdpClient(this.localPort);
}
public void Close()
{
if (this.udpClient!=null) this.udpClient.Close();
this.udpClient = null;
}
public OSCPacket Receive()
{
try
{
IPEndPoint ip = new IPEndPoint(IPAddress.Any, 0);
byte[] bytes = this.udpClient.Receive(ref ip);
if (bytes != null && bytes.Length > 0)
return OSCPacket.Unpack(bytes);
} catch (Exception e) {
Console.WriteLine(e.Message);
return null;
}
return null;
}
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 87f223074907a514aba8f8e9fb8559cf
timeCreated: 1482467657
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,313 +0,0 @@
/* Microsoft Public License (MS-PL)
* 2013, Paul Varcholik
* http://bespokesoftware.org/
This license governs use of the accompanying software. If you use the software, you
accept this license. If you do not accept the license, do not use the software.
1. Definitions
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the
same meaning here as under U.S. copyright law.
A "contribution" is the original software, or any additions or changes to the software.
A "contributor" is any person that distributes its contribution under this license.
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
2. Grant of Rights
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
3. Conditions and Limitations
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
*/
using System;
using System.Collections.Generic;
namespace OSC.NET
{
public class OscTimeTag
{
/// <summary>
/// Osc Time Epoch (January 1, 1900 00:00:00).
/// </summary>
public static readonly DateTime Epoch = new DateTime(1900, 1, 1, 0, 0, 0, 0);
/// <summary>
/// Minimum Osc Time Tag.
/// </summary>
public static readonly OscTimeTag MinValue = new OscTimeTag(Epoch + TimeSpan.FromMilliseconds(1.0));
/// <summary>
/// Gets the first 32 bits of the Osc Time Tag. Specifies the number of seconds since the epoch.
/// </summary>
public uint SecondsSinceEpoch
{
get
{
return (uint)(mTimeStamp - Epoch).TotalSeconds;
}
}
/// <summary>
/// Gets the last 32 bits of the Osc Time Tag. Specifies the fractional part of a second.
/// </summary>
public uint FractionalSecond
{
get
{
return (uint)((mTimeStamp - Epoch).Milliseconds);
}
}
/// <summary>
/// Gets the Osc Time Tag as a DateTime value.
/// </summary>
public DateTime DateTime
{
get
{
return mTimeStamp;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="OscTimeTag"/> class.
/// </summary>
/// <remarks>Defaults the Osc Time Tag value to DateTime.Now.</remarks>
public OscTimeTag()
: this(DateTime.Now)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="OscTimeTag"/> class.
/// </summary>
/// <param name="timeStamp">The time stamp to use to set the Osc Time Tag.</param>
public OscTimeTag(DateTime timeStamp)
{
Set(timeStamp);
}
/// <summary>
/// Initializes a new instance of the <see cref="OscTimeTag"/> class.
/// </summary>
/// <param name="data">The time stamp to use to set the Osc Time Tag.</param>
public OscTimeTag(byte[] data)
{
byte[] secondsSinceEpochData = new byte[4];
Array.Copy(data, 0, secondsSinceEpochData, 0, 4);
byte[] fractionalSecondData = new byte[4];
Array.Copy(data, 4, fractionalSecondData, 0, 4);
if (BitConverter.IsLittleEndian)
{
secondsSinceEpochData = OSCPacket.swapEndian(secondsSinceEpochData);
fractionalSecondData = OSCPacket.swapEndian(fractionalSecondData);
}
uint secondsSinceEpoch = BitConverter.ToUInt32(secondsSinceEpochData, 0);
uint fractionalSecond = BitConverter.ToUInt32(fractionalSecondData, 0);
DateTime timeStamp = Epoch.AddSeconds(secondsSinceEpoch).AddMilliseconds(fractionalSecond);
if (!IsValidTime(timeStamp)) throw new Exception("Not a valid OSC Timetag discovered.");
mTimeStamp = timeStamp;
}
/// <summary>
/// Convert the Osc Time Tag to a byte array.
/// </summary>
/// <returns>A byte array containing the Osc Time Tag.</returns>
public byte[] ToByteArray()
{
List<byte> timeStamp = new List<byte>();
byte[] secondsSinceEpoch = BitConverter.GetBytes(SecondsSinceEpoch);
byte[] fractionalSecond = BitConverter.GetBytes(FractionalSecond);
if (BitConverter.IsLittleEndian) // != OscPacket.LittleEndianByteOrder)
{
secondsSinceEpoch = OSCPacket.swapEndian(secondsSinceEpoch);
fractionalSecond = OSCPacket.swapEndian(fractionalSecond);
}
timeStamp.AddRange(secondsSinceEpoch);
timeStamp.AddRange(fractionalSecond);
return timeStamp.ToArray();
}
/// <summary>
/// Determines whether two specified instances of OscTimeTag are equal.
/// </summary>
/// <param name="lhs">An OscTimeTag.</param>
/// <param name="rhs">An OscTimeTag.</param>
/// <returns>true if lhs and rhs represent the same time tag; otherwise, false.</returns>
public static bool Equals(OscTimeTag lhs, OscTimeTag rhs)
{
return lhs.Equals(rhs);
}
/// <summary>
/// Determines whether two specified instances of OscTimeTag are equal.
/// </summary>
/// <param name="lhs">An OscTimeTag.</param>
/// <param name="rhs">An OscTimeTag.</param>
/// <returns>true if lhs and rhs represent the same time tag; otherwise, false.</returns>
public static bool operator ==(OscTimeTag lhs, OscTimeTag rhs)
{
if (ReferenceEquals(lhs, rhs))
{
return true;
}
if (((object)lhs == null) || ((object)rhs == null))
{
return false;
}
return lhs.DateTime == rhs.DateTime;
}
/// <summary>
/// Determines whether two specified instances of OscTimeTag are not equal.
/// </summary>
/// <param name="lhs">An OscTimeTag.</param>
/// <param name="rhs">An OscTimeTag.</param>
/// <returns>true if lhs and rhs do not represent the same time tag; otherwise, false.</returns>
public static bool operator !=(OscTimeTag lhs, OscTimeTag rhs)
{
return !(lhs == rhs);
}
/// <summary>
/// Determines whether one specified <see cref="OscTimeTag"/> is less than another specified <see cref="OscTimeTag"/>.
/// </summary>
/// <param name="lhs">An OscTimeTag.</param>
/// <param name="rhs">An OscTimeTag.</param>
/// <returns>true if lhs is less than rhs; otherwise, false.</returns>
public static bool operator <(OscTimeTag lhs, OscTimeTag rhs)
{
return lhs.DateTime < rhs.DateTime;
}
/// <summary>
/// Determines whether one specified <see cref="OscTimeTag"/> is less than or equal to another specified <see cref="OscTimeTag"/>.
/// </summary>
/// <param name="lhs">An OscTimeTag.</param>
/// <param name="rhs">An OscTimeTag.</param>
/// <returns>true if lhs is less than or equal to rhs; otherwise, false.</returns>
public static bool operator <=(OscTimeTag lhs, OscTimeTag rhs)
{
return lhs.DateTime <= rhs.DateTime;
}
/// <summary>
/// Determines whether one specified <see cref="OscTimeTag"/> is greater than another specified <see cref="OscTimeTag"/>.
/// </summary>
/// <param name="lhs">An OscTimeTag.</param>
/// <param name="rhs">An OscTimeTag.</param>
/// <returns>true if lhs is greater than rhs; otherwise, false.</returns>
public static bool operator >(OscTimeTag lhs, OscTimeTag rhs)
{
return lhs.DateTime > rhs.DateTime;
}
/// <summary>
/// Determines whether one specified <see cref="OscTimeTag"/> is greater than or equal to another specified <see cref="OscTimeTag"/>.
/// </summary>
/// <param name="lhs">An OscTimeTag.</param>
/// <param name="rhs">An OscTimeTag.</param>
/// <returns>true if lhs is greater than or equal to rhs; otherwise, false.</returns>
public static bool operator >=(OscTimeTag lhs, OscTimeTag rhs)
{
return lhs.DateTime >= rhs.DateTime;
}
/// <summary>
/// Validates the time stamp for use in an Osc Time Tag.
/// </summary>
/// <param name="timeStamp">The time stamp to validate.</param>
/// <returns>True if the time stamp is a valid Osc Time Tag; false, otherwise.</returns>
/// <remarks>Time stamps must be greater-than-or-equal to <see cref="OscTimeTag.MinValue"/>.</remarks>
public static bool IsValidTime(DateTime timeStamp)
{
return (timeStamp >= Epoch + TimeSpan.FromMilliseconds(1.0));
}
/// <summary>
/// Sets the value of the Osc Time Tag.
/// </summary>
/// <param name="timeStamp">The time stamp to use to set the Osc Time Tag.</param>
public void Set(DateTime timeStamp)
{
timeStamp = new DateTime(timeStamp.Ticks - (timeStamp.Ticks % TimeSpan.TicksPerMillisecond), timeStamp.Kind);
if(!IsValidTime(timeStamp)) throw new Exception("Not a valid OSC Timetag.");
mTimeStamp = timeStamp;
}
/// <summary>
/// Returns a value indicating whether this instance is equal to a specified object.
/// </summary>
/// <param name="value">An object to compare to this instance.</param>
/// <returns>true if value is an instance of System.DateTime and equals the value of this instance; otherwise, false.</returns>
public override bool Equals(object value)
{
if (value == null)
{
return false;
}
OscTimeTag rhs = value as OscTimeTag;
if (rhs == null)
{
return false;
}
return mTimeStamp.Equals(rhs.mTimeStamp);
}
/// <summary>
/// Returns a value indicating whether this instance is equal to a specified OscTimeTag instance.
/// </summary>
/// <param name="value">An object to compare to this instance.</param>
/// <returns>true if value is an instance of System.DateTime and equals the value of this instance; otherwise, false.</returns>
public bool Equals(OscTimeTag value)
{
if ((object)value == null)
{
return false;
}
return mTimeStamp.Equals(value.mTimeStamp);
}
/// <summary>
/// Returns the hash code for this instance.
/// </summary>
/// <returns>A 32-bit signed integer hash code.</returns>
public override int GetHashCode()
{
return mTimeStamp.GetHashCode();
}
/// <summary>
/// Converts the value of the current <see cref="OscTimeTag"/> object to its equivalent string representation.
/// </summary>
/// <returns>A string representation of the value of the current <see cref="OscTimeTag"/> object.</returns>
public override string ToString()
{
return mTimeStamp.ToString();
}
private DateTime mTimeStamp;
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 279fb1fcfe44c074f8df93e4e6c301c7
timeCreated: 1482467657
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,80 +0,0 @@
#region licence/info
// OSC.NET - Open Sound Control for .NET
// http://luvtechno.net/
//
// Copyright (c) 2006, Yoshinori Kawasaki
// All rights reserved.
//
// Changes and improvements:
// Copyright (c) 2006-2014 Martin Kaltenbrunner <martin@tuio.org>
// As included with http://reactivision.sourceforge.net/
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// * Neither the name of "luvtechno.net" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
// WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion licence/info
using System;
using System.Net;
using System.Net.Sockets;
using System.Diagnostics;
namespace OSC.NET
{
/// <summary>
/// OSCTransmitter
/// </summary>
public class OSCTransmitter
{
protected UdpClient udpClient;
protected string remoteHost;
protected int remotePort;
public OSCTransmitter(string remoteHost, int remotePort)
{
this.remoteHost = remoteHost;
this.remotePort = remotePort;
Connect();
}
public void Connect()
{
if(this.udpClient != null) Close();
this.udpClient = new UdpClient(this.remoteHost, this.remotePort);
}
public void Close()
{
this.udpClient.Close();
this.udpClient = null;
}
public int Send(OSCPacket packet)
{
int byteNum = 0;
byte[] data = packet.BinaryData;
try
{
byteNum = this.udpClient.Send(data, data.Length);
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
Debug.WriteLine(e.StackTrace);
}
return byteNum;
}
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: bb78f7ece681028498e13b4403bb5ee3
timeCreated: 1482467657
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: deb7d6460f0841542b7fbcd85e9e3f92
folderAsset: yes
timeCreated: 1505186844
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -1,75 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using OSC.NET;
using UnityEngine.Events;
public class QrCodeOSCReceiver : UCOSCReceiver {
private const string OSCqrcodeAddress = "/qrcode";
[SerializeField]
private string qrcodeaddress;
private int TimeStep;
private int tempTimeStep;
[System.Serializable]
public class QrcodeAddressHandler : UnityEvent<string> { };
public QrcodeAddressHandler QrcodeAddressEvent = new QrcodeAddressHandler();
private List<string> qrcodes = new List<string>();
new void Awake()
{
base.Awake();
PacketReceivedEvent += PacketToQrcode;
}
private new void Update()
{
base.Update();
if(TimeStep != tempTimeStep)
{
TimeStep = tempTimeStep;
if(qrcodes.Count != 0)
{
lock(qrcodes)
{
qrcodeaddress = qrcodes[0];
print(qrcodeaddress + ";");
qrcodes.RemoveAt(0);
QrcodeAddressEvent.Invoke(qrcodeaddress);
}
}
}
}
new void OnDestroy()
{
base.OnDestroy();
}
public void PacketToQrcode(OSCPacket packet)
{
ArrayList arraylist;
if (!packet.IsBundle())
{
OSCMessage msg = (OSCMessage)packet;
arraylist = msg.Values;
}
else
{
OSCBundle bundle = (OSCBundle)packet;
arraylist = bundle.Values;
}
Debug.Log(packet.Address);
if (packet.Address == OSCqrcodeAddress)
{
if (tempTimeStep != (int)arraylist[0])
{
tempTimeStep = (int)arraylist[0];
lock (qrcodes)
{
qrcodes.Add((string)arraylist[1]);
}
}
}
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 14027a9fa6ea80343add45670fbba46e
timeCreated: 1505126203
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,80 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using OSC.NET;
using System.Threading;
using UnityEngine.Events;
public class UCOSCReceiver : MonoBehaviour {
protected Thread thread;
protected OSCReceiver oscreceiver;
public int OSCReceivePort;
protected bool isOSCReceiving = false;
[System.Serializable]
public class OSCPacketHandler : UnityEvent<OSCPacket> { };
public OSCPacketHandler OSCPacketReceiveEvent = new OSCPacketHandler();
public delegate void PacketReceivedEventHandler(OSCPacket packet);
public event PacketReceivedEventHandler PacketReceivedEvent;
private Queue<OSCPacket> OscPacketQueue = new Queue<OSCPacket>();
protected void Awake()
{
oscreceiver = new OSCReceiver(OSCReceivePort);
thread = new Thread(Receive);
thread.Start();
}
protected void Update()
{
if(OscPacketQueue.Count !=0)
{
SendEventQueue();
}
}
protected void SendEventQueue()
{
OSCPacket packet = null;
while (true)
{
lock (OscPacketQueue)
{
if (OscPacketQueue.Count > 0)
packet = OscPacketQueue.Dequeue();
else
return;
}
if (PacketReceivedEvent != null)
PacketReceivedEvent.Invoke(packet);
if (OSCPacketReceiveEvent != null)
OSCPacketReceiveEvent.Invoke(packet);
}
}
protected void Receive()
{
isOSCReceiving = true;
while (isOSCReceiving)
{
OSCPacket packet = oscreceiver.Receive();
if (packet != null)
{
lock(OscPacketQueue)
{
OscPacketQueue.Enqueue(packet);
}
}
Thread.Sleep(1);
}
}
protected void OnDestroy()
{
oscreceiver.Close();
isOSCReceiving = false;
thread.Join();
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: bce2447b045f72647ab51f6dd6cfba77
timeCreated: 1505123819
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: ed93ffb713e535d4a95e9ef7f57b6a33
folderAsset: yes
timeCreated: 1482467558
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -1,440 +0,0 @@
/*
TUIO C# Library - part of the reacTIVision project
Copyright (c) 2005-2014 Martin Kaltenbrunner <martin@tuio.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
*/
using System;
using System.Collections.Generic;
namespace TUIO
{
/**
* <remarks>
* The TuioBlob class encapsulates /tuio/2Dblb TUIO objects.
* </remarks>
*
* @author Martin Kaltenbrunner
* @version 1.1.5
*/
public class TuioBlob : TuioContainer
{
/**
* <summary>
* The individual symbol ID number that is assigned to each TuioBlob.</summary>
*/
protected int blob_id;
/**
* <summary>
* The rotation angle value.</summary>
*/
protected float angle;
/**
* <summary>
* The blob width value.</summary>
*/
protected float width;
/**
* <summary>
* The blob height value.</summary>
*/
protected float height;
/**
* <summary>
* The blob area value.</summary>
*/
protected float area;
/**
* <summary>
* The rotation speed value.</summary>
*/
protected float rotation_speed;
/**
* <summary>
* The rotation acceleration value.</summary>
*/
protected float rotation_accel;
#region State Enumeration Values
/**
* <summary>
* Defines the ROTATING state.</summary>
*/
public static readonly int TUIO_ROTATING = 5;
#endregion
#region Constructors
/**
* <summary>
* This constructor takes a TuioTime argument and assigns it along with the provided
* Session ID, Symbol ID, X and Y coordinate and angle to the newly created TuioBlob.</summary>
*
* <param name="ttime">the TuioTime to assign</param>
* <param name="si">the Session ID to assign</param>
* <param name="bi">the Blob ID to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
* <param name="a">the angle to assign</param>
* <param name="w">the width to assign</param>
* <param name="h">the height to assign</param>
* <param name="f">the area to assign</param>
*/
public TuioBlob(TuioTime ttime, long si, int bi, float xp, float yp, float a, float w, float h, float f)
: base(ttime, si, xp, yp)
{
blob_id = bi;
angle = a;
width = w;
height = h;
area = f;
rotation_speed = 0.0f;
rotation_accel = 0.0f;
}
/**
* <summary>
* This constructor takes the provided Session ID, Symbol ID, X and Y coordinate
* and angle, and assigs these values to the newly created TuioBlob.</summary>
*
* <param name="si">the Session ID to assign</param>
* <param name="sym">the Symbol ID to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
* <param name="a">the angle to assign</param>
* <param name="w">the width to assign</param>
* <param name="h">the height to assign</param>
* <param name="f">the area to assign</param>
*/
public TuioBlob(long si, int bi, float xp, float yp, float a, float w, float h, float f)
: base(si, xp, yp)
{
blob_id = bi;
angle = a;
width = w;
height = h;
area = f;
rotation_speed = 0.0f;
rotation_accel = 0.0f;
}
/**
* <summary>
* This constructor takes the atttibutes of the provided TuioBlob
* and assigs these values to the newly created TuioBlob.</summary>
*
* <param name="tblb">the TuioBlob to assign</param>
*/
public TuioBlob(TuioBlob tblb)
: base(tblb)
{
blob_id = tblb.BlobID;
angle = tblb.Angle;
width = tblb.Width;
height = tblb.Height;
area = tblb.Area;
rotation_speed = 0.0f;
rotation_accel = 0.0f;
}
#endregion
#region Update Methods
/**
* <summary>
* Takes a TuioTime argument and assigns it along with the provided
* X and Y coordinate, angle, X and Y velocity, motion acceleration,
* rotation speed and rotation acceleration to the private TuioBlob attributes.</summary>
*
* <param name="ttime">the TuioTime to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
* <param name="a">the angle coordinate to assign</param>
* <param name="w">the width to assign</param>
* <param name="h">the height to assign</param>
* <param name="f">the area to assign</param>
* <param name="xs">the X velocity to assign</param>
* <param name="ys">the Y velocity to assign</param>
* <param name="rs">the rotation velocity to assign</param>
* <param name="ma">the motion acceleration to assign</param>
* <param name="ra">the rotation acceleration to assign</param>
*/
public void update(TuioTime ttime, float xp, float yp, float a, float w, float h, float f, float xs, float ys, float rs, float ma, float ra)
{
base.update(ttime, xp, yp, xs, ys, ma);
angle = a;
width = w;
height = h;
area = f;
rotation_speed = rs;
rotation_accel = ra;
if ((rotation_accel != 0) && (state != TUIO_STOPPED)) state = TUIO_ROTATING;
}
/**
* <summary>
* Assigns the provided X and Y coordinate, angle, X and Y velocity, motion acceleration
* rotation velocity and rotation acceleration to the private TuioContainer attributes.
* The TuioTime time stamp remains unchanged.</summary>
*
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
* <param name="a">the angle coordinate to assign</param>
* <param name="w">the width to assign</param>
* <param name="h">the height to assign</param>
* <param name="f">the area to assign</param>
* <param name="xs">the X velocity to assign</param>
* <param name="ys">the Y velocity to assign</param>
* <param name="rs">the rotation velocity to assign</param>
* <param name="ma">the motion acceleration to assign</param>
* <param name="ra">the rotation acceleration to assign</param>
*/
public void update(float xp, float yp, float a, float w, float h, float f, float xs, float ys, float rs, float ma, float ra)
{
base.update(xp, yp, xs, ys, ma);
angle = a;
width = w;
height = h;
area = f;
rotation_speed = rs;
rotation_accel = ra;
if ((rotation_accel != 0) && (state != TUIO_STOPPED)) state = TUIO_ROTATING;
}
/**
* <summary>
* Takes a TuioTime argument and assigns it along with the provided
* X and Y coordinate and angle to the private TuioBlob attributes.
* The speed and accleration values are calculated accordingly.</summary>
*
* <param name="ttime">the TuioTime to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
* <param name="a">the angle coordinate to assign</param>
* <param name="w">the width to assign</param>
* <param name="h">the height to assign</param>
* <param name="f">the area to assign</param>
*/
public void update(TuioTime ttime, float xp, float yp, float a,float w, float h, float f)
{
TuioPoint lastPoint = path[path.Count - 1];
base.update(ttime, xp, yp);
width = w;
height = h;
area = f;
TuioTime diffTime = currentTime - lastPoint.TuioTime;
float dt = diffTime.TotalMilliseconds / 1000.0f;
float last_angle = angle;
float last_rotation_speed = rotation_speed;
angle = a;
float da = (angle - last_angle) / (2.0f * (float)Math.PI);
if (da > 0.75f) da -= 1.0f;
else if (da < -0.75f) da += 1.0f;
rotation_speed = da / dt;
rotation_accel = (rotation_speed - last_rotation_speed) / dt;
if ((rotation_accel != 0) && (state != TUIO_STOPPED)) state = TUIO_ROTATING;
}
/**
* <summary>
* Takes the atttibutes of the provided TuioBlob
* and assigs these values to this TuioBlob.
* The TuioTime time stamp of this TuioContainer remains unchanged.</summary>
*
* <param name="tblb">the TuioContainer to assign</param>
*/
public void update(TuioBlob tblb)
{
base.update(tblb);
angle = tblb.Angle;
width = tblb.Width;
height = tblb.Height;
area = tblb.Area;
rotation_speed = tblb.RotationSpeed;
rotation_accel = tblb.RotationAccel;
if ((rotation_accel != 0) && (state != TUIO_STOPPED)) state = TUIO_ROTATING;
}
/**
* <summary>
* This method is used to calculate the speed and acceleration values of a
* TuioBlob with unchanged position and angle.</summary>
*/
public new void stop(TuioTime ttime)
{
update(ttime, this.xpos, this.ypos, this.angle, this.width, this.height, this.area);
}
#endregion
#region Properties & Getter/Setter Methods
/**
* <summary>
* Returns the symbol ID of this TuioBlob.</summary>
* <returns>the symbol ID of this TuioBlob</returns>
*/
public int BlobID
{
get { return blob_id; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public int getBlobID()
{
return BlobID;
}
/**
* <summary>
* Returns the width of this TuioBlob.</summary>
* <returns>the width of this TuioBlob</returns>
*/
public float Width
{
get { return width; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public float getWidth()
{
return Width;
}
/**
* <summary>
* Returns the height of this TuioBlob.</summary>
* <returns>the heigth of this TuioBlob</returns>
*/
public float Height
{
get { return height; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public float getHeight()
{
return Height;
}
/**
* <summary>
* Returns the area of this TuioBlob.</summary>
* <returns>the area of this TuioBlob</returns>
*/
public float Area
{
get { return area; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public float getArea()
{
return Area;
}
/**
* <summary>
* Returns the rotation angle of this TuioBlob.</summary>
* <returns>the rotation angle of this TuioBlob</returns>
*/
public float Angle
{
get { return angle; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public float getAngle()
{
return Angle;
}
/**
* <summary>
* Returns the rotation angle in degrees of this TuioBlob.</summary>
* <returns>the rotation angle in degrees of this TuioBlob</returns>
*/
public float AngleDegrees
{
get { return angle / (float)Math.PI * 180.0f; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public float getAngleDegrees()
{
return AngleDegrees;
}
/**
* <summary>
* Returns the rotation speed of this TuioBlob.</summary>
* <returns>the rotation speed of this TuioBlob</returns>
*/
public float RotationSpeed
{
get { return rotation_speed; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public float getRotationSpeed()
{
return RotationSpeed;
}
/**
* <summary>
* Returns the rotation acceleration of this TuioBlob.</summary>
* <returns>the rotation acceleration of this TuioBlob</returns>
*/
public float RotationAccel
{
get { return rotation_accel; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public float getRotationAccel()
{
return RotationAccel;
}
/**
* <summary>
* Returns true of this TuioBlob is moving.</summary>
* <returns>true of this TuioBlob is moving</returns>
*/
public override bool isMoving
{
get
{
if ((state == TUIO_ACCELERATING) || (state == TUIO_DECELERATING) || (state == TUIO_ROTATING)) return true;
else return false;
}
}
#endregion
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 3e648284471a6a84cac17552235670f8
timeCreated: 1482467612
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,868 +0,0 @@
/*
TUIO C# Library - part of the reacTIVision project
Copyright (c) 2005-2014 Martin Kaltenbrunner <martin@tuio.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
*/
using System;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using OSC.NET;
namespace TUIO
{
/**
* <remarks>
* The TuioClient class is the central TUIO protocol decoder component. It provides a simple callback infrastructure using the {@link TuioListener} interface.
* In order to receive and decode TUIO messages an instance of TuioClient needs to be created. The TuioClient instance then generates TUIO events
* which are broadcasted to all registered classes that implement the {@link TuioListener} interface.
* </remarks>
* <example>
* <code>
* TuioClient client = new TuioClient();
* client.addTuioListener(myTuioListener);
* client.start();
* </code>
* </example>
*
* @author Martin Kaltenbrunner
* @version 1.1,5
*/
public class TuioClient
{
private bool connected = false;
private int port = 3333;
private OSCReceiver receiver;
private Thread thread;
private object cursorSync = new object();
private object objectSync = new object();
private object blobSync = new object();
private Dictionary<long, TuioObject> objectList = new Dictionary<long, TuioObject>(32);
private List<long> aliveObjectList = new List<long>(32);
private List<long> newObjectList = new List<long>(32);
private Dictionary<long, TuioCursor> cursorList = new Dictionary<long, TuioCursor>(32);
private List<long> aliveCursorList = new List<long>(32);
private List<long> newCursorList = new List<long>(32);
private Dictionary<long, TuioBlob> blobList = new Dictionary<long, TuioBlob>(32);
private List<long> aliveBlobList = new List<long>(32);
private List<long> newBlobList = new List<long>(32);
private List<TuioObject> frameObjects = new List<TuioObject>(32);
private List<TuioCursor> frameCursors = new List<TuioCursor>(32);
private List<TuioBlob> frameBlobs = new List<TuioBlob>(32);
private List<TuioCursor> freeCursorList = new List<TuioCursor>();
private int maxCursorID = -1;
private List<TuioBlob> freeBlobList = new List<TuioBlob>();
private int maxBlobID = -1;
private int currentFrame = 0;
private TuioTime currentTime;
private List<TuioListener> listenerList = new List<TuioListener>();
#region Constructors
/**
* <summary>
* The default constructor creates a client that listens to the default TUIO port 3333</summary>
*/
public TuioClient() { }
/**
* <summary>
* This constructor creates a client that listens to the provided port</summary>
* <param name="port">the listening port number</param>
*/
public TuioClient(int port)
{
this.port = port;
}
#endregion
#region Connection Methods
/**
* <summary>
* Returns the port number listening to.</summary>
* <returns>the listening port number</returns>
*/
public int getPort()
{
return port;
}
/**
* <summary>
* The TuioClient starts listening to TUIO messages on the configured UDP port
* All reveived TUIO messages are decoded and the resulting TUIO events are broadcasted to all registered TuioListeners</summary>
*/
public void connect()
{
TuioTime.initSession();
currentTime = new TuioTime();
currentTime.reset();
try
{
receiver = new OSCReceiver(port);
connected = true;
thread = new Thread(new ThreadStart(listen));
thread.Start();
}
catch (Exception e)
{
Console.WriteLine("failed to connect to port " + port);
Console.WriteLine(e.Message);
}
}
/**
* <summary>
* The TuioClient stops listening to TUIO messages on the configured UDP port</summary>
*/
public void disconnect()
{
connected = false;
if (receiver != null) receiver.Close();
receiver = null;
aliveObjectList.Clear();
aliveCursorList.Clear();
aliveBlobList.Clear();
objectList.Clear();
cursorList.Clear();
blobList.Clear();
frameObjects.Clear();
frameCursors.Clear();
frameBlobs.Clear();
freeCursorList.Clear();
freeBlobList.Clear();
}
/**
* <summary>
* Returns true if this TuioClient is currently connected.</summary>
* <returns>true if this TuioClient is currently connected</returns>
*/
public bool isConnected() { return connected; }
private void listen()
{
while (connected)
{
try
{
OSCPacket packet = receiver.Receive();
if (packet != null)
{
if (packet.IsBundle())
{
ArrayList messages = packet.Values;
for (int i = 0; i < messages.Count; i++)
{
processMessage((OSCMessage)messages[i]);
}
}
else processMessage((OSCMessage)packet);
}
else Console.WriteLine("null packet");
}
catch (Exception e) { Console.WriteLine(e.Message); }
}
}
#endregion
/**
* <summary>
* The OSC callback method where all TUIO messages are received and decoded
* and where the TUIO event callbacks are dispatched</summary>
* <param name="message">the received OSC message</param>
*/
private void processMessage(OSCMessage message)
{
string address = message.Address;
ArrayList args = message.Values;
string command = (string)args[0];
if (address == "/tuio/2Dobj")
{
if (command == "set")
{
long s_id = (int)args[1];
int f_id = (int)args[2];
float xpos = (float)args[3];
float ypos = (float)args[4];
float angle = (float)args[5];
float xspeed = (float)args[6];
float yspeed = (float)args[7];
float rspeed = (float)args[8];
float maccel = (float)args[9];
float raccel = (float)args[10];
lock (objectSync)
{
if (!objectList.ContainsKey(s_id))
{
TuioObject addObject = new TuioObject(s_id, f_id, xpos, ypos, angle);
frameObjects.Add(addObject);
}
else
{
TuioObject tobj = objectList[s_id];
if (tobj == null) return;
if ((tobj.X != xpos) || (tobj.Y != ypos) || (tobj.Angle != angle) || (tobj.XSpeed != xspeed) || (tobj.YSpeed != yspeed) || (tobj.RotationSpeed != rspeed) || (tobj.MotionAccel != maccel) || (tobj.RotationAccel != raccel))
{
TuioObject updateObject = new TuioObject(s_id, f_id, xpos, ypos, angle);
updateObject.update(xpos, ypos, angle, xspeed, yspeed, rspeed, maccel, raccel);
frameObjects.Add(updateObject);
}
}
}
}
else if (command == "alive")
{
newObjectList.Clear();
for (int i = 1; i < args.Count; i++)
{
// get the message content
long s_id = (int)args[i];
newObjectList.Add(s_id);
// reduce the object list to the lost objects
if (aliveObjectList.Contains(s_id))
aliveObjectList.Remove(s_id);
}
// remove the remaining objects
lock (objectSync)
{
for (int i = 0; i < aliveObjectList.Count; i++)
{
long s_id = aliveObjectList[i];
TuioObject removeObject = objectList[s_id];
removeObject.remove(currentTime);
frameObjects.Add(removeObject);
}
}
}
else if (command == "fseq")
{
int fseq = (int)args[1];
bool lateFrame = false;
if (fseq > 0)
{
if (fseq > currentFrame) currentTime = TuioTime.SessionTime;
if ((fseq >= currentFrame) || ((currentFrame - fseq) > 100)) currentFrame = fseq;
else lateFrame = true;
}
else if ((TuioTime.SessionTime.TotalMilliseconds - currentTime.TotalMilliseconds) > 100)
{
currentTime = TuioTime.SessionTime;
}
if (!lateFrame)
{
IEnumerator<TuioObject> frameEnum = frameObjects.GetEnumerator();
while (frameEnum.MoveNext())
{
TuioObject tobj = frameEnum.Current;
switch (tobj.TuioState)
{
case TuioObject.TUIO_REMOVED:
TuioObject removeObject = tobj;
removeObject.remove(currentTime);
for (int i = 0; i < listenerList.Count; i++)
{
TuioListener listener = (TuioListener)listenerList[i];
if (listener != null) listener.removeTuioObject(removeObject);
}
lock (objectSync)
{
objectList.Remove(removeObject.SessionID);
}
break;
case TuioObject.TUIO_ADDED:
TuioObject addObject = new TuioObject(currentTime, tobj.SessionID, tobj.SymbolID, tobj.X, tobj.Y, tobj.Angle);
lock (objectSync)
{
objectList.Add(addObject.SessionID, addObject);
}
for (int i = 0; i < listenerList.Count; i++)
{
TuioListener listener = (TuioListener)listenerList[i];
if (listener != null) listener.addTuioObject(addObject);
}
break;
default:
TuioObject updateObject = getTuioObject(tobj.SessionID);
if ((tobj.X != updateObject.X && tobj.XSpeed == 0) || (tobj.Y != updateObject.Y && tobj.YSpeed == 0))
updateObject.update(currentTime, tobj.X, tobj.Y, tobj.Angle);
else
updateObject.update(currentTime, tobj.X, tobj.Y, tobj.Angle, tobj.XSpeed, tobj.YSpeed, tobj.RotationSpeed, tobj.MotionAccel, tobj.RotationAccel);
for (int i = 0; i < listenerList.Count; i++)
{
TuioListener listener = (TuioListener)listenerList[i];
if (listener != null) listener.updateTuioObject(updateObject);
}
break;
}
}
for (int i = 0; i < listenerList.Count; i++)
{
TuioListener listener = (TuioListener)listenerList[i];
if (listener != null) listener.refresh(new TuioTime(currentTime));
}
List<long> buffer = aliveObjectList;
aliveObjectList = newObjectList;
// recycling the List
newObjectList = buffer;
}
frameObjects.Clear();
}
}
else if (address == "/tuio/2Dcur")
{
if (command == "set")
{
long s_id = (int)args[1];
float xpos = (float)args[2];
float ypos = (float)args[3];
float xspeed = (float)args[4];
float yspeed = (float)args[5];
float maccel = (float)args[6];
lock (cursorList)
{
if (!cursorList.ContainsKey(s_id))
{
TuioCursor addCursor = new TuioCursor(s_id, -1, xpos, ypos);
frameCursors.Add(addCursor);
}
else
{
TuioCursor tcur = (TuioCursor)cursorList[s_id];
if (tcur == null) return;
if ((tcur.X != xpos) || (tcur.Y != ypos) || (tcur.XSpeed != xspeed) || (tcur.YSpeed != yspeed) || (tcur.MotionAccel != maccel))
{
TuioCursor updateCursor = new TuioCursor(s_id, tcur.CursorID, xpos, ypos);
updateCursor.update(xpos, ypos, xspeed, yspeed, maccel);
frameCursors.Add(updateCursor);
}
}
}
}
else if (command == "alive")
{
newCursorList.Clear();
for (int i = 1; i < args.Count; i++)
{
// get the message content
long s_id = (int)args[i];
newCursorList.Add(s_id);
// reduce the cursor list to the lost cursors
if (aliveCursorList.Contains(s_id))
aliveCursorList.Remove(s_id);
}
// remove the remaining cursors
lock (cursorSync)
{
for (int i = 0; i < aliveCursorList.Count; i++)
{
long s_id = aliveCursorList[i];
if (!cursorList.ContainsKey(s_id)) continue;
TuioCursor removeCursor = cursorList[s_id];
removeCursor.remove(currentTime);
frameCursors.Add(removeCursor);
}
}
}
else if (command == "fseq")
{
int fseq = (int)args[1];
bool lateFrame = false;
if (fseq > 0)
{
if (fseq > currentFrame) currentTime = TuioTime.SessionTime;
if ((fseq >= currentFrame) || ((currentFrame - fseq) > 100)) currentFrame = fseq;
else lateFrame = true;
}
else if ((TuioTime.SessionTime.TotalMilliseconds - currentTime.TotalMilliseconds) > 100)
{
currentTime = TuioTime.SessionTime;
}
if (!lateFrame)
{
IEnumerator<TuioCursor> frameEnum = frameCursors.GetEnumerator();
while (frameEnum.MoveNext())
{
TuioCursor tcur = frameEnum.Current;
switch (tcur.TuioState)
{
case TuioCursor.TUIO_REMOVED:
TuioCursor removeCursor = tcur;
removeCursor.remove(currentTime);
for (int i = 0; i < listenerList.Count; i++)
{
TuioListener listener = (TuioListener)listenerList[i];
if (listener != null) listener.removeTuioCursor(removeCursor);
}
lock (cursorSync)
{
cursorList.Remove(removeCursor.SessionID);
if (removeCursor.CursorID == maxCursorID)
{
maxCursorID = -1;
if (cursorList.Count > 0)
{
IEnumerator<KeyValuePair<long, TuioCursor>> clist = cursorList.GetEnumerator();
while (clist.MoveNext())
{
int f_id = clist.Current.Value.CursorID;
if (f_id > maxCursorID) maxCursorID = f_id;
}
List<TuioCursor> freeCursorBuffer = new List<TuioCursor>();
IEnumerator<TuioCursor> flist = freeCursorList.GetEnumerator();
while (flist.MoveNext())
{
TuioCursor testCursor = flist.Current;
if (testCursor.CursorID < maxCursorID) freeCursorBuffer.Add(testCursor);
}
freeCursorList = freeCursorBuffer;
}
else freeCursorList.Clear();
}
else if (removeCursor.CursorID < maxCursorID) freeCursorList.Add(removeCursor);
}
break;
case TuioCursor.TUIO_ADDED:
TuioCursor addCursor;
lock (cursorSync)
{
int c_id = cursorList.Count;
if ((cursorList.Count <= maxCursorID) && (freeCursorList.Count > 0))
{
TuioCursor closestCursor = freeCursorList[0];
IEnumerator<TuioCursor> testList = freeCursorList.GetEnumerator();
while (testList.MoveNext())
{
TuioCursor testCursor = testList.Current;
if (testCursor.getDistance(tcur) < closestCursor.getDistance(tcur)) closestCursor = testCursor;
}
c_id = closestCursor.CursorID;
freeCursorList.Remove(closestCursor);
}
else maxCursorID = c_id;
addCursor = new TuioCursor(currentTime, tcur.SessionID, c_id, tcur.X, tcur.Y);
cursorList.Add(addCursor.SessionID, addCursor);
}
for (int i = 0; i < listenerList.Count; i++)
{
TuioListener listener = (TuioListener)listenerList[i];
if (listener != null) listener.addTuioCursor(addCursor);
}
break;
default:
TuioCursor updateCursor = getTuioCursor(tcur.SessionID);
if ((tcur.X != updateCursor.X && tcur.XSpeed == 0) || (tcur.Y != updateCursor.Y && tcur.YSpeed == 0))
updateCursor.update(currentTime, tcur.X, tcur.Y);
else
updateCursor.update(currentTime, tcur.X, tcur.Y, tcur.XSpeed, tcur.YSpeed, tcur.MotionAccel);
for (int i = 0; i < listenerList.Count; i++)
{
TuioListener listener = (TuioListener)listenerList[i];
if (listener != null) listener.updateTuioCursor(updateCursor);
}
break;
}
}
for (int i = 0; i < listenerList.Count; i++)
{
TuioListener listener = (TuioListener)listenerList[i];
if (listener != null) listener.refresh(new TuioTime(currentTime));
}
List<long> buffer = aliveCursorList;
aliveCursorList = newCursorList;
// recycling the List
newCursorList = buffer;
}
frameCursors.Clear();
}
}
else if (address == "/tuio/2Dblb")
{
if (command == "set")
{
long s_id = (int)args[1];
float xpos = (float)args[2];
float ypos = (float)args[3];
float angle = (float)args[4];
float width = (float)args[5];
float height = (float)args[6];
float area = (float)args[7];
float xspeed = (float)args[8];
float yspeed = (float)args[9];
float rspeed = (float)args[10];
float maccel = (float)args[11];
float raccel = (float)args[12];
lock (blobList)
{
if (!blobList.ContainsKey(s_id))
{
TuioBlob addBlob = new TuioBlob(s_id, -1, xpos, ypos, angle, width, height, area);
frameBlobs.Add(addBlob);
}
else
{
TuioBlob tblb = (TuioBlob)blobList[s_id];
if (tblb == null) return;
if ((tblb.X != xpos) || (tblb.Y != ypos) || (tblb.Angle != angle) || (tblb.Width != width) || (tblb.Height != height) || (tblb.Area != area) || (tblb.XSpeed != xspeed) || (tblb.YSpeed != yspeed) || (tblb.RotationSpeed != rspeed) || (tblb.MotionAccel != maccel) || (tblb.RotationAccel != raccel))
{
TuioBlob updateBlob = new TuioBlob(s_id, tblb.BlobID, xpos, ypos, angle, width, height, area);
updateBlob.update(xpos, ypos, angle, width, height, area, xspeed, yspeed, rspeed, maccel, raccel);
frameBlobs.Add(updateBlob);
}
}
}
}
else if (command == "alive")
{
newBlobList.Clear();
for (int i = 1; i < args.Count; i++)
{
// get the message content
long s_id = (int)args[i];
newBlobList.Add(s_id);
// reduce the blob list to the lost blobs
if (aliveBlobList.Contains(s_id))
aliveBlobList.Remove(s_id);
}
// remove the remaining blobs
lock (blobSync)
{
for (int i = 0; i < aliveBlobList.Count; i++)
{
long s_id = aliveBlobList[i];
if (!blobList.ContainsKey(s_id)) continue;
TuioBlob removeBlob = blobList[s_id];
removeBlob.remove(currentTime);
frameBlobs.Add(removeBlob);
}
}
}
else if (command == "fseq")
{
int fseq = (int)args[1];
bool lateFrame = false;
if (fseq > 0)
{
if (fseq > currentFrame) currentTime = TuioTime.SessionTime;
if ((fseq >= currentFrame) || ((currentFrame - fseq) > 100)) currentFrame = fseq;
else lateFrame = true;
}
else if ((TuioTime.SessionTime.TotalMilliseconds - currentTime.TotalMilliseconds) > 100)
{
currentTime = TuioTime.SessionTime;
}
if (!lateFrame)
{
IEnumerator<TuioBlob> frameEnum = frameBlobs.GetEnumerator();
while (frameEnum.MoveNext())
{
TuioBlob tblb = frameEnum.Current;
switch (tblb.TuioState)
{
case TuioBlob.TUIO_REMOVED:
TuioBlob removeBlob = tblb;
removeBlob.remove(currentTime);
for (int i = 0; i < listenerList.Count; i++)
{
TuioListener listener = (TuioListener)listenerList[i];
if (listener != null) listener.removeTuioBlob(removeBlob);
}
lock (blobSync)
{
blobList.Remove(removeBlob.SessionID);
if (removeBlob.BlobID == maxBlobID)
{
maxBlobID = -1;
if (blobList.Count > 0)
{
IEnumerator<KeyValuePair<long, TuioBlob>> blist = blobList.GetEnumerator();
while (blist.MoveNext())
{
int b_id = blist.Current.Value.BlobID;
if (b_id > maxBlobID) maxBlobID = b_id;
}
List<TuioBlob> freeBlobBuffer = new List<TuioBlob>();
IEnumerator<TuioBlob> flist = freeBlobList.GetEnumerator();
while (flist.MoveNext())
{
TuioBlob testBlob = flist.Current;
if (testBlob.BlobID < maxBlobID) freeBlobBuffer.Add(testBlob);
}
freeBlobList = freeBlobBuffer;
}
else freeBlobList.Clear();
}
else if (removeBlob.BlobID < maxBlobID) freeBlobList.Add(removeBlob);
}
break;
case TuioBlob.TUIO_ADDED:
TuioBlob addBlob;
lock (blobSync)
{
int b_id = blobList.Count;
if ((blobList.Count <= maxBlobID) && (freeBlobList.Count > 0))
{
TuioBlob closestBlob = freeBlobList[0];
IEnumerator<TuioBlob> testList = freeBlobList.GetEnumerator();
while (testList.MoveNext())
{
TuioBlob testBlob = testList.Current;
if (testBlob.getDistance(tblb) < closestBlob.getDistance(tblb)) closestBlob = testBlob;
}
b_id = closestBlob.BlobID;
freeBlobList.Remove(closestBlob);
}
else maxBlobID = b_id;
addBlob = new TuioBlob(currentTime, tblb.SessionID, b_id, tblb.X, tblb.Y, tblb.Angle, tblb.Width, tblb.Height, tblb.Area);
blobList.Add(addBlob.SessionID, addBlob);
}
for (int i = 0; i < listenerList.Count; i++)
{
TuioListener listener = (TuioListener)listenerList[i];
if (listener != null) listener.addTuioBlob(addBlob);
}
break;
default:
TuioBlob updateBlob = getTuioBlob(tblb.SessionID);
if ((tblb.X != updateBlob.X && tblb.XSpeed == 0) || (tblb.Y != updateBlob.Y && tblb.YSpeed == 0) || (tblb.Angle != updateBlob.Angle && tblb.RotationSpeed == 0))
updateBlob.update(currentTime, tblb.X, tblb.Y, tblb.Angle, tblb.Width, tblb.Height, tblb.Area);
else
updateBlob.update(currentTime, tblb.X, tblb.Y, tblb.Angle, tblb.Width, tblb.Height, tblb.Area, tblb.XSpeed, tblb.YSpeed, tblb.RotationSpeed, tblb.MotionAccel, tblb.RotationAccel);
for (int i = 0; i < listenerList.Count; i++)
{
TuioListener listener = (TuioListener)listenerList[i];
if (listener != null) listener.updateTuioBlob(updateBlob);
}
break;
}
}
for (int i = 0; i < listenerList.Count; i++)
{
TuioListener listener = (TuioListener)listenerList[i];
if (listener != null) listener.refresh(new TuioTime(currentTime));
}
List<long> buffer = aliveBlobList;
aliveBlobList = newBlobList;
// recycling the List
newBlobList = buffer;
}
frameBlobs.Clear();
}
}
}
#region Listener Management
/**
* <summary>
* Adds the provided TuioListener to the list of registered TUIO event listeners</summary>
* <param name="listener">the TuioListener to add</param>
*/
public void addTuioListener(TuioListener listener)
{
listenerList.Add(listener);
}
/**
* <summary>
* Removes the provided TuioListener from the list of registered TUIO event listeners</summary>
* <param name="listener">the TuioListener to remove</param>
*/
public void removeTuioListener(TuioListener listener)
{
listenerList.Remove(listener);
}
/**
* <summary>
* Removes all TuioListener from the list of registered TUIO event listeners</summary>
*/
public void removeAllTuioListeners()
{
listenerList.Clear();
}
#endregion
#region Object Management
/**
* <summary>
* Returns a List of all currently active TuioObjects</summary>
* <returns>a List of all currently active TuioObjects</returns>
*/
public List<TuioObject> getTuioObjects()
{
List<TuioObject> listBuffer;
lock (objectSync)
{
listBuffer = new List<TuioObject>(objectList.Values);
}
return listBuffer;
}
/**
* <summary>
* Returns a List of all currently active TuioCursors</summary>
* <returns>a List of all currently active TuioCursors</returns>
*/
public List<TuioCursor> getTuioCursors()
{
List<TuioCursor> listBuffer;
lock (cursorSync)
{
listBuffer = new List<TuioCursor>(cursorList.Values);
}
return listBuffer;
}
/**
* <summary>
* Returns a List of all currently active TuioBlobs</summary>
* <returns>a List of all currently active TuioBlobs</returns>
*/
public List<TuioBlob> getTuioBlobs()
{
List<TuioBlob> listBuffer;
lock (blobSync)
{
listBuffer = new List<TuioBlob>(blobList.Values);
}
return listBuffer;
}
/**
* <summary>
* Returns the TuioObject corresponding to the provided Session ID
* or NULL if the Session ID does not refer to an active TuioObject</summary>
* <returns>an active TuioObject corresponding to the provided Session ID or NULL</returns>
*/
public TuioObject getTuioObject(long s_id)
{
TuioObject tobject = null;
lock (objectSync)
{
objectList.TryGetValue(s_id, out tobject);
}
return tobject;
}
/**
* <summary>
* Returns the TuioCursor corresponding to the provided Session ID
* or NULL if the Session ID does not refer to an active TuioCursor</summary>
* <returns>an active TuioCursor corresponding to the provided Session ID or NULL</returns>
*/
public TuioCursor getTuioCursor(long s_id)
{
TuioCursor tcursor = null;
lock (cursorSync)
{
cursorList.TryGetValue(s_id, out tcursor);
}
return tcursor;
}
/**
* <summary>
* Returns the TuioBlob corresponding to the provided Session ID
* or NULL if the Session ID does not refer to an active TuioBlob</summary>
* <returns>an active TuioBlob corresponding to the provided Session ID or NULL</returns>
*/
public TuioBlob getTuioBlob(long s_id)
{
TuioBlob tblob = null;
lock (blobSync)
{
blobList.TryGetValue(s_id, out tblob);
}
return tblob;
}
#endregion
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: a6249948503ed8e46a389f399a008aee
timeCreated: 1482467613
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,454 +0,0 @@
/*
TUIO C# Library - part of the reacTIVision project
Copyright (c) 2005-2014 Martin Kaltenbrunner <martin@tuio.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
*/
using System;
using System.Collections.Generic;
namespace TUIO
{
/**
* <remarks>The abstract TuioContainer class defines common attributes that apply
* to both subclasses (TuioObject and TuioCursor).</remarks>
* <seealso cref="TuioObject"/>
* <seealso cref="TuioCursor"/>
*
* @author Martin Kaltenbrunner
* @version 1.1.5
*/
public abstract class TuioContainer : TuioPoint
{
/**
* <summary>
* The unique session ID number that is assigned to each TUIO object or cursor.</summary>
*/
protected long session_id;
/**
* <summary>
* The X-axis velocity value.</summary>
*/
protected float x_speed;
/**
* <summary>
* The Y-axis velocity value.</summary>
*/
protected float y_speed;
/**
* <summary>
* The motion speed value.</summary>
*/
protected float motion_speed;
/**
* <summary>
* The motion acceleration value.</summary>
*/
protected float motion_accel;
/**
* <summary>
* A Vector of TuioPoints containing all the previous positions of the TUIO component.</summary>
*/
protected List<TuioPoint> path;
#region State Enumeration Values
/**
* <summary>
* Defines the ADDED state.</summary>
*/
public const int TUIO_ADDED = 0;
/**
* <summary>
* Defines the ACCELERATING state.</summary>
*/
public const int TUIO_ACCELERATING = 1;
/**
* <summary>
* Defines the DECELERATING state.</summary>
*/
public const int TUIO_DECELERATING = 2;
/**
* <summary>
* Defines the STOPPED state.</summary>
*/
public const int TUIO_STOPPED = 3;
/**
* <summary>
* Defines the REMOVED state.</summary>
*/
public const int TUIO_REMOVED = 4;
#endregion
/**
* <summary>
* Reflects the current state of the TuioComponent</summary>
*/
protected int state;
#region Constructors
/**
* <summary>
* This constructor takes a TuioTime argument and assigns it along with the provided
* Session ID, X and Y coordinate to the newly created TuioContainer.</summary>
*
* <param name="ttime">the TuioTime to assign</param>
* <param name="si">the Session ID to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
*/
public TuioContainer(TuioTime ttime, long si, float xp, float yp)
: base(ttime, xp, yp)
{
session_id = si;
x_speed = 0.0f;
y_speed = 0.0f;
motion_speed = 0.0f;
motion_accel = 0.0f;
path = new List<TuioPoint>();
path.Add(new TuioPoint(currentTime, xpos, ypos));
state = TUIO_ADDED;
}
/**
* <summary>
* This constructor takes the provided Session ID, X and Y coordinate
* and assigs these values to the newly created TuioContainer.</summary>
*
* <param name="si">the Session ID to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
*/
public TuioContainer(long si, float xp, float yp)
: base(xp, yp)
{
session_id = si;
x_speed = 0.0f;
y_speed = 0.0f;
motion_speed = 0.0f;
motion_accel = 0.0f;
path = new List<TuioPoint>();
path.Add(new TuioPoint(currentTime, xpos, ypos));
state = TUIO_ADDED;
}
/**
* <summary>
* This constructor takes the atttibutes of the provided TuioContainer
* and assigs these values to the newly created TuioContainer.</summary>
*
* <param name="tcon">the TuioContainer to assign</param>
*/
public TuioContainer(TuioContainer tcon)
: base(tcon)
{
session_id = tcon.SessionID;
x_speed = 0.0f;
y_speed = 0.0f;
motion_speed = 0.0f;
motion_accel = 0.0f;
path = new List<TuioPoint>();
path.Add(new TuioPoint(currentTime, xpos, ypos));
state = TUIO_ADDED;
}
#endregion
#region Update Methods
/**
* <summary>
* Takes a TuioTime argument and assigns it along with the provided
* X and Y coordinate to the private TuioContainer attributes.
* The speed and accleration values are calculated accordingly.</summary>
* <param name="ttime">the TuioTime to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
*/
public new void update(TuioTime ttime, float xp, float yp)
{
TuioPoint lastPoint = path[path.Count - 1];
base.update(ttime, xp, yp);
TuioTime diffTime = currentTime - lastPoint.TuioTime;
float dt = diffTime.TotalMilliseconds / 1000.0f;
float dx = this.xpos - lastPoint.X;
float dy = this.ypos - lastPoint.Y;
float dist = (float)Math.Sqrt(dx * dx + dy * dy);
float last_motion_speed = this.motion_speed;
this.x_speed = dx / dt;
this.y_speed = dy / dt;
this.motion_speed = dist / dt;
this.motion_accel = (motion_speed - last_motion_speed) / dt;
path.Add(new TuioPoint(currentTime, xpos, ypos));
if (motion_accel > 0) state = TUIO_ACCELERATING;
else if (motion_accel < 0) state = TUIO_DECELERATING;
else state = TUIO_STOPPED;
}
/**
* <summary>
* This method is used to calculate the speed and acceleration values of
* TuioContainers with unchanged positions.</summary>
*/
public void stop(TuioTime ttime)
{
update(ttime, this.xpos, this.ypos);
}
/**
* <summary>
* Takes a TuioTime argument and assigns it along with the provided
* X and Y coordinate, X and Y velocity and acceleration
* to the private TuioContainer attributes.</summary>
*
* <param name="ttime">the TuioTime to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
* <param name="xs">the X velocity to assign</param>
* <param name="ys">the Y velocity to assign</param>
* <param name="ma">the acceleration to assign</param>
*/
public void update(TuioTime ttime, float xp, float yp, float xs, float ys, float ma)
{
base.update(ttime, xp, yp);
x_speed = xs;
y_speed = ys;
motion_speed = (float)Math.Sqrt(x_speed * x_speed + y_speed * y_speed);
motion_accel = ma;
path.Add(new TuioPoint(currentTime, xpos, ypos));
if (motion_accel > 0) state = TUIO_ACCELERATING;
else if (motion_accel < 0) state = TUIO_DECELERATING;
else state = TUIO_STOPPED;
}
/**
* <summary>
* Assigns the provided X and Y coordinate, X and Y velocity and acceleration
* to the private TuioContainer attributes. The TuioTime time stamp remains unchanged.</summary>
*
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
* <param name="xs">the X velocity to assign</param>
* <param name="ys">the Y velocity to assign</param>
* <param name="ma">the acceleration to assign</param>
*/
public void update(float xp, float yp, float xs, float ys, float ma)
{
base.update(xp, yp);
x_speed = xs;
y_speed = ys;
motion_speed = (float)Math.Sqrt(x_speed * x_speed + y_speed * y_speed);
motion_accel = ma;
path.Add(new TuioPoint(currentTime, xpos, ypos));
if (motion_accel > 0) state = TUIO_ACCELERATING;
else if (motion_accel < 0) state = TUIO_DECELERATING;
else state = TUIO_STOPPED;
}
/**
* <summary>
* Takes the atttibutes of the provided TuioContainer
* and assigs these values to this TuioContainer.
* The TuioTime time stamp of this TuioContainer remains unchanged.</summary>
*
* <param name="tcon">the TuioContainer to assign</param>
*/
public void update(TuioContainer tcon)
{
base.update(tcon.X, tcon.Y);
x_speed = tcon.XSpeed;
y_speed = tcon.YSpeed;
motion_speed = (float)Math.Sqrt(x_speed * x_speed + y_speed * y_speed);
motion_accel = tcon.MotionAccel;
path.Add(new TuioPoint(currentTime, xpos, ypos));
if (motion_accel > 0) state = TUIO_ACCELERATING;
else if (motion_accel < 0) state = TUIO_DECELERATING;
else state = TUIO_STOPPED;
}
#endregion
/**
* <summary>
* Assigns the REMOVE state to this TuioContainer and sets
* its TuioTime time stamp to the provided TuioTime argument.</summary>
*
* <param name="ttime">the TuioTime to assign</param>
*/
public void remove(TuioTime ttime)
{
currentTime = ttime;
state = TUIO_REMOVED;
}
#region Properties & Getter/Setter Methods
/**
* <summary>
* Returns the Session ID of this TuioContainer.</summary>
* <returns>the Session ID of this TuioContainer</returns>
*/
public long SessionID
{
get { return session_id; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property SessionID instead is recommended.")]
public long getSessionID()
{
return SessionID;
}
/**
* <summary>
* Returns the X velocity of this TuioContainer.</summary>
* <returns>the X velocity of this TuioContainer</returns>
*/
public float XSpeed
{
get { return x_speed; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property XSpeed instead is recommended.")]
public float getXSpeed()
{
return XSpeed;
}
/**
* <summary>
* Returns the Y velocity of this TuioContainer.</summary>
* <returns>the Y velocity of this TuioContainer</returns>
*/
public float YSpeed
{
get { return y_speed; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property YSpeed instead is recommended.")]
public float getYSpeed()
{
return YSpeed;
}
/**
* <summary>
* Returns the position of this TuioContainer.</summary>
* <returns>the position of this TuioContainer</returns>
*/
public TuioPoint Position
{
get { return new TuioPoint(xpos, ypos); }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property Position instead is recommended.")]
public TuioPoint getPosition()
{
return Position;
}
/**
* <summary>
* Returns the path of this TuioContainer.</summary>
* <returns>the path of this TuioContainer</returns>
*/
public List<TuioPoint> Path
{
get { return path; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property Path instead is recommended.")]
public List<TuioPoint> getPath()
{
return Path;
}
/**
* <summary>
* Returns the motion speed of this TuioContainer.</summary>
* <returns>the motion speed of this TuioContainer</returns>
*/
public float MotionSpeed
{
get { return motion_speed; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property MotionSpeed instead is recommended.")]
public float getMotionSpeed()
{
return MotionSpeed;
}
/**
* <summary>
* Returns the motion acceleration of this TuioContainer.</summary>
* <returns>the motion acceleration of this TuioContainer</returns>
*/
public float MotionAccel
{
get { return motion_accel; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property MotionAccel instead is recommended.")]
public float getMotionAccel()
{
return MotionAccel;
}
/**
* <summary>
* Returns the TUIO state of this TuioContainer.</summary>
* <returns>the TUIO state of this TuioContainer</returns>
*/
public int TuioState
{
get { return state; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property TuioState instead is recommended.")]
public int getTuioState()
{
return TuioState;
}
/**
* <summary>
* Returns true of this TuioContainer is moving.</summary>
* <returns>true of this TuioContainer is moving</returns>
*/
public virtual bool isMoving
{
get
{
if ((state == TUIO_ACCELERATING) || (state == TUIO_DECELERATING)) return true;
else return false;
}
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property isMoving instead is recommended.")]
public virtual bool getIsMoving()
{
return isMoving;
}
#endregion
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 4b7eb4a9908ba6e4083e3a5f8917f2e7
timeCreated: 1482467612
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,109 +0,0 @@
/*
TUIO C# Library - part of the reacTIVision project
Copyright (c) 2005-2014 Martin Kaltenbrunner <martin@tuio.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
*/
using System;
namespace TUIO
{
/**
* <summary>
* The TuioCursor class encapsulates /tuio/2Dcur TUIO cursors.</summary>
*
* @author Martin Kaltenbrunner
* @version 1.1.5
*/
public class TuioCursor : TuioContainer
{
/**
* <summary>
* The individual cursor ID number that is assigned to each TuioCursor.</summary>
*/
protected int cursor_id;
#region Constructors
/**
* <summary>
* This constructor takes a TuioTime argument and assigns it along with the provided
* Session ID, Cursor ID, X and Y coordinate to the newly created TuioCursor.</summary>
*
* <param name="ttime">the TuioTime to assign</param>
* <param name="si">the Session ID to assign</param>
* <param name="ci">the Cursor ID to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
*/
public TuioCursor(TuioTime ttime, long si, int ci, float xp, float yp)
: base(ttime, si, xp, yp)
{
cursor_id = ci;
}
/**
* <summary>
* This constructor takes the provided Session ID, Cursor ID, X and Y coordinate
* and assigs these values to the newly created TuioCursor.</summary>
*
* <param name="si">the Session ID to assign</param>
* <param name="ci">the Cursor ID to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
*/
public TuioCursor(long si, int ci, float xp, float yp)
: base(si, xp, yp)
{
cursor_id = ci;
}
/**
* <summary>
* This constructor takes the atttibutes of the provided TuioCursor
* and assigs these values to the newly created TuioCursor.</summary>
*
* <param name="tcur">the TuioCursor to assign</param>
*/
public TuioCursor(TuioCursor tcur)
: base(tcur)
{
cursor_id = tcur.CursorID;
}
#endregion
#region Properties & Getter/Setter Methods
/**
* <summary>
* Returns the Cursor ID of this TuioCursor.</summary>
* <returns>the Cursor ID of this TuioCursor</returns>
*/
public int CursorID
{
get { return cursor_id; }
}
[Obsolete("This method has been depracated and is provided only for compatability with legacy code. The CursorID property should be used instead.")]
public int getCursorID()
{
return cursor_id;
}
#endregion
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 54bb8d387f6dcc1479661811db078497
timeCreated: 1482467613
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,131 +0,0 @@
/*
TUIO C# Library - part of the reacTIVision project
Copyright (c) 2005-2014 Martin Kaltenbrunner <martin@tuio.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
*/
using System;
namespace TUIO
{
/**
* <remarks
* <para>
* The TuioListener interface provides a simple callback infrastructure which is used by the {@link TuioClient} class
* to dispatch TUIO events to all registered instances of classes that implement the TuioListener interface defined here.
* </para>
* <para>
* Any class that implements the TuioListener interface is required to implement all of the callback methods defined here.
* The {@link TuioClient} makes use of these interface methods in order to dispatch TUIO events to all registered TuioListener implementations.
* </para>
* </remarks>
* <example>
* <code>
* public class MyTuioListener implements TuioListener
* ...
* MyTuioListener listener = new MyTuioListener();
* TuioClient client = new TuioClient();
* client.addTuioListener(listener);
* client.start();
* </code>
* </example>
*
* @author Martin Kaltenbrunner
* @version 1.1.5
*/
public interface TuioListener
{
/**
* <summary>
* This callback method is invoked by the TuioClient when a new TuioObject is added to the session.</summary>
*
* <param name="tobj">the TuioObject reference associated to the addTuioObject event</param>
*/
void addTuioObject(TuioObject tobj);
/**
* <summary>
* This callback method is invoked by the TuioClient when an existing TuioObject is updated during the session.</summary>
*
* <param name="tobj">the TuioObject reference associated to the updateTuioObject event</param>
*/
void updateTuioObject(TuioObject tobj);
/**
* <summary>
* This callback method is invoked by the TuioClient when an existing TuioObject is removed from the session.</summary>
*
* <param name="tobj">the TuioObject reference associated to the removeTuioObject event</param>
*/
void removeTuioObject(TuioObject tobj);
/**
* <summary>
* This callback method is invoked by the TuioClient when a new TuioCursor is added to the session.</summary>
*
* <param name="tcur">the TuioCursor reference associated to the addTuioCursor event</param>
*/
void addTuioCursor(TuioCursor tcur);
/**
* <summary>
* This callback method is invoked by the TuioClient when an existing TuioCursor is updated during the session.</summary>
*
* <param name="tcur">the TuioCursor reference associated to the updateTuioCursor event</param>
*/
void updateTuioCursor(TuioCursor tcur);
/**
* <summary>
* This callback method is invoked by the TuioClient when an existing TuioCursor is removed from the session.</summary>
*
* <param name="tcur">the TuioCursor reference associated to the removeTuioCursor event</param>
*/
void removeTuioCursor(TuioCursor tcur);
/**
* <summary>
* This callback method is invoked by the TuioClient when a new TuioBlob is added to the session.</summary>
*
* <param name="tblb">the TuioBlob reference associated to the addTuioBlob event</param>
*/
void addTuioBlob(TuioBlob tblb);
/**
* <summary>
* This callback method is invoked by the TuioClient when an existing TuioBlob is updated during the session.</summary>
*
* <param name="tblb">the TuioBlob reference associated to the updateTuioBlob event</param>
*/
void updateTuioBlob(TuioBlob tblb);
/**
* <summary>
* This callback method is invoked by the TuioClient when an existing TuioBlob is removed from the session.</summary>
*
* <param name="tblb">the TuioBlob reference associated to the removeTuioBlob event</param>
*/
void removeTuioBlob(TuioBlob tblb);
/**
* <summary>
* This callback method is invoked by the TuioClient to mark the end of a received TUIO message bundle.</summary>
*
* <param name="ftime">the TuioTime associated to the current TUIO message bundle</param>
*/
void refresh(TuioTime ftime);
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 46bcfef90b64a5a4bb73b7fbe12418f4
timeCreated: 1482467612
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,336 +0,0 @@
/*
TUIO C# Library - part of the reacTIVision project
Copyright (c) 2005-2014 Martin Kaltenbrunner <martin@tuio.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
*/
using System;
using System.Collections.Generic;
namespace TUIO
{
/**
* <remarks>
* The TuioObject class encapsulates /tuio/2Dobj TUIO objects.
* </remarks>
*
* @author Martin Kaltenbrunner
* @version 1.1.5
*/
public class TuioObject : TuioContainer
{
/**
* <summary>
* The individual symbol ID number that is assigned to each TuioObject.</summary>
*/
protected int symbol_id;
/**
* <summary>
* The rotation angle value.</summary>
*/
protected float angle;
/**
* <summary>
* The rotation speed value.</summary>
*/
protected float rotation_speed;
/**
* <summary>
* The rotation acceleration value.</summary>
*/
protected float rotation_accel;
#region State Enumeration Values
/**
* <summary>
* Defines the ROTATING state.</summary>
*/
public static readonly int TUIO_ROTATING = 5;
#endregion
#region Constructors
/**
* <summary>
* This constructor takes a TuioTime argument and assigns it along with the provided
* Session ID, Symbol ID, X and Y coordinate and angle to the newly created TuioObject.</summary>
*
* <param name="ttime">the TuioTime to assign</param>
* <param name="si">the Session ID to assign</param>
* <param name="sym">the Symbol ID to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
* <param name="a">the angle to assign</param>
*/
public TuioObject(TuioTime ttime, long si, int sym, float xp, float yp, float a)
: base(ttime, si, xp, yp)
{
symbol_id = sym;
angle = a;
rotation_speed = 0.0f;
rotation_accel = 0.0f;
}
/**
* <summary>
* This constructor takes the provided Session ID, Symbol ID, X and Y coordinate
* and angle, and assigs these values to the newly created TuioObject.</summary>
*
* <param name="si">the Session ID to assign</param>
* <param name="sym">the Symbol ID to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
* <param name="a">the angle to assign</param>
*/
public TuioObject(long si, int sym, float xp, float yp, float a)
: base(si, xp, yp)
{
symbol_id = sym;
angle = a;
rotation_speed = 0.0f;
rotation_accel = 0.0f;
}
/**
* <summary>
* This constructor takes the atttibutes of the provided TuioObject
* and assigs these values to the newly created TuioObject.</summary>
*
* <param name="tobj">the TuioObject to assign</param>
*/
public TuioObject(TuioObject tobj)
: base(tobj)
{
symbol_id = tobj.SymbolID;
angle = tobj.Angle;
rotation_speed = 0.0f;
rotation_accel = 0.0f;
}
#endregion
#region Update Methods
/**
* <summary>
* Takes a TuioTime argument and assigns it along with the provided
* X and Y coordinate, angle, X and Y velocity, motion acceleration,
* rotation speed and rotation acceleration to the private TuioObject attributes.</summary>
*
* <param name="ttime">the TuioTime to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
* <param name="a">the angle coordinate to assign</param>
* <param name="xs">the X velocity to assign</param>
* <param name="ys">the Y velocity to assign</param>
* <param name="rs">the rotation velocity to assign</param>
* <param name="ma">the motion acceleration to assign</param>
* <param name="ra">the rotation acceleration to assign</param>
*/
public void update(TuioTime ttime, float xp, float yp, float a, float xs, float ys, float rs, float ma, float ra)
{
base.update(ttime, xp, yp, xs, ys, ma);
angle = a;
rotation_speed = rs;
rotation_accel = ra;
if ((rotation_accel != 0) && (state != TUIO_STOPPED)) state = TUIO_ROTATING;
}
/**
* <summary>
* Assigns the provided X and Y coordinate, angle, X and Y velocity, motion acceleration
* rotation velocity and rotation acceleration to the private TuioContainer attributes.
* The TuioTime time stamp remains unchanged.</summary>
*
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
* <param name="a">the angle coordinate to assign</param>
* <param name="xs">the X velocity to assign</param>
* <param name="ys">the Y velocity to assign</param>
* <param name="rs">the rotation velocity to assign</param>
* <param name="ma">the motion acceleration to assign</param>
* <param name="ra">the rotation acceleration to assign</param>
*/
public void update(float xp, float yp, float a, float xs, float ys, float rs, float ma, float ra)
{
base.update(xp, yp, xs, ys, ma);
angle = a;
rotation_speed = rs;
rotation_accel = ra;
if ((rotation_accel != 0) && (state != TUIO_STOPPED)) state = TUIO_ROTATING;
}
/**
* <summary>
* Takes a TuioTime argument and assigns it along with the provided
* X and Y coordinate and angle to the private TuioObject attributes.
* The speed and accleration values are calculated accordingly.</summary>
*
* <param name="ttime">the TuioTime to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
* <param name="a">the angle coordinate to assign</param>
*/
public void update(TuioTime ttime, float xp, float yp, float a)
{
TuioPoint lastPoint = path[path.Count - 1];
base.update(ttime, xp, yp);
TuioTime diffTime = currentTime - lastPoint.TuioTime;
float dt = diffTime.TotalMilliseconds / 1000.0f;
float last_angle = angle;
float last_rotation_speed = rotation_speed;
angle = a;
float da = (angle - last_angle) / (2.0f * (float)Math.PI);
if (da > 0.75f) da -= 1.0f;
else if (da < -0.75f) da += 1.0f;
rotation_speed = da / dt;
rotation_accel = (rotation_speed - last_rotation_speed) / dt;
if ((rotation_accel != 0) && (state != TUIO_STOPPED)) state = TUIO_ROTATING;
}
/**
* <summary>
* Takes the atttibutes of the provided TuioObject
* and assigs these values to this TuioObject.
* The TuioTime time stamp of this TuioContainer remains unchanged.</summary>
*
* <param name="tobj">the TuioContainer to assign</param>
*/
public void update(TuioObject tobj)
{
base.update(tobj);
angle = tobj.Angle;
rotation_speed = tobj.RotationSpeed;
rotation_accel = tobj.RotationAccel;
if ((rotation_accel != 0) && (state != TUIO_STOPPED)) state = TUIO_ROTATING;
}
/**
* <summary>
* This method is used to calculate the speed and acceleration values of a
* TuioObject with unchanged position and angle.</summary>
*/
public new void stop(TuioTime ttime)
{
update(ttime, this.xpos, this.ypos, this.angle);
}
#endregion
#region Properties & Getter/Setter Methods
/**
* <summary>
* Returns the symbol ID of this TuioObject.</summary>
* <returns>the symbol ID of this TuioObject</returns>
*/
public int SymbolID
{
get { return symbol_id; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public int getSymbolID()
{
return SymbolID;
}
/**
* <summary>
* Returns the rotation angle of this TuioObject.</summary>
* <returns>the rotation angle of this TuioObject</returns>
*/
public float Angle
{
get { return angle; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public float getAngle()
{
return Angle;
}
/**
* <summary>
* Returns the rotation angle in degrees of this TuioObject.</summary>
* <returns>the rotation angle in degrees of this TuioObject</returns>
*/
public float AngleDegrees
{
get { return angle / (float)Math.PI * 180.0f; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public float getAngleDegrees()
{
return AngleDegrees;
}
/**
* <summary>
* Returns the rotation speed of this TuioObject.</summary>
* <returns>the rotation speed of this TuioObject</returns>
*/
public float RotationSpeed
{
get { return rotation_speed; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public float getRotationSpeed()
{
return RotationSpeed;
}
/**
* <summary>
* Returns the rotation acceleration of this TuioObject.</summary>
* <returns>the rotation acceleration of this TuioObject</returns>
*/
public float RotationAccel
{
get { return rotation_accel; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public float getRotationAccel()
{
return RotationAccel;
}
/**
* <summary>
* Returns true of this TuioObject is moving.</summary>
* <returns>true of this TuioObject is moving</returns>
*/
public override bool isMoving
{
get
{
if ((state == TUIO_ACCELERATING) || (state == TUIO_DECELERATING) || (state == TUIO_ROTATING)) return true;
else return false;
}
}
#endregion
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: a8acb1fc36a04454ea75ddb6b663b4dd
timeCreated: 1482467613
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,353 +0,0 @@
/*
TUIO C# Library - part of the reacTIVision project
Copyright (c) 2005-2014 Martin Kaltenbrunner <martin@tuio.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
*/
using System;
namespace TUIO
{
/**
* The TuioPoint class on the one hand is a simple container and utility class to handle TUIO positions in general,
* on the other hand the TuioPoint is the base class for the TuioCursor and TuioObject classes.
*
* @author Martin Kaltenbrunner
* @version 1.1.5
*/
public class TuioPoint
{
#region Member Variables
/**
* <summary>
* X coordinate, representated as a floating point value in a range of 0..1</summary>
*/
protected float xpos;
/**
* <summary>
* Y coordinate, representated as a floating point value in a range of 0..1</summary>
*/
protected float ypos;
/**
* <summary>
* The time stamp of the last update represented as TuioTime (time since session start)</summary>
*/
protected TuioTime currentTime;
/**
* <summary>
* The creation time of this TuioPoint represented as TuioTime (time since session start)</summary>
*/
protected TuioTime startTime;
#endregion
#region Constructors
/**
* <summary>
* The default constructor takes no arguments and sets
* its coordinate attributes to zero and its time stamp to the current session time.</summary>
*/
public TuioPoint()
{
xpos = 0.0f;
ypos = 0.0f;
currentTime = TuioTime.SessionTime;
startTime = new TuioTime(currentTime);
}
/**
* <summary>
* This constructor takes two floating point coordinate arguments and sets
* its coordinate attributes to these values and its time stamp to the current session time.</summary>
*
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
*/
public TuioPoint(float xp, float yp)
{
xpos = xp;
ypos = yp;
currentTime = TuioTime.SessionTime;
startTime = new TuioTime(currentTime);
}
/**
* <summary>
* This constructor takes a TuioPoint argument and sets its coordinate attributes
* to the coordinates of the provided TuioPoint and its time stamp to the current session time.</summary>
*
* <param name="tpoint">the TuioPoint to assign</param>
*/
public TuioPoint(TuioPoint tpoint)
{
xpos = tpoint.X;
ypos = tpoint.Y;
currentTime = TuioTime.SessionTime;
startTime = new TuioTime(currentTime);
}
/**
* <summary>
* This constructor takes a TuioTime object and two floating point coordinate arguments and sets
* its coordinate attributes to these values and its time stamp to the provided TUIO time object.</summary>
*
* <param name="ttime">the TuioTime to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
*/
public TuioPoint(TuioTime ttime, float xp, float yp)
{
xpos = xp;
ypos = yp;
currentTime = new TuioTime(ttime);
startTime = new TuioTime(currentTime);
}
#endregion
#region Update Methods
/**
* <summary>
* Takes a TuioPoint argument and updates its coordinate attributes
* to the coordinates of the provided TuioPoint and leaves its time stamp unchanged.</summary>
*
* <param name="tpoint">the TuioPoint to assign</param>
*/
public void update(TuioPoint tpoint)
{
xpos = tpoint.X;
ypos = tpoint.Y;
}
/**
* <summary>
* Takes two floating point coordinate arguments and updates its coordinate attributes
* to the coordinates of the provided TuioPoint and leaves its time stamp unchanged.</summary>
*
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
*/
public void update(float xp, float yp)
{
xpos = xp;
ypos = yp;
}
/**
* <summary>
* Takes a TuioTime object and two floating point coordinate arguments and updates its coordinate attributes
* to the coordinates of the provided TuioPoint and its time stamp to the provided TUIO time object.</summary>
*
* <param name="ttime">the TuioTime to assign</param>
* <param name="xp">the X coordinate to assign</param>
* <param name="yp">the Y coordinate to assign</param>
*/
public void update(TuioTime ttime, float xp, float yp)
{
xpos = xp;
ypos = yp;
currentTime = new TuioTime(ttime);
}
#endregion
#region Properties & Getter/Setter Methods
/**
* <summary>
* Returns the X coordinate of this TuioPoint.</summary>
* <returns>the X coordinate of this TuioPoint</returns>
*/
public float X
{
get { return xpos; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public float getX()
{
return X;
}
/**
* <summary>
* Returns the Y coordinate of this TuioPoint.</summary>
* <returns>the Y coordinate of this TuioPoint</returns>
*/
public float Y
{
get { return ypos; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public float getY()
{
return Y;
}
/**
* <summary>
* Returns the distance to the provided coordinates</summary>
*
* <param name="xp">the X coordinate of the distant point</param>
* <param name="yp">the Y coordinate of the distant point</param>
* <returns>the distance to the provided coordinates</returns>
*/
public float getDistance(float x, float y)
{
float dx = xpos - x;
float dy = ypos - y;
return (float)Math.Sqrt(dx * dx + dy * dy);
}
/**
* <summary>
* Returns the distance to the provided TuioPoint</summary>
*
* <param name="tpoint">the distant TuioPoint</param>
* <returns>the distance to the provided TuioPoint</returns>
*/
public float getDistance(TuioPoint tpoint)
{
return getDistance(tpoint.X, tpoint.Y);
}
/**
* <summary>
* Returns the angle to the provided coordinates</summary>
*
* <param name="xp">the X coordinate of the distant point</param>
* <param name="yp">the Y coordinate of the distant point</param>
* <returns>the angle to the provided coordinates</returns>
*/
public float getAngle(float xp, float yp)
{
float side = xp - xpos;
float height = yp - ypos;
float distance = getDistance(xp, yp);
float angle = (float)(Math.Asin(side / distance) + Math.PI / 2);
if (height < 0) angle = 2.0f * (float)Math.PI - angle;
return angle;
}
/**
* <summary>
* Returns the angle to the provided TuioPoint</summary>
*
* <param name="tpoint">the distant TuioPoint</param>
* <returns>the angle to the provided TuioPoint</returns>
*/
public float getAngle(TuioPoint tpoint)
{
return getAngle(tpoint.X, tpoint.Y);
}
/**
* <summary>
* Returns the angle in degrees to the provided coordinates</summary>
*
* <param name="xp">the X coordinate of the distant point</param>
* <param name="yp">the Y coordinate of the distant point</param>
* <returns>the angle in degrees to the provided TuioPoint</returns>
*/
public float getAngleDegrees(float xp, float yp)
{
return (getAngle(xp, yp) / (float)Math.PI) * 180.0f;
}
/**
* <summary>
* Returns the angle in degrees to the provided TuioPoint</summary>
*
* <param name="tpoint">the distant TuioPoint</param>
* <returns>the angle in degrees to the provided TuioPoint</returns>
*/
public float getAngleDegrees(TuioPoint tpoint)
{
return (getAngle(tpoint) / (float)Math.PI) * 180.0f;
}
/**
* <summary>
* Returns the X coordinate in pixels relative to the provided screen width.</summary>
*
* <param name="width">the screen width</param>
* <returns>the X coordinate of this TuioPoint in pixels relative to the provided screen width</returns>
*/
public int getScreenX(int width)
{
return (int)Math.Round(xpos * width);
}
/**
* <summary>
* Returns the Y coordinate in pixels relative to the provided screen height.</summary>
*
* <param name="height">the screen height</param>
* <returns>the Y coordinate of this TuioPoint in pixels relative to the provided screen height</returns>
*/
public int getScreenY(int height)
{
return (int)Math.Round(ypos * height);
}
/**
* <summary>
* Returns the time stamp of this TuioPoint as TuioTime.</summary>
*
* <returns>the time stamp of this TuioPoint as TuioTime</returns>
*/
public TuioTime TuioTime
{
get { return new TuioTime(currentTime); }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public TuioTime getTuioTime()
{
return TuioTime;
}
/**
* <summary>
* Returns the start time of this TuioPoint as TuioTime.</summary>
*
* <returns>the start time of this TuioPoint as TuioTime</returns>
*/
public TuioTime StartTime
{
get { return new TuioTime(startTime); }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property instead is recommended.")]
public TuioTime getStartTime()
{
return StartTime;
}
#endregion
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 4cc3fc32f3d1d59478d3f5f84aa13d2e
timeCreated: 1482467613
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,315 +0,0 @@
/*
TUIO C# Library - part of the reacTIVision project
Copyright (c) 2005-2014 Martin Kaltenbrunner <martin@tuio.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
*/
using System;
namespace TUIO
{
/**
* <remarks>
* The TuioTime class is a simple structure that is used to reprent the time that has elapsed since the session start.
* The time is internally represented as seconds and fractions of microseconds which should be more than sufficient for gesture related timing requirements.
* Therefore at the beginning of a typical TUIO session the static method initSession() will set the reference time for the session.
* Another important static method getSessionTime will return a TuioTime object representing the time elapsed since the session start.
* The class also provides various addtional convience method, which allow some simple time arithmetics.
* </remarks>
*
* @author Martin Kaltenbrunner
* @version 1.1.5
*/
public class TuioTime
{
/**
* <summary>
* the time since session start in seconds</summary>
*/
private long seconds = 0;
/**
* <summary>
* time fraction in microseconds</summary>
*/
private long micro_seconds = 0;
/**
* <summary>
* the session start time in seconds</summary>
*/
private static long start_seconds = 0;
/**
* <summary>
* start time fraction in microseconds</summary>
*/
private static long start_micro_seconds = 0;
#region Constructors
/**
* <summary>
* The default constructor takes no arguments and sets
* the Seconds and Microseconds attributes of the newly created TuioTime both to zero.</summary>
*/
public TuioTime()
{
this.seconds = 0;
this.micro_seconds = 0;
}
/**
* <summary>
* This constructor takes the provided time represented in total Milliseconds
* and assigs this value to the newly created TuioTime.</summary>
*
* <param name="msec">the total time in Millseconds</param>
*/
public TuioTime(long msec)
{
this.seconds = msec / 1000;
this.micro_seconds = 1000 * (msec % 1000);
}
/**
* <summary>
* This constructor takes the provided time represented in Seconds and Microseconds
* and assigs these value to the newly created TuioTime.</summary>
*
* <param name="sec">the total time in seconds</param>
* <param name="usec">the microseconds time component</param>
*/
public TuioTime(long sec, long usec)
{
this.seconds = sec;
this.micro_seconds = usec;
}
/**
* <summary>
* This constructor takes the provided TuioTime
* and assigs its Seconds and Microseconds values to the newly created TuioTime.</summary>
*
* <param name="ttime">the TuioTime used to copy</param>
*/
public TuioTime(TuioTime ttime)
{
this.seconds = ttime.Seconds;
this.micro_seconds = ttime.Microseconds;
}
#endregion
#region Operator Overloads
/**
* <summary>
* Sums the provided time value represented in total Microseconds to the base TuioTime.</summary>
*
* <param name="btime">the base TuioTime</param>
* <param name="us">the total time to add in Microseconds</param>
* <returns>the sum of this TuioTime with the provided argument in microseconds</returns>
*/
public static TuioTime operator +(TuioTime atime, long us)
{
long sec = atime.Seconds + us / 1000000;
long usec = atime.Microseconds + us % 1000000;
return new TuioTime(sec, usec);
}
/**
* <summary>
* Sums the provided TuioTime to the base TuioTime.</summary>
*
* <param name="btime">the base TuioTime</param>
* <param name="ttime">the TuioTime to add</param>
* <returns>the sum of this TuioTime with the provided TuioTime argument</returns>
*/
public static TuioTime operator +(TuioTime btime, TuioTime ttime)
{
long sec = btime.Seconds + ttime.Seconds;
long usec = btime.Microseconds + ttime.Microseconds;
sec += usec / 1000000;
usec = usec % 1000000;
return new TuioTime(sec, usec);
}
/**
* <summary>
* Subtracts the provided time represented in Microseconds from the base TuioTime.</summary>
*
* <param name="btime">the base TuioTime</param>
* <param name="us">the total time to subtract in Microseconds</param>
* <returns>the subtraction result of this TuioTime minus the provided time in Microseconds</returns>
*/
public static TuioTime operator -(TuioTime btime, long us)
{
long sec = btime.Seconds - us / 1000000;
long usec = btime.Microseconds - us % 1000000;
if (usec < 0)
{
usec += 1000000;
sec--;
}
return new TuioTime(sec, usec);
}
/**
* <summary>
* Subtracts the provided TuioTime from the private Seconds and Microseconds attributes.</summary>
*
* <param name="btime">the base TuioTime</param>
* <param name="ttime">the TuioTime to subtract</param>
* <returns>the subtraction result of this TuioTime minus the provided TuioTime</returns>
*/
public static TuioTime operator -(TuioTime btime, TuioTime ttime)
{
long sec = btime.Seconds - ttime.Seconds;
long usec = btime.Microseconds - ttime.Microseconds;
if (usec < 0)
{
usec += 1000000;
sec--;
}
return new TuioTime(sec, usec);
}
/**
* <summary>
* Takes a TuioTime argument and compares the provided TuioTime to the private Seconds and Microseconds attributes.</summary>
*
* <param name="ttime">the TuioTime to compare</param>
* <returns>true if the two TuioTime have equal Seconds and Microseconds attributes</returns>
*/
public bool Equals(TuioTime ttime)
{
if ((seconds == ttime.Seconds) && (micro_seconds == ttime.Microseconds)) return true;
else return false;
}
#endregion
/**
* <summary>
* Resets the seconds and micro_seconds attributes to zero.</summary>
*/
public void reset()
{
seconds = 0;
micro_seconds = 0;
}
/**
* <summary>
* Returns the TuioTime Seconds component.</summary>
* <returns>the TuioTime Seconds component</returns>
*/
public long Seconds
{
get { return seconds; }
}
/**
* <summary>
* Returns the TuioTime Microseconds component.</summary>
* <returns>the TuioTime Microseconds component</returns>
*/
public long Microseconds
{
get { return micro_seconds; }
}
/**
* <summary>
* Returns the total TuioTime in Milliseconds.</summary>
* <returns>the total TuioTime in Milliseconds</returns>
*/
public long TotalMilliseconds
{
get { return seconds * 1000 + micro_seconds / 1000; }
}
/**
* <summary>
* This static method globally resets the TUIO session time.</summary>
*/
public static void initSession()
{
TuioTime startTime = SystemTime;
start_seconds = startTime.Seconds;
start_micro_seconds = startTime.Microseconds;
}
/**
* <summary>
* Returns the present TuioTime representing the time since session start.</summary>
* <returns>the present TuioTime representing the time since session start</returns>
*/
public static TuioTime SessionTime
{
get { return SystemTime - StartTime; }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property SessionTime instead is recommended.")]
public static TuioTime getSessionTime()
{
return SessionTime;
}
/**
* <summary>
* Returns the absolut TuioTime representing the session start.</summary>
* <returns>the absolut TuioTime representing the session start</returns>
*/
public static TuioTime StartTime
{
get { return new TuioTime(start_seconds, start_micro_seconds); }
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property StartTime instead is recommended.")]
public static TuioTime getStartTime()
{
return StartTime;
}
/**
* <summary>
* Returns the absolut TuioTime representing the current system time.</summary>
* <returns>the absolut TuioTime representing the current system time</returns>
*/
public static TuioTime SystemTime
{
get
{
long usec = DateTime.Now.Ticks / 10;
return new TuioTime(usec / 1000000, usec % 1000000);
}
}
[Obsolete("This method is provided only for compatability with legacy code. Use of the property SystemTime instead is recommended.")]
public static TuioTime getSystemTime()
{
return SystemTime;
}
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 6d85dc9dcd5a4584ebd92f2b0ae13d17
timeCreated: 1482467613
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 835588de3ec3de54f8e357889ed10313
folderAsset: yes
timeCreated: 1482488022
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: c2b099cde0bbd1b48807dff5ed3cc2cd
folderAsset: yes
timeCreated: 1503912043
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -1,15 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public static class CreateUCEventSystem
{
[MenuItem("GameObject/UC/UC Event System",false , 0)]
private static void CreateUceventSystem()
{
GameObject temp = AssetDatabase.LoadAssetAtPath("Assets/UC/TUIO/UCEventSystem.prefab", typeof(GameObject)) as GameObject;
if (PrefabUtility.GetPrefabType(temp) == PrefabType.Prefab || PrefabUtility.GetPrefabType(temp) == PrefabType.ModelPrefab)
PrefabUtility.InstantiatePrefab(temp);
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 88204e8fb26f80e4b9bdbb88d9519645
timeCreated: 1503547507
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TUIO;
namespace UnityUtils.TUIO
{
public interface ITuioHandler
{
}
public interface ITuioFilterHandler
{
void Filter(TuioContainer tcur);
}
}

@ -1,13 +0,0 @@
fileFormatVersion: 2
guid: 750a2064e88b8dc45a94694b4d2c324b
timeCreated: 1523594583
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,503 +0,0 @@
using Gma.System.MouseKeyHook;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms;
using UnityEngine;
using UnityEngine.EventSystems;
[RequireComponent(typeof(BaseInputModule))]
public class GlobalMKHookInput : BaseInput
{
public bool ignoreAppFocus = false;
IKeyboardMouseEvents m_GlobalHook;
bool focus = false;
[SerializeField]
bool verbose = false;
public override int touchCount { get { return base.touchCount + TUIOManager.Instance.touches.Count; } }
public override bool touchSupported { get { return true; } }
private bool control = false;
private bool shift = false;
private string inputtext;
//Dictionary<int, float> index_stamp = new Dictionary<int, float>();
//Dictionary<int, Touch> index_touch = new Dictionary<int, Touch>();
//Dictionary<int, TouchPhase> index_prev_phase = new Dictionary<int, TouchPhase>();
//public float touchDelay = 0.1f;
//Dictionary<int, Touch> tuio_touches = new Dictionary<int, Touch>();
public override Touch GetTouch(int index)
{
if (index < base.touchCount)
{
return base.GetTouch(index);
}
else
{
index -= base.touchCount;
#if true
int[] keys = new int[TUIOManager.Instance.touches.Count];
TUIOManager.Instance.touches.Keys.CopyTo(keys, 0);
return TUIOManager.Instance.touches[keys[index]];
#else
int[] keys = new int[tuio_touches.Count];
tuio_touches.Keys.CopyTo(keys, 0);
return tuio_touches[keys[index]];
#endif
}
}
new void Awake()
{
m_GlobalHook = Hook.GlobalEvents();
m_GlobalHook.KeyDown += GlobalHookKeyDown;
m_GlobalHook.KeyPress += GlobalHookKeyPress;
m_GlobalHook.KeyUp += GlobalHookKeyUp;
}
new void OnDestroy()
{
m_GlobalHook.KeyDown -= GlobalHookKeyDown;
m_GlobalHook.KeyPress -= GlobalHookKeyPress;
m_GlobalHook.KeyUp -= GlobalHookKeyUp;
m_GlobalHook.Dispose();
}
private void OnApplicationFocus(bool focus)
{
this.focus = focus;
}
private void LateUpdate()
{
keys.Clear();
#if false
// update index_stamp
{
// collect missing touch id
List<int> candidates = new List<int>();
List<int> remove_candidates = new List<int>();
foreach (var id in index_stamp.Keys)
{
if (TUIOManager.Instance.touches.ContainsKey(id) == false)
candidates.Add(id);
}
// check missing id is Ended or set it
foreach (var id in candidates)
{
var t = index_touch[id];
if (t.phase == TouchPhase.Ended)
{
remove_candidates.Add(id);
}
else
{
t.phase = TouchPhase.Ended;
index_touch[id] = t;
}
}
// remove ended id
foreach (var id in remove_candidates)
{
index_stamp.Remove(id);
index_touch.Remove(id);
}
// check current id
int[] indices = new int[TUIOManager.Instance.touches.Keys.Count];
TUIOManager.Instance.touches.Keys.CopyTo(indices, 0);
for (int i = 0; i < indices.Length; i++)
{
int id = indices[i];
Touch t = TUIOManager.Instance.touches[indices[i]];
// new id
if (index_stamp.ContainsKey(id) == false)
{
t.phase = TouchPhase.Stationary;
index_stamp.Add(id, Time.time);
index_touch.Add(id, t);
}
else
{
t.phase = index_touch[id].phase;
index_touch[id] = t;
}
}
// update phase by time stamp
indices = new int[index_touch.Keys.Count];
index_touch.Keys.CopyTo(indices, 0);
tuio_touches.Clear();
List<TouchPhase> valid_phases = new List<TouchPhase>() { TouchPhase.Began, TouchPhase.Moved, TouchPhase.Ended };
foreach (var i in indices)
{
float dt = Time.time - index_stamp[i];
Touch t = index_touch[i];
TouchPhase tp = t.phase;
if (tp == TouchPhase.Stationary)
{
if (dt > touchDelay)
{
tp = TouchPhase.Began;
}
}
else if (tp == TouchPhase.Began)
{
tp = TouchPhase.Moved;
}
t.phase = tp;
index_touch[i] = t;
if (valid_phases.Contains(t.phase))
tuio_touches.Add(i, t);
}
}
#endif
}
public override bool GetButtonDown(string buttonName)
{
if (focus && !ignoreAppFocus)
return base.GetButtonDown(buttonName);
else
return CheckButtonDown(buttonName);
}
private bool CheckButtonDown(string buttonName)
{
foreach (Keys k in keys)
{
if(KeyConvertion.ContainsKey(k))
{
if (KeyConvertion[k].ToString() == buttonName)
return true;
}
}
return false;
}
private static Queue<Event> m_events = new Queue<Event>();
HashSet<Keys> keys = new HashSet<Keys>();
private void GlobalHookKeyDown(object sender, KeyEventArgs e)
{
if (verbose) Debug.Log("GlobalHookKeyDown: " + ToString(e));
Event m_event = ToEvent(e, EventType.KeyDown);
if (m_event != null)
{
m_events.Enqueue(m_event);
if(m_event.character != char.MinValue)
inputtext += m_event.character.ToString();
if(m_event.keyCode == KeyCode.Return)
{
print(inputtext);
inputtext = "";
}
}
keys.Add(e.KeyCode);
}
private void GlobalHookKeyPress(object sender, KeyPressEventArgs e)
{
//Debug.Log("SystemTime:" + DateTime.Now + ";keyboard:" + e.KeyChar + ";");
}
private void GlobalHookKeyUp(object sender, KeyEventArgs e)
{
if (verbose) Debug.Log("GlobalHookKeyUp: " + ToString(e));
Event m_event = ToEvent(e, EventType.KeyUp);
if (m_event != null)
{
m_events.Enqueue(m_event);
}
keys.Remove(e.KeyCode);
}
public static bool PopEvents(ref Event _event)
{
if (m_events.Count != 0)
{
_event = m_events.Dequeue();
return true;
}
else
return false;
}
string ToString(KeyEventArgs e)
{
return "[Key Down] KeyCode: " + e.KeyCode + " KeyData: " + e.KeyData + " Modifiers: " + e.Modifiers;
}
Event ToEvent(KeyEventArgs e, EventType keytype)
{
Event keyEvent = new Event();
keyEvent.type = keytype;
keyEvent.shift = shift;
keyEvent.control = control;
if (EngKeywords.ContainsKey(e.KeyCode))
{
keyEvent.keyCode = EngKeywords[e.KeyCode];
char[] keystring = e.KeyCode.ToString().ToCharArray(0, 1);
if (shift)
{
keystring[0] = char.ToUpper(keystring[0]);
}
else
{
keystring[0] = char.ToLower(keystring[0]);
}
keyEvent.character = keystring[0];
return keyEvent;
}
else if(AlphaNums.ContainsKey(e.KeyCode))
{
keyEvent.keyCode = AlphaNums[e.KeyCode];
char[] keystring = e.KeyCode.ToString().ToCharArray(1,1);
keyEvent.character = keystring[0];
keyEvent.numeric = true;
return keyEvent;
}
else if (NumPads.ContainsKey(e.KeyCode))
{
keyEvent.keyCode = NumPads[e.KeyCode];
char[] keystring = e.KeyCode.ToString().ToCharArray(6,1);
keyEvent.character = keystring[0];
keyEvent.numeric = true;
return keyEvent;
}
else if (Modifierkeys.ContainsKey(e.KeyCode))
{
keyEvent.keyCode = Modifierkeys[e.KeyCode];
if (e.KeyCode == Keys.LShiftKey || e.KeyCode == Keys.RShiftKey)
{
if(keytype == EventType.KeyDown)
shift = true;
else if(keytype == EventType.KeyUp)
shift = false;
}
if (e.KeyCode == Keys.LControlKey || e.KeyCode == Keys.RControlKey)
{
if (keytype == EventType.KeyDown)
control = true;
else if (keytype == EventType.KeyUp)
control = false;
}
keyEvent.shift = shift;
keyEvent.control = control;
return keyEvent;
}
else if (SpecialKeywords.ContainsKey(e.KeyCode))
{
keyEvent.keyCode = SpecialKeywords[e.KeyCode];
char keystring;
if (shift)
keystring = SpecialKeywordsShift[e.KeyCode];
else
keystring = SpecialKeywordsnoShift[e.KeyCode];
keyEvent.character = keystring;
return keyEvent;
}
return null;
}
private static readonly IDictionary<Keys, KeyCode> EngKeywords =
new Dictionary<Keys, KeyCode>
{
{ Keys.A, KeyCode.A},
{ Keys.B, KeyCode.B},
{ Keys.C, KeyCode.C},
{ Keys.D, KeyCode.D},
{ Keys.E, KeyCode.E},
{ Keys.F, KeyCode.F},
{ Keys.G, KeyCode.G},
{ Keys.H, KeyCode.H},
{ Keys.I, KeyCode.I},
{ Keys.J, KeyCode.J},
{ Keys.K, KeyCode.K},
{ Keys.L, KeyCode.L},
{ Keys.M, KeyCode.M},
{ Keys.N, KeyCode.N},
{ Keys.O, KeyCode.O},
{ Keys.P, KeyCode.P},
{ Keys.Q, KeyCode.Q},
{ Keys.R, KeyCode.R},
{ Keys.S, KeyCode.S},
{ Keys.T, KeyCode.T},
{ Keys.U, KeyCode.U},
{ Keys.V, KeyCode.V},
{ Keys.W, KeyCode.W},
{ Keys.X, KeyCode.X},
{ Keys.Y, KeyCode.Y},
{ Keys.Z, KeyCode.Z},
};
private static readonly IDictionary<Keys, KeyCode> SpecialKeywords =
new Dictionary<Keys, KeyCode>
{
{ Keys.OemPipe, KeyCode.Backslash},
{ Keys.Divide, KeyCode.KeypadDivide},
{ Keys.OemSemicolon, KeyCode.Colon },
{ Keys.OemQuestion, KeyCode.Question },
{ Keys.OemPeriod, KeyCode.Period },
{ Keys.OemMinus, KeyCode.Minus },
{ Keys.Oem3, KeyCode.BackQuote },
{ Keys.Oem4, KeyCode.LeftBracket },
{ Keys.OemCloseBrackets, KeyCode.RightBracket },
{ Keys.Oemplus, KeyCode.Equals },
};
private static readonly IDictionary<Keys, char> SpecialKeywordsnoShift =
new Dictionary<Keys, char>
{
{ Keys.OemPipe, '\''},
{ Keys.Divide, '/'},
{ Keys.OemSemicolon, ';'},
{ Keys.OemQuestion, '/'},
{ Keys.OemPeriod, '.' },
{ Keys.OemMinus, '-' },
{ Keys.Oem3, '`' },
{ Keys.Oem4, '[' },
{ Keys.OemCloseBrackets, ']' },
{ Keys.Oemplus, '=' },
};
private static readonly IDictionary<Keys, char> SpecialKeywordsShift =
new Dictionary<Keys, char>
{
{ Keys.OemPipe, '\\'},
{ Keys.Divide, '/'},
{ Keys.OemSemicolon, ':'},
{ Keys.OemQuestion, '?'},
{ Keys.OemPeriod, '>' },
{ Keys.OemMinus, '_' },
{ Keys.Oem3, '~' },
{ Keys.Oem4, '{' },
{ Keys.OemCloseBrackets, '}' },
{ Keys.Oemplus, '+' },
};
private static readonly IDictionary<Keys, KeyCode> AlphaNums =
new Dictionary<Keys, KeyCode>
{
{ Keys.D0, KeyCode.Alpha0 },
{ Keys.D1, KeyCode.Alpha1 },
{ Keys.D2, KeyCode.Alpha2 },
{ Keys.D3, KeyCode.Alpha3 },
{ Keys.D4, KeyCode.Alpha4 },
{ Keys.D5, KeyCode.Alpha5 },
{ Keys.D6, KeyCode.Alpha6 },
{ Keys.D7, KeyCode.Alpha7 },
{ Keys.D8, KeyCode.Alpha8 },
{ Keys.D9, KeyCode.Alpha9 },
};
private static readonly IDictionary<Keys, KeyCode> NumPads =
new Dictionary<Keys, KeyCode>
{
{ Keys.NumPad0, KeyCode.Keypad0 },
{ Keys.NumPad1, KeyCode.Keypad1 },
{ Keys.NumPad2, KeyCode.Keypad2 },
{ Keys.NumPad3, KeyCode.Keypad3 },
{ Keys.NumPad4, KeyCode.Keypad4 },
{ Keys.NumPad5, KeyCode.Keypad5 },
{ Keys.NumPad6, KeyCode.Keypad6 },
{ Keys.NumPad7, KeyCode.Keypad7 },
{ Keys.NumPad8, KeyCode.Keypad8 },
{ Keys.NumPad9, KeyCode.Keypad9 },
};
private static readonly IDictionary<Keys, KeyCode> Modifierkeys =
new Dictionary<Keys, KeyCode>
{
{ Keys.PageUp, KeyCode.PageUp},
{ Keys.PageDown, KeyCode.PageDown},
{ Keys.End, KeyCode.End},
{ Keys.Home, KeyCode.Home},
{ Keys.Return, KeyCode.Return},
{ Keys.LShiftKey, KeyCode.LeftShift},
{ Keys.RShiftKey, KeyCode.RightShift},
{ Keys.LControlKey, KeyCode.LeftControl},
{ Keys.RControlKey, KeyCode.RightControl}
};
private static readonly IDictionary<Keys, KeyCode> KeyConvertion =
new Dictionary<Keys, KeyCode> {
{ Keys.Up , KeyCode.UpArrow },
{ Keys.Down , KeyCode.DownArrow },
{ Keys.Right, KeyCode.RightArrow},
{ Keys.Left, KeyCode.LeftArrow},
{ Keys.D0, KeyCode.Alpha0 },
{ Keys.D1, KeyCode.Alpha1 },
{ Keys.D2, KeyCode.Alpha2 },
{ Keys.D3, KeyCode.Alpha3 },
{ Keys.D4, KeyCode.Alpha4 },
{ Keys.D5, KeyCode.Alpha5 },
{ Keys.D6, KeyCode.Alpha6 },
{ Keys.D7, KeyCode.Alpha7 },
{ Keys.D8, KeyCode.Alpha8 },
{ Keys.D9, KeyCode.Alpha9 },
{ Keys.NumPad0, KeyCode.Keypad0 },
{ Keys.NumPad1, KeyCode.Keypad1 },
{ Keys.NumPad2, KeyCode.Keypad2 },
{ Keys.NumPad3, KeyCode.Keypad3 },
{ Keys.NumPad4, KeyCode.Keypad4 },
{ Keys.NumPad5, KeyCode.Keypad5 },
{ Keys.NumPad6, KeyCode.Keypad6 },
{ Keys.NumPad7, KeyCode.Keypad7 },
{ Keys.NumPad8, KeyCode.Keypad8 },
{ Keys.NumPad9, KeyCode.Keypad9 },
{ Keys.F1, KeyCode.F1 },
{ Keys.F2, KeyCode.F2 },
{ Keys.F3, KeyCode.F3 },
{ Keys.F4, KeyCode.F4 },
{ Keys.F5, KeyCode.F5 },
{ Keys.F6, KeyCode.F6 },
{ Keys.F7, KeyCode.F7 },
{ Keys.F8, KeyCode.F8 },
{ Keys.F9, KeyCode.F9 },
{ Keys.F10, KeyCode.F10 },
{ Keys.F11, KeyCode.F11 },
{ Keys.F12, KeyCode.F12 },
//{ Keys.Prior, KeyCode.PageUp},
{ Keys.PageUp, KeyCode.PageUp},
//{ Keys.Next, KeyCode.PageDown},
{ Keys.PageDown, KeyCode.PageDown},
{ Keys.End, KeyCode.End},
{ Keys.Home, KeyCode.Home},
{ Keys.A, KeyCode.A},
{ Keys.B, KeyCode.B},
{ Keys.C, KeyCode.C},
{ Keys.D, KeyCode.D},
{ Keys.E, KeyCode.E},
{ Keys.F, KeyCode.F},
{ Keys.G, KeyCode.G},
{ Keys.H, KeyCode.H},
{ Keys.I, KeyCode.I},
{ Keys.J, KeyCode.J},
{ Keys.K, KeyCode.K},
{ Keys.L, KeyCode.L},
{ Keys.M, KeyCode.M},
{ Keys.N, KeyCode.N},
{ Keys.O, KeyCode.O},
{ Keys.P, KeyCode.P},
{ Keys.Q, KeyCode.Q},
{ Keys.R, KeyCode.R},
{ Keys.S, KeyCode.S},
{ Keys.T, KeyCode.T},
{ Keys.U, KeyCode.U},
{ Keys.V, KeyCode.V},
{ Keys.W, KeyCode.W},
{ Keys.X, KeyCode.X},
{ Keys.Y, KeyCode.Y},
{ Keys.Z, KeyCode.Z},
};
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: fe29c1405d598044db227a4b345e815d
timeCreated: 1489129364
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,29 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
[RequireComponent(typeof(GlobalMKHookInput))]
public class GlobalMKHookInputModule : StandaloneInputModule
{
public bool forceProcessMouseEvent = true;
public Dictionary<int, PointerEventData> GetPointerDatas { get { return m_PointerData; } }
protected override void Awake()
{
base.Awake();
m_InputOverride = GetComponent<GlobalMKHookInput>();
}
public override bool IsModuleSupported()
{
return TUIOManager.Instance.IsReady();
}
public override void Process()
{
base.Process();
if (forceProcessMouseEvent && input.touchCount > 0 == true && input.mousePresent)
base.ProcessMouseEvent();
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 513b3b72b9bf8a4438d7c4bb4aab849e
timeCreated: 1489145429
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,89 +0,0 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.EventSystems;
using System;
public class InputVisualizer : MonoBehaviour
{
[SerializeField]
Texture2D ball;
// [AutoUI]
[SerializeField]
private bool debugInput = false;
public static float ball_size = 1;
public delegate void OnTouchDown(Vector2 p);
public static event OnTouchDown TouchEvent;
public void trigger_tuio_event(Vector2 p)
{
if (TouchEvent != null)
TouchEvent(p);
}
// Use this for initialization
void Awake()
{
#if UNITY_EDITOR
// debugInput = false;
#endif
}
void Start()
{
Debug.LogWarning("InputVisualizer is not fully implemented yet!!!!");
//Cursor.visible = false;
}
void Update()
{
if (EventSystem.current == null || EventSystem.current.currentInputModule == null)
return;
BaseInput input = EventSystem.current.currentInputModule.input;
if (input.GetMouseButton(0))
{
trigger_tuio_event(input.mousePosition);
}
for (int i = 0; i < input.touchCount; i++)
{
Touch t = input.GetTouch(i);
trigger_tuio_event(t.position);
}
}
void OnGUI()
{
if (!debugInput)
return;
if (EventSystem.current == null || EventSystem.current.currentInputModule == null)
return;
BaseInput input = EventSystem.current.currentInputModule.input;
if (input.GetMouseButton(0))
{
DrawPointer(input.mousePosition);
}
for (int i = 0; i < input.touchCount; i++)
{
Touch t = input.GetTouch(i);
DrawPointer(t.position);
}
}
void DrawPointer(Vector2 position)
{
float x = position.x - ball.width / 2 * ball_size;
float y = Screen.height - position.y - ball.height / 2 * ball_size;
Rect ballRect = new Rect(x, y, ball.width * ball_size, ball.height * ball_size);
GUI.DrawTexture(ballRect, ball);
}
}

@ -1,13 +0,0 @@
fileFormatVersion: 2
guid: 7aa9f9acee84c6544ae78641b47946d8
timeCreated: 1489050306
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences:
- ball: {fileID: 10912, guid: 0000000000000000f000000000000000, type: 0}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,183 +0,0 @@
using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
[AddComponentMenu("Event/TUIO Input Module")]
public class TUIOInputModule : PointerInputModule
{
protected TUIOInputModule()
{
}
public override bool IsModuleSupported()
{
return TUIOManager.Instance.IsReady();
}
public override bool ShouldActivateModule()
{
if (!base.ShouldActivateModule())
return false;
return TUIOManager.Instance.touches.Count > 0;
}
public override void Process()
{
ProcessTUIOEvents();
}
void OnApplicationFocus(bool hasFocus)
{
_hasFocus = hasFocus;
}
private void Update()
{
//return;
if (_hasFocus)
return;
UpdateModule();
Process();
}
private bool ProcessTUIOEvents()
{
foreach (int key in TUIOManager.Instance.touches.Keys)
{
Touch touch = TUIOManager.Instance.touches[key];
if (touch.type == TouchType.Indirect)
{
print("touch.type == TouchType.Indirect");
//continue;
}
bool released;
bool pressed;
var pointer = GetTouchPointerEventData(touch, out pressed, out released);
if(released)
{
// print("remove 2, " + touch.fingerId);
}
ProcessTouchPress(pointer, pressed, released);
if (!released)
{
ProcessMove(pointer);
ProcessDrag(pointer);
}
else
RemovePointerData(pointer);
}
return TUIOManager.Instance.touches.Count > 0;
}
protected void ProcessTouchPress(PointerEventData pointerEvent, bool pressed, bool released)
{
var currentOverGo = pointerEvent.pointerCurrentRaycast.gameObject;
// PointerDown notification
if (pressed)
{
pointerEvent.eligibleForClick = true;
pointerEvent.delta = Vector2.zero;
pointerEvent.dragging = false;
pointerEvent.useDragThreshold = true;
pointerEvent.pressPosition = pointerEvent.position;
pointerEvent.pointerPressRaycast = pointerEvent.pointerCurrentRaycast;
DeselectIfSelectionChanged(currentOverGo, pointerEvent);
if (pointerEvent.pointerEnter != currentOverGo)
{
// send a pointer enter to the touched element if it isn't the one to select...
HandlePointerExitAndEnter(pointerEvent, currentOverGo);
pointerEvent.pointerEnter = currentOverGo;
}
// search for the control that will receive the press
// if we can't find a press handler set the press
// handler to be what would receive a click.
var newPressed = ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.pointerDownHandler);
// didnt find a press handler... search for a click handler
if (newPressed == null)
newPressed = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo);
// Debug.Log("Pressed: " + newPressed);
float time = Time.unscaledTime;
if (newPressed == pointerEvent.lastPress)
{
var diffTime = time - pointerEvent.clickTime;
if (diffTime < 0.3f)
++pointerEvent.clickCount;
else
pointerEvent.clickCount = 1;
pointerEvent.clickTime = time;
}
else
{
pointerEvent.clickCount = 1;
}
pointerEvent.pointerPress = newPressed;
pointerEvent.rawPointerPress = currentOverGo;
pointerEvent.clickTime = time;
// Save the drag handler as well
pointerEvent.pointerDrag = ExecuteEvents.GetEventHandler<IDragHandler>(currentOverGo);
if (pointerEvent.pointerDrag != null)
ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.initializePotentialDrag);
}
// PointerUp notification
if (released)
{
// Debug.Log("Executing pressup on: " + pointer.pointerPress);
ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler);
// Debug.Log("KeyCode: " + pointer.eventData.keyCode);
// see if we mouse up on the same element that we clicked on...
var pointerUpHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo);
// PointerClick and Drop events
if (pointerEvent.pointerPress == pointerUpHandler && pointerEvent.eligibleForClick)
{
ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerClickHandler);
}
else if (pointerEvent.pointerDrag != null && pointerEvent.dragging)
{
ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.dropHandler);
}
pointerEvent.eligibleForClick = false;
pointerEvent.pointerPress = null;
pointerEvent.rawPointerPress = null;
if (pointerEvent.pointerDrag != null && pointerEvent.dragging)
ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.endDragHandler);
pointerEvent.dragging = false;
pointerEvent.pointerDrag = null;
if (pointerEvent.pointerDrag != null)
ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.endDragHandler);
pointerEvent.pointerDrag = null;
// send exit events as we need to simulate this on touch up on touch device
ExecuteEvents.ExecuteHierarchy(pointerEvent.pointerEnter, pointerEvent, ExecuteEvents.pointerExitHandler);
pointerEvent.pointerEnter = null;
}
}
private bool _hasFocus;
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 679afa98eba7ead4a83f5e68ad3a9ee1
timeCreated: 1482468162
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,238 +0,0 @@
//#define TUIO_DEBUG
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TUIO;
using System;
using UnityEngine.Events;
public class ARTag
{
public int sessionId { get; set; }
public int symbolId { get; set; }
public Vector2 position { get; set; }
public TouchPhase phase { get; set; }
public float angle { get; set; }
}
public class TUIOManager : MonoBehaviour, TuioListener
{
const int MAX_OBJ_NUM_PRE_FRAME = 500;
public static TUIOManager Instance
{
get
{
if (_instance == null)
{
_instance = (TUIOManager)GameObject.FindObjectOfType(typeof(TUIOManager));
if (_instance == null)
{
Debug.LogWarning("TUIOManager component required - adding dynamically now");
GameObject go = new GameObject("TUIOManager");
_instance = go.AddComponent<TUIOManager>();
}
}
return _instance;
}
}
[SerializeField]
TuioFilter[] blobFilters;
[SerializeField]
TuioFilter[] objectFilters;
public double TouchFps = 0;
public double ObjectFps = 0;
public Dictionary<int, Touch> touches
{
get;
private set;
}
public Dictionary<int, ARTag> objects
{
get;
private set;
}
public void addTuioCursor(TuioCursor tcur)
{
tuio_buffer[TuioType.TOUCH].Add(new TuioData(tcur, TouchPhase.Began));
}
public void updateTuioCursor(TuioCursor tcur)
{
tuio_buffer[TuioType.TOUCH].Add(new TuioData(tcur, TouchPhase.Moved));
}
public void removeTuioCursor(TuioCursor tcur)
{
tuio_buffer[TuioType.TOUCH].Add(new TuioData(tcur, TouchPhase.Ended));
}
public void addTuioBlob(TuioBlob tblb)
{
tuio_buffer[TuioType.TOUCH].Add(new TuioData(tblb, TouchPhase.Began));
}
public void updateTuioBlob(TuioBlob tblb)
{
tuio_buffer[TuioType.TOUCH].Add(new TuioData(tblb, TouchPhase.Moved));
}
public void removeTuioBlob(TuioBlob tblb)
{
tuio_buffer[TuioType.TOUCH].Add(new TuioData(tblb, TouchPhase.Ended));
}
public void addTuioObject(TuioObject tobj)
{
tuio_buffer[TuioType.OBJECT].Add(new TuioData(tobj, TouchPhase.Began));
}
public void updateTuioObject(TuioObject tobj)
{
tuio_buffer[TuioType.OBJECT].Add(new TuioData(tobj, TouchPhase.Moved));
}
public void removeTuioObject(TuioObject tobj)
{
tuio_buffer[TuioType.OBJECT].Add(new TuioData(tobj, TouchPhase.Ended));
}
public void refresh(TuioTime ftime)
{
foreach (var buffer in tuio_buffer)
{
buffer.Value.Refresh();
}
}
public bool IsReady()
{
return client.isConnected ();
}
private Touch ToTouch(TuioContainer tcur, TouchPhase phase)
{
Touch result = new Touch();
result.phase = phase;
if (tcur is TuioCursor)
result.fingerId = (int)(tcur as TuioCursor).SessionID;
else if (tcur is TuioBlob)
result.fingerId = (int)(tcur as TuioBlob).SessionID;
result.position = new Vector2(tcur.X, tcur.Y);
result.type = TouchType.Direct;
return result;
}
private ARTag ToARTag(TuioContainer tcur, TouchPhase phase)
{
TuioObject obj = (TuioObject)tcur;
ARTag result = new ARTag();
result.phase = phase;
result.sessionId = (int)obj.SessionID;
result.symbolId = (int)obj.SymbolID;
result.position = new Vector2(tcur.X, tcur.Y);
return result;
}
void Awake()
{
foreach(TuioType tuiotype in Enum.GetValues(typeof(TuioType)))
{
TuioBuffer buffer = new TuioBuffer();
tuio_buffer.Add(tuiotype, buffer);
}
touches = new Dictionary<int, Touch>();
objects = new Dictionary<int, ARTag>();
}
// Use this for initialization
void Start()
{
client = new TuioClient(TuioPort);
client.addTuioListener(this);
client.connect();
}
void OnDestroy()
{
client.disconnect ();
}
// Update is called once per frame
void LateUpdate()
{
foreach (var buffer in tuio_buffer)
{
buffer.Value.Update();
}
TouchFps = tuio_buffer[TuioType.TOUCH].FPS;
ObjectFps = tuio_buffer[TuioType.OBJECT].FPS;
touches.Clear();
foreach (var key_tuiodata in tuio_buffer[ TuioType.TOUCH] .DataList)
{
TuioContainer tcur = null;
if (key_tuiodata.Value.container as TuioCursor != null)
tcur = new TuioCursor(key_tuiodata.Value.container as TuioCursor);
if (key_tuiodata.Value.container as TuioBlob != null)
tcur = new TuioBlob(key_tuiodata.Value.container as TuioBlob);
foreach (var f in blobFilters)
{
f.Filter(tcur);
}
touches[(int)key_tuiodata.Key] = ToTouch(tcur, key_tuiodata.Value.phase);
}
objects.Clear();
foreach (var key_tuiodata in tuio_buffer[TuioType.OBJECT].DataList)
{
TuioContainer tcur = new TuioObject(key_tuiodata.Value.container as TuioObject);
foreach (var f in objectFilters)
{
f.Filter(tcur);
}
ARTag artag = ToARTag(tcur, key_tuiodata.Value.phase); ;
objects[(int)key_tuiodata.Key] = artag;
}
foreach (var key_tuiodata in objects)
{
switch (key_tuiodata.Value.phase)
{
case TouchPhase.Began:
AddTuioObjectEvent.Invoke(key_tuiodata.Value);
break;
case TouchPhase.Moved:
UpdateTuioObjectEvent.Invoke(key_tuiodata.Value);
break;
case TouchPhase.Ended:
RemoveTuioObjectEvent.Invoke(key_tuiodata.Value);
break;
default:
break;
}
}
}
private static void swap(ref int a, ref int b)
{
int tmp = a;
a = b;
b = tmp;
}
public int TuioPort = 3333;
private static TUIOManager _instance;
private TuioClient client;
enum TuioType
{
TOUCH,
OBJECT
}
Dictionary<TuioType, TuioBuffer> tuio_buffer = new Dictionary<TuioType, TuioBuffer>();
[System.Serializable]
public class TuioObjectHandler : UnityEvent<ARTag> { };
public TuioObjectHandler AddTuioObjectEvent = new TuioObjectHandler();
public TuioObjectHandler UpdateTuioObjectEvent = new TuioObjectHandler();
public TuioObjectHandler RemoveTuioObjectEvent = new TuioObjectHandler();
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: efb261ab42149004580a10ea28a14a0f
timeCreated: 1482474047
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,90 +0,0 @@
using System.Collections.Generic;
using System;
using UnityEngine;
public class TuioBuffer
{
private int BACK = 0;
private int FRONT = 1;
private int READY = 2;
private TuioFrame[] frame = new TuioFrame[3];
private List<long> raw_available_list = new List<long>();
public TuioBuffer()
{
for (int i = 0; i < frame.Length; ++i)
frame[i] = new TuioFrame();
}
public void Add(TuioData data)
{
switch (data.phase)
{
case TouchPhase.Began:
raw_available_list.Add(data.container.SessionID);
break;
case TouchPhase.Ended:
raw_available_list.Remove(data.container.SessionID);
break;
default:
break;
}
frame[BACK].data_list.Add(data);
}
public void Refresh()
{
if (frame[BACK].data_list.Count == 0)
return;
frame[BACK].available_list.AddRange(raw_available_list);
lock (this)
{
swap(ref BACK, ref FRONT);
is_front_ok = true;
}
DateTime now = DateTime.Now;
double delta = (now - stamp).TotalSeconds;
double duration = 0.5;
smooth_delta += (delta - smooth_delta) * Math.Min(1.0, delta / duration);
FPS = 1.0 / smooth_delta;
stamp = now;
frame[BACK].data_list.Clear();
frame[BACK].available_list.Clear();
}
public void Update()
{
is_ready_ok = false;
if (is_front_ok)
{
lock (this)
{
swap(ref READY, ref FRONT);
is_front_ok = false;
}
is_ready_ok = true;
}
if (is_ready_ok)
updater.Update(frame[READY].data_list, frame[READY].available_list);
else
updater.Update();
}
private TuioUpdater updater = new TuioUpdater();
//public List<long> AvailableList { get { return frame[READY].available_list; } }
public Dictionary<long, TuioData> DataList { get { return updater.tuio_data_list; } }
public double FPS { get; private set; }
private bool is_front_ok = false;
private bool is_ready_ok = false;
private double smooth_delta;
private DateTime stamp = DateTime.Now;
private static void swap(ref int a, ref int b)
{
int tmp = a;
a = b;
b = tmp;
}
}

@ -1,13 +0,0 @@
fileFormatVersion: 2
guid: eb0056bd31eee42408783d0f4d22afe6
timeCreated: 1523591670
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,38 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using TUIO;
using UnityEngine;
public class TuioDefaultFilter : TuioFilter
{
public Rect customRoi;
private Rect roi = Rect.zero;
public void Start()
{
roi.width = Camera.main.pixelWidth;
roi.height = Camera.main.pixelHeight;
}
protected void FixedUpdate()
{
if (customRoi != Rect.zero)
{
roi = customRoi;
}
else
{
roi.width = Camera.main.pixelWidth;
roi.height = Camera.main.pixelHeight;
}
}
public override void Filter(TuioContainer tcur)
{
if (isActiveAndEnabled == false)
return;
tcur.update(tcur.X * roi.width + roi.x, (1.0f - tcur.Y) * roi.height + roi.y);
}
}

@ -1,13 +0,0 @@
fileFormatVersion: 2
guid: c0cf9367f1409d14eacc224f20a139d4
timeCreated: 1523595222
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,11 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TUIO;
using UnityEngine;
using UnityUtils.TUIO;
public class TuioFilter : MonoBehaviour, ITuioFilterHandler
{
public virtual void Filter(TuioContainer tcur) { }
}

@ -1,13 +0,0 @@
fileFormatVersion: 2
guid: 2af43f939ed5a924a830f88cc306c952
timeCreated: 1523593745
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,127 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TUIO;
using UnityEngine;
public class TuioData
{
public TouchPhase phase = TouchPhase.Began;
public TuioContainer container = null;
public TuioData() { }
public TuioData(TuioContainer container, TouchPhase phase)
{
this.container = container;
this.phase = phase;
}
}
public class TuioFrame
{
public List<long> available_list = new List<long>();
public List<TuioData> data_list = new List<TuioData>();
}
public class TuioUpdater
{
public Dictionary<long, TuioData> tuio_data_list = new Dictionary<long, TuioData>();
public void Update(List<TuioData> raw_data_list = null, List<long> raw_available_list = null)
{
foreach (var key_touch in tuio_data_list)
{
switch (key_touch.Value.phase)
{
case TouchPhase.Ended:
removal_ids.Add(key_touch.Key);
break;
case TouchPhase.Began:
moved_ids.Add(key_touch.Key);
break;
case TouchPhase.Moved:
//Do nothing!!!
break;
default:
Debug.LogWarning("Imposible touch-phase " + key_touch.Value.phase + "!!!");
break;
}
}
foreach (int id in removal_ids)
tuio_data_list.Remove(id);
removal_ids.Clear();
foreach (int id in moved_ids)
{
TuioData new_touch = tuio_data_list[id];
new_touch.phase = TouchPhase.Moved;
tuio_data_list[id] = new_touch;
}
moved_ids.Clear();
if (raw_data_list == null || raw_available_list == null)
return;
foreach (TuioData tuio_data in raw_data_list)
{
if (tuio_data_list.ContainsKey(tuio_data.container.SessionID))
{
switch (tuio_data.phase)
{
case TouchPhase.Ended:
tuio_data_list[tuio_data.container.SessionID] = tuio_data;
break;
case TouchPhase.Moved:
tuio_data_list[tuio_data.container.SessionID] = tuio_data;
break;
case TouchPhase.Began:
Debug.LogError("SessionID " + tuio_data.container.SessionID + " already exists!!!");
break;
default:
Debug.LogError("Imposible touch-phase " + tuio_data.phase + "!!!");
break;
}
}
else
{
switch (tuio_data.phase)
{
case TouchPhase.Began:
case TouchPhase.Moved:
{
TuioData new_tuio_data = tuio_data;
new_tuio_data.phase = TouchPhase.Began;
tuio_data_list.Add(new_tuio_data.container.SessionID, new_tuio_data);
}
break;
case TouchPhase.Ended:
//do nothing.
break;
default:
Debug.LogWarning("Imposible touch-phase " + tuio_data.phase + "!!!");
break;
}
}
}
foreach (var key_touch in tuio_data_list)
{
if (raw_available_list.FindIndex(id => { return id == key_touch.Value.container.SessionID; }) == -1)
{
ended_ids.Add(key_touch.Value.container.SessionID);
}
}
foreach (int id in ended_ids)
{
TuioData new_touch = tuio_data_list[id];
new_touch.phase = TouchPhase.Ended;
tuio_data_list[id] = new_touch;
}
ended_ids.Clear();
}
private List<long> removal_ids = new List<long>();
private List<long> moved_ids = new List<long>();
private List<long> ended_ids = new List<long>();
}

@ -1,13 +0,0 @@
fileFormatVersion: 2
guid: 1fd92776ea9677a429b8f921fc0e9935
timeCreated: 1523605961
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,11 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class UCEventSystem : EventSystem {
protected override void OnApplicationFocus(bool hasFocus)
{
//base.OnApplicationFocus(false);
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: a1b8f7bfe9062b34fa444249c80bb93a
timeCreated: 1490240076
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1,154 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1641997025252556}
m_IsPrefabParent: 1
--- !u!1 &1641997025252556
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4472652550524646}
- component: {fileID: 114540009425154000}
- component: {fileID: 114872970294644716}
- component: {fileID: 114080462365263002}
- component: {fileID: 114569137293014918}
- component: {fileID: 114504107585269582}
- component: {fileID: 114833196982375236}
m_Layer: 0
m_Name: UCEventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 4294967295
m_IsActive: 1
--- !u!4 &4472652550524646
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1641997025252556}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &114080462365263002
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1641997025252556}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 513b3b72b9bf8a4438d7c4bb4aab849e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
forceProcessMouseEvent: 1
--- !u!114 &114504107585269582
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1641997025252556}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7aa9f9acee84c6544ae78641b47946d8, type: 3}
m_Name:
m_EditorClassIdentifier:
ball: {fileID: 10912, guid: 0000000000000000f000000000000000, type: 0}
debugInput: 0
--- !u!114 &114540009425154000
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1641997025252556}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: efb261ab42149004580a10ea28a14a0f, type: 3}
m_Name:
m_EditorClassIdentifier:
blobFilters:
- {fileID: 114872970294644716}
objectFilters: []
TouchFps: 0
ObjectFps: 0
TuioPort: 3333
AddTuioObjectEvent:
m_PersistentCalls:
m_Calls: []
m_TypeName: TUIOManager+TuioObjectHandler, Assembly-CSharp, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
UpdateTuioObjectEvent:
m_PersistentCalls:
m_Calls: []
m_TypeName: TUIOManager+TuioObjectHandler, Assembly-CSharp, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
RemoveTuioObjectEvent:
m_PersistentCalls:
m_Calls: []
m_TypeName: TUIOManager+TuioObjectHandler, Assembly-CSharp, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
--- !u!114 &114569137293014918
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1641997025252556}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe29c1405d598044db227a4b345e815d, type: 3}
m_Name:
m_EditorClassIdentifier:
ignoreAppFocus: 0
--- !u!114 &114833196982375236
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1641997025252556}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a1b8f7bfe9062b34fa444249c80bb93a, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 5
--- !u!114 &114872970294644716
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1641997025252556}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c0cf9367f1409d14eacc224f20a139d4, type: 3}
m_Name:
m_EditorClassIdentifier:
customRoi:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 1f68bf7cec2600e49a46d2f0554453c8
timeCreated: 1490242242
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

@ -1,58 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
using UnityEngine.UI;
public class UCInputField : InputField
{
public Event globalkeyEvent;
public override void OnUpdateSelected(BaseEventData eventData)
{
if (!isFocused)
return;
bool consumedEvent = false;
globalkeyEvent = new Event();
while (GlobalMKHookInput.PopEvents(ref globalkeyEvent))
{
if (globalkeyEvent.rawType == EventType.KeyDown)
{
consumedEvent = true;
var shouldContinue = KeyPressed(globalkeyEvent);
if (shouldContinue == EditState.Finish)
{
DeactivateInputField();
break;
}
}
switch (globalkeyEvent.type)
{
case EventType.ValidateCommand:
case EventType.ExecuteCommand:
switch (globalkeyEvent.commandName)
{
case "SelectAll":
SelectAll();
consumedEvent = true;
break;
}
break;
}
}
if (consumedEvent)
UpdateLabel();
eventData.Use();
}
}

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 8254c9084159a264e81e721f51ae2066
timeCreated: 1496388358
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -1 +1 @@
Subproject commit da27a6820768fa330cc335ae0b470e874cad395f Subproject commit ca704e07d74af1887017c9b8a295f5bfd2fd8a41

@ -4,6 +4,8 @@
"com.ultracombos.grpc": "file:<project>/../../../_Package/com.ultracombos.grpc", "com.ultracombos.grpc": "file:<project>/../../../_Package/com.ultracombos.grpc",
"com.ultracombos.generic-grpc": "file:<project>/../../../_Package/com.ultracombos.generic-grpc", "com.ultracombos.generic-grpc": "file:<project>/../../../_Package/com.ultracombos.generic-grpc",
"com.ultracombos.movie-player": "file:<project>/../../../_Package/com.ultracombos.movie-player", "com.ultracombos.movie-player": "file:<project>/../../../_Package/com.ultracombos.movie-player",
"com.ultracombos.osc": "file:<project>/../../../_Package/com.ultracombos.osc",
"com.ultracombos.tuio": "file:<project>/../../../_Package/com.ultracombos.tuio",
"com.unity.ads": "2.0.8", "com.unity.ads": "2.0.8",
"com.unity.analytics": "3.2.2", "com.unity.analytics": "3.2.2",
"com.unity.collab-proxy": "1.2.15", "com.unity.collab-proxy": "1.2.15",

@ -0,0 +1 @@
Subproject commit e594dfc8647586530b53cd990d56caa0d07adde2

@ -0,0 +1 @@
Subproject commit a91e9cf29e230c28d7fd72f78e790c9b68513d62
Loading…
Cancel
Save