Esempio n. 1
0
    public void receiveImageSize(TopicDataRecord dir)
    {
        imageSize = UbiiParser.ProtoToUnity(dir.Vector2);

        Debug.Log("Received Image Size");
        received = true;
    }
Esempio n. 2
0
 public void receiveImageFormat(TopicDataRecord dir)
 {
     imageFormatIndex = (int)UbiiParser.ProtoToUnity(dir.Double) - 1;      //added -1 to not send empty data (0)
     Debug.Log(imageFormatIndex);
     Debug.Log("Received Image Format");
     received = true;
 }
Esempio n. 3
0
    //private async void reconnect()
    //{
    //    if (connected) CancelInvoke();
    //    await client.InitializeClient();
    //    Debug.Log("connected");
    //    connected = true;
    //    CancelInvoke();
    //}


    public void send_texture(Texture2D texture, string filename)
    {
        if (!connected)
        {
            return;
        }
        //send filename
        client.Publish(UbiiParser.UnityToProto("image name", filename));
        //send size
        client.Publish(UbiiParser.UnityToProto("image size", new Vector2(texture.width, texture.height)));
        //send format
        int index = 0;

        for (; index < texture_formats.Length; index++)
        {
            if (texture_formats[index] == texture.format)
            {
                break;
            }
        }
        ;
        client.Publish(UbiiParser.UnityToProto("image format", index + 1));   // added +1 to not send empty data
        client.Publish(UbiiParser.UnityToProto("image", Convert.ToBase64String(texture.GetRawTextureData())));

        Debug.Log("Sent texture");
    }
Esempio n. 4
0
 public void send_color(Color c)
 {
     if (!connected)
     {
         return;
     }
     client.Publish(UbiiParser.UnityToProto("color", c));
     Debug.Log("Sent color: " + c);
 }
Esempio n. 5
0
 public void send_reset_canvas()
 {
     if (!connected)
     {
         return;
     }
     client.Publish(UbiiParser.UnityToProto("reset canvas", ""));
     Debug.Log("Sent reset canvas");
 }
Esempio n. 6
0
 public void sendUVResolution(Vector2 resolution)
 {
     if (!connected)
     {
         return;
     }
     client.Publish(UbiiParser.UnityToProto("uvimage resolution", resolution));
     Debug.Log("Sent uv resolution");
 }
Esempio n. 7
0
        private void Publish_TOPIC_HOST_DISCONNECTED()
        {
            LogConsole("Publish_TOPIC_HOST_DISCONNECTED");

            if (ARE_EQUAL(LocalNetworkID, ENetworkID.HOST))
            {
                Publish(UbiiParser.UnityToProto(TOPIC_HOST_DISCONNECTED, localGuid));
            }
        }
Esempio n. 8
0
 public void send_brush_size(int size)
 {
     if (!connected)
     {
         return;
     }
     client.Publish(UbiiParser.UnityToProto("brush size", size + ""));
     Debug.Log("Sent brush size " + size);
 }
Esempio n. 9
0
 public void send_command(string command)
 {
     if (!connected)
     {
         return;
     }
     client.Publish(UbiiParser.UnityToProto("command", command));
     Debug.Log("Sent command: " + command);
 }
Esempio n. 10
0
 public void send_position(Vector4 position_data)
 {
     if (!connected)
     {
         return;
     }
     client.Publish(UbiiParser.UnityToProto("position", position_data));
     Debug.Log("Sent position: " + position_data);
 }
Esempio n. 11
0
    // Test function subscribing to "TestTopic" to demonstrate how topic subscription works
    public void SendTopicDataTestPosition()
    {
        // set some random coordinates for the cube in the test scene
        float   x = UnityEngine.Random.Range(-7f, 7f);
        float   y = UnityEngine.Random.Range(-3f, 5f);
        Vector2 v = new Vector2(x, y);

        // Use utility function to publish on topic with data
        Publish(UbiiParser.UnityToProto("TestTopicPos", v));
    }
