Beispiel #1
0
        private SceneContainer CreateGui()
        {
            var vsTex = AssetStorage.Get <string>("texture.vert");
            var psTex = AssetStorage.Get <string>("texture.frag");

            var btnFuseeLogo = new GUIButton
            {
                Name = "Canvas_Button"
            };

            btnFuseeLogo.OnMouseEnter += BtnLogoEnter;
            btnFuseeLogo.OnMouseExit  += BtnLogoExit;
            btnFuseeLogo.OnMouseDown  += BtnLogoDown;

            var guiFuseeLogo = new Texture(AssetStorage.Get <ImageData>("FuseeText.png"));
            var fuseeLogo    = new TextureNode(
                "fuseeLogo",
                vsTex,
                psTex,
                //Set the diffuse texture you want to use.
                guiFuseeLogo,
                //Define anchor points. They are given in percent, seen from the lower left corner, respectively to the width/height of the parent.
                //In this setup the element will stretch horizontally but stay the same vertically if the parent element is scaled.
                UIElementPosition.GetAnchors(AnchorPos.TopTopLeft),
                //Define Offset and therefor the size of the element.
                UIElementPosition.CalcOffsets(AnchorPos.TopTopLeft, new float2(0, _initCanvasHeight - 0.5f), _initCanvasHeight, _initCanvasWidth, new float2(1.75f, 0.5f))
                );

            fuseeLogo.AddComponent(btnFuseeLogo);

            // Initialize the information text line.
            var textToDisplay = "FUSEE 3D Scene";

            if (_scene.Header.CreatedBy != null || _scene.Header.CreationDate != null)
            {
                textToDisplay += " created";
                if (_scene.Header.CreatedBy != null)
                {
                    textToDisplay += " by " + _scene.Header.CreatedBy;
                }

                if (_scene.Header.CreationDate != null)
                {
                    textToDisplay += " on " + _scene.Header.CreationDate;
                }
            }

            var fontLato     = AssetStorage.Get <Font>("Lato-Black.ttf");
            var guiLatoBlack = new FontMap(fontLato, 24);

            var text = new TextNode(
                textToDisplay,
                "SceneDescriptionText",
                vsTex,
                psTex,
                UIElementPosition.GetAnchors(AnchorPos.StretchHorizontal),
                UIElementPosition.CalcOffsets(AnchorPos.StretchHorizontal, new float2(_initCanvasWidth / 2 - 4, 0), _initCanvasHeight, _initCanvasWidth, new float2(8, 1)),
                guiLatoBlack,
                ColorUint.Tofloat4(ColorUint.Greenery),
                HorizontalTextAlignment.Center,
                VerticalTextAlignment.Center);


            var canvas = new CanvasNode(
                "Canvas",
                _canvasRenderMode,
                new MinMaxRect
            {
                Min = new float2(-_canvasWidth / 2, -_canvasHeight / 2f),
                Max = new float2(_canvasWidth / 2, _canvasHeight / 2f)
            });

            canvas.Children.Add(fuseeLogo);
            canvas.Children.Add(text);

            return(new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    //Add canvas.
                    canvas
                }
            });
        }
