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 TextureNodeContainer( "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.TOP_TOP_LEFT), //Define Offset and therefor the size of the element. UIElementPosition.CalcOffsets(AnchorPos.TOP_TOP_LEFT, 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, 18); var text = new TextNodeContainer( textToDisplay, "SceneDescriptionText", vsTex, psTex, UIElementPosition.GetAnchors(AnchorPos.STRETCH_HORIZONTAL), UIElementPosition.CalcOffsets(AnchorPos.STRETCH_HORIZONTAL, new float2(_initCanvasWidth / 2 - 4, 0), _initCanvasHeight, _initCanvasWidth, new float2(8, 1)), guiLatoBlack, ColorUint.Tofloat4(ColorUint.Greenery), 200f); var canvas = new CanvasNodeContainer( "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); //Create canvas projection component and add resize delegate var canvasProjComp = new ProjectionComponent(ProjectionMethod.ORTHOGRAPHIC, ZNear, ZFar, _fovy); canvas.Components.Insert(0, canvasProjComp); AddResizeDelegate(delegate { canvasProjComp.Resize(Width, Height); }); return(new SceneContainer { Children = new List <SceneNodeContainer> { //Add canvas. canvas } }); }
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 TextureNodeContainer( "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.TOP_TOP_LEFT), //Define Offset and therefor the size of the element. UIElementPosition.CalcOffsets(AnchorPos.TOP_TOP_LEFT, 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, 18); var text = new TextNodeContainer( "FUSEE Simple Example", "ButtonText", vsTex, psTex, UIElementPosition.GetAnchors(AnchorPos.STRETCH_HORIZONTAL), UIElementPosition.CalcOffsets(AnchorPos.STRETCH_HORIZONTAL, new float2(canvasWidth / 2 - 4, 0), canvasHeight, canvasWidth, new float2(8, 1)), guiLatoBlack, ColorUint.Tofloat4(ColorUint.Greenery), 250f); var canvas = new CanvasNodeContainer( "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 } }; var canvasProjComp = new ProjectionComponent(ProjectionMethod.ORTHOGRAPHIC, ZNear, ZFar, _fovy); canvas.Components.Insert(0, canvasProjComp); AddResizeDelegate(delegate { canvasProjComp.Resize(Width, Height); }); return(new SceneContainer { Children = new List <SceneNodeContainer> { //Add canvas. canvas } }); }
private SceneContainer CreateGui() { var canvasScaleFactor = _initWidth / _canvasWidth; float textSize = 2; float borderScaleFactor = 1; if (_canvasRenderMode == CanvasRenderMode.SCREEN) { textSize *= canvasScaleFactor; borderScaleFactor = canvasScaleFactor; } 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 TextureNodeContainer( "fuseeLogo", UIHelper.VsTex, UIHelper.PsTex, guiFuseeLogo, UIElementPosition.GetAnchors(AnchorPos.TOP_TOP_LEFT), UIElementPosition.CalcOffsets(AnchorPos.TOP_TOP_LEFT, new float2(0, _canvasHeight - 0.5f), _canvasHeight, _canvasWidth, new float2(1.75f, 0.5f))); fuseeLogo.AddComponent(btnFuseeLogo); var markModelContainer = new SceneNodeContainer { Name = "MarkModelContainer", }; var canvas = new CanvasNodeContainer( "Canvas", _canvasRenderMode, new MinMaxRect { Min = new float2(-_canvasWidth / 2f, -_canvasHeight / 2f), Max = new float2(_canvasWidth / 2f, _canvasHeight / 2f) } ) { Children = new ChildList() { fuseeLogo, markModelContainer } }; for (var i = 0; i < _uiInput.Count; i++) { var item = _uiInput[i]; if (item.AnnotationKind != UIHelper.AnnotationKind.CONFIRMED) { UIHelper.CreateAndAddCircleAnnotationAndLine(markModelContainer, item.AnnotationKind, item.Size, _uiInput[i].AnnotationCanvasPos, textSize, borderScaleFactor, "#" + i + " " + item.SegmentationClass + ", " + item.Probability.ToString(CultureInfo.GetCultureInfo("en-gb"))); } else { UIHelper.CreateAndAddCircleAnnotationAndLine(markModelContainer, item.AnnotationKind, item.Size, _uiInput[i].AnnotationCanvasPos, textSize, borderScaleFactor, "#" + i + " " + item.SegmentationClass); } } var canvasProjComp = new ProjectionComponent(_canvasRenderMode == CanvasRenderMode.SCREEN ? ProjectionMethod.ORTHOGRAPHIC : ProjectionMethod.PERSPECTIVE, ZNear, ZFar, _fovy); canvas.Components.Insert(0, canvasProjComp); AddResizeDelegate(delegate { canvasProjComp.Resize(Width, Height); }); return(new SceneContainer { Children = new List <SceneNodeContainer> { //Add canvas. canvas } }); }