Exemplo n.º 1
0
        private void OnMessageReceived(IncomingCommand cmd)
        {
            switch (cmd.command)
            {
                case "plane-order":
                    ReorderPlanes(cmd.payload);
                    break;

                case "plane-position":
                    RepositionPlane(cmd.payload);
                    break;

                case "plane-add":
                    AddPlane(cmd.payload);
                    break;

                case "plane-remove":
                    RemovePlane(int.Parse(cmd.payload));
                    break;

                case "plane-mod":
                    ModifyPlane(cmd.payload);
                    break;
            }
        }
Exemplo n.º 2
0
        private void HandleCommand(IncomingCommand cmd)
        {
            switch (cmd.command)
            {
            case "pixelCmRatio":
                if (SurfaceManager.Instance.Has(DisplayName))
                {
                    var display = SurfaceManager.Instance.Get(DisplayName);
                    display.PixelToCmRatio = float.Parse(cmd.payload.Trim('"'));
                    Debug.Log("Setting PixelCmRatio to " + display.PixelToCmRatio);
                }
                break;

            case "window-size":
                // TODO: use cmd.origin
                if (SurfaceManager.Instance.Has(DisplayName))
                {
                    var display    = SurfaceManager.Instance.Get(DisplayName);
                    var windowSize = JsonUtility.FromJson <WindowSize>(cmd.payload);
                    display.DisplayResolution = new Resolution
                    {
                        width  = windowSize.width,
                        height = windowSize.height
                    };

                    Debug.Log("Using remote display resolution " + windowSize.width + "x" + windowSize.height);
                }
                break;
            }
        }
Exemplo n.º 3
0
        private void HandleCommand(IncomingCommand cmd)
        {
            switch (cmd.command)
            {
                case "pixelCmRatio":
                    DisplayUtility.PixelToCmRatio = float.Parse(cmd.payload.Trim('"'));
                    Debug.Log("Setting PixelCmRatio to " + DisplayUtility.PixelToCmRatio);
                    break;

                case "window-size":
                    // TODO: use cmd.origin
                    if (FixedDisplays.Has(DisplayName))
                    {
                        var display = FixedDisplays.Get(DisplayName);
                        var windowSize = JsonUtility.FromJson<WindowSize>(cmd.payload);
                        display.DisplayResolution = new Resolution
                        {
                            width = windowSize.width,
                            height = windowSize.height
                        };

                        Debug.Log("Using remote display resolution " + windowSize.width + "x" + windowSize.height);
                    }
                    break;
            }
        }
Exemplo n.º 4
0
 void FixedUpdate()
 {
     if (OnMessageReceived != null)
     {
         IncomingCommand cmd = new IncomingCommand();
         while (_queuedCommands.Dequeue(out cmd))
         {
             OnMessageReceived(cmd);
         }
     }
 }
Exemplo n.º 5
0
        private void OnMessage(IncomingCommand msg)
        {
            if (msg.command == "panzoom" && FixedDisplays.Has(DisplayName))
            {
                var display = FixedDisplays.Get(DisplayName);

                var payload = JsonUtility.FromJson<MessagePayload>(msg.payload);
                var x = TranslateX ? DisplayUtility.PixelToUnityCoord(payload.posX) * payload.zoom : 0;
                var z = TranslateZ ? -DisplayUtility.PixelToUnityCoord(payload.posY) * payload.zoom : 0;

                transform.position = display.GetCornerPosition(Corner.TopLeft) + display.Rotation * new Vector3(-x, HeightOffset, -z) + PositionOffset;
                if (Zoom)
                    transform.localScale = new Vector3(ZoomX ? Mathf.Max(payload.zoom, 0.002f) : 1f, 0.4f + payload.zoom / 4f, Mathf.Max(payload.zoom, 0.002f));
                transform.rotation = Quaternion.Euler(display.Rotation.eulerAngles + RotationOffset);
            }
        }
Exemplo n.º 6
0
Arquivo: PanZoom.cs Projeto: SebiH/ART
        private void OnMessage(IncomingCommand msg)
        {
            if (msg.command == "panzoom" && SurfaceManager.Instance.Has(DisplayName))
            {
                var surface = SurfaceManager.Instance.Get(DisplayName);

                var payload = JsonUtility.FromJson <MessagePayload>(msg.payload);
                var x       = TranslateX ? surface.PixelToUnityCoord(payload.posX) * payload.zoom : 0;
                var z       = TranslateZ ? -surface.PixelToUnityCoord(payload.posY) * payload.zoom : 0;

                transform.position = surface.GetCornerPosition(Corner.TopLeft) + surface.Rotation * new Vector3(-x, HeightOffset, -z) + PositionOffset;
                if (Zoom)
                {
                    transform.localScale = new Vector3(ZoomX ? Mathf.Max(payload.zoom, 0.002f) : 1f, 0.4f + payload.zoom / 4f, Mathf.Max(payload.zoom, 0.002f));
                }
                transform.rotation = Quaternion.Euler(surface.Rotation.eulerAngles + RotationOffset);
            }
        }
        private void HandleMarkerMessage(IncomingCommand cmd)
        {
            if (cmd.command == "map" && UseMaps)
            {
                var payload = JsonUtility.FromJson<DisplayMap>(cmd.payload);
                var existingMap = _maps.FirstOrDefault((m) => m.id == payload.id);

                if (existingMap == null)
                {
                    _maps.Add(payload);
                    var registeredMaps = ArucoMapListener.Instance.GetMaps();
                    registeredMaps.Add(new Vision.Processors.ArucoMapProcessor.Map
                    {
                        id = payload.id,
                        marker_size_m = 0.025f,
                        path = payload.GetConfigurationPath()
                    });
                    ArucoMapListener.Instance.UpdateMaps();
                    Debug.Log("registered map " + payload.id);
                }
                else
                {
                    existingMap.posX = payload.posX;
                    existingMap.posY = payload.posY;
                    existingMap.sizeX = payload.sizeX;
                    existingMap.sizeY = payload.sizeY;
                }

                // TODO.
                //var unitySize = DisplayUtility.PixelToUnityCoord(payload.size);
                //ArucoMapListener.Instance.MarkerSizeInMeter = unitySize;
            }

            if (cmd.command == "marker-data")
            {
                var payload = JsonUtility.FromJson<DisplayMarker>(cmd.payload);
                var existingMarker = _markers.FirstOrDefault((m) => m.id == payload.id);

                if (existingMarker == null)
                {
                    _markers.Add(payload);
                }
                else
                {
                    existingMarker.posX = payload.posX;
                    existingMarker.posY = payload.posY;
                    existingMarker.size = payload.size;
                }

                var unitySize = DisplayUtility.PixelToUnityCoord(payload.size);

                ArucoListener.Instance.MarkerSizeInMeter = unitySize;
            }

            if (cmd.command == "remove-marker")
            {
                var payload = int.Parse(cmd.payload);
                _markers.RemoveAll((m) => m.id == payload);
            }
        }