void Awake()
        {
            Debug.Log("OSSIA: Starting");
            if (!set)
            {
                set = true;

                // Setup the log so that the errors in the C API are shown in the
                // Unity3D console
                callback_delegate = new DebugLogDelegate(DebugLogCallback);

                // Convert callback_delegate into a function pointer that can be
                // used in unmanaged code.
                IntPtr intptr_delegate =
                    Marshal.GetFunctionPointerForDelegate(callback_delegate);

                // Call the API passing along the function pointer.
                Ossia.Network.ossia_set_debug_logger(intptr_delegate);

                local_protocol = new Ossia.Local();
                local_device   = new Ossia.Device(local_protocol, appName);
                scene_node     = local_device.GetRootNode().AddChild("scene");

                Queue = new Ossia.MessageQueue(local_device);

                oscq_protocol = new Ossia.OSCQuery(scorePort, unityPort);
                local_protocol.ExposeTo(oscq_protocol);
            }
        }
Пример #2
0
    Ossia.Device getDevice()
    {
        var dev = Controller.Get();

        Ossia.Device local_device = dev.GetDevice();
        if (local_device == null)
        {
            throw new Exception("LocalDevice is null");
        }
        return(local_device);
    }
Пример #3
0
 public void ApplyToDevice(Ossia.Device dev, bool KeepArch)
 {
     if (dev.GetDevice() != IntPtr.Zero)
     {
         //Debug.Log (dev.GetDevice ());
         ossia_preset_result_enum code = ossia_preset_result_enum.OSSIA_PRESETS_OK;
         code = BlueYetiAPI.ossia_devices_apply_preset(dev.GetDevice(), preset, KeepArch);
         if (code != ossia_preset_result_enum.OSSIA_PRESETS_OK)
         {
             throw new Exception("Error code " + code);
         }
     }
     else
     {
         throw new Exception("Can't apply preset to null device");
     }
 }
Пример #4
0
    void OnReadPreset()
    {
        string jsontext = System.IO.File.ReadAllText(presetPath);

        Preset p = new Preset(jsontext);

        Ossia.Device dev = getDevice();
        p.ApplyToDevice(dev, true);

        {
            var objects = UnityEngine.Object.FindObjectsOfType <Ossia.ExposeAttributes> ();
            foreach (Ossia.ExposeAttributes obj in objects)
            {
                obj.ReceiveUpdates();
            }
        }
        {
            var exposed = UnityEngine.Object.FindObjectsOfType <Ossia.ExposeComponents> ();
            foreach (Ossia.ExposeComponents obj in exposed)
            {
                obj.ReceiveUpdates();
            }
        }
    }
Пример #5
0
    void Start()
    {
        Application.runInBackground = true;

        var    callback_delegate = new debug_log_delegate((string str) => Debug.Log("OSSIA : " + str));
        IntPtr intptr_delegate   = Marshal.GetFunctionPointerForDelegate(callback_delegate);

        Ossia.Network.ossia_set_debug_logger(intptr_delegate);

        local = new Ossia.Device(new Ossia.OSCQuery(1234, 5678), "newDevice");

        var root = local.GetRootNode();

        Assert.AreEqual(root.ChildSize(), 0);

        // Just for tests:
        {
            // Create a node and an address
            var bar  = Ossia.Node.CreateNode(root, "/foo/bar");
            var addr = bar.CreateParameter(Ossia.ossia_type.VEC3F);
            Assert.AreEqual(root.ChildSize(), 1);

            var foo = root.GetChild(0);
            Assert.AreEqual(foo.GetName(), "foo");

            // Try removing the address
            Assert.AreNotEqual(bar.GetNode(), IntPtr.Zero);
            Assert.AreEqual(bar.GetParameter(), addr);

            foo.RemoveChild(foo.GetChild(0));
            Assert.AreEqual(bar.GetNode(), IntPtr.Zero);
            Assert.AreEqual(bar.GetParameter(), null);
        }

        {
            var str  = Ossia.Node.CreateNode(root, "/my_string");
            var addr = str.CreateParameter(Ossia.ossia_type.STRING);
            addr.PushValue(new Ossia.Value("some string !"));
            Debug.Log(addr.GetValue().GetString());
        }

        {
            var blu = Ossia.Node.CreateNode(root, "/foo/blu");
            blu.CreateParameter(Ossia.ossia_type.VEC3F);
        }

        {
            Ossia.Node.CreatePattern(root, "/{boo,bzu}/zaza.[0-5]");
            Ossia.Node.FindPattern(root, "/{boo,bzu}/zaza.[0-5]");
        }

        {
            var             array = Ossia.Node.CreateNode(root, "/my_array");
            Ossia.Parameter addr2 = array.CreateParameter(Ossia.ossia_type.LIST);
            addr2.PushValue(new int[] { 1, 2, 4, 65 });
            for (int i = 0; i < 4; i++)
            {
                Debug.Log(addr2.GetValue().GetIntArray()[i]);
            }
        }
    }