Esempio n. 12
0
 public void send_gallery_command(string filename)
 {
     if (!connected)
     {
         return;
     }
     //send filename
     client.Publish(UbiiParser.UnityToProto("gallery command", filename));
     Debug.Log("Sent filename: " + filename);
 }
Esempio n. 13
0
 public void send_undo()
 {
     if (!connected)
     {
         Debug.Log("Couldn't send undo command. Not connected.");
         return;
     }
     client.Publish(UbiiParser.UnityToProto("undo", true));
     Debug.Log("Sent undo command");
 }
Esempio n. 14
0
    public void receivePositionData(TopicDataRecord dir)
    {
        position_data     = UbiiParser.ProtoToUnity(dir.Vector4);
        mouse_button_down = mouse_button_down || position_data.z >= 999;
        position_data.z   = position_data.z >= 999?position_data.z - 1000:position_data.z;
        //Debug.Log(position_data + ", " + mouse_button_down);
        Debug.Log("Recieved Position");

        position_changed = true;
        received         = true;
    }
Esempio n. 15
0
    private void SendTopicDataTestRotation()
    {
        // set some random coordinates for the cube in the test scene
        float      x = UnityEngine.Random.Range(-7f, 7f);
        float      y = UnityEngine.Random.Range(-3f, 5f);
        float      z = UnityEngine.Random.Range(-7f, 7f);
        float      w = UnityEngine.Random.Range(-3f, 5f);
        Quaternion q = new Quaternion(x, y, z, w);

        // publish topic data
        Publish(UbiiParser.UnityToProto("TestTopicRot", q));
    }
Esempio n. 16
0
        private void Publish_TOPIC_BROADCAST_HOST_IP()
        {
            // Debug
            if (MotherOfManagers.Instance.DebugUbiiTopicPublish)
            {
                LogConsole("Publish_TOPIC_BROADCAST_HOST_IP");
            }

            if (ARE_EQUAL(LocalNetworkID, ENetworkID.HOST))
            {
                Publish(UbiiParser.UnityToProto(TOPIC_BROADCAST_HOST_IP, localGuid));
            }
        }
Esempio n. 17
0
        private void Publish_TOPIC_CLIENT_CONNECTED(string connectedClientGuid, ENetworkID networkID)
        {
            // Debug
            if (MotherOfManagers.Instance.DebugUbiiTopicPublish)
            {
                LogConsole("Publish_TOPIC_CLIENT_CONNECTED");
            }

            if (ARE_EQUAL(LocalNetworkID, ENetworkID.HOST))
            {
                Publish(UbiiParser.UnityToProto(TOPIC_CLIENT_CONNECTED, localGuid + "|" + connectedClientGuid + "|" + networkID));
            }
        }
Esempio n. 18
0
        private void Publish_TOPIC_CLIENT_DISCONNECTED()
        {
            // Debug
            if (MotherOfManagers.Instance.DebugUbiiTopicPublish)
            {
                LogConsole("Publish_TOPIC_CLIENT_DISCONNECTED");
            }

            if (IS_TRUE(IsClient()))
            {
                Publish(UbiiParser.UnityToProto(TOPIC_CLIENT_DISCONNECTED, localGuid + '|' + joinedHostGuid + "|" + LocalNetworkID));
            }
        }
Esempio n. 19
0
        // TODO : publish a list of all already connected clients to the host
        private void Publish_TOPIC_REQUEST_JOIN_HOST(int hostID)
        {
            // Debug
            if (MotherOfManagers.Instance.DebugUbiiTopicPublish)
            {
                LogConsole("Publish_TOPIC_REQUEST_JOIN_HOST");
            }

            if (ARE_EQUAL(LocalNetworkID, ENetworkID.LOCAL) &&
                (discoveredHosts.Count > hostID))
            {
                string hostGuid = discoveredHosts[hostID];
                Publish(UbiiParser.UnityToProto(TOPIC_REQUEST_JOIN_HOST, localGuid + "|" + hostGuid));
            }
        }
