void TimeStampEditPopUpPressed(NetworkOutput output, GameObject parentButton, GameObject TSButton)
 {
     output.TimeStamp = $"({DateTime.Now})";
     EditColorChange(parentButton);
     TSButton.transform.Find("IconAndText").Find("TextMeshPro").gameObject.GetComponent <TextMeshPro>().text     = output.TimeStamp;
     parentButton.transform.Find("IconAndText").Find("TextMeshPro").gameObject.GetComponent <TextMeshPro>().text = $"{output.TimeStamp}\n{output.Asset}\n{output.Confidence}\n{output.Coordinate.ToString()}";
 }
Пример #2
0
        protected NetworkInterface(UDPConnection udpConnection, Logger logger)
        {
            Logger = logger;

            ClientConnections = new NetworkConnectionPool();
            In  = new NetworkInput(ClientConnections);
            Out = new NetworkOutput(ClientConnections);

            ErrorHandling = new NetworkErrorHandling(ClientConnections, this);

            UdpConnection                 = udpConnection;
            UdpConnection.Logger          = logger;
            UdpConnection.OnReceiveError += ErrorHandling.HandleUDPReceiveError;
            UdpConnection.OnSendError    += ErrorHandling.HandleUDPSendError;
            UdpConnection.InitializeReceiving();

            KeepAliveInterval = 1000;
            m_keepAlive       = true;

            HolePunchingInterval = 1000;
            m_holePunching       = false;

            Thread keepAliveThread = new Thread(KeepAliveLoop);

            keepAliveThread.Name = "Keep alive";
            keepAliveThread.Start();
        }
    void EditPressed(NetworkOutput output, GameObject parentButton, GameObject buttonEdit)
    {
        bool buttonClicked = false;

        foreach (Transform child in buttonEdit.transform)
        {
            if (child.tag == "EditPopUp")
            {
                Destroy(child.gameObject);
                buttonClicked = true;
            }
        }
        if (buttonClicked)
        {
            return;
        }

        List <Vector3> coordinates      = CalculateCoordinate(buttonEdit.transform.position, false);
        GameObject     TSButton         = CreateButton(coordinates[0], output.TimeStamp, "IconAdjust", buttonEdit, TextButton, "EditPopUp", 1);
        GameObject     AssetButton      = CreateButton(coordinates[1], output.Asset, "IconAdjust", buttonEdit, TextButton, "EditPopUp", 1);
        GameObject     CoordinateButton = CreateButton(coordinates[2], output.Coordinate.ToString(), "IconAdjust", buttonEdit, TextButton, "EditPopUp", 1);

        AssetButton.GetComponent <Interactable>().OnClick.AddListener(() => { AssetEditPopUpPressed(output, parentButton, AssetButton); });
        TSButton.GetComponent <Interactable>().OnClick.AddListener(() => { TimeStampEditPopUpPressed(output, parentButton, TSButton); });
        CoordinateButton.GetComponent <Interactable>().OnClick.AddListener(() => { CoordinateEditPopUpPressed(output, parentButton, CoordinateButton); });
    }
    void ObjectPressed(NetworkOutput output, GameObject parentButton)
    {
        bool buttonClicked = false;

        foreach (Transform child in parentButton.transform)
        {
            if (child.tag == "selectionButton")
            {
                Destroy(child.gameObject);
                buttonClicked = true;
            }
        }
        if (buttonClicked)
        {
            return;
        }
        List <Vector3> buttonCoordinates = CalculateCoordinate(output.Coordinate);
        GameObject     buttonAccept      = CreateButton(buttonCoordinates[0], "Accept", "IconDone", parentButton, SelectionButton, "selectionButton", 0.33f);
        GameObject     buttonEdit        = CreateButton(buttonCoordinates[1], "Edit", "IconSettings", parentButton, SelectionButton, "selectionButton", 0.33f);
        GameObject     buttonReject      = CreateButton(buttonCoordinates[2], "Reject", "IconClose", parentButton, SelectionButton, "selectionButton", 0.33f);

        buttonAccept.GetComponent <Interactable>().OnClick.AddListener(() => { AcceptPressed(output, parentButton); });
        buttonEdit.GetComponent <Interactable>().OnClick.AddListener(() => { EditPressed(output, parentButton, buttonEdit); });
        buttonReject.GetComponent <Interactable>().OnClick.AddListener(() => { RejectPressed(parentButton); });
    }
 void updateCoordinate(NetworkOutput output, GameObject parentButton, GameObject CoordianteButton)
 {
     output.Coordinate = parentButton.transform.position;
     if (CoordianteButton != null)
     {
         CoordianteButton.transform.Find("IconAndText").Find("TextMeshPro").gameObject.GetComponent <TextMeshPro>().text = output.Coordinate.ToString();
     }
     parentButton.transform.Find("IconAndText").Find("TextMeshPro").gameObject.GetComponent <TextMeshPro>().text = $"{output.TimeStamp}\n{output.Asset}\n{output.Confidence}\n{output.Coordinate.ToString()}";
 }
 void AcceptPressed(NetworkOutput output, GameObject parentButton)
 {
     AcceptColorChange(parentButton);
     if (parentButton.GetComponent <ManipulationHandler>() != null)
     {
         Destroy(parentButton.GetComponent <ManipulationHandler>());
         Destroy(parentButton.GetComponent <NearInteractionGrabbable>());
     }
     // upload to server
 }
    public void CreateObjectAtVector(NetworkOutput output)
    {
        GameObject button = Instantiate(TextButton, output.Coordinate, Quaternion.identity);

        button.transform.parent = canvas.transform;
        button.transform.LookAt(MainCamera.transform);
        button.transform.rotation  *= Quaternion.Euler(0, 180, 0);
        button.transform.localScale = new Vector3(10000, 10000, 100);
        button.transform.position   = output.Coordinate;
        TextMeshPro text = button.transform.Find("IconAndText").Find("TextMeshPro").gameObject.GetComponent <TextMeshPro>();

        text.text = $"{output.TimeStamp}\n{output.Asset}\n{output.Confidence}\n{output.Coordinate.ToString()}";

        button.GetComponent <Interactable>().OnClick.AddListener(() => { ObjectPressed(output, button); });

        GameObject left = GameObject.CreatePrimitive(PrimitiveType.Cube);

        left.name                    = "left";
        left.transform.parent        = button.transform;
        left.transform.localPosition = new Vector3(-output.Width / 2, 0, 0) * 0.1f;
        left.transform.localScale    = new Vector3(0.01f, output.Height, 0.01f) * 0.1f;
        left.transform.localRotation = Quaternion.identity;

        GameObject right = GameObject.CreatePrimitive(PrimitiveType.Cube);

        right.name                    = "right";
        right.transform.parent        = button.transform;
        right.transform.localPosition = new Vector3(output.Width / 2, 0, 0) * 0.1f;
        right.transform.localScale    = new Vector3(0.01f, output.Height, 0.01f) * 0.1f;
        right.transform.localRotation = Quaternion.identity;

        GameObject top = GameObject.CreatePrimitive(PrimitiveType.Cube);

        top.name                    = "top";
        top.transform.parent        = button.transform;
        top.transform.localPosition = new Vector3(0, output.Height / 2, 0) * 0.1f;
        top.transform.localScale    = new Vector3(output.Width, 0.01f, 0.01f) * 0.1f;
        top.transform.localRotation = Quaternion.identity;

        GameObject bot = GameObject.CreatePrimitive(PrimitiveType.Cube);

        bot.name                    = "bot";
        bot.transform.parent        = button.transform;
        bot.transform.localPosition = new Vector3(0, -output.Height / 2, 0) * 0.1f;
        bot.transform.localScale    = new Vector3(output.Width, 0.01f, 0.01f) * 0.1f;
        bot.transform.localRotation = Quaternion.identity;


        ExistedCoordinates.Add(output.Coordinate);
    }
    void AssetEditPopUpPressed(NetworkOutput output, GameObject parentButton, GameObject AssetButton)
    {
        int i = AssetTypes.IndexOf(output.Asset);

        i += 1;
        if (i >= AssetTypes.Count)
        {
            i = 0;
        }
        output.Asset = AssetTypes[i];
        EditColorChange(parentButton);
        AssetButton.transform.Find("IconAndText").Find("TextMeshPro").gameObject.GetComponent <TextMeshPro>().text  = output.Asset;
        parentButton.transform.Find("IconAndText").Find("TextMeshPro").gameObject.GetComponent <TextMeshPro>().text = $"{output.TimeStamp}\n{output.Asset}\n{output.Confidence}\n{output.Coordinate.ToString()}";
    }
    void CoordinateEditPopUpPressed(NetworkOutput output, GameObject parentButton, GameObject CoordianteButton)
    {
        EditColorChange(parentButton);
        if (parentButton.GetComponent <ManipulationHandler>() != null)
        {
            Destroy(parentButton.GetComponent <ManipulationHandler>());
            Destroy(parentButton.GetComponent <NearInteractionGrabbable>());
        }
        else
        {
            parentButton.AddComponent(typeof(NearInteractionGrabbable));
            ManipulationHandler manipulationHander = parentButton.AddComponent(typeof(ManipulationHandler)) as ManipulationHandler;
            manipulationHander.OneHandRotationModeNear = ManipulationHandler.RotateInOneHandType.FaceAwayFromUser;
            manipulationHander.OneHandRotationModeFar  = ManipulationHandler.RotateInOneHandType.FaceAwayFromUser;

            manipulationHander.OnManipulationEnded.AddListener((ManipulationEventData test) => { updateCoordinate(output, parentButton, CoordianteButton); });
        }
    }
Пример #10
0
        public void Learn(ref ActivationNetwork network, double[] crossInput, double[] circleInput, double[] blankInput)
        {
            NetworkInput networkInput = new NetworkInput(crossInput, circleInput, blankInput);

            double[][] input = networkInput.Input;

            NetworkOutput networkOutput = new NetworkOutput(0);

            double[][] output = networkOutput.Output;

            BackPropagationLearning teacher =
                new BackPropagationLearning(network);

            for (int i = 0; i < 100000; i++)
            {
                double error = teacher.RunEpoch(input, output);
            }

            network.Save("Net.bin");
            MessageBox.Show("Learning finished");
        }