Beispiel #2
0
        private SceneContainer CreateGui()
        {
            float canvasScaleFactor = _initWidth / _canvasWidth;
            float borderScaleFactor = 1;

            if (_canvasRenderMode == CanvasRenderMode.Screen)
            {
                borderScaleFactor = canvasScaleFactor;
            }

            GuiButton btnFuseeLogo = new()
            {
                Name = "Canvas_Button"
            };

            btnFuseeLogo.OnMouseEnter += BtnLogoEnter;
            btnFuseeLogo.OnMouseExit  += BtnLogoExit;
            btnFuseeLogo.OnMouseDown  += BtnLogoDown;

            Texture     guiFuseeLogo = new(AssetStorage.Get <ImageData>("FuseeText.png"));
            TextureNode fuseeLogo    = TextureNode.Create(
                "fuseeLogo",
                guiFuseeLogo,
                GuiElementPosition.GetAnchors(AnchorPos.TopTopLeft),
                GuiElementPosition.CalcOffsets(AnchorPos.TopTopLeft, new float2(0, _canvasHeight - 0.5f), _canvasHeight, _canvasWidth, new float2(1.75f, 0.5f)), float2.One);

            fuseeLogo.AddComponent(btnFuseeLogo);

            SceneNode markModelContainer = new()
            {
                Name = "MarkModelContainer",
            };

            CanvasNode canvas = new(
                "Canvas",
                _canvasRenderMode,
                new MinMaxRect
            {
                Min = new float2(-_canvasWidth / 2f, -_canvasHeight / 2f),
                Max = new float2(_canvasWidth / 2f, _canvasHeight / 2f)
            }
                )
            { Children = new ChildList()
              {
                  fuseeLogo, markModelContainer
              } };

            for (int i = 0; i < _uiInput.Count; i++)
            {
                var item = _uiInput[i];
                if (item.AnnotationKind != UserInterfaceHelper.AnnotationKind.Confirmed)
                {
                    UserInterfaceHelper.CreateAndAddCircleAnnotationAndLine(markModelContainer, item.AnnotationKind, item.Size, _uiInput[i].AnnotationCanvasPos, borderScaleFactor,
                                                                            "#" + i + " " + item.SegmentationClass + ", " + item.Probability.ToString(CultureInfo.GetCultureInfo("en-gb")));
                }
                else
                {
                    UserInterfaceHelper.CreateAndAddCircleAnnotationAndLine(markModelContainer, item.AnnotationKind, item.Size, _uiInput[i].AnnotationCanvasPos, borderScaleFactor,
                                                                            "#" + i + " " + item.SegmentationClass);
                }
            }

            return(new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    //Add canvas.
                    canvas
                }
            });
        }
Beispiel #3
0
        private SceneContainer CreateGui()
        {
            var vsTex = AssetStorage.Get <string>("texture.vert");
            var psTex = AssetStorage.Get <string>("texture.frag");

            var canvasWidth  = Width / 100f;
            var canvasHeight = Height / 100f;

            var btnFuseeLogo = new GUIButton
            {
                Name = "Canvas_Button"
            };

            btnFuseeLogo.OnMouseEnter += BtnLogoEnter;
            btnFuseeLogo.OnMouseExit  += BtnLogoExit;
            btnFuseeLogo.OnMouseDown  += BtnLogoDown;

            var guiFuseeLogo = new Texture(AssetStorage.Get <ImageData>("FuseeText.png"));
            var fuseeLogo    = new TextureNode(
                "fuseeLogo",
                vsTex,
                psTex,
                //Set the albedo texture you want to use.
                guiFuseeLogo,
                //Define anchor points. They are given in percent, seen from the lower left corner, respectively to the width/height of the parent.
                //In this setup the element will stretch horizontally but stay the same vertically if the parent element is scaled.
                UIElementPosition.GetAnchors(AnchorPos.TopTopLeft),
                //Define Offset and therefor the size of the element.
                UIElementPosition.CalcOffsets(AnchorPos.TopTopLeft, new float2(0, canvasHeight - 0.5f), canvasHeight, canvasWidth, new float2(1.75f, 0.5f))
                );

            fuseeLogo.AddComponent(btnFuseeLogo);

            var fontLato     = AssetStorage.Get <Font>("Lato-Black.ttf");
            var guiLatoBlack = new FontMap(fontLato, 24);

            var text = new TextNode(
                "FUSEE Simple Example",
                "ButtonText",
                vsTex,
                psTex,
                UIElementPosition.GetAnchors(AnchorPos.StretchHorizontal),
                UIElementPosition.CalcOffsets(AnchorPos.StretchHorizontal, new float2(canvasWidth / 2 - 4, 0), canvasHeight, canvasWidth, new float2(8, 1)),
                guiLatoBlack,
                ColorUint.Tofloat4(ColorUint.Greenery),
                HorizontalTextAlignment.Center,
                VerticalTextAlignment.Center);

            var canvas = new CanvasNode(
                "Canvas",
                _canvasRenderMode,
                new MinMaxRect
            {
                Min = new float2(-canvasWidth / 2, -canvasHeight / 2f),
                Max = new float2(canvasWidth / 2, canvasHeight / 2f)
            })
            {
                Children = new ChildList()
                {
                    //Simple Texture Node, contains the fusee logo.
                    fuseeLogo,
                    text
                }
            };

            return(new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    //Add canvas.
                    canvas
                }
            });
        }