Esempio n. 20
0
        private void Publish_TOPIC_BROADCAST_BEVENT(AbstractBEHandle bEHandle, ENetworkID targetNetworkID)
        {
            // Debug
            if (MotherOfManagers.Instance.DebugUbiiTopicPublish)
            {
                LogConsole("Publish_TOPIC_BROADCAST_BEVENT");
            }

            if (ARE_NOT_EQUAL(LocalNetworkID, targetNetworkID))
            {
                string serializedBEHandle = BUtils.SerializeObject(bEHandle);


                Publish(UbiiParser.UnityToProto(TOPIC_BROADCAST_BEVENT, joinedHostGuid + "|" + targetNetworkID + "|" + serializedBEHandle));
            }
        }
Esempio n. 21
0
    // SPACE moves Cube, RETURN rotates cube
    private void Update()
    {
        // Only for testing and demonstration purposes
        // Sends a random vector on subscribed topic, that the client also publishes to; vector moves the cube in the "Test" scene
        if (Input.GetKeyDown(KeyCode.Space) && subscribed)
        {
            Debug.Log("Send example topic data for position");
            SendTopicDataTestPosition();
        }
        // Sends a random Quaternion on subscribed topic, that the client also publishes to; Quaternion rotates the cube in the "Test" scene
        if (Input.GetKeyDown(KeyCode.Return) && subscribed)
        {
            Debug.Log("Send example topic data for rotation");
            SendTopicDataTestRotation();
        }
        if (Input.GetAxis("Fire1") != 0 && subscribed)
        {
            Publish(UbiiParser.UnityToProto("MoveCubeH", new Vector3(Input.GetAxis("Fire1"), 0, 0)));
        }
        else
        {
            newMoveH = Vector3.zero;
        }

        if (Input.GetAxis("Fire2") != 0 && subscribed)
        {
            Publish(UbiiParser.UnityToProto("MoveCubeV", new Vector3(0, Input.GetAxis("Fire2"), 0)));
        }
        else
        {
            newMoveV = Vector3.zero;
        }

        if (Input.GetButton("Fire3") && subscribed)
        {
            Publish(UbiiParser.UnityToProto("SayWazza", "a"));
        }

        //cube.transform.position = newPos;
        cube.transform.rotation = newRot;
        cube.transform.position = Vector3.Lerp(cube.transform.position, cube.transform.position + newMoveH + newMoveV, Time.deltaTime * 10f);
        if (wazzaText)
        {
            wazzaText.text = wazzaString;
        }
    }
Esempio n. 22
0
 private void MoveCubeV(TopicDataRecord obj)
 {
     newMoveV = UbiiParser.ProtoToUnity(obj.Vector3);
 }
Esempio n. 23
0
 public void TestTopicDataSubRot(TopicDataRecord topicDataRecord)
 {
     // rotation cannot be directly set as this does not run from main thread, so save position to global variable which will be applied in Update() in main thread
     newRot = UbiiParser.ProtoToUnity(topicDataRecord.Quaternion);
 }
Esempio n. 24
0
 public void Publish_TOPIC_TEST_INT(int integer)
 {
     LogConsole("Publish_TOPIC_TEST_INT : " + integer + " - " + BUtils.GetTimeAsString());
     Publish(UbiiParser.UnityToProto(TOPIC_TEST_INT, integer));
 }
Esempio n. 25
0
 public void receiveColor(TopicDataRecord dir)
 {
     color = UbiiParser.ProtoToUnity(dir.Color);
     Debug.Log("received color " + color);
     received = true;
 }
Esempio n. 26
0
 public void receiveUVImage_resolution(TopicDataRecord dir)
 {
     uv_resolution = UbiiParser.ProtoToUnity(dir.Vector2);
     Debug.Log("received uv image resolution " + uv_resolution);
     received = true;
 }