Пример #1
0
        void OnMessageReceived(OscMessage message)
        {
            // Use TryGetFromBlob to read a list of floats from a byte blob.
            if (message.TryGetBlob(0, ref _receivedFloats))
            {
                Debug.Log("Receiving: " + ListToString(_receivedFloats) + "\n");
            }

            // Always recycle received messages when used.
            OscPool.Recycle(message);
        }
    void OnReceiveVertex(OscMessage message)
    {
//        meshfilter.mesh.Clear();
//        mesh.vertices.

        var vertices = new List <Vector3>();

//        indices = new List<int>();
        if (message.TryGetBlob(0, ref _receivedFloats))
        {
//            Debug.Log( "vertex: " + ListToString( _receivedFloats ) + "\n" );

            var count = 0;

            for (int i = 0; i < _receivedFloats.Count; i += 3)
            {
                var x = _receivedFloats[i];
                var y = _receivedFloats[i + 1];
                var z = _receivedFloats[i + 2];
                vertices.Add(new Vector3(x, y, z));
                baseVertices[count] = new Vector3(x, y, z);

//                indices.Add(count);
                count++;
            }
        }

        Debug.Log(vertices.Count);
        Debug.Log(baseVertices.Count);

//        if(mesh.vertices.Length != vertices.Count) return;
//        mesh.Clear();

//        Debug.Log(indices.Count);
//
//        if (indices.Count < 3)
//        {
//            int count = 0;
//            while (indices.Count < 3)
//            {
//                indices.Add(count);
//                Debug.Log(count);
//                count++;
//            }
//        }

        mesh.SetVertices(baseVertices);

//        mesh.vertices = baseVertices.ToArray();
        mesh.SetIndices(indices.ToArray(), MeshTopology.Triangles, 0);
        mesh.RecalculateNormals();
        meshfilter.sharedMesh = mesh;
        OscPool.Recycle(message);
    }
Пример #3
0
        void OnMessageReceived(OscMessage message)
        {
            // Use TryGetFromBlob to read a Vector2 value from a byte blob.
            Vector2 value;

            if (message.TryGetBlob(0, out value))
            {
                Debug.Log("Receiving: " + value + "\n");
            }

            // Always recycle received messages when used.
            OscPool.Recycle(message);
        }
        void OnMessageReceived(OscMessage message)
        {
            // Use TryGetFromBlob to read a Vector2 value from a byte blob.
            string receviedText;

            if (message.TryGetBlob(0, System.Text.Encoding.UTF8, out receviedText))
            {
                Debug.Log("Receiving: " + receviedText + "\n");
            }

            // Always recycle received messages when used.
            OscPool.Recycle(message);
        }