Ejemplo n.º 1
0
    public void SendCalibrationData(bool value)
    {
        CalibrationMessage msg = new CalibrationMessage();

        msg.enable   = value;
        msg.idDevice = client.getConnectionId();
        client.SendMessage(CalibrationMessage.id, msg);
    }
Ejemplo n.º 2
0
    public void OnCalibrationMessageReceived(NetworkMessage netMsg)
    {
        CalibrationMessage msg = netMsg.ReadMessage <CalibrationMessage>();

        minX = msg.minX;
        minY = msg.minY;
        maxX = msg.maxX;
        maxY = msg.maxY;
    }
Ejemplo n.º 3
0
    public void SendCalibrationMessage(float minX, float minY, float maxX, float maxY, int id)
    {
        CalibrationMessage msg = new CalibrationMessage();

        msg.minX = minX;
        msg.minY = minY;
        msg.maxX = maxX;
        msg.maxY = maxY;

        Debug.Log("MinX = " + minX + "MinY = " + minY + "MaxX = " + maxX + "MaxY = " + maxY);

        NetworkServer.SendToClient(id, CalibrationMessage.id, msg);
    }
Ejemplo n.º 4
0
    public void OnCalibrationMessageReceived(NetworkMessage netMsg)
    {
        CalibrationMessage msg = netMsg.ReadMessage <CalibrationMessage>();

        if (msg.enable)
        {
            //Enable();
            Vector3 topLeft, bottomRight;
            topLeft     = Camera.main.ScreenToWorldPoint(new Vector3(0f, Camera.main.pixelHeight, 10f));
            bottomRight = Camera.main.ScreenToWorldPoint(new Vector3(Camera.main.pixelWidth, 0f, 10f));
            Debug.Log(topLeft + " " + bottomRight);
            gameSceneManager.SendCalibrationMessage(topLeft.x, bottomRight.y, bottomRight.x, topLeft.y, netMsg.conn.connectionId);
        }
        else
        {
            Disable();
        }
    }
Ejemplo n.º 5
0
    private void OnCalibration(NetworkMessage netMsg)
    {
        CalibrationMessage msg = netMsg.ReadMessage <CalibrationMessage>();
        Texture2D          tex = new Texture2D(2, 2);

        tex.LoadImage(msg.imageData);

        // Create a GameObject to which the texture can be applied
        GameObject quad         = GameObject.CreatePrimitive(PrimitiveType.Quad);
        Renderer   quadRenderer = quad.GetComponent <Renderer>() as Renderer;

        quadRenderer.material        = new Material(Shader.Find("Unlit/Texture"));
        quad.transform.parent        = this.transform;
        quad.transform.localPosition = new Vector3(0.0f, 0.0f, 3.0f);
        quadRenderer.material.SetTexture("_MainTex", tex);

        var response = new CalibrationResponseMessage();

        response.response = "Image received";
        netMsg.conn.Send(NetMsg.StartCalibration, response);
    }
Ejemplo n.º 6
0
    void OnCapturedPhotoToMemory(PhotoCapture.PhotoCaptureResult result, PhotoCaptureFrame photoCaptureFrame)
    {
        // Copy the raw image data into the target texture
        photoCaptureFrame.UploadImageDataToTexture(targetTexture);

        // Create a GameObject to which the texture can be applied
        GameObject quad         = GameObject.CreatePrimitive(PrimitiveType.Quad);
        Renderer   quadRenderer = quad.GetComponent <Renderer>() as Renderer;

        quadRenderer.material        = new Material(Shader.Find("Unlit/Texture"));
        quad.transform.parent        = this.transform;
        quad.transform.localPosition = new Vector3(0.0f, 0.0f, 3.0f);
        quadRenderer.material.SetTexture("_MainTex", targetTexture);

        //Encode the texture and send over network
        var msg = new CalibrationMessage();

        msg.imageData = targetTexture.EncodeToPNG();
        client.Send(NetMsg.StartCalibration, msg);
        Debug.Log("Image sent");

        // Deactivate the camera
        photoCaptureObject.StopPhotoModeAsync(OnStoppedPhotoMode);
    }