PopMessage() 공개 메소드

public PopMessage ( ) : Message
리턴 Message
예제 #1
0
    void Update()
    {
        while (udpClient_.Available > 0)
        {
            var data = udpClient_.Receive(ref endPoint_);
            osc_.FeedData(data);
        }

        while (osc_.MessageCount > 0)
        {
            var msg = osc_.PopMessage();
            OnMessage(msg);
        }
    }
예제 #2
0
    void Update()
    {
        while (udpClient.Available > 0)
        {
            osc.FeedData(udpClient.Receive(ref endPoint));
        }

        int count = 0;

        while (osc.MessageCount > 0)
        {
            var msg = osc.PopMessage();

            if (msg.path.StartsWith(OSCPath) && count < maxSend)
            {
                float
                    x = (float)msg.data [0],
                    y = (float)msg.data [1],
                    w = (float)msg.data [2],
                    h = (float)msg.data [3];

                Vector2 point = Random.insideUnitCircle;
                point.x *= w / 2f;
                point.y *= h / 2f;
                point.x += x + w / 2f;
                point.y += y + h / 2f;

                if (target != null)
                {
                    target.SendMessage("OnOSC", point, SendMessageOptions.DontRequireReceiver);
                }
                count++;
            }
        }
    }
예제 #3
0
    void Update()
    {
        while (udpClient.Available > 0)
        {
            osc.FeedData(udpClient.Receive(ref endPoint));
        }

        while (osc.MessageCount > 0)
        {
            var msg = osc.PopMessage();
            if (msg.path == "/touchpad")
            {
                float[] position = new float[2];
                position[0] = (float)msg.data [0];
                position[1] = (float)msg.data [1];
                player.SendMessage("OnPositionMessage", position);
            }
            if (msg.path == "/accxyz")
            {
//				player.SendMessage ("OnTiltMessage", msg.data);
            }

            //	Debug.Log (msg);
        }
    }
예제 #4
0
    void Update()
    {
        while (udpClient.Available > 0)
        {
            osc.FeedData(udpClient.Receive(ref endPoint));
        }

        while (osc.MessageCount > 0)
        {
            var msg = osc.PopMessage();

//			Debug.Log (msg.data.Length);


            //
            // new version uses the following pattern:
            //

            //			__________________
            //
            //			|  0	1	2
            //
            //			|  3	4	5
            //
            //			|  6	7	8



            float depthVal = float.Parse(msg.data [0].ToString());

            Debug.Log(msg.path + " " + depthVal);

            // thresholding
            if (depthVal < 100 || depthVal > 4300)
            {
                continue;
            }


            // smooth the values a bit
            depth = Mathf.Lerp(depth, depthVal, 0.5f);

            // use only reasonable range
            if (depth > 300.0f && depth < 4500.0f && affectedObject)
            {
                Vector3 p = affectedObject.transform.localPosition;

                p.z = depth / 1000.0f;                 // convert to meter

                affectedObject.transform.localPosition = p;
            }
        }
    }
예제 #5
0
    void Update()
    {
        while (udpClient.Available > 0)
        {
            osc.FeedData(udpClient.Receive(ref endPoint));
        }

        while (osc.MessageCount > 0)
        {
            var msg = osc.PopMessage();

            var target = GameObject.Find(msg.path.Replace("/", "_"));
            if (target)
            {
                target.SendMessage("OnOscMessage", msg.data [0]);
            }

            // Debug.Log (msg);
        }
    }
예제 #6
0
    void Update()
    {
        while (udpClient_.Available > 0)
        {
            osc_.FeedData(udpClient_.Receive(ref endPoint_));
        }

        while (osc_.MessageCount > 0)
        {
            var msg = osc_.PopMessage();
            if (msg.path.IndexOf("/marker") == 0)
            {
                ProcessMarkerMessage(msg);
            }
            else if (msg.path.IndexOf("/landolt") == 0)
            {
                ProcessLandoltMessage(msg);
            }
        }
    }
예제 #7
0
    void Update()
    {
        if (multicast != lastMulticastSetting)
        {
            setListenPort();
        }

        if (udpClient == null)
        {
            return;
        }

        while (udpClient.Available > 0)
        {
            osc.FeedData(udpClient.Receive(ref endPoint));
        }

        while (osc.MessageCount > 0)
        {
            Osc.Message msg = osc.PopMessage();
            if (msg.path == "/touchDown")
            {
                int id = (int)msg.data[0];
                position.x = float.Parse(msg.data[1].ToString());
                position.y = float.Parse(msg.data[2].ToString());

                touches.Add(id, new touch(id, position));

                foreach (touchscreenTarget t in targets)
                {
                    t.onTouchDown(id, position);
                }
            }
            else if (msg.path == "/touchUp")
            {
                int id = (int)msg.data[0];
                position.x = float.Parse(msg.data[1].ToString());
                position.y = float.Parse(msg.data[2].ToString());

                touches.Remove(id);

                foreach (touchscreenTarget t in targets)
                {
                    t.onTouchUp(id, position);
                }
            }
            else if (msg.path == "/touchMove")
            {
                int id = (int)msg.data[0];
                position.x = float.Parse(msg.data[1].ToString());
                position.y = float.Parse(msg.data[2].ToString());
                size.x     = float.Parse(msg.data[3].ToString());
                size.y     = float.Parse(msg.data[4].ToString());

                difference.x = touches[id].position.x - position.x;
                difference.y = touches[id].position.y - position.y;

                touches[id].set(position, size);

                foreach (touchscreenTarget t in targets)
                {
                    t.onTouchRelativeMoved(id, difference);
                    t.onTouchMoved(id, position, size);
                }
            }

            if (debug)
            {
                string outstring = "";
                foreach (var v in msg.data)
                {
                    outstring += v.ToString() + "\t";
                }
                Debug.Log("OSC: " + outstring);
            }
        }
    }
예제 #8
0
    void Update()
    {
        if (multicast != lastBoolean)
        {
            lastBoolean = multicast;
            if (multicast)
            {
                listenPort = multicastPort;
            }
            else
            {
                listenPort = directPort;
            }
            endPoint  = new IPEndPoint(IPAddress.Any, listenPort);
            udpClient = new UdpClient(endPoint);
        }

        if (udpClient != null)
        {
            while (udpClient.Available > 0)
            {
                osc.FeedData(udpClient.Receive(ref endPoint));
            }
        }

        while (osc.MessageCount > 0)
        {
            var msg = osc.PopMessage();

            if (msg.path == "/touchDown")
            {
                int     id       = (int)msg.data [0];
                Vector2 position = mapToRange(float.Parse(msg.data [1].ToString()), float.Parse(msg.data [2].ToString()));
                foreach (touchscreenTarget t in targets)
                {
                    t.onFingerDown(id, position);
                }
                touches [id] = new Touch(id, position);
                if (debug)
                {
                    Debug.Log("new touch!  ID:  " + id + "  (" + position.x + ", " + position.y + ")");
                }
            }

            if (msg.path == "/touchUp")
            {
                int     id       = (int)msg.data [0];
                Vector2 position = mapToRange(float.Parse(msg.data [1].ToString()), float.Parse(msg.data [2].ToString()));
                foreach (touchscreenTarget t in targets)
                {
                    t.onFingerUp(id, position);
                }
                touches.Remove(id);
                if (debug)
                {
                    Debug.Log("touch up!  ID:  " + id + "  (" + position.x + ", " + position.y + ")");
                }
            }


            if (msg.path == "/touchMove")
            {
                int     id       = (int)msg.data [0];
                Vector2 position = mapToRange(float.Parse(msg.data [1].ToString()), float.Parse(msg.data [2].ToString()));
                Vector2 size     = new Vector2(float.Parse(msg.data [3].ToString()), float.Parse(msg.data [4].ToString()));
                foreach (touchscreenTarget t in targets)
                {
                    t.onFingerMove(id, position, size);
                }
                if ((Touch)touches [id] != null)
                {
                    ((Touch)touches [id]).Update(position, size);
                }
                else
                {
                    touches [id] = new Touch(id, position);
                }
                if (debug)
                {
                    Debug.Log("touch moved! ID:  " + id + "  (" + position.x + ", " + position.y + ")");
                    Debug.Log(msg.data[1] + " " + msg.data[2]);
                }
            }

            //	Debug.Log (msg);
        }
        //dumb hack to make the contents of touches show up in the editor
        //the unity editor can't show a hashtable, but it can show an array, so if the debug flag is set,
        //we'll just put all the contents of touches into the array badTouch
        if (debug)
        {
            badTouch = new Touch[touches.Count];
            int i = 0;
            foreach (DictionaryEntry pair in touches)
            {
                badTouch [i] = (Touch)touches [pair.Key];
                i++;
            }
        }
    }